Commit c2f37fd4 authored by mrAppleXZ's avatar mrAppleXZ 💾

Code Storage refactring, all the tiles use new NBT system since this commit

parent 544446ec
......@@ -59,7 +59,6 @@ public class GuiCodeStorageUnlock extends GuiCodeStorageLockUnlock
Minecraft.getMinecraft().displayGuiScreen(null);
else
wrong = true;
}
@Override
......
......@@ -22,6 +22,7 @@ public class TESRCodeStorage extends PXLFastTESR<TileCodeStorage>
{
public static final ModelSupplied BODY = new ModelSupplied(new ModelResourceLocation(Utils.gRL("code_storage/body"), "normal"));
public static final ModelSupplied TOP = new ModelSupplied(new ModelResourceLocation(Utils.gRL("code_storage/top"), "normal"));
public static final int ANIMATION_DURATION = 1000;
@Override
public void render(TileCodeStorage te, double x, double y, double z, float partialTicks, int destroyStage, float partial, BufferBuilder buffer, Tessellator tessellator)
......@@ -44,31 +45,22 @@ public class TESRCodeStorage extends PXLFastTESR<TileCodeStorage>
//top
GlStateManager.pushMatrix();
String state = te.anim.getElement("head").getState();
if(!state.equals("closed"))
long delta = System.currentTimeMillis() - te.getOpenTime();
if(delta >= 0)
{
GlStateManager.translate(0.5f, 0, 0.5f);
GlStateManager.translate(0, 0.703f, 0.4457f);
if(state.equals("opened"))
GlStateManager.rotate(90, 1, 0, 0);
if(state.equals("opening") || state.equals("closing"))
float degrees;
if(delta >= ANIMATION_DURATION)
{
if(!te.anim_data.startedOpeningAnim)
{
te.anim_data.animStartTime = System.currentTimeMillis();
te.anim_data.startedOpeningAnim = true;
}
int degrees = (int)((System.currentTimeMillis() - te.anim_data.animStartTime) / 5);
if(degrees >= 90)
{
degrees = 90;
te.anim.changeState("head", state.equals("opening") ? "opened" : "closed");
te.anim_data.startedOpeningAnim = false;
}
GlStateManager.rotate(state.equals("opening") ? degrees : 90 - degrees, 1, 0, 0);
degrees = te.isOpened() ? 90 : 0;
}
else
{
float percentage = (delta / (float)ANIMATION_DURATION);
degrees = te.isOpened() ? 90 * percentage : 90 - 90*percentage;
}
GlStateManager.translate(0.5f, 0, 0.5f);
GlStateManager.translate(0, 0.703f, 0.4457f);
GlStateManager.rotate(degrees, 1, 0, 0);
GlStateManager.translate(0, -0.703f, -0.4457f);
GlStateManager.translate(-0.5f, 0, -0.5f);
}
......
......@@ -59,10 +59,10 @@ public class TESRStoneCrusher extends TESRMultiblock<TileStoneCrusher>
tes.draw();
GlStateManager.popMatrix();
long timeDelta = te.getWorld().getTotalWorldTime() - te.getPreviousAction();
float deltaCooldown = (float) timeDelta / te.getCooldownBetweenSpins();
/* long timeDelta = te.getWorld().getTotalWorldTime() - te.getPreviousAction();
float deltaCooldown = (float) timeDelta / te.getCooldownBetweenSpins();*/
{
float rot = timeDelta > te.getCooldownBetweenSpins() ? te.getSpins() * 90 : te.getPreviousSpins() * 90 + (te.getSpins() - te.getPreviousSpins()) * 90 * deltaCooldown;
float rot = /*timeDelta > te.getCooldownBetweenSpins() ? te.getSpins() * 90 : te.getAnimationData().getPreviousSpins() * 90 + (te.getSpins() - te.getAnimationData().getPreviousSpins()) * 90 * deltaCooldown;*/ 0;
//handle
GlStateManager.pushMatrix();
......@@ -86,22 +86,22 @@ public class TESRStoneCrusher extends TESRMultiblock<TileStoneCrusher>
}
{
float os = 1f / te.getMaxSpins();
/* float os = 1f / te.getMaxSpins();
boolean onGround = timeDelta > te.getCooldownBetweenSpins() && te.getSpins() <= 0;
float anvilX = 1;
float anvilY = timeDelta > te.getCooldownBetweenSpins() ? te.getSpins() * os : te.getPreviousSpins() * os + (te.getSpins() - te.getPreviousSpins()) * os * deltaCooldown;
float anvilY = timeDelta > te.getCooldownBetweenSpins() ? te.getSpins() * os : te.getAnimationData().getPreviousSpins() * os + (te.getSpins() - te.getAnimationData().getPreviousSpins()) * os * deltaCooldown;
if (!onGround)
{
float sin = MathHelper.sin(MathUtils.toRadians((System.currentTimeMillis() / 8) % 360));
float sin = MathHelper.sin(MathUtils.toRadians(((System.currentTimeMillis() - te.getAnimationData().getUpTime()) / 8) % 360));
anvilX += sin * 0.2f * (1 - anvilY);
anvilY += Math.abs(sin) * 0.05f * (1 - anvilY);
}
}*/
//anvil
GlStateManager.pushMatrix();
GlStateManager.translate(anvilX, anvilY, 0);
/*GlStateManager.translate(anvilX, anvilY, 0);*/
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
setTrans(buffer, te);
Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModel(te.getWorld(), MDL_ANVIL.get(), te.getWorld().getBlockState(te.getPos()), te.getPos(), buffer, false, MathHelper.getPositionRandom(te.getPos()));
......@@ -109,7 +109,7 @@ public class TESRStoneCrusher extends TESRMultiblock<TileStoneCrusher>
tes.draw();
GlStateManager.popMatrix();
{
/*{
//rope
float width = 0.05f;
Color c = Colors.BROWN_800;
......@@ -148,7 +148,7 @@ public class TESRStoneCrusher extends TESRMultiblock<TileStoneCrusher>
buffer.pos(x1, y0, z0).color(r, g, b, a).endVertex();
tes.draw();
GlStateManager.enableTexture2D();
}
}*/
}
//item
......
......@@ -114,7 +114,7 @@ public abstract class BlockAbstractWallIfTablet extends BlockBase
TileEntity te = world.getTileEntity(pos);
if (te != null && te instanceof TileWallIfTablet)
{
((TileWallIfTablet) te).setTier(stack.getMetadata(), false);
((TileWallIfTablet) te).setTier(stack.getMetadata());
}
}
......
......@@ -30,6 +30,8 @@ import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import ru.pearx.libmc.common.blocks.controllers.HorizontalFacingController;
import ru.pearx.libmc.common.nbt.NBTTagCompoundBuilder;
import ru.pearx.libmc.common.tiles.syncable.WriteTarget;
import ru.pearx.purmag.PurMag;
import ru.pearx.purmag.common.blocks.base.BlockBase;
import ru.pearx.purmag.common.tiles.TileCodeStorage;
......@@ -102,14 +104,14 @@ public class BlockCodeStorage extends BlockBase
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
TileEntity te = worldIn.getTileEntity(pos);
if(te != null && te instanceof TileCodeStorage)
if(te instanceof TileCodeStorage)
{
TileCodeStorage storage = (TileCodeStorage) te;
if(storage.isUnlocked())
{
storage.setOpenedAndUpdate(playerIn, true);
if(!worldIn.isRemote)
{
storage.setOpened(true);
playerIn.openGui(PurMag.INSTANCE, GUI_ID, worldIn, pos.getX(), pos.getY(), pos.getZ());
}
}
......@@ -146,13 +148,11 @@ public class BlockCodeStorage extends BlockBase
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
{
TileEntity te = world.getTileEntity(pos);
if (te != null && te instanceof TileCodeStorage)
if (te instanceof TileCodeStorage)
{
TileCodeStorage storage = (TileCodeStorage) te;
ItemStack stack = new ItemStack(this, 1, storage.isLockable() ? 0 : 1);
NBTTagCompound tag = new NBTTagCompound();
tag.setTag("data", storage.serializeMin(new NBTTagCompound()));
stack.setTagCompound(tag);
stack.setTagCompound(new NBTTagCompoundBuilder().setTag("data", storage.writeCustomData(WriteTarget.SAVE, TileCodeStorage.NBT_ITEM_DATA)).build());
drops.add(stack);
}
}
......@@ -161,23 +161,17 @@ public class BlockCodeStorage extends BlockBase
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
TileEntity te = worldIn.getTileEntity(pos);
if (te != null && te instanceof TileCodeStorage)
if (te instanceof TileCodeStorage)
{
TileCodeStorage storage = (TileCodeStorage) te;
//meta == 0 - lockable; meta == 1 - not lockable
storage.setLockable(stack.getMetadata() == 0);
boolean unloc = true;
if (stack.hasTagCompound())
{
NBTTagCompound tag = stack.getTagCompound();
if(tag.hasKey("data", Constants.NBT.TAG_COMPOUND))
{
storage.deserializeMin(tag.getCompoundTag("data"));
unloc = false;
}
storage.readCustomData(tag.getCompoundTag("data"));
}
if(unloc)
storage.setUnlocked(true);
}
}
......@@ -195,7 +189,7 @@ public class BlockCodeStorage extends BlockBase
{
int meta = 0;
TileEntity te = world.getTileEntity(pos);
if (te != null && te instanceof TileCodeStorage)
if (te instanceof TileCodeStorage)
meta = ((TileCodeStorage) te).isLockable() ? 0 : 1;
return new ItemStack(this, 1, meta);
}
......
......@@ -103,10 +103,10 @@ public class BlockMagibench extends BlockBase
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
TileEntity te = worldIn.getTileEntity(pos);
if (te != null && te instanceof TileMagibench)
if (te instanceof TileMagibench)
{
TileMagibench bench = (TileMagibench) te;
bench.setTier(stack.getMetadata(), false);
bench.setTier(stack.getMetadata());
}
}
......
package ru.pearx.purmag.common.blocks.base;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
......@@ -11,10 +10,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import ru.pearx.purmag.PurMag;
import ru.pearx.purmag.common.blocks.base.BlockBase;
import ru.pearx.purmag.common.sip.SipType;
import ru.pearx.purmag.common.sip.SipUtils;
import ru.pearx.purmag.common.tiles.TileSingleSip;
......@@ -61,7 +58,7 @@ public class BlockSingleSip extends BlockBase
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
SipUtils.setSipInBlock(worldIn, pos, SipUtils.getSipInStack(stack), false);
SipUtils.setSipInBlock(worldIn, pos, SipUtils.getSipInStack(stack));
}
@Override
......
......@@ -474,7 +474,7 @@ public class IfRegistry
for (SipType t : PurMag.INSTANCE.getSipRegistry().getTypes())
{
TileSingleSip tile = new TileSingleSip();
tile.setType(t.getName(), false);
tile.setType(t.getName());
arr.getMap().put(new BlockPos(x, 0, 0), new BlockArrayEntry(BlockRegistry.crystal.getDefaultState(), SipUtils.getStackWithSip(new ItemStack(ItemRegistry.crystal), t.getName()), tile));
x += 2;
}
......@@ -532,7 +532,7 @@ public class IfRegistry
);
{
TileMagibench mag = new TileMagibench();
mag.setTier(0, false);
mag.setTier(0);
registerEntryClient(
"magibench", new ItemDrawable(new ItemStack(ItemRegistry.magibench), 1.5f),
new IfPageText("magibench.0"),
......
......@@ -45,7 +45,7 @@ public class ContainerCodeStorage extends PXLContainer
public void onContainerClosed(EntityPlayer playerIn)
{
super.onContainerClosed(playerIn);
storage.setOpened(false);
storage.setOpenedAndUpdate(playerIn, false);
}
@Override
......
package ru.pearx.purmag.common.networking.packets.code_storage;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.common.network.ByteBufUtils;
......@@ -51,10 +52,10 @@ public class SPacketLock implements IMessage
(ctx.getServerHandler().player.getServerWorld()).addScheduledTask(() ->
{
TileEntity te = ctx.getServerHandler().player.world.getTileEntity(message.pos);
if(te != null && te instanceof TileCodeStorage)
if(te instanceof TileCodeStorage)
{
TileCodeStorage storage = (TileCodeStorage) te;
storage.tryLock(false, message.text, message.code);
storage.tryLock(ctx.getServerHandler().player, false, message.text, message.code);
}
});
return null;
......
......@@ -47,14 +47,11 @@ public class SPacketUnlock implements IMessage
{
ctx.getServerHandler().player.getServerWorld().addScheduledTask(() ->
{
boolean result = false;
TileEntity te = ctx.getServerHandler().player.world.getTileEntity(message.pos);
if(te != null && te instanceof TileCodeStorage)
if(te instanceof TileCodeStorage)
{
TileCodeStorage storage = (TileCodeStorage) te;
result = storage.tryUnlock(message.code);
((TileCodeStorage) te).tryUnlock(ctx.getServerHandler().player, message.code);
}
NetworkManager.sendTo(new CPacketUnlockResponse(result), ctx.getServerHandler().player);
});
return null;
}
......
......@@ -48,12 +48,12 @@ public class SipUtils
return PurMag.INSTANCE.getSipRegistry().getDefaultType().getName();
}
public static void setSipInBlock(IBlockAccess access, BlockPos pos, String type, boolean sync)
public static void setSipInBlock(IBlockAccess access, BlockPos pos, String type)
{
TileEntity te = access.getTileEntity(pos);
if (te != null && te instanceof TileSingleSip)
{
((TileSingleSip) te).setType(type, sync);
((TileSingleSip) te).setType(type);
}
}
}
......@@ -137,7 +137,7 @@ public class CodeStorageProcessor extends StructureProcessor
if(te != null && te instanceof TileCodeStorage)
{
TileCodeStorage storage = (TileCodeStorage) te;
storage.tryLock(true, expr.getText(), expr.getResult());
storage.tryLock(null, true, expr.getText(), expr.getResult());
PXLMC.fillBlockWithLoot(world, rand, d.getAbsolutePos(), EnumFacing.NORTH, d.table, expr.getLuck());
}
}
......
......@@ -6,8 +6,10 @@ import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.ItemStackHandler;
import ru.pearx.libmc.common.ItemStackUtils;
import ru.pearx.libmc.common.nbt.NBTTagCompoundBuilder;
import ru.pearx.libmc.common.tiles.TileSyncable;
import ru.pearx.libmc.common.nbt.serialization.NBTSerializer;
import ru.pearx.libmc.common.tiles.syncable.TileSyncableComposite;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
......@@ -15,15 +17,18 @@ import javax.annotation.Nullable;
/*
* Created by mrAppleXZ on 17.08.17 21:28.
*/
public abstract class TileAbstractSingleItem extends TileSyncable
public abstract class TileAbstractSingleItem extends TileSyncableComposite
{
public static final String NBT_ITEMS = "items";
public static final String NBT_ITEMS_UPDATE = "items_update";
public ItemStackHandler handler = new ItemStackHandler(1)
{
@Override
protected void onContentsChanged(int slot)
{
TileAbstractSingleItem.this.markDirty();
sendUpdates(new NBTTagCompoundBuilder().setTag("items", serializeNBT()).build(), null);
markDirty();
sendUpdates(null, new NBTTagCompoundBuilder().setTag(NBT_ITEMS_UPDATE, ItemStackUtils.writeSlotUpdate(this, slot)).build());
}
@Nonnull
......@@ -36,6 +41,12 @@ public abstract class TileAbstractSingleItem extends TileSyncable
}
};
public TileAbstractSingleItem()
{
getSerializers().add(new NBTSerializer.ReaderWriter<>(NBT_ITEMS, NBTTagCompound.class, handler::deserializeNBT, handler::serializeNBT));
getSerializers().add(new NBTSerializer.Reader<>(NBT_ITEMS_UPDATE, NBTTagCompound.class, (tag) -> ItemStackUtils.loadSlotUpdate(tag, handler)));
}
@Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing)
{
......@@ -51,18 +62,5 @@ public abstract class TileAbstractSingleItem extends TileSyncable
return super.getCapability(capability, facing);
}
@Override
public void readCustomData(NBTTagCompound tag)
{
if (tag.hasKey("items"))
handler.deserializeNBT((NBTTagCompound) tag.getTag("items"));
}
@Override
public void writeCustomData(NBTTagCompound tag)
{
tag.setTag("items", handler.serializeNBT());
}
public abstract boolean isItemValid(ItemStack stack);
}
package ru.pearx.purmag.common.tiles;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.NonNullList;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.ItemStackHandler;
import ru.pearx.libmc.common.ItemStackUtils;
import ru.pearx.libmc.common.nbt.NBTTagCompoundBuilder;
import ru.pearx.libmc.common.tiles.TileSyncable;
import ru.pearx.libmc.common.nbt.serialization.NBTSerializer;
import ru.pearx.libmc.common.tiles.syncable.TileSyncableComposite;
import ru.pearx.purmag.PurMag;
import ru.pearx.purmag.common.magibench.MagibenchRegistry;
......@@ -22,53 +21,51 @@ import javax.annotation.Nullable;
/*
* Created by mrAppleXZ on 30.10.17 21:48.
*/
public class TileMagibench extends TileSyncable
public class TileMagibench extends TileSyncableComposite
{
public class Handler extends ItemStackHandler
{
public Handler()
{
super();
}
public static final String NBT_ITEMS = "items";
public static final String NBT_TIER = "tier";
public static final String NBT_ITEMS_UPDATE = "items_update";
public Handler(int size)
{
super(size);
}
public Handler(NonNullList<ItemStack> stacks)
{
super(stacks);
}
private int tier;
public ItemStackHandler handler;
@Override
protected void onContentsChanged(int slot)
{
TileMagibench.this.markDirty();
sendUpdates(new NBTTagCompoundBuilder().setTag("items", serializeNBT()).build(), null);
}
public TileMagibench()
{
getSerializers().add(new NBTSerializer.ReaderWriter<>(NBT_TIER, int.class, this::setTier, this::getTier));
getSerializers().add(new NBTSerializer.ReaderWriter<>(NBT_ITEMS, NBTTagCompound.class, (tag) -> handler.deserializeNBT(tag), () -> handler.serializeNBT()));
}
private int tier;
public Handler handler;
public int getTier()
{
return tier;
}
public void setTier(int tier, boolean sync)
public void setTier(int tier)
{
MagibenchRegistry.Tier t = PurMag.INSTANCE.getMagibenchRegistry().getTier(tier);
if(handler != null && getTier() != tier && !getWorld().isRemote)
{
ItemStackUtils.drop(handler, getWorld(), getPos());
}
handler = new ItemStackHandler(t.getWidth() * t.getHeight())
{
@Override
protected void onContentsChanged(int slot)
{
markDirty();
sendUpdates(null, new NBTTagCompoundBuilder().setTag(NBT_ITEMS_UPDATE, ItemStackUtils.writeSlotUpdate(handler, slot)).build());
}
};
this.tier = tier;
handler = new Handler(t.getWidth() * t.getHeight());
if(sync)
sendUpdates(new NBTTagCompoundBuilder().setInteger("tier", tier).build(), null);
markDirty();
}
public void setTierAndSync(int tier, EntityPlayer p)
{
setTier(tier);
sendUpdates(p, NBT_TIER);
}
@Nullable
......@@ -84,22 +81,6 @@ public class TileMagibench extends TileSyncable
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
}
@Override
public void readCustomData(NBTTagCompound tag)
{
if(tag.hasKey("tier", Constants.NBT.TAG_INT))
setTier(tag.getInteger("tier"), false);
if(tag.hasKey("items", Constants.NBT.TAG_COMPOUND))
handler.deserializeNBT(tag.getCompoundTag("items"));
}
@Override
public void writeCustomData(NBTTagCompound tag)
{
tag.setInteger("tier", getTier());
tag.setTag("items", handler.serializeNBT());
}
public boolean canWork()
{
return true;
......
package ru.pearx.purmag.common.tiles;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import ru.pearx.libmc.common.nbt.NBTTagCompoundBuilder;
import ru.pearx.libmc.common.tiles.TileSyncable;
import ru.pearx.libmc.common.nbt.serialization.NBTSerializer;
import ru.pearx.libmc.common.tiles.syncable.TileSyncable;
import ru.pearx.libmc.common.tiles.syncable.TileSyncableComposite;
import ru.pearx.libmc.common.tiles.syncable.WriteTarget;
import ru.pearx.purmag.PurMag;
/*
* Created by mrAppleXZ on 09.07.17 8:48.
*/
public class TileSingleSip extends TileSyncable
public class TileSingleSip extends TileSyncableComposite
{
public static final String NBT_SIP_TYPE = "sip_type";
private String type = PurMag.INSTANCE.getSipRegistry().getDefaultType().getName();
public TileSingleSip()
{
getSerializers().add(new NBTSerializer.ReaderWriter<>(NBT_SIP_TYPE, String.class, this::setType, this::getType));
}
public String getType()
{
return type;
}
public void setType(String type, boolean sync)
public void setType(String type)
{
this.type = type;
markDirty();
if (sync)
sendUpdates(new NBTTagCompoundBuilder().setString("sip_type", type).build(), null);
}
@Override
public void readCustomData(NBTTagCompound tag)
{
if (tag.hasKey("sip_type"))
setType(tag.getString("sip_type"), false);
}
@Override
public void writeCustomData(NBTTagCompound tag)
public void setTypeAndSync(EntityPlayer p, String type)
{
tag.setString("sip_type", getType());
setType(type);
sendUpdates(p, NBT_SIP_TYPE);
}
}
package ru.pearx.purmag.common.tiles;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.ItemStackHandler;
import ru.pearx.libmc.common.ItemStackUtils;
import ru.pearx.libmc.common.nbt.NBTTagCompoundBuilder;
import ru.pearx.libmc.common.structure.multiblock.IMultiblockPart;
import ru.pearx.libmc.common.structure.multiblock.events.MultiblockActivatedEvent;
import ru.pearx.libmc.common.structure.multiblock.events.MultiblockBreakEvent;
......@@ -32,46 +26,10 @@ public class TileStoneCrusher extends TilePMMultiblockMaster
protected void onContentsChanged(int slot)
{
TileStoneCrusher.this.markDirty();
sendUpdates(new NBTTagCompoundBuilder().setTag("items", serializeNBT()).build(), null);
//sendUpdates(ItemStackUtils.writeSlotUpdate(this, slot, "slotUpdateStack", "slotUpdateStack"), null);
}
};
@SideOnly(Side.CLIENT)
private int previousSpins;
@SideOnly(Side.CLIENT)
public int getPreviousSpins()
{
return previousSpins;
}
@SideOnly(Side.CLIENT)
public void setPreviousSpins(int previousSpins)
{
this.previousSpins = previousSpins;
}
private int crushes;
private int spins;
private long previousAction;
public int getCrushes()
{
return crushes;
}
public void setCrushes(int crushes, boolean sync, EntityPlayer p)
{
this.crushes = crushes;
if(sync)
sendUpdates(new NBTTagCompoundBuilder().setInteger("crushes", crushes).build(), p);
}
public int getSpins()
{
return spins;
}
public int getMaxSpins()
{
return 10;
......@@ -82,49 +40,15 @@ public class TileStoneCrusher extends TilePMMultiblockMaster
return 6;
}
public void setSpins(int spins, boolean sync, EntityPlayer p)
{
if(FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT && getWorld().isRemote)
setPreviousSpins(getSpins());
this.spins = spins;
if(sync)
sendUpdates(new NBTTagCompoundBuilder().setInteger("spins", spins).build(), p);
}
public long getPreviousAction()
{
return previousAction;
}
public void setPreviousSpin(long previousSpin, boolean sync, EntityPlayer p)