mirror of
https://github.com/GTNewHorizons/MagicBees.git
synced 2026-11-13 08:44:17 +00:00
Adding network packet stuff.
This commit is contained in:
1 parent
b881283492
commit
cbb0b15dee
12 files changed
+466
-81
No files matched your search
@@ -56,7 +56,7 @@ public class ContainerThaumicApiary extends ContainerMB {
|
||||
j++;
|
||||
}
|
||||
|
||||
addPlayerInventory(inventoryPlayer, 6, 109);
|
||||
addPlayerInventory(inventoryPlayer, 0, 109);
|
||||
|
||||
maxSlot = currentSlot;
|
||||
|
||||
|
||||
@@ -74,21 +74,58 @@ public class GuiThaumicApiary extends GuiContainer
|
||||
this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
TileEntityThaumicApiary apiary = ((ContainerThaumicApiary)this.inventorySlots).apiary;
|
||||
int value = LIFEBAR_HEIGHT - (apiary.getHealthScaled(100) * LIFEBAR_HEIGHT) / 100;
|
||||
this.drawTexturedModalRect(this.guiLeft + LIFEBAR_DEST_X, this.guiTop + LIFEBAR_DEST_Y,
|
||||
LIFEBAR_SRC_STAGE1_X, LIFEBAR_SRC_Y, LIFEBAR_WIDTH, value);
|
||||
|
||||
drawLifebar(apiary);
|
||||
|
||||
if (apiary.isWorkBoosted()) {
|
||||
this.drawTexturedModalRect(this.guiLeft + WORKBOOST_DEST_X, this.guiTop + WORKBOOST_DEST_Y,
|
||||
WORKBOOST_SRC_X, WORKBOOST_SRC_Y, WORKBOOST_WIDTH, WORKBOOST_HEIGHT);
|
||||
}
|
||||
if (apiary.isDeathRateBoosted()) {
|
||||
this.drawTexturedModalRect(this.guiLeft + DEATHBOOST_DEST_X, this.guiTop + DEATHBOOST_DEST_Y,
|
||||
DEATHBOOST_SRC_X, DEATHBOOST_SRC_Y, DEATHBOOST_WIDTH, DEATHBOOST_HEIGHT);
|
||||
}
|
||||
if (apiary.isMutationBoosted()) {
|
||||
drawWorkBoostIcon(apiary);
|
||||
drawDeathRateIcon(apiary);
|
||||
drawMutationIcon(apiary);
|
||||
}
|
||||
|
||||
private void drawMutationIcon(TileEntityThaumicApiary apiary) {
|
||||
if (apiary.isMutationBoosted()) {
|
||||
this.drawTexturedModalRect(this.guiLeft + MUTATIONBOOST_DEST_X, this.guiTop + MUTATIONBOOST_DEST_Y,
|
||||
MUTATIONBOOST_SRC_X, MUTATIONBOOST_SRC_Y, MUTATIONBOOST_WIDTH, MUTATIONBOOST_HEIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawDeathRateIcon(TileEntityThaumicApiary apiary) {
|
||||
if (apiary.isDeathRateBoosted()) {
|
||||
this.drawTexturedModalRect(this.guiLeft + DEATHBOOST_DEST_X, this.guiTop + DEATHBOOST_DEST_Y,
|
||||
DEATHBOOST_SRC_X, DEATHBOOST_SRC_Y, DEATHBOOST_WIDTH, DEATHBOOST_HEIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawWorkBoostIcon(TileEntityThaumicApiary apiary) {
|
||||
if (apiary.isWorkBoosted()) {
|
||||
this.drawTexturedModalRect(this.guiLeft + WORKBOOST_DEST_X, this.guiTop + WORKBOOST_DEST_Y,
|
||||
WORKBOOST_SRC_X, WORKBOOST_SRC_Y, WORKBOOST_WIDTH, WORKBOOST_HEIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawLifebar(TileEntityThaumicApiary apiary) {
|
||||
int value = LIFEBAR_HEIGHT - apiary.getHealthScaled(LIFEBAR_HEIGHT);
|
||||
int lifebarSrc = getLifebarSrc(apiary);
|
||||
this.drawTexturedModalRect(this.guiLeft + LIFEBAR_DEST_X, this.guiTop + value + LIFEBAR_DEST_Y,
|
||||
lifebarSrc, LIFEBAR_SRC_Y, LIFEBAR_WIDTH, LIFEBAR_HEIGHT - value);
|
||||
}
|
||||
|
||||
private int getLifebarSrc(TileEntityThaumicApiary apiary) {
|
||||
int value = apiary.getHealthScaled(5);
|
||||
if (value >= 5) {
|
||||
return LIFEBAR_SRC_STAGE1_X;
|
||||
}
|
||||
else if (value >= 4) {
|
||||
return LIFEBAR_SRC_STAGE2_X;
|
||||
}
|
||||
else if (value >= 3) {
|
||||
return LIFEBAR_SRC_STAGE3_X;
|
||||
}
|
||||
else if (value >= 2) {
|
||||
return LIFEBAR_SRC_STAGE4_X;
|
||||
}
|
||||
else {
|
||||
return LIFEBAR_SRC_STAGE5_X;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,5 @@
|
||||
package magicbees.main;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
|
||||
import magicbees.bees.BeeManager;
|
||||
import magicbees.bees.TransmutationEffectController;
|
||||
import magicbees.client.gui.GUIHandler;
|
||||
@@ -17,6 +8,15 @@ import magicbees.main.utils.IMCManager;
|
||||
import magicbees.main.utils.LogHelper;
|
||||
import magicbees.main.utils.VersionInfo;
|
||||
import magicbees.main.utils.compat.ModHelper;
|
||||
import magicbees.main.utils.net.NetworkEventHandler;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
|
||||
@Mod(
|
||||
modid = VersionInfo.ModName,
|
||||
@@ -34,10 +34,12 @@ public class MagicBees
|
||||
|
||||
public GUIHandler guiHandler;
|
||||
private Config modConfig;
|
||||
public final NetworkEventHandler netHandler = new NetworkEventHandler();
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
LogHelper.info("Preinit started");
|
||||
this.modConfig = new Config(event.getSuggestedConfigurationFile());
|
||||
FMLCommonHandler.instance().bus().register(modConfig);
|
||||
|
||||
|
||||
@@ -1,17 +1,35 @@
|
||||
package magicbees.main.utils;
|
||||
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ChunkCoords
|
||||
{
|
||||
public int dimension;
|
||||
public int xCoord;
|
||||
public int zCoord;
|
||||
public final int dimension;
|
||||
public final int x;
|
||||
public final int y;
|
||||
public final int z;
|
||||
|
||||
public ChunkCoords(Chunk chunk)
|
||||
{
|
||||
this.dimension = chunk.worldObj.provider.dimensionId;
|
||||
this.xCoord = chunk.xPosition;
|
||||
this.zCoord = chunk.zPosition;
|
||||
public ChunkCoords(TileEntity entity) {
|
||||
this(entity.getWorldObj(), entity.xCoord, entity.yCoord, entity.zCoord);
|
||||
}
|
||||
|
||||
public ChunkCoords(Entity entity) {
|
||||
this(entity.worldObj, entity.chunkCoordX, entity.chunkCoordY, entity.chunkCoordZ);
|
||||
}
|
||||
|
||||
public ChunkCoords(World world, int xCoord, int yCoord, int zCoord)
|
||||
{
|
||||
this(world.provider.dimensionId, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
public ChunkCoords(int dimId, int xCoord, int yCoord, int zCoord)
|
||||
{
|
||||
this.dimension = dimId;
|
||||
this.x = xCoord;
|
||||
this.y = yCoord;
|
||||
this.z = zCoord;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package magicbees.main.utils;
|
||||
|
||||
import cpw.mods.fml.common.network.FMLEventChannel;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
|
||||
public class PacketHandler {
|
||||
|
||||
public enum PacketTypes {
|
||||
INVENTORY_UPDATE,
|
||||
}
|
||||
|
||||
private FMLEventChannel channel;
|
||||
|
||||
public PacketHandler() {
|
||||
channel = NetworkRegistry.INSTANCE.newEventDrivenChannel(VersionInfo.ModName);
|
||||
channel.register(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package magicbees.main.utils.error;
|
||||
|
||||
public class InvalidEventTypeIndexException extends RuntimeException {
|
||||
private static final long serialVersionUID = 8920019214439088440L;
|
||||
|
||||
public InvalidEventTypeIndexException(String message) {
|
||||
this(message, null);
|
||||
}
|
||||
|
||||
public InvalidEventTypeIndexException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package magicbees.main.utils.net;
|
||||
|
||||
import forestry.core.proxy.Proxies;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import magicbees.main.utils.LogHelper;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
|
||||
public class EventBase {
|
||||
|
||||
private NetworkEventHandler.EventType eventType;
|
||||
|
||||
public EventBase() {
|
||||
this.eventType = NetworkEventHandler.EventType.UNKNOWN;
|
||||
}
|
||||
|
||||
public EventBase(NetworkEventHandler.EventType type) {
|
||||
this.eventType = type;
|
||||
}
|
||||
|
||||
public FMLProxyPacket getPacket() {
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
DataOutputStream data = new DataOutputStream(bytes);
|
||||
|
||||
try {
|
||||
data.writeInt(eventType.ordinal());
|
||||
writeDataToOutputStream(data);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LogHelper.error("Could not write EventBase data.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return new FMLProxyPacket(Unpooled.wrappedBuffer(bytes.toByteArray()), NetworkEventHandler.CHANNEL_NAME);
|
||||
}
|
||||
|
||||
public void process(EntityPlayerMP player) {
|
||||
|
||||
}
|
||||
|
||||
protected void writeDataToOutputStream(DataOutputStream data) {
|
||||
return;
|
||||
}
|
||||
|
||||
protected void readDataFromInputStream(DataInputStream data) {
|
||||
return;
|
||||
}
|
||||
|
||||
protected ItemStack readItemStackFromData(DataInputStream data) throws IOException {
|
||||
ItemStack itemstack = null;
|
||||
|
||||
String itemName = data.readUTF();
|
||||
|
||||
if (!itemName.isEmpty()) {
|
||||
Item item = GameData.getItemRegistry().getRaw(itemName);
|
||||
byte stackSize = data.readByte();
|
||||
short meta = data.readShort();
|
||||
itemstack = new ItemStack(item, stackSize, meta);
|
||||
|
||||
if (item.isDamageable() || Proxies.common.needsTagCompoundSynched(item)) {
|
||||
itemstack.stackTagCompound = this.readNBTTagCompound(data);
|
||||
}
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
protected void writeItemStackToData(ItemStack itemstack, DataOutputStream data) throws IOException {
|
||||
if (itemstack == null) {
|
||||
data.writeUTF("");
|
||||
} else {
|
||||
data.writeUTF(GameData.getItemRegistry().getNameForObject(itemstack.getItem()));
|
||||
data.writeByte(itemstack.stackSize);
|
||||
data.writeShort(itemstack.getItemDamage());
|
||||
|
||||
if (itemstack.getItem().isDamageable() || Proxies.common.needsTagCompoundSynched(itemstack.getItem())) {
|
||||
this.writeNBTTagCompound(itemstack.stackTagCompound, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected NBTTagCompound readNBTTagCompound(DataInputStream data) throws IOException {
|
||||
|
||||
short length = data.readShort();
|
||||
|
||||
if (length < 0) {
|
||||
return null;
|
||||
} else {
|
||||
byte[] compressed = new byte[length];
|
||||
data.readFully(compressed);
|
||||
return CompressedStreamTools.readCompressed(new ByteArrayInputStream(compressed));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void writeNBTTagCompound(NBTTagCompound nbttagcompound, DataOutputStream data) throws IOException {
|
||||
|
||||
if (nbttagcompound == null) {
|
||||
data.writeShort(-1);
|
||||
} else {
|
||||
byte[] compressed = CompressedStreamTools.compress(nbttagcompound);
|
||||
data.writeShort((short) compressed.length);
|
||||
data.write(compressed);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package magicbees.main.utils.net;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import magicbees.main.utils.ChunkCoords;
|
||||
import magicbees.main.utils.LogHelper;
|
||||
|
||||
public class EventCoords extends EventBase {
|
||||
|
||||
private ChunkCoords coords;
|
||||
|
||||
public EventCoords(NetworkEventHandler.EventType type, ChunkCoords position) {
|
||||
super(type);
|
||||
this.coords = position;
|
||||
}
|
||||
|
||||
public EventCoords(NetworkEventHandler.EventType type, DataInputStream byteStream) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public ChunkCoords getCoords() {
|
||||
return this.coords;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeDataToOutputStream(DataOutputStream byteStream) {
|
||||
super.writeDataToOutputStream(byteStream);
|
||||
|
||||
try {
|
||||
byteStream.writeInt(coords.dimension);
|
||||
byteStream.writeInt(coords.x);
|
||||
byteStream.writeInt(coords.y);
|
||||
byteStream.writeInt(coords.z);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LogHelper.error("Could not write EventCoords data to stream.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readDataFromInputStream(DataInputStream byteStream) {
|
||||
super.readDataFromInputStream(byteStream);
|
||||
|
||||
try {
|
||||
int dim = byteStream.readInt();
|
||||
int x = byteStream.readInt();
|
||||
int y = byteStream.readInt();
|
||||
int z = byteStream.readInt();
|
||||
|
||||
this.coords = new ChunkCoords(dim, x, y, z);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LogHelper.error("Could not read EventCoords data from stream.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package magicbees.main.utils.net;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import magicbees.main.utils.ChunkCoords;
|
||||
import magicbees.main.utils.LogHelper;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class EventInventoryUpdate extends EventCoords {
|
||||
|
||||
private int slotIndex;
|
||||
private ItemStack itemStack;
|
||||
|
||||
public EventInventoryUpdate(ChunkCoords position, int slot, ItemStack item) {
|
||||
super(NetworkEventHandler.EventType.INVENTORY_UPDATE, position);
|
||||
|
||||
this.slotIndex = slot;
|
||||
this.itemStack = item;
|
||||
}
|
||||
|
||||
public EventInventoryUpdate(DataInputStream byteStream) {
|
||||
super(NetworkEventHandler.EventType.INVENTORY_UPDATE, byteStream);
|
||||
|
||||
this.readDataFromInputStream(byteStream);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeDataToOutputStream(DataOutputStream byteStream) {
|
||||
super.writeDataToOutputStream(byteStream);
|
||||
|
||||
try {
|
||||
byteStream.writeInt(this.slotIndex);
|
||||
this.writeItemStackToData(this.itemStack, byteStream);
|
||||
} catch (IOException e) {
|
||||
LogHelper.error("Could not write EventInventoryUpdate to byte stream.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readDataFromInputStream(DataInputStream byteStream) {
|
||||
super.readDataFromInputStream(byteStream);
|
||||
|
||||
try {
|
||||
this.slotIndex = byteStream.readInt();
|
||||
this.itemStack = this.readItemStackFromData(byteStream);
|
||||
} catch (IOException e) {
|
||||
LogHelper.error("Could not read EventInventoryUpdate to byte stream.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(EntityPlayerMP player) {
|
||||
TileEntity tile = FMLClientHandler.instance().getClient().theWorld.getTileEntity(getCoords().x, getCoords().y, getCoords().z);
|
||||
|
||||
if (tile != null && tile instanceof IInventory) {
|
||||
((IInventory) tile).setInventorySlotContents(slotIndex, itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package magicbees.main.utils.net;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufInputStream;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import magicbees.main.utils.ChunkCoords;
|
||||
import magicbees.main.utils.LogHelper;
|
||||
import magicbees.main.utils.VersionInfo;
|
||||
import magicbees.main.utils.error.InvalidEventTypeIndexException;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.network.FMLEventChannel;
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent;
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
|
||||
public class NetworkEventHandler {
|
||||
|
||||
public static final String CHANNEL_NAME = VersionInfo.ModName;
|
||||
|
||||
public enum EventType {
|
||||
UNKNOWN,
|
||||
INVENTORY_UPDATE,
|
||||
;
|
||||
}
|
||||
|
||||
private FMLEventChannel channel;
|
||||
|
||||
public NetworkEventHandler() {
|
||||
channel = NetworkRegistry.INSTANCE.newEventDrivenChannel(CHANNEL_NAME);
|
||||
channel.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPacket(ServerCustomPacketEvent event) {
|
||||
this.parseAndDispatchPacket(event.packet.payload(), ((NetHandlerPlayServer)event.handler).playerEntity);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPacket(ClientCustomPacketEvent event) {
|
||||
this.parseAndDispatchPacket(event.packet.payload(), null);
|
||||
}
|
||||
|
||||
public void sendInventoryUpdate(TileEntity entity, int slotIndex, ItemStack itemStack) {
|
||||
EventInventoryUpdate event = new EventInventoryUpdate(new ChunkCoords(entity), slotIndex, itemStack);
|
||||
FMLProxyPacket packet = event.getPacket();
|
||||
|
||||
sendPacket(packet);
|
||||
}
|
||||
|
||||
private void sendPacket(FMLProxyPacket packet) {
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
|
||||
channel.sendToAll(packet);
|
||||
}
|
||||
else {
|
||||
channel.sendToServer(packet);
|
||||
}
|
||||
}
|
||||
|
||||
private void parseAndDispatchPacket(ByteBuf packetPayload, EntityPlayerMP player) {
|
||||
try {
|
||||
DataInputStream data = new DataInputStream(new ByteBufInputStream(packetPayload));
|
||||
|
||||
processEventData(data, player);
|
||||
|
||||
data.close();
|
||||
} catch (IOException e) {
|
||||
LogHelper.info("DataInputStream had a problem closing. Good for it.");
|
||||
//e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void processEventData(DataInputStream data, EntityPlayerMP player) throws IOException {
|
||||
int eventId = data.readInt();
|
||||
|
||||
if (eventId == EventType.INVENTORY_UPDATE.ordinal()) {
|
||||
EventInventoryUpdate eventData = new EventInventoryUpdate(data);
|
||||
eventData.process(player);
|
||||
}
|
||||
else {
|
||||
throw new InvalidEventTypeIndexException("");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package magicbees.main.utils.net;
|
||||
|
||||
public class PacketInventoryUpdate {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package magicbees.tileentity;
|
||||
|
||||
import magicbees.bees.BeeManager;
|
||||
import magicbees.main.CommonProxy;
|
||||
import magicbees.main.MagicBees;
|
||||
import magicbees.main.utils.LogHelper;
|
||||
import magicbees.reference.Names;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -17,7 +19,6 @@ import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
@@ -28,12 +29,9 @@ import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ErrorStateRegistry;
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.inventory.InvTools;
|
||||
import forestry.core.inventory.InventoryAdapter;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class TileEntityThaumicApiary extends TileEntity implements ISidedInventory, IBeeHousing {
|
||||
|
||||
@@ -62,7 +60,7 @@ public class TileEntityThaumicApiary extends TileEntity implements ISidedInvento
|
||||
public TileEntityThaumicApiary()
|
||||
{
|
||||
items = new ItemStack[12];
|
||||
logic = PluginApiculture.beeInterface.createBeekeepingLogic(this);
|
||||
logic = BeeManager.beeRoot.createBeekeepingLogic(this);
|
||||
}
|
||||
|
||||
public void setOwner(EntityPlayer player) { this.ownerName = player.getGameProfile(); }
|
||||
@@ -92,15 +90,17 @@ public class TileEntityThaumicApiary extends TileEntity implements ISidedInvento
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: Investigate this :D
|
||||
@Override
|
||||
public void onQueenChange(ItemStack queenStack) {
|
||||
|
||||
if (!worldObj.isRemote) {
|
||||
MagicBees.object.netHandler.sendInventoryUpdate(this, SLOT_QUEEN, queenStack);
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wearOutEquipment(int amount) {
|
||||
int wear = Math.round(amount * PluginApiculture.beeInterface.getBeekeepingMode(worldObj).getWearModifier());
|
||||
int wear = Math.round(amount * BeeManager.beeRoot.getBeekeepingMode(worldObj).getWearModifier());
|
||||
|
||||
for (int i = SLOT_FRAME_START; i < SLOT_FRAME_START + SLOT_FRAME_COUNT; i++) {
|
||||
if (getStackInSlot(i) == null) {
|
||||
@@ -111,7 +111,7 @@ public class TileEntityThaumicApiary extends TileEntity implements ISidedInvento
|
||||
}
|
||||
|
||||
setInventorySlotContents(i, ((IHiveFrame) getStackInSlot(i).getItem()).frameUsed(this, getStackInSlot(i),
|
||||
PluginApiculture.beeInterface.getMember(getStackInSlot(SLOT_QUEEN)), wear));
|
||||
BeeManager.beeRoot.getMember(getStackInSlot(SLOT_QUEEN)), wear));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,14 +398,14 @@ public class TileEntityThaumicApiary extends TileEntity implements ISidedInvento
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack itemStack, int side) {
|
||||
if(slot == SLOT_QUEEN && PluginApiculture.beeInterface.isMember(itemStack)
|
||||
&& !PluginApiculture.beeInterface.isDrone(itemStack)) {
|
||||
if(slot == SLOT_QUEEN && BeeManager.beeRoot.isMember(itemStack)
|
||||
&& !BeeManager.beeRoot.isDrone(itemStack)) {
|
||||
return true;
|
||||
}
|
||||
else if (slot == SLOT_DRONE && PluginApiculture.beeInterface.isDrone(itemStack)) {
|
||||
else if (slot == SLOT_DRONE && BeeManager.beeRoot.isDrone(itemStack)) {
|
||||
return true;
|
||||
}
|
||||
return slot == SLOT_DRONE && PluginApiculture.beeInterface.isDrone(itemStack);
|
||||
return slot == SLOT_DRONE && BeeManager.beeRoot.isDrone(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -428,10 +428,10 @@ public class TileEntityThaumicApiary extends TileEntity implements ISidedInvento
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) {
|
||||
return PluginApiculture.beeInterface.getMember(getStackInSlot(SLOT_QUEEN)).getHealth();
|
||||
if (BeeManager.beeRoot.isMated(getStackInSlot(SLOT_QUEEN))) {
|
||||
return BeeManager.beeRoot.getMember(getStackInSlot(SLOT_QUEEN)).getHealth();
|
||||
}
|
||||
else if (ForestryItem.beePrincessGE.isItemEqual(getStackInSlot(SLOT_QUEEN))) {
|
||||
else if (!BeeManager.beeRoot.isDrone(getStackInSlot(SLOT_QUEEN))) {
|
||||
return displayHealth;
|
||||
}
|
||||
else {
|
||||
@@ -443,10 +443,10 @@ public class TileEntityThaumicApiary extends TileEntity implements ISidedInvento
|
||||
if (getStackInSlot(SLOT_QUEEN) == null) {
|
||||
return 0;
|
||||
}
|
||||
if (ForestryItem.beeQueenGE.isItemEqual(getStackInSlot(SLOT_QUEEN))) {
|
||||
return PluginApiculture.beeInterface.getMember(getStackInSlot(SLOT_QUEEN)).getMaxHealth();
|
||||
if (BeeManager.beeRoot.isMated(getStackInSlot(SLOT_QUEEN))) {
|
||||
return BeeManager.beeRoot.getMember(getStackInSlot(SLOT_QUEEN)).getMaxHealth();
|
||||
}
|
||||
else if (ForestryItem.beePrincessGE.isItemEqual(getStackInSlot(SLOT_QUEEN))) {
|
||||
else if (!BeeManager.beeRoot.isDrone(getStackInSlot(SLOT_QUEEN))) {
|
||||
return displayHealthMax;
|
||||
}
|
||||
else {
|
||||
@@ -531,11 +531,11 @@ public class TileEntityThaumicApiary extends TileEntity implements ISidedInvento
|
||||
updateBiome();
|
||||
}
|
||||
|
||||
if (!Proxies.common.isSimulating(worldObj)) {
|
||||
updateClientSide();
|
||||
if (worldObj.isRemote) {
|
||||
updateServerSide();
|
||||
}
|
||||
else {
|
||||
updateServerSide();
|
||||
updateClientSide();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -552,9 +552,9 @@ public class TileEntityThaumicApiary extends TileEntity implements ISidedInvento
|
||||
}
|
||||
|
||||
public void updateClientSide() {
|
||||
if (PluginApiculture.beeInterface.isMated(getStackInSlot(SLOT_QUEEN))) {
|
||||
if (getErrorState() == ErrorStateRegistry.getErrorState("OK") && worldObj.getTotalWorldTime() % 2 % 2 == 0) {
|
||||
IBee displayQueen = PluginApiculture.beeInterface.getMember(getStackInSlot(SLOT_QUEEN));
|
||||
if (BeeManager.beeRoot.isMated(getStackInSlot(SLOT_QUEEN))) {
|
||||
if (getErrorState() == ErrorStateRegistry.getErrorState("OK") && worldObj.getTotalWorldTime() % 10 == 0) {
|
||||
IBee displayQueen = BeeManager.beeRoot.getMember(getStackInSlot(SLOT_QUEEN));
|
||||
displayQueen.doFX(logic.getEffectData(), this);
|
||||
}
|
||||
}
|
||||
@@ -568,7 +568,7 @@ public class TileEntityThaumicApiary extends TileEntity implements ISidedInvento
|
||||
return;
|
||||
}
|
||||
|
||||
if (worldObj.getTotalWorldTime() % 200 * 10 == 0) {
|
||||
if (worldObj.getTotalWorldTime() % 5 == 0) {
|
||||
onQueenChange(getStackInSlot(SLOT_QUEEN));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user