diff options
Diffstat (limited to 'src/Java/gtPlusPlus/xmod')
8 files changed, 347 insertions, 3 deletions
diff --git a/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java b/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java index fd9fd940c8..71ccb5be51 100644 --- a/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java +++ b/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java @@ -29,9 +29,9 @@ public class HANDLER_FR extends BlockRegistry { public static void Init(){ if (LoadedMods.Forestry){ - apiculture = new BlockDenseBeeHouse(); - apiculture.setBlockName("gtpp." + "beehouse"); - GameRegistry.registerBlock(apiculture, ItemBlockForestry.class, StringUtil.cleanBlockName(apiculture)); + //apiculture = new BlockDenseBeeHouse(); + //apiculture.setBlockName("gtpp." + "beehouse"); + //GameRegistry.registerBlock(apiculture, ItemBlockForestry.class, StringUtil.cleanBlockName(apiculture)); } } diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/blocks/BlockDenseBeeHouse.java b/src/Java/gtPlusPlus/xmod/forestry/bees/blocks/BlockDenseBeeHouse.java new file mode 100644 index 0000000000..77ee15c5d5 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/blocks/BlockDenseBeeHouse.java @@ -0,0 +1,24 @@ + +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package gtPlusPlus.xmod.forestry.bees.blocks; + +import forestry.apiculture.blocks.BlockApicultureType; +import forestry.core.blocks.BlockBase; +import gtPlusPlus.core.creative.AddToCreativeTab; + +public class BlockDenseBeeHouse extends BlockBase<BlockApicultureType> { + public BlockDenseBeeHouse() { + super(); + setCreativeTab(AddToCreativeTab.tabBOP); + setHarvestLevel("axe", 0); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/blocks/FR_BlockRegistry.java b/src/Java/gtPlusPlus/xmod/forestry/bees/blocks/FR_BlockRegistry.java new file mode 100644 index 0000000000..f896dcd05c --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/blocks/FR_BlockRegistry.java @@ -0,0 +1,24 @@ +package gtPlusPlus.xmod.forestry.bees.blocks; + +import cpw.mods.fml.common.registry.GameRegistry; +import forestry.core.utils.StringUtil; +import forestry.plugins.PluginManager; +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +public abstract class FR_BlockRegistry { + protected static <T extends Block> T registerBlock(T block, Class<? extends ItemBlock> itemClass, String name) { + if (PluginManager.getStage() != PluginManager.Stage.SETUP) { + throw new RuntimeException("Tried to register Block outside of Setup"); + } + block.setBlockName("for." + name); + GameRegistry.registerBlock(block, itemClass, StringUtil.cleanBlockName(block)); + return block; + } + + protected static void registerOreDictWildcard(String oreDictName, Block block) { + OreDictionary.registerOre(oreDictName, new ItemStack(block, 1, 32767)); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/gui/ContainerBeeHouse.java b/src/Java/gtPlusPlus/xmod/forestry/bees/gui/ContainerBeeHouse.java new file mode 100644 index 0000000000..91ab60f8bb --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/gui/ContainerBeeHouse.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package gtPlusPlus.xmod.forestry.bees.gui; + +import net.minecraft.entity.player.InventoryPlayer; +import forestry.apiculture.gui.ContainerBeeHelper; +import forestry.apiculture.gui.IContainerBeeHousing; +import forestry.apiculture.tiles.TileBeeHousingBase; +import forestry.core.gui.ContainerTile; +import forestry.core.network.IForestryPacketClient; +import forestry.core.network.packets.PacketGuiUpdate; + +public class ContainerBeeHouse extends ContainerTile<TileBeeHousingBase> implements IContainerBeeHousing { + + public ContainerBeeHouse(InventoryPlayer player, TileBeeHousingBase tile, boolean hasFrames) { + super(tile, player, 8, 108); + ContainerBeeHelper.addSlots(this, tile, hasFrames); + } + + private int beeProgress = 0; + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + + int beeProgress = tile.getBeekeepingLogic().getBeeProgressPercent(); + if (this.beeProgress != beeProgress) { + this.beeProgress = beeProgress; + IForestryPacketClient packet = new PacketGuiUpdate(tile); + sendPacketToCrafters(packet); + } + } + +} diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/gui/GuiBeeHouse.java b/src/Java/gtPlusPlus/xmod/forestry/bees/gui/GuiBeeHouse.java new file mode 100644 index 0000000000..b510b7a4d6 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/gui/GuiBeeHouse.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package gtPlusPlus.xmod.forestry.bees.gui; + +import net.minecraft.inventory.Container; +import forestry.apiculture.gui.IContainerBeeHousing; +import forestry.apiculture.gui.IGuiBeeHousingInventory; +import forestry.core.config.Constants; +import forestry.core.gui.GuiForestryTitled; +import forestry.core.render.EnumTankLevel; + +public class GuiBeeHouse<C extends Container & IContainerBeeHousing> extends GuiForestryTitled<C, IGuiBeeHousingInventory> { + + public enum Icon { + APIARY("/apiary.png"), + BEE_HOUSE("/alveary.png"); + + private final String path; + + Icon(String path) { + this.path = path; + } + } + + public GuiBeeHouse(IGuiBeeHousingInventory tile, C container, Icon icon) { + super(Constants.TEXTURE_PATH_GUI + icon.path, container, tile); + ySize = 190; + } + + @Override + protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY); + + drawHealthMeter(guiLeft + 20, guiTop + 37, inventory.getHealthScaled(46), EnumTankLevel.rateTankLevel(inventory.getHealthScaled(100))); + } + + private void drawHealthMeter(int x, int y, int height, EnumTankLevel rated) { + int i = 176 + rated.getLevelScaled(16); + int k = 0; + + this.drawTexturedModalRect(x, y + 46 - height, i, k + 46 - height, 4, height); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/inventory/InventoryDenseBeeHouse.java b/src/Java/gtPlusPlus/xmod/forestry/bees/inventory/InventoryDenseBeeHouse.java new file mode 100644 index 0000000000..6b21461b62 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/inventory/InventoryDenseBeeHouse.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package gtPlusPlus.xmod.forestry.bees.inventory; + +import java.util.ArrayList; +import java.util.Collection; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import forestry.api.apiculture.BeeManager; +import forestry.api.apiculture.IBee; +import forestry.api.apiculture.IBeeHousing; +import forestry.api.apiculture.IBeekeepingMode; +import forestry.api.apiculture.IHiveFrame; +import forestry.apiculture.InventoryBeeHousing; +import forestry.apiculture.inventory.IApiaryInventory; +import forestry.core.access.IAccessHandler; +import forestry.core.utils.SlotUtil; + +public class InventoryDenseBeeHouse extends InventoryBeeHousing implements IApiaryInventory { + public static final int SLOT_FRAMES_1 = 9; + public static final int SLOT_FRAMES_COUNT = 3; + + public InventoryDenseBeeHouse(IAccessHandler accessHandler) { + super(12, accessHandler); + } + + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (SlotUtil.isSlotInRange(slotIndex, SLOT_FRAMES_1, SLOT_FRAMES_COUNT)) { + return (itemStack.getItem() instanceof IHiveFrame) && (getStackInSlot(slotIndex) == null); + } + + return super.canSlotAccept(slotIndex, itemStack); + } + + // override for pipe automation + @Override + public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) { + if (SlotUtil.isSlotInRange(slotIndex, SLOT_FRAMES_1, SLOT_FRAMES_COUNT)) { + return false; + } + return super.isItemValidForSlot(slotIndex, itemStack); + } + + public Collection<IHiveFrame> getFrames() { + Collection<IHiveFrame> hiveFrames = new ArrayList<>(SLOT_FRAMES_COUNT); + + for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) { + ItemStack stackInSlot = getStackInSlot(i); + if (stackInSlot == null) { + continue; + } + + Item itemInSlot = stackInSlot.getItem(); + if (itemInSlot instanceof IHiveFrame) { + hiveFrames.add((IHiveFrame) itemInSlot); + } + } + + return hiveFrames; + } + + public void wearOutFrames(IBeeHousing beeHousing, int amount) { + IBeekeepingMode beekeepingMode = BeeManager.beeRoot.getBeekeepingMode(beeHousing.getWorld()); + int wear = Math.round(amount * beekeepingMode.getWearModifier()); + + for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) { + ItemStack hiveFrameStack = getStackInSlot(i); + if (hiveFrameStack == null) { + continue; + } + + Item hiveFrameItem = hiveFrameStack.getItem(); + if (!(hiveFrameItem instanceof IHiveFrame)) { + continue; + } + + IHiveFrame hiveFrame = (IHiveFrame) hiveFrameItem; + + ItemStack queenStack = getQueen(); + IBee queen = BeeManager.beeRoot.getMember(queenStack); + ItemStack usedFrame = hiveFrame.frameUsed(beeHousing, hiveFrameStack, queen, wear); + + setInventorySlotContents(i, usedFrame); + } + } +} diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/items/FR_CustomBee.java b/src/Java/gtPlusPlus/xmod/forestry/bees/items/FR_CustomBee.java new file mode 100644 index 0000000000..7d9a9e231b --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/items/FR_CustomBee.java @@ -0,0 +1,5 @@ +package gtPlusPlus.xmod.forestry.bees.items; + +public class FR_CustomBee { + +} diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/tileentities/TileDenseBeeHouse.java b/src/Java/gtPlusPlus/xmod/forestry/bees/tileentities/TileDenseBeeHouse.java new file mode 100644 index 0000000000..d121c920b2 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/tileentities/TileDenseBeeHouse.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package gtPlusPlus.xmod.forestry.bees.tileentities; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + +import cpw.mods.fml.common.Optional; + +import forestry.api.apiculture.IBeeHousingInventory; +import forestry.api.apiculture.IBeeListener; +import forestry.api.apiculture.IBeeModifier; +import forestry.api.apiculture.IHiveFrame; +import forestry.apiculture.ApiaryBeeListener; +import forestry.apiculture.ApiaryBeeModifier; +import forestry.apiculture.IApiary; +import forestry.apiculture.inventory.IApiaryInventory; +import forestry.apiculture.inventory.InventoryApiary; +import forestry.apiculture.tiles.TileBeeHousingBase; +import forestry.apiculture.trigger.ApicultureTriggers; +import gtPlusPlus.xmod.forestry.bees.gui.ContainerBeeHouse; +import gtPlusPlus.xmod.forestry.bees.gui.GuiBeeHouse; +import buildcraft.api.statements.ITriggerExternal; + +public class TileDenseBeeHouse extends TileBeeHousingBase implements IApiary { + private final IBeeModifier beeModifier = new ApiaryBeeModifier(); + private final IBeeListener beeListener = new ApiaryBeeListener(this); + private final InventoryApiary inventory = new InventoryApiary(getAccessHandler()); + + public TileDenseBeeHouse() { + super("apiary2"); + setInternalInventory(inventory); + } + + @Override + public IBeeHousingInventory getBeeInventory() { + return inventory; + } + + @Override + public IApiaryInventory getApiaryInventory() { + return inventory; + } + + @Override + public Collection<IBeeModifier> getBeeModifiers() { + List<IBeeModifier> beeModifiers = new ArrayList<>(); + + beeModifiers.add(beeModifier); + + for (IHiveFrame frame : inventory.getFrames()) { + beeModifiers.add(frame.getBeeModifier()); + } + + return beeModifiers; + } + + @Override + public Iterable<IBeeListener> getBeeListeners() { + return Collections.singleton(beeListener); + } + + /* ITRIGGERPROVIDER */ + @Optional.Method(modid = "BuildCraftAPI|statements") + @Override + public Collection<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity tile) { + LinkedList<ITriggerExternal> res = new LinkedList<>(); + res.add(ApicultureTriggers.missingQueen); + res.add(ApicultureTriggers.missingDrone); + res.add(ApicultureTriggers.noFrames); + return res; + } + + @Override + public Object getGui(EntityPlayer player, int data) { + ContainerBeeHouse container = new ContainerBeeHouse(player.inventory, this, true); + return new GuiBeeHouse<>(this, container, GuiBeeHouse.Icon.APIARY); + } + + @Override + public Object getContainer(EntityPlayer player, int data) { + return new ContainerBeeHouse(player.inventory, this, true); + } +} |