Fix #31, fix #32, as well as some other potential issues on dedicated servers

This commit is contained in:
malte0811 2018-07-16 19:00:51 +02:00
parent 17598cc9e9
commit cb7aef646a
5 changed files with 13 additions and 3 deletions

View file

@ -21,6 +21,8 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nonnull;
@ -54,6 +56,7 @@ public abstract class TileEntityIWBase extends TileEntity {
}
@Override
@SideOnly(Side.CLIENT)
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
super.onDataPacket(net, pkt);
readNBT(pkt.getNbtCompound(), true);

View file

@ -45,6 +45,8 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -92,8 +94,8 @@ public class ItemIC2Coil extends Item implements IWireCoil {
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
tooltip.add(I18n.format(IndustrialWires.MODID + ".desc.wireLength", getLength(stack)));
IC2Wiretype wireType = IC2Wiretype.ALL[stack.getMetadata()];
int transferRate = wireType.getTransferRate();

View file

@ -28,6 +28,8 @@ import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.util.*;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -50,6 +52,7 @@ public class ItemKey extends Item implements INetGUIItem {
@Nonnull
@Override
@SideOnly(Side.CLIENT)
public String getItemStackDisplayName(@Nonnull ItemStack stack) {
NBTTagCompound nbt = stack.getTagCompound();
if (nbt!=null&&nbt.hasKey(NAME)&&!nbt.getString(NAME).trim().isEmpty()) {
@ -59,6 +62,7 @@ public class ItemKey extends Item implements INetGUIItem {
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
super.addInformation(stack, worldIn, tooltip, flagIn);
if (stack.getMetadata()==2&&stack.getTagCompound()!=null) {

View file

@ -69,6 +69,7 @@ public class ItemPanelComponent extends Item implements INetGUIItem {
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List<String> list, ITooltipFlag flag) {
if (GuiScreen.isShiftKeyDown()) {
NBTTagCompound nbt = getTagCompound(stack);

View file

@ -17,7 +17,6 @@ package malte0811.industrialWires.network;
import io.netty.buffer.ByteBuf;
import malte0811.industrialWires.items.INetGUIItem;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -54,7 +53,8 @@ public class MessageItemSync implements IMessage {
public static class HandlerServer implements IMessageHandler<MessageItemSync, IMessage> {
@Override
public IMessage onMessage(MessageItemSync message, MessageContext ctx) {
Minecraft.getMinecraft().addScheduledTask(()-> {
ctx.getServerHandler().player.getServerWorld()
.addScheduledTask(()-> {
EntityPlayer player = ctx.getServerHandler().player;
ItemStack held = player.getHeldItem(message.hand);
if (held.getItem() instanceof INetGUIItem) {