Fixed I18n crash on servers.
This commit is contained in:
parent
eeabae123e
commit
303f077089
|
@ -1,6 +1,9 @@
|
|||
package com.gildedgames.the_aether.inventory.slots;
|
||||
|
||||
import com.gildedgames.the_aether.network.AetherNetwork;
|
||||
import com.gildedgames.the_aether.network.packets.PacketCheckKey;
|
||||
import com.gildedgames.the_aether.registry.AetherLore;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
@ -14,6 +17,20 @@ public class SlotLore extends Slot
|
|||
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
{
|
||||
return !I18n.format(AetherLore.getLoreEntryKey(stack)).contains("lore.");
|
||||
if (FMLCommonHandler.instance().getSide().isClient())
|
||||
{
|
||||
if (!I18n.format(AetherLore.getLoreEntryKey(stack)).contains("lore."))
|
||||
{
|
||||
AetherLore.hasKey = true;
|
||||
AetherNetwork.sendToServer(new PacketCheckKey(true));
|
||||
}
|
||||
else
|
||||
{
|
||||
AetherLore.hasKey = false;
|
||||
AetherNetwork.sendToServer(new PacketCheckKey(false));
|
||||
}
|
||||
}
|
||||
|
||||
return AetherLore.hasKey;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,8 @@ public class AetherNetwork {
|
|||
|
||||
INSTANCE.registerMessage(PacketSendSeenDialogue.class, PacketSendSeenDialogue.class, discriminant++, Side.CLIENT);
|
||||
INSTANCE.registerMessage(PacketPortalItem.class, PacketPortalItem.class, discriminant++, Side.CLIENT);
|
||||
|
||||
INSTANCE.registerMessage(PacketCheckKey.class, PacketCheckKey.class, discriminant++, Side.SERVER);
|
||||
}
|
||||
|
||||
public static void sendToAll(IMessage message) {
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package com.gildedgames.the_aether.network.packets;
|
||||
|
||||
import com.gildedgames.the_aether.registry.AetherLore;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public class PacketCheckKey extends AetherPacket<PacketCheckKey>
|
||||
{
|
||||
private boolean bool;
|
||||
|
||||
public PacketCheckKey()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public PacketCheckKey(boolean bool)
|
||||
{
|
||||
this.bool = bool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf)
|
||||
{
|
||||
this.bool = buf.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf)
|
||||
{
|
||||
buf.writeBoolean(this.bool);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleClient(PacketCheckKey message, EntityPlayer player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServer(PacketCheckKey message, EntityPlayer player)
|
||||
{
|
||||
AetherLore.hasKey = message.bool;
|
||||
}
|
||||
}
|
|
@ -7,6 +7,8 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
|||
|
||||
public class AetherLore {
|
||||
|
||||
public static boolean hasKey;
|
||||
|
||||
public static String getLoreEntryKey(ItemStack stack) {
|
||||
|
||||
if (stack.getItem() instanceof ItemBlockEnchanter)
|
||||
|
|
Loading…
Reference in a new issue