Compare commits

..
Author SHA1 Message Date
Martin Robertz 075caff6c2 update bs+deps 2024-01-22 18:25:11 +01:00
Martin Robertz dca553a13d Merge remote-tracking branch 'Quantumlyy/bring-closer-to-forestry' into dev
# Conflicts:
#	build.gradle
#	dependencies.gradle
2024-01-22 18:24:31 +01:00
Martin Robertz 96b526e982 update bs+deps 2024-01-12 19:06:20 +01:00
Martin Robertz d738730898 Merge remote-tracking branch 'origin/dev' into dev
# Conflicts:
#	build.gradle
#	dependencies.gradle
2024-01-12 19:04:55 +01:00
6 changed files with 53 additions and 37 deletions

No files matched your search

+2 -3
View File
@@ -3,12 +3,11 @@
dependencies {
compile('com.github.GTNewHorizons:ForestryMC:4.8.2:dev')
compileOnly('com.github.GTNewHorizons:BloodMagic:1.5.1:dev')
compileOnly('com.github.GTNewHorizons:BloodMagic:1.5.0:dev')
compileOnly('com.github.GTNewHorizons:ThaumicHorizons:1.5.1:dev')
compileOnly('com.github.GTNewHorizons:Baubles:1.0.4:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:Botania:1.10.5-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.53:dev')
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.6.2-GTNH:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.45.41:dev')
}
@@ -61,8 +61,9 @@ public class MagicApiaryInventory implements IApiaryInventory {
if (all) {
return countAdded == product.stackSize;
} else {
return countAdded > 0;
}
return countAdded > 0;
}
public int getSizeInventory() {
@@ -75,6 +76,7 @@ public class MagicApiaryInventory implements IApiaryInventory {
public void setInventorySlotContents(int i, ItemStack itemStack) {
items[i] = itemStack;
if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) {
itemStack.stackSize = getInventoryStackLimit();
}
@@ -83,12 +85,13 @@ 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) {
@@ -110,6 +113,7 @@ 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) {
@@ -121,34 +125,42 @@ 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);
@@ -161,9 +173,11 @@ 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));
}
@@ -45,13 +45,13 @@ public class BlockApimancersDrainer extends BlockContainer {
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float par7,
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7,
float par8, float par9) {
if (world.isRemote) {
return false;
} else {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityApimancersDrainerCommon && side != 1) {
if (tile instanceof TileEntityApimancersDrainerCommon) {
ItemStack tItemStack = player.getHeldItem();
if (tItemStack != null) {
Item tItem = tItemStack.getItem();
@@ -71,8 +71,7 @@ public class BlockApimancersDrainer extends BlockContainer {
}
world.markBlockForUpdate(x, y, z);
return true;
}
return false;
} else return false;
}
}
@@ -86,6 +85,7 @@ 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);
}
+1 -2
View File
@@ -165,7 +165,6 @@ public class Config {
// ---- Loaded mods -----------------------------------------
public static boolean isGTLoaded = Loader.isModLoaded("gregtech");
public static boolean isGTNHCoreModLoaded = Loader.isModLoaded("gregtech") && Loader.isModLoaded("dreamcraft");
public Config(File configFile) {
configuration = new Configuration(configFile);
@@ -508,7 +507,7 @@ public class Config {
GameRegistry.registerBlock(visAuraProvider, "visAuraProvider");
GameRegistry.registerTileEntity(TileEntityVisAuraProvider.class, "visAuraProvider");
if (isGTNHCoreModLoaded) BlockApimancersDrainer.drainer = TileEntityApimancersDrainerGT.class;
if (isGTLoaded) BlockApimancersDrainer.drainer = TileEntityApimancersDrainerGT.class;
apimancersDrainer = new BlockApimancersDrainer();
GameRegistry.registerBlock(apimancersDrainer, "apimancersDrainer");
GameRegistry.registerTileEntity(BlockApimancersDrainer.drainer, "apimancersDrainer");
@@ -7,7 +7,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBee;
@@ -23,12 +22,8 @@ import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.aspects.IAspectContainer;
import thaumcraft.api.aspects.IEssentiaTransport;
import thaumicenergistics.api.storage.IAspectStorage;
@Optional.InterfaceList({
@Optional.Interface(iface = "thaumicenergistics.api.storage.IAspectStorage", modid = "thaumicenergistics") })
public class TileEntityApimancersDrainerCommon extends TileEntity
implements IEssentiaTransport, IAspectContainer, IAspectStorage {
public class TileEntityApimancersDrainerCommon extends TileEntity implements IAspectContainer, IEssentiaTransport {
public Aspect aspect;
public AspectList essentia = new AspectList();
@@ -43,7 +38,6 @@ public class TileEntityApimancersDrainerCommon extends TileEntity
@Override
public void updateEntity() {
super.updateEntity();
// If there's no stored aspect we shouldn't even check for the above block.
// We also don't need to run all the logic if the cabinet is full.
if (aspect == null || essentia.visSize() == maxAmount) return;
@@ -57,16 +51,21 @@ public class TileEntityApimancersDrainerCommon extends TileEntity
// 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);
}
@@ -94,30 +93,20 @@ public class TileEntityApimancersDrainerCommon extends TileEntity
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);
housing.getBeeInventory().getQueen().setTagCompound(nbttagcompound);
}
@Override
@Optional.Method(modid = "thaumicenergistics")
public int getContainerCapacity() {
return maxAmount;
}
@Override
@Optional.Method(modid = "thaumicenergistics")
public boolean doesShareCapacity() {
return true;
}
@Override
public AspectList getAspects() {
return this.essentia;
@@ -136,11 +125,13 @@ public class TileEntityApimancersDrainerCommon extends TileEntity
@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;
}
@@ -220,11 +211,14 @@ public class TileEntityApimancersDrainerCommon extends TileEntity
int total = this.essentia.getAmount(aspect);
this.essentia.reduce(aspect, total);
return total;
} else {
this.essentia.reduce(aspect, amount);
return amount;
}
this.essentia.reduce(aspect, amount);
return amount;
} else {
return 0;
}
return 0;
}
@Override
@@ -280,6 +274,7 @@ public class TileEntityApimancersDrainerCommon extends TileEntity
@Override
public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(compound);
this.essentia.readFromNBT(compound);
if (this.essentia.visSize() > this.maxAmount) {
this.essentia = new AspectList();
@@ -40,10 +40,13 @@ 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;
}
@@ -53,6 +56,7 @@ 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);
}
@@ -60,6 +64,7 @@ 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);
}
@@ -67,7 +72,9 @@ 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;
@@ -75,6 +82,7 @@ public class TileEntityApimancersDrainerGT extends TileEntityApimancersDrainerCo
private BaseMetaTileEntity getGTTileEntity(TileEntity te) {
boolean isGTMetaTileEntity = te instanceof BaseMetaTileEntity;
return isGTMetaTileEntity ? (BaseMetaTileEntity) te : null;
}
@@ -82,6 +90,7 @@ 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;