mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
Developed and implemented the foundation for Item/Gas/Energy/Fluid/Heat dynamic side configuration.
As of now, only items are supported, and the actual config GUI has not been changed. Only gameplay difference is three new configurator modes.
This commit is contained in:
1 parent
35518ad01f
commit
d4d7e88c4e
41 files changed
+563
-453
No files matched your search
@@ -1,16 +1,15 @@
|
||||
package mekanism.common.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.item.ItemConfigurator;
|
||||
import mekanism.common.item.ItemConfigurator.ConfiguratorMode;
|
||||
import mekanism.common.network.PacketConfiguratorState.ConfiguratorStateMessage;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class PacketConfiguratorState implements IMessageHandler<ConfiguratorStateMessage, IMessage>
|
||||
{
|
||||
@Override
|
||||
@@ -20,7 +19,7 @@ public class PacketConfiguratorState implements IMessageHandler<ConfiguratorStat
|
||||
|
||||
if(itemstack != null && itemstack.getItem() instanceof ItemConfigurator)
|
||||
{
|
||||
((ItemConfigurator)itemstack.getItem()).setState(itemstack, (byte)message.state);
|
||||
((ItemConfigurator)itemstack.getItem()).setState(itemstack, message.state);
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -28,11 +27,11 @@ public class PacketConfiguratorState implements IMessageHandler<ConfiguratorStat
|
||||
|
||||
public static class ConfiguratorStateMessage implements IMessage
|
||||
{
|
||||
public byte state;
|
||||
public ConfiguratorMode state;
|
||||
|
||||
public ConfiguratorStateMessage() {}
|
||||
|
||||
public ConfiguratorStateMessage(byte s)
|
||||
public ConfiguratorStateMessage(ConfiguratorMode s)
|
||||
{
|
||||
state = s;
|
||||
}
|
||||
@@ -40,13 +39,13 @@ public class PacketConfiguratorState implements IMessageHandler<ConfiguratorStat
|
||||
@Override
|
||||
public void toBytes(ByteBuf dataStream)
|
||||
{
|
||||
dataStream.writeByte(state);
|
||||
dataStream.writeInt(state.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf dataStream)
|
||||
{
|
||||
state = dataStream.readByte();
|
||||
state = ConfiguratorMode.values()[dataStream.readInt()];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user