Work on Thaumic Apiary. Creating Packet Handler for sending network events (ie queen item stack changes)

Tweaking textures on thaumic apiary again
Adding MORE crap to gitignore
build.gradle missing a runDir argument, apparently.
This commit is contained in:
MysteriousAges committed 2015-03-17 23:03:48 -07:00
1 parent ad9135590d
commit 5d4b84727d
11 files changed
+196 -68

No files matched your search

@@ -13,12 +13,12 @@ public class ContainerMB extends Container
public void addPlayerInventory(InventoryPlayer inventoryPlayer, int xStart, int yStart)
{
for (int x = 0; x < PLAYER_INVENTORY_COLUMNS; x++){
addSlotToContainer(new Slot(inventoryPlayer, x, 8 + 18 * x, yStart + 4 + PLAYER_INVENTORY_ROWS * 18));
addSlotToContainer(new Slot(inventoryPlayer, x, xStart + 8 + 18 * x, yStart + 4 + PLAYER_INVENTORY_ROWS * 18));
}
for (int y = 0; y < PLAYER_INVENTORY_ROWS; y++){
for (int x = 0; x < PLAYER_INVENTORY_COLUMNS; x++){
addSlotToContainer(new Slot(inventoryPlayer, x + y * 9 + 9, 8 + 18 * x, yStart + y * 18));
addSlotToContainer(new Slot(inventoryPlayer, x + y * 9 + 9, xStart + 8 + 18 * x, yStart + y * 18));
}
}
}
@@ -12,7 +12,7 @@ import net.minecraft.item.ItemStack;
public class ContainerThaumicApiary extends ContainerMB {
private TileEntityThaumicApiary thaumicApiary;
public TileEntityThaumicApiary apiary;
public int maxSlot = 0;
// Constants
@@ -24,12 +24,12 @@ public class ContainerThaumicApiary extends ContainerMB {
private static final int SLOT_INVENTORY_COUNT = 7;
public ContainerThaumicApiary(InventoryPlayer inventoryPlayer, TileEntityThaumicApiary thaumicApiary){
this.thaumicApiary = thaumicApiary;
this.apiary = thaumicApiary;
// Queen/Princess slot
addSlotToContainer(new SlotCustomItems(this.thaumicApiary, 0, 29, 39, ItemInterface.getItemStack("Forestry", "beeQueenGE", 1), ItemInterface.getItemStack("Forestry", "beePrincessGE", 1)));
addSlotToContainer(new SlotCustomItems(this.apiary, 0, 29, 39, ItemInterface.getItemStack("Forestry", "beeQueenGE", 1), ItemInterface.getItemStack("Forestry", "beePrincessGE", 1)));
// Drone slot
addSlotToContainer(new SlotCustomItems(this.thaumicApiary, 1, 29, 65, ItemInterface.getItemStack("Forestry", "beeDroneGE", 64)));
addSlotToContainer(new SlotCustomItems(this.apiary, 1, 29, 65, ItemInterface.getItemStack("Forestry", "beeDroneGE", 64)));
int currentSlot = 1;
@@ -56,7 +56,7 @@ public class ContainerThaumicApiary extends ContainerMB {
j++;
}
addPlayerInventory(inventoryPlayer, 0, 108);
addPlayerInventory(inventoryPlayer, 6, 109);
maxSlot = currentSlot;
@@ -105,13 +105,13 @@ public class ContainerThaumicApiary extends ContainerMB {
@Override
public boolean canInteractWith(EntityPlayer entityPlayer) {
return thaumicApiary.isUseableByPlayer(entityPlayer);
return apiary.isUseableByPlayer(entityPlayer);
}
@Override
public void updateProgressBar(int i, int j) {
thaumicApiary.getGUINetworkData(i, j);
apiary.getGUINetworkData(i, j);
}
@Override
@@ -119,7 +119,7 @@ public class ContainerThaumicApiary extends ContainerMB {
super.detectAndSendChanges();
for (Object crafter : crafters) {
thaumicApiary.sendGUINetworkData(this, (ICrafting) crafter);
apiary.sendGUINetworkData(this, (ICrafting) crafter);
}
}
}
@@ -8,6 +8,7 @@ import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
@@ -17,6 +18,40 @@ public class GuiThaumicApiary extends GuiContainer
private static final int WIDTH = 176;
private static final int HEIGHT = 190;
private static final int LIFEBAR_WIDTH = 2;
private static final int LIFEBAR_HEIGHT = 46;
private static final int LIFEBAR_DEST_X = 21;
private static final int LIFEBAR_DEST_Y = 37;
private static final int LIFEBAR_SRC_Y = 0;
private static final int LIFEBAR_SRC_STAGE1_X = 193;
private static final int LIFEBAR_SRC_STAGE2_X = 189;
private static final int LIFEBAR_SRC_STAGE3_X = 185;
private static final int LIFEBAR_SRC_STAGE4_X = 181;
private static final int LIFEBAR_SRC_STAGE5_X = 177;
private static final int WORKBOOST_WIDTH = 16;
private static final int WORKBOOST_HEIGHT = 12;
private static final int WORKBOOST_DEST_X = 37;
private static final int WORKBOOST_DEST_Y = 18;
private static final int WORKBOOST_SRC_X = 176;
private static final int WORKBOOST_SRC_Y = 46;
private static final int DEATHBOOST_WIDTH = 11;
private static final int DEATHBOOST_HEIGHT = 13;
private static final int DEATHBOOST_DEST_X = 25;
private static final int DEATHBOOST_DEST_Y = 17;
private static final int DEATHBOOST_SRC_X = 176;
private static final int DEATHBOOST_SRC_Y = 58;
private static final int MUTATIONBOOST_WIDTH = 9;
private static final int MUTATIONBOOST_HEIGHT = 13;
private static final int MUTATIONBOOST_DEST_X = 15;
private static final int MUTATIONBOOST_DEST_Y = 17;
private static final int MUTATIONBOOST_SRC_X = 176;
private static final int MUTATIONBOOST_SRC_Y = 71;
public GuiThaumicApiary(InventoryPlayer inventoryPlayer, TileEntityThaumicApiary thaumicApiary) {
super(new ContainerThaumicApiary(inventoryPlayer, thaumicApiary));
@@ -25,12 +60,35 @@ public class GuiThaumicApiary extends GuiContainer
this.ySize = HEIGHT;
}
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2)
{
fontRendererObj.drawString("Inventory", 9, 99, 0);
}
@Override
protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y) {
GL11.glColor4f(1, 1, 1, 1);
this.mc.getTextureManager().bindTexture(BACKGROUND_LOCATION);
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);
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()) {
this.drawTexturedModalRect(this.guiLeft + MUTATIONBOOST_DEST_X, this.guiTop + MUTATIONBOOST_DEST_Y,
MUTATIONBOOST_SRC_X, MUTATIONBOOST_SRC_Y, MUTATIONBOOST_WIDTH, MUTATIONBOOST_HEIGHT);
}
}
}
@@ -0,0 +1,19 @@
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,5 @@
package magicbees.main.utils.net;
public class PacketInventoryUpdate {
}
@@ -1,18 +1,5 @@
package magicbees.tileentity;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.*;
import forestry.api.core.ErrorStateRegistry;
import forestry.api.core.IErrorState;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.genetics.IIndividual;
import forestry.core.config.ForestryItem;
import forestry.core.inventory.InvTools;
import forestry.core.proxy.Proxies;
import forestry.core.inventory.InventoryAdapter;
import forestry.core.utils.Utils;
import forestry.plugins.PluginApiculture;
import magicbees.main.CommonProxy;
import magicbees.main.utils.LogHelper;
import magicbees.reference.Names;
@@ -28,6 +15,26 @@ import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
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;
import forestry.api.apiculture.IBeekeepingLogic;
import forestry.api.apiculture.IHiveFrame;
import forestry.api.core.EnumHumidity;
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 {
public static final String tileEntityName = CommonProxy.DOMAIN + ".thaumicApiary";
@@ -95,15 +102,15 @@ public class TileEntityThaumicApiary extends TileEntity implements ISidedInvento
public void wearOutEquipment(int amount) {
int wear = Math.round(amount * PluginApiculture.beeInterface.getBeekeepingMode(worldObj).getWearModifier());
for (int i = SLOT_FRAME_START; i < SLOT_FRAME_START + SLOT_FRAME_COUNT; i++){
if (getStackInSlot(i) == null)
for (int i = SLOT_FRAME_START; i < SLOT_FRAME_START + SLOT_FRAME_COUNT; i++) {
if (getStackInSlot(i) == null) {
continue;
if (!(getStackInSlot(i).getItem() instanceof IHiveFrame))
}
if (!(getStackInSlot(i).getItem() instanceof IHiveFrame)) {
continue;
}
setInventorySlotContents(
i,
((IHiveFrame) getStackInSlot(i).getItem()).frameUsed(this, getStackInSlot(i),
setInventorySlotContents(i, ((IHiveFrame) getStackInSlot(i).getItem()).frameUsed(this, getStackInSlot(i),
PluginApiculture.beeInterface.getMember(getStackInSlot(SLOT_QUEEN)), wear));
}
}
@@ -149,6 +156,9 @@ public class TileEntityThaumicApiary extends TileEntity implements ISidedInvento
if (getStackInSlot(i).getItem() instanceof IHiveFrame)
mod *= ((IHiveFrame) getStackInSlot(i).getItem()).getMutationModifier(genome, mate, mod);
}
if (this.isMutationBoosted()) {
mod = mod * 2f;
}
return mod;
}
@@ -161,6 +171,9 @@ public class TileEntityThaumicApiary extends TileEntity implements ISidedInvento
if (getStackInSlot(i).getItem() instanceof IHiveFrame)
mod *= ((IHiveFrame) getStackInSlot(i).getItem()).getLifespanModifier(genome, mate, mod);
}
if (this.isDeathRateBoosted()) {
mod = mod / 2f;
}
return mod;
}
@@ -173,6 +186,9 @@ public class TileEntityThaumicApiary extends TileEntity implements ISidedInvento
if (getStackInSlot(i).getItem() instanceof IHiveFrame)
mod *= ((IHiveFrame) getStackInSlot(i).getItem()).getProductionModifier(genome, mod);
}
if (this.isWorkBoosted()) {
mod = mod * 2f;
}
return mod;
}
@@ -407,33 +423,41 @@ public class TileEntityThaumicApiary extends TileEntity implements ISidedInvento
}
/* Health display */
private int getHealthDisplay(){
if (getStackInSlot(SLOT_QUEEN) == null)
private int getHealthDisplay() {
if (getStackInSlot(SLOT_QUEEN) == null) {
return 0;
}
if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN)))
if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) {
return PluginApiculture.beeInterface.getMember(getStackInSlot(SLOT_QUEEN)).getHealth();
else if (ForestryItem.beePrincessGE.isItemEqual(getStackInSlot(SLOT_QUEEN)))
}
else if (ForestryItem.beePrincessGE.isItemEqual(getStackInSlot(SLOT_QUEEN))) {
return displayHealth;
else
}
else {
return 0;
}
}
private int getMaxHealthDisplay(){
if (getStackInSlot(SLOT_QUEEN) == null)
private int getMaxHealthDisplay() {
if (getStackInSlot(SLOT_QUEEN) == null) {
return 0;
if (ForestryItem.beeQueenGE.isItemEqual(getStackInSlot(SLOT_QUEEN)))
}
if (ForestryItem.beeQueenGE.isItemEqual(getStackInSlot(SLOT_QUEEN))) {
return PluginApiculture.beeInterface.getMember(getStackInSlot(SLOT_QUEEN)).getMaxHealth();
else if (ForestryItem.beePrincessGE.isItemEqual(getStackInSlot(SLOT_QUEEN)))
}
else if (ForestryItem.beePrincessGE.isItemEqual(getStackInSlot(SLOT_QUEEN))) {
return displayHealthMax;
else
}
else {
return 0;
}
}
private int getHealthScaled(int i){
if (getMaxHealthDisplay() == 0)
public int getHealthScaled(int i) {
if (getMaxHealthDisplay() == 0) {
return 0;
}
return (getHealthDisplay() * i) / getMaxHealthDisplay();
}
@@ -448,15 +472,15 @@ public class TileEntityThaumicApiary extends TileEntity implements ISidedInvento
/* Saving and loading */
@Override
public void writeToNBT(NBTTagCompound compound){
public void writeToNBT(NBTTagCompound compound) {
super.writeToNBT(compound);
NBTTagList items = new NBTTagList();
for (int i = 0; i < getSizeInventory(); i++){
for (int i = 0; i < getSizeInventory(); i++) {
ItemStack itemStack = getStackInSlot(i);
if (itemStack != null){
if (itemStack != null) {
NBTTagCompound item = new NBTTagCompound();
item.setByte("Slot", (byte)i);
itemStack.writeToNBT(item);
@@ -465,23 +489,24 @@ public class TileEntityThaumicApiary extends TileEntity implements ISidedInvento
}
compound.setInteger("BiomeId", biome.biomeID);
if (logic != null)
if (logic != null) {
logic.writeToNBT(compound);
}
compound.setTag("Items", items);
}
@Override
public void readFromNBT(NBTTagCompound compound){
public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(compound);
NBTTagList items = compound.getTagList("Items", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < items.tagCount(); i++){
for (int i = 0; i < items.tagCount(); i++) {
NBTTagCompound item = (NBTTagCompound)items.getCompoundTagAt(i);
int slot = item.getByte("Slot");
if (slot >= 0 && slot < getSizeInventory()){
if (slot >= 0 && slot < getSizeInventory()) {
setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(item));
}
}
@@ -491,32 +516,34 @@ public class TileEntityThaumicApiary extends TileEntity implements ISidedInvento
logic.readFromNBT(compound);
}
public float getExactTemperature(){
public float getExactTemperature() {
return biome.temperature;
}
public float getExactHumidity(){
public float getExactHumidity() {
return biome.rainfall;
}
@Override
public void updateEntity(){
if (init == false){
public void updateEntity() {
if (init == false) {
init = true;
updateBiome();
}
if (!Proxies.common.isSimulating(worldObj))
if (!Proxies.common.isSimulating(worldObj)) {
updateClientSide();
else
}
else {
updateServerSide();
}
}
public void updateBiome(){
if (worldObj != null){
if (biome == null){
public void updateBiome() {
if (worldObj != null) {
if (biome == null) {
BiomeGenBase biome = Utils.getBiomeAt(worldObj, xCoord, yCoord);
if (biome != null){
if (biome != null) {
this.biome = biome;
setErrorState(ErrorStateRegistry.getErrorState("OK"));
}
@@ -524,7 +551,7 @@ public class TileEntityThaumicApiary extends TileEntity implements ISidedInvento
}
}
public void updateClientSide(){
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));
@@ -533,21 +560,23 @@ public class TileEntityThaumicApiary extends TileEntity implements ISidedInvento
}
}
public void updateServerSide(){
public void updateServerSide() {
logic.update();
IBee queen = logic.getQueen();
if (queen == null)
if (queen == null) {
return;
}
// Swarm effects
if (worldObj.getTotalWorldTime() % 200 * 10 == 0)
if (worldObj.getTotalWorldTime() % 200 * 10 == 0) {
onQueenChange(getStackInSlot(SLOT_QUEEN));
}
}
public void getGUINetworkData(int i, int j){
if (logic == null)
public void getGUINetworkData(int i, int j) {
if (logic == null) {
return;
}
switch(i) {
case 0:
@@ -559,10 +588,23 @@ public class TileEntityThaumicApiary extends TileEntity implements ISidedInvento
}
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
if (logic == null)
if (logic == null) {
return;
}
iCrafting.sendProgressBarUpdate(container, 0, logic.getBreedingTime());
iCrafting.sendProgressBarUpdate(container, 1, logic.getTotalBreedingTime());
}
public boolean isWorkBoosted() {
return false;
}
public boolean isDeathRateBoosted() {
return false;
}
public boolean isMutationBoosted() {
return false;
}
}