mirror of
https://github.com/GTNewHorizons/MagicBees.git
synced 2026-11-21 04:32:34 +00:00
PR comment fixes.
This commit is contained in:
1 parent
2b1e179eeb
commit
e24a94f0ba
8 files changed
+132
-157
No files matched your search
@@ -12,27 +12,15 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ContainerEffectJar extends Container {
|
||||
|
||||
public TileEntityEffectJar jar;
|
||||
public class ContainerEffectJar extends effectContainer {
|
||||
|
||||
public int lastBeeHealth = 0;
|
||||
public int speciesColour = 0xffffff;
|
||||
|
||||
TileEntityEffectJar jar;
|
||||
public ContainerEffectJar(TileEntityEffectJar tileEntityEffectJar, EntityPlayer player) {
|
||||
this.jar = tileEntityEffectJar;
|
||||
this.addSlotToContainer(
|
||||
new SlotCustomItems(this.jar, 0, 80, 22, GameRegistry.findItemStack("Forestry", "beeDroneGE", 1)));
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 74 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 132));
|
||||
}
|
||||
super(tileEntityEffectJar, player);
|
||||
jar = (TileEntityEffectJar) inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,29 +63,4 @@ public class ContainerEffectJar extends Container {
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return this.jar.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
|
||||
Slot itemSlot = this.getSlot(slot);
|
||||
boolean clearSlot = false;
|
||||
|
||||
if (itemSlot != null && itemSlot.getHasStack()) {
|
||||
ItemStack srcStack = itemSlot.getStack();
|
||||
if (slot == 0 && srcStack != null) {
|
||||
clearSlot = this.mergeItemStack(srcStack, 1, 36 + 1, false);
|
||||
} else {
|
||||
if (this.getSlot(0).isItemValid(srcStack)) {
|
||||
clearSlot = this.mergeItemStack(srcStack, 0, 1, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (clearSlot) {
|
||||
itemSlot.putStack(null);
|
||||
}
|
||||
itemSlot.onSlotChanged();
|
||||
player.inventory.markDirty();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -9,24 +9,10 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ContainerEffectRing extends Container {
|
||||
|
||||
InventoryBeeRing IBR;
|
||||
public class ContainerEffectRing extends effectContainer {
|
||||
|
||||
public ContainerEffectRing(InventoryBeeRing IBR, EntityPlayer player) {
|
||||
this.IBR = IBR;
|
||||
this.addSlotToContainer(
|
||||
new SlotCustomItems(this.IBR, 0, 80, 22, GameRegistry.findItemStack("Forestry", "beeDroneGE", 1)));
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 74 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 132));
|
||||
}
|
||||
super(IBR, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -34,31 +20,6 @@ public class ContainerEffectRing extends Container {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
|
||||
Slot itemSlot = this.getSlot(slot);
|
||||
boolean clearSlot = false;
|
||||
|
||||
if (itemSlot != null && itemSlot.getHasStack()) {
|
||||
ItemStack srcStack = itemSlot.getStack();
|
||||
if (slot == 0 && srcStack != null) {
|
||||
clearSlot = this.mergeItemStack(srcStack, 1, 36 + 1, false);
|
||||
} else {
|
||||
if (this.getSlot(0).isItemValid(srcStack)) {
|
||||
clearSlot = this.mergeItemStack(srcStack, 0, 1, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (clearSlot) {
|
||||
itemSlot.putStack(null);
|
||||
}
|
||||
itemSlot.onSlotChanged();
|
||||
player.inventory.markDirty();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
@@ -9,28 +9,14 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GUIEffectJar extends GuiContainer {
|
||||
public class GUIEffectJar extends effectGui {
|
||||
|
||||
public static final String BACKGROUND_FILE = "jarScreen.png";
|
||||
public static final ResourceLocation BACKGROUND_LOCATION = new ResourceLocation(
|
||||
CommonProxy.DOMAIN,
|
||||
CommonProxy.GUI_TEXTURE + "jarScreen.png");
|
||||
CommonProxy.GUI_TEXTURE + BACKGROUND_FILE);
|
||||
|
||||
private static final int WIDTH = 176;
|
||||
private static final int HEIGHT = 156;
|
||||
|
||||
private static final int SLOT_JAR_X = 80;
|
||||
private static final int SLOT_JAR_Y = 22;
|
||||
private static final int SLOT_INVENTORY_X = 8;
|
||||
private static final int SLOT_INVENTORY_Y = 74;
|
||||
private static final int BAR_DEST_X = 117;
|
||||
private static final int BAR_DEST_Y = 10;
|
||||
|
||||
private static final int BAR_SRC_X = 176;
|
||||
private static final int BAR_SRC_Y = 0;
|
||||
|
||||
private static final int BAR_WIDTH = 10;
|
||||
private static final int BAR_HEIGHT = 40;
|
||||
|
||||
public GUIEffectJar(TileEntityEffectJar jar, EntityPlayer player) {
|
||||
super(new ContainerEffectJar(jar, player));
|
||||
@@ -38,11 +24,6 @@ public class GUIEffectJar extends GuiContainer {
|
||||
this.ySize = HEIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
fontRendererObj.drawString("Inventory", 9, 63, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
|
||||
GL11.glColor4f(1f, 1f, 1f, 1f);
|
||||
@@ -51,7 +32,7 @@ public class GUIEffectJar extends GuiContainer {
|
||||
|
||||
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
TileEntityEffectJar jar = ((ContainerEffectJar) this.inventorySlots).jar;
|
||||
TileEntityEffectJar jar = (TileEntityEffectJar) ((ContainerEffectJar) this.inventorySlots).inventory;
|
||||
float r = ((jar.currentBeeColour >> 16) & 255) / 255f;
|
||||
float g = ((jar.currentBeeColour >> 8) & 255) / 255f;
|
||||
float b = (jar.currentBeeColour & 255) / 255f;
|
||||
|
||||
@@ -4,31 +4,19 @@ import magicbees.item.ItemBeeRing;
|
||||
import magicbees.itemInventories.InventoryBeeRing;
|
||||
import magicbees.main.CommonProxy;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GUIEffectRing extends GuiContainer {
|
||||
public class GUIEffectRing extends effectGui {
|
||||
|
||||
public static final String BACKGROUND_FILE = "ringScreen.png";
|
||||
public static final ResourceLocation BACKGROUND_LOCATION = new ResourceLocation(
|
||||
CommonProxy.DOMAIN,
|
||||
CommonProxy.GUI_TEXTURE + BACKGROUND_FILE);
|
||||
|
||||
private static final int WIDTH = 176;
|
||||
private static final int HEIGHT = 156;
|
||||
|
||||
private static final int BAR_DEST_X = 117;
|
||||
private static final int BAR_DEST_Y = 10;
|
||||
|
||||
private static final int BAR_SRC_X = 176;
|
||||
private static final int BAR_SRC_Y = 0;
|
||||
|
||||
private static final int BAR_WIDTH = 10;
|
||||
private static final int BAR_HEIGHT = 40;
|
||||
|
||||
public GUIEffectRing(ItemStack itemStack, EntityPlayer player) {
|
||||
super(
|
||||
@@ -39,10 +27,7 @@ public class GUIEffectRing extends GuiContainer {
|
||||
this.ySize = HEIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
fontRendererObj.drawString("Inventory", 9, 63, 0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
|
||||
@@ -52,7 +37,7 @@ public class GUIEffectRing extends GuiContainer {
|
||||
|
||||
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
InventoryBeeRing IBR = ((ContainerEffectRing) this.inventorySlots).IBR;
|
||||
InventoryBeeRing IBR = (InventoryBeeRing) ((ContainerEffectRing) this.inventorySlots).inventory;
|
||||
float r = ((IBR.currentBeeColour >> 16) & 255) / 255f;
|
||||
float g = ((IBR.currentBeeColour >> 8) & 255) / 255f;
|
||||
float b = (IBR.currentBeeColour & 255) / 255f;
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package magicbees.client.gui;
|
||||
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class effectContainer extends Container {
|
||||
|
||||
public IInventory inventory;
|
||||
|
||||
public effectContainer(IInventory inventory, EntityPlayer player) {
|
||||
this.inventory = inventory;
|
||||
this.addSlotToContainer(
|
||||
new SlotCustomItems(this.inventory, 0, 80, 22, GameRegistry.findItemStack("Forestry", "beeDroneGE", 1)));
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 74 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 132));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
|
||||
Slot itemSlot = this.getSlot(slot);
|
||||
boolean clearSlot = false;
|
||||
|
||||
if (itemSlot != null && itemSlot.getHasStack()) {
|
||||
ItemStack srcStack = itemSlot.getStack();
|
||||
if (slot == 0 && srcStack != null) {
|
||||
clearSlot = this.mergeItemStack(srcStack, 1, 36 + 1, false);
|
||||
} else {
|
||||
if (this.getSlot(0).isItemValid(srcStack)) {
|
||||
clearSlot = this.mergeItemStack(srcStack, 0, 1, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (clearSlot) {
|
||||
itemSlot.putStack(null);
|
||||
}
|
||||
itemSlot.onSlotChanged();
|
||||
player.inventory.markDirty();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package magicbees.client.gui;
|
||||
|
||||
import magicbees.itemInventories.InventoryBeeRing;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public abstract class effectGui extends GuiContainer {
|
||||
|
||||
protected static final int WIDTH = 176;
|
||||
protected static final int HEIGHT = 156;
|
||||
|
||||
protected static final int BAR_DEST_X = 117;
|
||||
protected static final int BAR_DEST_Y = 10;
|
||||
|
||||
protected static final int BAR_SRC_X = 176;
|
||||
protected static final int BAR_SRC_Y = 0;
|
||||
|
||||
protected static final int BAR_WIDTH = 10;
|
||||
protected static final int BAR_HEIGHT = 40;
|
||||
|
||||
public effectGui(Container cont) {
|
||||
super(cont);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
fontRendererObj.drawString("Inventory", 9, 63, 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -98,56 +98,55 @@ public class ItemBeeRing extends Item implements IBauble {
|
||||
|
||||
// Logic to run the ring (this logic could be moved out of the item class, but it seems fine here)
|
||||
if (slot != -1) {
|
||||
if (hasQueen(itemStack, (EntityPlayer) entityLivingBase, slot)) {
|
||||
tickQueen(itemStack, (EntityPlayer) entityLivingBase, slot);
|
||||
} else if (hasDrone(itemStack, (EntityPlayer) entityLivingBase, slot)) {
|
||||
createQueenFromDrone(itemStack, (EntityPlayer) entityLivingBase, slot);
|
||||
InventoryBeeRing inventoryRing = getInventory((EntityPlayer) entityLivingBase, itemStack, slot, true);
|
||||
if (hasQueen(itemStack, (EntityPlayer) entityLivingBase, slot, inventoryRing)) {
|
||||
tickQueen(itemStack, (EntityPlayer) entityLivingBase, slot, inventoryRing);
|
||||
} else if (hasDrone(itemStack, (EntityPlayer) entityLivingBase, slot, inventoryRing)) {
|
||||
createQueenFromDrone(itemStack, (EntityPlayer) entityLivingBase, slot, inventoryRing);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createQueenFromDrone(ItemStack itemStack, EntityPlayer player, int slot) {
|
||||
private void createQueenFromDrone(ItemStack itemStack, EntityPlayer player, int slot, InventoryBeeRing ringInventory) {
|
||||
|
||||
InventoryBeeRing IBR = getInventory(player, itemStack, slot, true);
|
||||
ItemStack droneStack = IBR.getStackInSlot(0);
|
||||
ItemStack droneStack = ringInventory.getStackInSlot(0);
|
||||
if (magicbees.bees.BeeManager.beeRoot.isDrone(droneStack)) {
|
||||
IBee bee = magicbees.bees.BeeManager.beeRoot.getMember(droneStack);
|
||||
if (droneStack.stackSize == 1) {
|
||||
IBR.setInventorySlotContents(0, null);
|
||||
ringInventory.setInventorySlotContents(0, null);
|
||||
} else {
|
||||
droneStack.stackSize = droneStack.stackSize - 1;
|
||||
IBR.setInventorySlotContents(0, droneStack);
|
||||
ringInventory.setInventorySlotContents(0, droneStack);
|
||||
}
|
||||
ItemStack temp = droneStack.copy();
|
||||
temp.stackSize = 1;
|
||||
IBR.setInventorySlotContents(1, temp);
|
||||
ringInventory.setInventorySlotContents(1, temp);
|
||||
|
||||
int current = bee.getHealth();
|
||||
int max = bee.getMaxHealth();
|
||||
IBR.setCurrentBeeHealth((current * 100) / max);
|
||||
IBR.setCurrentBeeColour(bee.getGenome().getPrimary().getIconColour(0));
|
||||
ringInventory.setCurrentBeeHealth((current * 100) / max);
|
||||
ringInventory.setCurrentBeeColour(bee.getGenome().getPrimary().getIconColour(0));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasDrone(ItemStack itemStack, EntityPlayer player, int slot) {
|
||||
private boolean hasDrone(ItemStack itemStack, EntityPlayer player, int slot, InventoryBeeRing ringInventory) {
|
||||
return getInventory(player, itemStack, slot, true).getStackInSlot(DRONE_SLOT) != null;
|
||||
}
|
||||
|
||||
private void tickQueen(ItemStack itemStack, EntityPlayer player, int slot) {
|
||||
private void tickQueen(ItemStack itemStack, EntityPlayer player, int slot, InventoryBeeRing ringInventory) {
|
||||
|
||||
InventoryBeeRing IBR = getInventory(player, itemStack, slot, true);
|
||||
|
||||
IBee queen = magicbees.bees.BeeManager.beeRoot.getMember(IBR.getStackInSlot(QUEEN_SLOT));
|
||||
IBR.setCurrentBeeHealth((queen.getHealth() * 100) / queen.getMaxHealth());
|
||||
IBR.setCurrentBeeColour(queen.getGenome().getPrimary().getIconColour(0));
|
||||
IBee queen = magicbees.bees.BeeManager.beeRoot.getMember(ringInventory.getStackInSlot(QUEEN_SLOT));
|
||||
ringInventory.setCurrentBeeHealth((queen.getHealth() * 100) / queen.getMaxHealth());
|
||||
ringInventory.setCurrentBeeColour(queen.getGenome().getPrimary().getIconColour(0));
|
||||
|
||||
RingHousing housingLogic = new RingHousing(player, IBR);
|
||||
RingHousing housingLogic = new RingHousing(player, ringInventory);
|
||||
|
||||
IBR.setEffectAndInitialize(queen);
|
||||
IBR.effectData = queen.doEffect(IBR.effectData, housingLogic);
|
||||
IBR.writeEffectNBT();
|
||||
ringInventory.setEffectAndInitialize(queen);
|
||||
ringInventory.effectData = queen.doEffect(ringInventory.effectData, housingLogic);
|
||||
ringInventory.writeEffectNBT();
|
||||
|
||||
// Crashes irregularly for some reason I can't figure out, but this is just the bee effects around you, so it's
|
||||
// not a huge deal. It would be nice to have though
|
||||
@@ -158,24 +157,24 @@ public class ItemBeeRing extends Item implements IBauble {
|
||||
// }
|
||||
|
||||
// run the queen
|
||||
if (IBR.throttle > 550) {
|
||||
IBR.setThrottle(0);
|
||||
if (ringInventory.throttle > 550) {
|
||||
ringInventory.setThrottle(0);
|
||||
queen.age(player.getEntityWorld(), 0.26f);
|
||||
|
||||
if (queen.getHealth() == 0) {
|
||||
IBR.setInventorySlotContents(1, null);
|
||||
IBR.setCurrentBeeHealth(0);
|
||||
IBR.setCurrentBeeColour(0x0ffffff);
|
||||
ringInventory.setInventorySlotContents(1, null);
|
||||
ringInventory.setCurrentBeeHealth(0);
|
||||
ringInventory.setCurrentBeeColour(0x0ffffff);
|
||||
} else {
|
||||
queen.writeToNBT(IBR.contents[QUEEN_SLOT].stackTagCompound);
|
||||
queen.writeToNBT(ringInventory.contents[QUEEN_SLOT].stackTagCompound);
|
||||
}
|
||||
} else {
|
||||
IBR.setThrottle(IBR.throttle + 1);
|
||||
ringInventory.setThrottle(ringInventory.throttle + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasQueen(ItemStack itemStack, EntityPlayer player, int slot) {
|
||||
return getInventory(player, itemStack, slot, true).getStackInSlot(QUEEN_SLOT) != null;
|
||||
private boolean hasQueen(ItemStack itemStack, EntityPlayer player, int slot, InventoryBeeRing ringInventory) {
|
||||
return ringInventory.getStackInSlot(QUEEN_SLOT) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,10 +26,10 @@ import forestry.api.core.IErrorState;
|
||||
// Class that simulates a BeeHouse using both player data and info from InventoryBeeRing
|
||||
public class RingHousing implements IBeeHousing {
|
||||
|
||||
EntityPlayer player;
|
||||
BiomeGenBase biome;
|
||||
IBeeHousingInventory inventory;
|
||||
IBeekeepingLogic beekeepingLogic;
|
||||
private final EntityPlayer player;
|
||||
private final BiomeGenBase biome;
|
||||
private final IBeeHousingInventory inventory;
|
||||
private final IBeekeepingLogic beekeepingLogic;
|
||||
|
||||
private static final IErrorLogic errorLogic = new RingHousing.RingErrorLogic();
|
||||
private static final Iterable<IBeeListener> beeListeners = ImmutableSet.of(new DefaultBeeListener());
|
||||
|
||||
Reference in new issue
Block a user