Jump to content

ZigTheHedge

Members
  • Posts

    57
  • Joined

  • Last visited

Everything posted by ZigTheHedge

  1. Hello, dear modders! For my mod I need some kind of solution to make TE's from other mods stop doing their update(). It's like "freeze time" mechanic. The only thing I can think of - is to use bytecode to overwrite update methods with empty ones, but that's a bad idea. Maybe there's another solution?
  2. Oh my... Thanks!!! That was the issue!
  3. Hello! I ran into very strange issue while trying to sync TE from server to client AGAIN. But this time it's really magic. When I call tsTE.activate() everything is in sync and works fine, but when tsTE.deactivate() is called - value on server side is changing, but it doesn't on client side, although received packet is fine. So, the client thinks "isMoving" equals "true" no matter what. Here's some code: Method from which I call my update method: @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if(!worldIn.isRemote) { ... TileEntity te = worldIn.getTileEntity(pos); if(te instanceof PistonVesselTE) { TimeSymbolTE tsTE = (TimeSymbolTE) worldIn.getTileEntity(((PistonVesselTE) te).getMainBlockPos()); if (tsTE.isStructureComplete()) { tsTE.activate(); } else { if(tsTE.isMoving) tsTE.deactivate(); } } } return true; } TileEntity's methods: public void activate() { if(isMoving)return; if(world.isRemote)return; isMoving = true; ... markDirty(); world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 3); } public void deactivate() { if(!isMoving)return; if(world.isRemote)return; isMoving = false; ... markDirty(); world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 3); } TileEntity's NBT methods: @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); if(compound.hasKey("isMoving")) isMoving = compound.getBoolean("isMoving"); if(compound.hasKey("structureChecked")) isMoving = compound.getBoolean("structureChecked"); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { compound = super.writeToNBT(compound); compound.setBoolean("isMoving", isMoving); compound.setBoolean("structureChecked", structureChecked); return compound; } TileEntity's Sync stuff: @Override public NBTTagCompound getUpdateTag() { return writeToNBT(new NBTTagCompound()); } @Override public SPacketUpdateTileEntity getUpdatePacket() { NBTTagCompound nbtTag = new NBTTagCompound(); this.writeToNBT(nbtTag); return new SPacketUpdateTileEntity(getPos(), 1, nbtTag); } @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) { super.onDataPacket(net, packet); this.readFromNBT(packet.getNbtCompound()); ModMain.logger.info("Received packet: "+packet.getNbtCompound().toString()+", side: "+world.isRemote); world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 3); } In debug info, everything is fine. I get the correct isMoving=0b in NBT with world.isRemote=true
  4. @diesieben07, you're savior! Everything is working properly now! P.S: sendUpdates was the "last resort", when I tried everything else It's copied from somewhere in these forums
  5. I must be blind, but I can't find why my block doesn't get re-rendered with new data from TE... CommonTE.class //Base TE class public class CommonTE extends TileEntity { @Override public NBTTagCompound getUpdateTag() { ModMain.logger.warning("getUpdateTag()"); return writeToNBT(new NBTTagCompound()); } @Override public SPacketUpdateTileEntity getUpdatePacket() { ModMain.logger.warning("getUpdatePacket()"); NBTTagCompound nbtTag = new NBTTagCompound(); this.writeToNBT(nbtTag); return new SPacketUpdateTileEntity(getPos(), 1, nbtTag); } @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) { ModMain.logger.warning("onDataPacket()"); this.readFromNBT(packet.getNbtCompound()); } public void sendUpdates() { world.markBlockRangeForRenderUpdate(pos, pos); world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 3); world.scheduleBlockUpdate(pos, this.getBlockType(),0,0); markDirty(); } } BlockSliderTE.class //Actial TE public class BlockSliderTE extends CommonTE implements ITickable { public int FACING; public int STATE; public int BLOCKSEXTENDED; public EnumHoleTypes HOLE_TYPE; @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); if(compound.hasKey("facing")) FACING = compound.getInteger("facing"); if(compound.hasKey("state")) STATE = compound.getInteger("state"); if(compound.hasKey("blocksextended")) BLOCKSEXTENDED = compound.getInteger("blocksextended"); if(compound.hasKey("holetype")) HOLE_TYPE = EnumHoleTypes.values()[compound.getInteger("holetype")]; } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setInteger("facing", FACING); compound.setInteger("state", STATE); compound.setInteger("blocksextended", BLOCKSEXTENDED); compound.setInteger("holetype", HOLE_TYPE.getIndex()); return compound; } } GUI: public class BlockSliderGUIContainer<TE extends CommonTE, CNT extends CommonContainer> extends GuiContainer { private TE te; private List<GuiButton> holeTypeButtons = Lists.<GuiButton>newArrayList(); @Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { super.mouseClicked(mouseX, mouseY, mouseButton); for (int i = 0; i < holeTypeButtons.size(); i++) if (holeTypeButtons.get(i).mousePressed(mc, mouseX, mouseY)) { int rem = i % 3; if(rem == 0) ((BlockSliderTE)te).HOLE_TYPE = EnumHoleTypes.ROUND; if(rem == 1) ((BlockSliderTE)te).HOLE_TYPE = EnumHoleTypes.SQUARE; if(rem == 2) ((BlockSliderTE)te).HOLE_TYPE = EnumHoleTypes.CROSS; } SliderGUISync.send((BlockSliderTE)te); } } Network stuff: public class SliderGUISync implements IMessageHandler<SliderGUISync.Packet, IMessage> { @Override public IMessage onMessage(SliderGUISync.Packet message, MessageContext ctx) { EntityPlayerMP player = ctx.getServerHandler().player; player.getServerWorld().addScheduledTask(() -> { World world = player.world; BlockSliderTE te = (BlockSliderTE) world.getTileEntity(message.tePos); te.HOLE_TYPE = message.holeType; te.sendUpdates(); ModMain.logger.warning("TE synced. Data follows: X: "+message.tePos.getX() + ", Y: "+message.tePos.getY()+", Z: "+message.tePos.getZ()+", HOLE_TYPE:"+message.holeType); }); return null; } public static void send(BlockSliderTE te) { ModMain.network.sendToServer(new Packet(te)); } public static class Packet implements IMessage { public BlockPos tePos; public EnumHoleTypes holeType; public Packet(BlockSliderTE te) { tePos = te.getPos(); holeType = te.HOLE_TYPE; } public Packet(){} @Override public void fromBytes(ByteBuf buf) { tePos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt()); holeType = EnumHoleTypes.values()[buf.readInt()]; } @Override public void toBytes(ByteBuf buf) { buf.writeInt(tePos.getX()); buf.writeInt(tePos.getY()); buf.writeInt(tePos.getZ()); buf.writeInt(holeType.getIndex()); } } } Well, it doesn't sync. When I click button to change EnumHoleType, message successfully sending to server, server receives it (logger.warning is perfectly fine with data), but block just don't seem to care. It updates only when forcing blockupdate by placing block next to it or something, or GUI is reopened. Data in TE is fine. Help!
  6. Dear All, Could someone point me to the name of class which is responsible for credits animation happening when End Dragon is killed, and player jumps into end portal? I've spent about two hours trying to catch this event (?) with breakpoints but had no luck. The only thing I found is END_PORTAL block somehow differentiates between entering the End and going back from the End with the same block. The thing is - I want to implement my own "credits"-like cutscene.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.