mirror of
https://github.com/GTNewHorizons/MagicBees.git
synced 2026-11-20 04:09:48 +00:00
minor cleanup
This commit is contained in:
1 parent
38bc8a151c
commit
99c3cb68eb
4 files changed
+10
-48
No files matched your search
@@ -61,9 +61,8 @@ public class MagicApiaryInventory implements IApiaryInventory {
|
||||
|
||||
if (all) {
|
||||
return countAdded == product.stackSize;
|
||||
} else {
|
||||
return countAdded > 0;
|
||||
}
|
||||
return countAdded > 0;
|
||||
}
|
||||
|
||||
public int getSizeInventory() {
|
||||
@@ -76,7 +75,6 @@ public class MagicApiaryInventory implements IApiaryInventory {
|
||||
|
||||
public void setInventorySlotContents(int i, ItemStack itemStack) {
|
||||
items[i] = itemStack;
|
||||
|
||||
if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) {
|
||||
itemStack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
@@ -85,13 +83,12 @@ public class MagicApiaryInventory implements IApiaryInventory {
|
||||
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;
|
||||
}
|
||||
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) {
|
||||
@@ -113,7 +110,6 @@ public class MagicApiaryInventory implements IApiaryInventory {
|
||||
|
||||
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) {
|
||||
@@ -125,42 +121,34 @@ public class MagicApiaryInventory implements IApiaryInventory {
|
||||
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);
|
||||
@@ -173,11 +161,9 @@ public class MagicApiaryInventory implements IApiaryInventory {
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -71,9 +71,8 @@ public class BlockApimancersDrainer extends BlockContainer {
|
||||
}
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +86,6 @@ public class BlockApimancersDrainer extends BlockContainer {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
icons = new IIcon[4];
|
||||
|
||||
for (int i = 0; i < icons.length; i++) {
|
||||
icons[i] = register.registerIcon(CommonProxy.DOMAIN + ":apimancersdrainer." + i);
|
||||
}
|
||||
|
||||
@@ -51,21 +51,16 @@ public class TileEntityApimancersDrainerCommon extends TileEntity implements IAs
|
||||
// This performs all the checks to see if the bee is a living queen and if the species conditions
|
||||
// are met.
|
||||
if (!canWork(beeHousing, above)) return;
|
||||
|
||||
// The beeRoot.isMember call will treat null the same as EnumBeeType.NONE which leads getSpecies to
|
||||
// return null.
|
||||
ItemStack queenStack = getQueen(beeHousing, above);
|
||||
IAlleleBeeSpecies queenSpecies = BeeGenome.getSpecies(queenStack);
|
||||
if (queenSpecies == null) return;
|
||||
|
||||
if (BeeManager.beeRoot.getType(queenStack) != EnumBeeType.QUEEN) return;
|
||||
|
||||
if (Objects.equals(queenSpecies.getUID(), BeeSpecies.TC_ESSENTIA.getSpecies().getUID())) {
|
||||
IBeeModifier modifier = BeeManager.beeRoot.createBeeHousingModifier(beeHousing);
|
||||
IBee queen = BeeManager.beeRoot.getMember(queenStack);
|
||||
|
||||
int amount = Config.drainerAmount * getProductionMultiplier(modifier, queen, above);
|
||||
|
||||
addToContainer(aspect, amount);
|
||||
drainQueen(beeHousing, modifier, queen);
|
||||
}
|
||||
@@ -93,14 +88,12 @@ public class TileEntityApimancersDrainerCommon extends TileEntity implements IAs
|
||||
IBeeGenome queenGenome = queen.getGenome();
|
||||
float productionMultiplier = modifier.getProductionModifier(queenGenome, 1.0F);
|
||||
float minimum = Math.max(productionMultiplier, 1.0F);
|
||||
|
||||
return (int) Math.ceil(minimum);
|
||||
}
|
||||
|
||||
private void drainQueen(IBeeHousing housing, IBeeModifier modifier, IBee queen) {
|
||||
float lifespanModifier = modifier.getLifespanModifier(queen.getGenome(), queen.getMate(), 1.0f);
|
||||
queen.age(housing.getWorld(), lifespanModifier);
|
||||
|
||||
// Write the changed queen back into the item stack.
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
queen.writeToNBT(nbttagcompound);
|
||||
@@ -125,13 +118,11 @@ public class TileEntityApimancersDrainerCommon extends TileEntity implements IAs
|
||||
@Override
|
||||
public int addToContainer(Aspect tag, int am) {
|
||||
int toAdd = Math.min(maxAmount - essentia.visSize(), am);
|
||||
|
||||
if (aspect.equals(tag) && toAdd > 0) {
|
||||
essentia.add(aspect, toAdd);
|
||||
markDirty();
|
||||
return am - toAdd;
|
||||
}
|
||||
|
||||
markDirty();
|
||||
return am;
|
||||
}
|
||||
@@ -211,14 +202,11 @@ public class TileEntityApimancersDrainerCommon extends TileEntity implements IAs
|
||||
int total = this.essentia.getAmount(aspect);
|
||||
this.essentia.reduce(aspect, total);
|
||||
return total;
|
||||
} else {
|
||||
this.essentia.reduce(aspect, amount);
|
||||
return amount;
|
||||
}
|
||||
|
||||
} else {
|
||||
return 0;
|
||||
this.essentia.reduce(aspect, amount);
|
||||
return amount;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -274,7 +262,6 @@ public class TileEntityApimancersDrainerCommon extends TileEntity implements IAs
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
super.readFromNBT(compound);
|
||||
|
||||
this.essentia.readFromNBT(compound);
|
||||
if (this.essentia.visSize() > this.maxAmount) {
|
||||
this.essentia = new AspectList();
|
||||
|
||||
@@ -40,13 +40,10 @@ public class TileEntityApimancersDrainerGT extends TileEntityApimancersDrainerCo
|
||||
protected IBeeHousing beeHousing(TileEntity above) {
|
||||
IBeeHousing regularCheck = super.beeHousing(above);
|
||||
if (regularCheck != null) return regularCheck;
|
||||
|
||||
BaseMetaTileEntity GTMetaTileEntity = getGTTileEntity(above);
|
||||
|
||||
if (GTMetaTileEntity != null) {
|
||||
IMetaTileEntity underlyingMetaTileEntity = GTMetaTileEntity.getMetaTileEntity();
|
||||
if (!(underlyingMetaTileEntity instanceof GT_MetaTileEntity_IndustrialApiary)) return null;
|
||||
|
||||
return (IBeeHousing) underlyingMetaTileEntity;
|
||||
}
|
||||
|
||||
@@ -56,7 +53,6 @@ public class TileEntityApimancersDrainerGT extends TileEntityApimancersDrainerCo
|
||||
@Override
|
||||
protected boolean canWork(IBeeHousing beeHousing, TileEntity te) {
|
||||
BaseMetaTileEntity GTMetaTileEntity = getGTTileEntity(te);
|
||||
|
||||
return GTMetaTileEntity != null ? GTMetaTileEntity.isActive() : super.canWork(beeHousing, te);
|
||||
}
|
||||
|
||||
@@ -64,7 +60,6 @@ public class TileEntityApimancersDrainerGT extends TileEntityApimancersDrainerCo
|
||||
protected ItemStack getQueen(IBeeHousing beeHousing, TileEntity te) {
|
||||
BaseMetaTileEntity GTMetaTileEntity = getGTTileEntity(te);
|
||||
GT_MetaTileEntity_IndustrialApiary industrialApiary = getGTIndustrialApiary(GTMetaTileEntity);
|
||||
|
||||
return industrialApiary != null ? industrialApiary.getUsedQueen() : super.getQueen(beeHousing, te);
|
||||
}
|
||||
|
||||
@@ -72,9 +67,7 @@ public class TileEntityApimancersDrainerGT extends TileEntityApimancersDrainerCo
|
||||
protected int getProductionMultiplier(IBeeModifier modifier, IBee queen, TileEntity te) {
|
||||
BaseMetaTileEntity GTMetaTileEntity = getGTTileEntity(te);
|
||||
GT_MetaTileEntity_IndustrialApiary industrialApiary = getGTIndustrialApiary(GTMetaTileEntity);
|
||||
|
||||
int housingProductionMultiplier = super.getProductionMultiplier(modifier, queen, te);
|
||||
|
||||
return industrialApiary != null
|
||||
? housingProductionMultiplier * (int) Math.ceil(Math.sqrt(industrialApiary.mSpeed))
|
||||
: housingProductionMultiplier;
|
||||
@@ -82,7 +75,6 @@ public class TileEntityApimancersDrainerGT extends TileEntityApimancersDrainerCo
|
||||
|
||||
private BaseMetaTileEntity getGTTileEntity(TileEntity te) {
|
||||
boolean isGTMetaTileEntity = te instanceof BaseMetaTileEntity;
|
||||
|
||||
return isGTMetaTileEntity ? (BaseMetaTileEntity) te : null;
|
||||
}
|
||||
|
||||
@@ -90,7 +82,6 @@ public class TileEntityApimancersDrainerGT extends TileEntityApimancersDrainerCo
|
||||
if (bmte != null) {
|
||||
IMetaTileEntity underlyingMetaTileEntity = bmte.getMetaTileEntity();
|
||||
if (!(underlyingMetaTileEntity instanceof GT_MetaTileEntity_IndustrialApiary)) return null;
|
||||
|
||||
return (GT_MetaTileEntity_IndustrialApiary) underlyingMetaTileEntity;
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in new issue
Block a user