forked from KryptonCaptain/MagicBees
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev' into dev
# Conflicts: # build.gradle # dependencies.gradle
- Loading branch information
Showing
16 changed files
with
1,038 additions
and
474 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
// Add your dependencies here | ||
|
||
dependencies { | ||
compile('com.github.GTNewHorizons:ForestryMC:4.8.2:dev') | ||
compile('com.github.GTNewHorizons:ForestryMC:4.8.1:dev') | ||
|
||
compileOnly('com.github.GTNewHorizons:BloodMagic:1.5.0:dev') | ||
compileOnly('com.github.GTNewHorizons:ThaumicHorizons:1.5.0:dev') | ||
compileOnly('com.github.GTNewHorizons:Baubles:1.0.4:dev') {transitive = false} | ||
compileOnly('com.github.GTNewHorizons:Botania:1.10.4-GTNH:api') {transitive = false} | ||
compileOnly('com.github.GTNewHorizons:BloodMagic:1.4.3:dev') | ||
compileOnly('com.github.GTNewHorizons:ThaumicHorizons:1.4.2:dev') | ||
compileOnly('com.github.GTNewHorizons:Baubles:1.0.3:dev') {transitive = false} | ||
compileOnly('com.github.GTNewHorizons:Botania:1.10.3-GTNH:api') {transitive = false} | ||
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev') {transitive = false} | ||
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.45.25:dev') { transitive = false } | ||
|
||
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.45.15:dev') | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
package magicbees.bees; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
|
||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.NBTTagCompound; | ||
import net.minecraft.nbt.NBTTagList; | ||
import net.minecraftforge.common.util.Constants; | ||
|
||
import forestry.api.apiculture.IBee; | ||
import forestry.api.apiculture.IBeeHousing; | ||
import forestry.api.apiculture.IBeekeepingMode; | ||
import forestry.api.apiculture.IHiveFrame; | ||
import forestry.apiculture.inventory.IApiaryInventory; | ||
import magicbees.main.utils.ItemStackUtils; | ||
import magicbees.tileentity.TileEntityMagicApiary; | ||
|
||
public class MagicApiaryInventory implements IApiaryInventory { | ||
|
||
public static final int SLOT_QUEEN = 0; | ||
public static final int SLOT_DRONE = 1; | ||
public static final int SLOT_FRAME_START = 2; | ||
public static final int SLOT_FRAME_COUNT = 3; | ||
public static final int SLOT_PRODUCTS_START = 5; | ||
public static final int SLOT_PRODUCTS_COUNT = 7; | ||
|
||
private final TileEntityMagicApiary magicApiary; | ||
private final ItemStack[] items; | ||
|
||
public MagicApiaryInventory(TileEntityMagicApiary magicApiary) { | ||
this.magicApiary = magicApiary; | ||
this.items = new ItemStack[12]; | ||
} | ||
|
||
@Override | ||
public ItemStack getQueen() { | ||
return magicApiary.getStackInSlot(SLOT_QUEEN); | ||
} | ||
|
||
@Override | ||
public ItemStack getDrone() { | ||
return magicApiary.getStackInSlot(SLOT_DRONE); | ||
} | ||
|
||
@Override | ||
public void setQueen(ItemStack itemstack) { | ||
magicApiary.setInventorySlotContents(SLOT_QUEEN, itemstack); | ||
} | ||
|
||
@Override | ||
public void setDrone(ItemStack itemstack) { | ||
magicApiary.setInventorySlotContents(SLOT_DRONE, itemstack); | ||
} | ||
|
||
@Override | ||
public boolean addProduct(ItemStack product, boolean all) { | ||
int countAdded = ItemStackUtils | ||
.addItemToInventory(magicApiary, product, SLOT_PRODUCTS_START, SLOT_PRODUCTS_COUNT); | ||
|
||
if (all) { | ||
return countAdded == product.stackSize; | ||
} else { | ||
return countAdded > 0; | ||
} | ||
} | ||
|
||
public int getSizeInventory() { | ||
return items.length; | ||
} | ||
|
||
public ItemStack getStackInSlot(int i) { | ||
return items[i]; | ||
} | ||
|
||
public void setInventorySlotContents(int i, ItemStack itemStack) { | ||
items[i] = itemStack; | ||
|
||
if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) { | ||
itemStack.stackSize = getInventoryStackLimit(); | ||
} | ||
} | ||
|
||
public int[] getAccessibleSlotsFromSide(int side) { | ||
if (side == 0 || side == 1) { | ||
return new int[] { SLOT_QUEEN, SLOT_DRONE }; | ||
} else { | ||
int[] slots = new int[SLOT_PRODUCTS_COUNT]; | ||
for (int i = 0, slot = SLOT_PRODUCTS_START; i < SLOT_PRODUCTS_COUNT; ++i, ++slot) { | ||
slots[i] = slot; | ||
} | ||
return slots; | ||
} | ||
} | ||
|
||
public boolean canInsertItem(int slot, ItemStack itemStack, int side) { | ||
if (slot == SLOT_QUEEN && BeeManager.beeRoot.isMember(itemStack) && !BeeManager.beeRoot.isDrone(itemStack)) { | ||
return true; | ||
} else if (slot == SLOT_DRONE && BeeManager.beeRoot.isDrone(itemStack)) { | ||
return true; | ||
} | ||
return slot == SLOT_DRONE && BeeManager.beeRoot.isDrone(itemStack); | ||
} | ||
|
||
public boolean canExtractItem(int slot, ItemStack itemStack, int side) { | ||
return slot >= SLOT_FRAME_START && slot <= SLOT_FRAME_START + 2; | ||
} | ||
|
||
public int getInventoryStackLimit() { | ||
return 64; | ||
} | ||
|
||
public Collection<IHiveFrame> getFrames() { | ||
Collection<IHiveFrame> hiveFrames = new ArrayList<IHiveFrame>(SLOT_FRAME_COUNT); | ||
|
||
for (int i = SLOT_FRAME_START; i < SLOT_FRAME_START + SLOT_FRAME_COUNT; i++) { | ||
ItemStack stackInSlot = magicApiary.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(magicApiary.getWorldObj()); | ||
int wear = Math.round(amount * beekeepingMode.getWearModifier()); | ||
|
||
for (int i = MagicApiaryInventory.SLOT_FRAME_START; i | ||
< MagicApiaryInventory.SLOT_FRAME_START + MagicApiaryInventory.SLOT_FRAME_COUNT; i++) { | ||
ItemStack hiveFrameStack = magicApiary.getStackInSlot(i); | ||
if (hiveFrameStack == null) { | ||
continue; | ||
} | ||
|
||
Item hiveFrameItem = hiveFrameStack.getItem(); | ||
if (!(hiveFrameItem instanceof IHiveFrame)) { | ||
continue; | ||
} | ||
|
||
IHiveFrame hiveFrame = (IHiveFrame) hiveFrameItem; | ||
|
||
ItemStack queenStack = magicApiary.getBeeInventory().getQueen(); | ||
IBee queen = BeeManager.beeRoot.getMember(queenStack); | ||
ItemStack usedFrame = hiveFrame.frameUsed(magicApiary, hiveFrameStack, queen, wear); | ||
|
||
magicApiary.setInventorySlotContents(i, usedFrame); | ||
} | ||
} | ||
|
||
public void writeToNBT(NBTTagCompound compound) { | ||
NBTTagList itemsNBT = new NBTTagList(); | ||
|
||
for (int i = 0; i < items.length; i++) { | ||
ItemStack itemStack = items[i]; | ||
|
||
if (itemStack != null) { | ||
NBTTagCompound item = new NBTTagCompound(); | ||
item.setByte("Slot", (byte) i); | ||
itemStack.writeToNBT(item); | ||
itemsNBT.appendTag(item); | ||
} | ||
} | ||
compound.setTag("Items", itemsNBT); | ||
} | ||
|
||
public void readFromNBT(NBTTagCompound compound) { | ||
NBTTagList items = compound.getTagList("Items", Constants.NBT.TAG_COMPOUND); | ||
|
||
for (int i = 0; i < items.tagCount(); i++) { | ||
NBTTagCompound item = items.getCompoundTagAt(i); | ||
int slot = item.getByte("Slot"); | ||
|
||
if (slot >= 0 && slot < getSizeInventory()) { | ||
setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(item)); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.