Compare commits

...
3 Commits
4 changed files with 34 additions and 59 deletions

No files matched your search

@@ -20,10 +20,13 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.IIcon;
import org.lwjgl.input.Mouse;
import binnie.core.craftgui.CraftGUI;
import binnie.core.craftgui.IWidget;
import binnie.core.craftgui.Tooltip;
import binnie.core.craftgui.events.EventMouse;
import binnie.core.craftgui.events.EventWidget;
import binnie.core.craftgui.geometry.IArea;
import binnie.core.craftgui.geometry.IPoint;
import binnie.core.craftgui.minecraft.CustomSlot;
@@ -61,22 +64,17 @@ public class ControlSlot extends ControlSlotBase {
@Override
public void onEvent(EventMouse.Down event) {
if (slot == null) {
return;
}
clickSlot(event.getButton());
}
});
addSelfEventHandler(new EventWidget.StartMouseOver.Handler() {
PlayerControllerMP playerController = ((Window) getSuperParent()).getGui()
.getMinecraft().playerController;
int windowId = ((Window) getSuperParent()).getContainer().windowId;
int slotNumber = slot.slotNumber;
int button = event.getButton();
Window.get(getWidget()).getGui();
playerController.windowClick(
windowId,
slotNumber,
button,
GuiScreen.isShiftKeyDown() ? 1 : 0,
((Window) getSuperParent()).getGui().getMinecraft().thePlayer);
@Override
public void onEvent(EventWidget.StartMouseOver event) {
if (GuiScreen.isShiftKeyDown() && Mouse.isButtonDown(0)
&& Window.get(ControlSlot.this).getDraggedWidget() instanceof ControlSlot) {
clickSlot(0);
}
}
});
}
@@ -92,6 +90,19 @@ public class ControlSlot extends ControlSlotBase {
return this;
}
private void clickSlot(int button) {
if (slot == null) return;
Window window = (Window) getSuperParent();
PlayerControllerMP playerController = window.getGui().getMinecraft().playerController;
playerController.windowClick(
window.getContainer().windowId,
slot.slotNumber,
button,
GuiScreen.isShiftKeyDown() ? 1 : 0,
window.getGui().getMinecraft().thePlayer);
}
@Override
public void onRenderBackground() {
CraftGUI.render.texture(slotTexture, IPoint.ZERO);
@@ -33,7 +33,6 @@ import binnie.extrabees.genetics.ExtraBeesFlowers;
import cofh.api.energy.IEnergyReceiver;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.apiculture.IArmorApiarist;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.AlleleManager;
@@ -111,43 +110,6 @@ public enum ExtraBeesEffect implements IAlleleBeeEffect {
}
}
public static boolean wearsHelmet(EntityPlayer player) {
ItemStack armorItem = player.inventory.armorInventory[3];
return armorItem != null && armorItem.getItem() instanceof IArmorApiarist;
}
public static boolean wearsChest(EntityPlayer player) {
ItemStack armorItem = player.inventory.armorInventory[2];
return armorItem != null && armorItem.getItem() instanceof IArmorApiarist;
}
public static boolean wearsLegs(EntityPlayer player) {
ItemStack armorItem = player.inventory.armorInventory[1];
return armorItem != null && armorItem.getItem() instanceof IArmorApiarist;
}
public static boolean wearsBoots(EntityPlayer player) {
ItemStack armorItem = player.inventory.armorInventory[0];
return armorItem != null && armorItem.getItem() instanceof IArmorApiarist;
}
public static int wearsItems(EntityPlayer player) {
int count = 0;
if (wearsHelmet(player)) {
count++;
}
if (wearsChest(player)) {
count++;
}
if (wearsLegs(player)) {
count++;
}
if (wearsBoots(player)) {
count++;
}
return count;
}
public void register() {
AlleleManager.alleleRegistry.registerAllele(this);
}
@@ -371,7 +333,7 @@ public enum ExtraBeesEffect implements IAlleleBeeEffect {
for (EntityLivingBase entity : getEntities(EntityLivingBase.class, genome, housing)) {
int damage = 4;
if (entity instanceof EntityPlayer) {
int count = wearsItems((EntityPlayer) entity);
int count = BeeManager.armorApiaristHelper.wearsItems(entity, getUID(), true);
if (count > 3) {
continue;
}
@@ -396,7 +358,8 @@ public enum ExtraBeesEffect implements IAlleleBeeEffect {
private void onHungerEffect(IBeeGenome genome, IBeeHousing housing, World world) {
for (EntityPlayer player : getEntities(EntityPlayer.class, genome, housing)) {
if (world.rand.nextInt(4) < wearsItems(player)) {
if (world.rand.nextInt(4)
< BeeManager.armorApiaristHelper.wearsItems((EntityLivingBase) player, getUID(), true)) {
continue;
}
player.addExhaustion(4.0f);
@@ -406,7 +369,8 @@ public enum ExtraBeesEffect implements IAlleleBeeEffect {
private void onPotionEffect(IBeeGenome genome, IBeeHousing housing, World world, PotionEffect potion) {
for (EntityPlayer player : getEntities(EntityPlayer.class, genome, housing)) {
if (world.rand.nextInt(4) < wearsItems(player)) {
if (world.rand.nextInt(4)
< BeeManager.armorApiaristHelper.wearsItems((EntityLivingBase) player, getUID(), true)) {
continue;
}
player.addPotionEffect(potion);
@@ -366,7 +366,7 @@ for.extratrees.item.food.gooseberry=Gooseberry
for.extratrees.item.food.goldenraspberry=Golden Raspberry
for.extratrees.item.food.coconut=Coconut
for.extratrees.item.food.cashew=Cashew
for.extratrees.item.food.avacado=Avacado
for.extratrees.item.food.avacado=Avocado
for.extratrees.item.food.nutmeg=Nutmeg
for.extratrees.item.food.allspice=Allspice
for.extratrees.item.food.chilli=Chilli
@@ -282,7 +282,7 @@ extratrees.species.goldenraspberry.name=Golden Raspberry
extratrees.species.cinnamon.name=Cinnamon
extratrees.species.coconut.name=Coconut
extratrees.species.cashew.name=Cashew
extratrees.species.avacado.name=Avacado
extratrees.species.avacado.name=Avocado
extratrees.species.nutmeg.name=Nutmeg
extratrees.species.allspice.name=Allspice
extratrees.species.chilli.name=Chilli Pepper
@@ -386,7 +386,7 @@ for.extratrees.item.food.gooseberry=Gooseberry
for.extratrees.item.food.goldenraspberry=Golden Raspberry
for.extratrees.item.food.coconut=Coconut
for.extratrees.item.food.cashew=Cashew
for.extratrees.item.food.avacado=Avacado
for.extratrees.item.food.avacado=Avocado
for.extratrees.item.food.nutmeg=Nutmeg
for.extratrees.item.food.allspice=Allspice
for.extratrees.item.food.chilli=Chilli