Implement missing data syncing methods

Fix MRS not syncing data immediately.
This commit is contained in:
Nicholas Ignoffo 2016-09-07 17:12:25 -07:00
parent f4feb07e47
commit 4d331aa758
10 changed files with 186 additions and 0 deletions

View file

@ -2,9 +2,15 @@ package WayofTime.bloodmagic.tile;
import WayofTime.bloodmagic.ritual.RitualPortal;
import com.google.common.base.Strings;
import net.minecraft.block.state.IBlockState;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class TileDimensionalPortal extends TileEntity
{
@ -52,4 +58,38 @@ public class TileDimensionalPortal extends TileEntity
this.masterStoneY = blockPos.getY();
this.masterStoneZ = blockPos.getZ();
}
@Override
public SPacketUpdateTileEntity getUpdatePacket()
{
NBTTagCompound nbt = new NBTTagCompound();
writeToNBT(nbt);
return new SPacketUpdateTileEntity(getPos(), -999, nbt);
}
@Override
@SideOnly(Side.CLIENT)
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt)
{
super.onDataPacket(net, pkt);
readFromNBT(pkt.getNbtCompound());
}
@Override
public NBTTagCompound getUpdateTag()
{
return writeToNBT(new NBTTagCompound());
}
@Override
public void handleUpdateTag(NBTTagCompound tag)
{
readFromNBT(tag);
}
@Override
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState)
{
return oldState.getBlock() != newState.getBlock();
}
}