Compare commits

...
9 Commits
Author SHA1 Message Date
mezz bf179c91d9 Bump patch version to 3.5.6 2015-05-09 17:55:08 -07:00
Nirek-K 5fc1b10298 Add meta checking to flower weight adjustment
(cherry picked from commit 49deb75278)
2015-05-09 17:54:44 -07:00
Nirek-K 23b8f8b892 #Fix 646 Move plantables registration to not be smashed by acceptable.
(cherry picked from commit c705486472)
2015-05-09 17:52:54 -07:00
Nirek-K 1598946632 Fix #650 Fix logic errors in bee planting
(cherry picked from commit d29f4c0b79)
2015-05-09 17:52:34 -07:00
mezz aad6dbaa3f Bump patch version to 3.5.5 2015-05-09 17:41:13 -07:00
mezz ca6cc89015 Fix #652 Bottler liquid dupe bug on server
(cherry picked from commit d5296fbc60)
2015-05-09 17:39:52 -07:00
Nirek-K 7a22f1d939 Fix #644 Make Clockwork engine recipe OreDictionary aware. 2015-05-09 00:15:28 -07:00
mezz feda84fbc6 bump patch version 2015-04-18 13:13:39 -07:00
mezz f7b36e11d1 Fix compatibility with Forge 10.13.3.x fluid changes 2015-04-18 13:08:25 -07:00
8 changed files with 103 additions and 161 deletions

No files matched your search

+1 -1
View File
@@ -2,4 +2,4 @@ mcversion=1.7.10
forgeversion=10.13.2.1286
version_major=3
version_minor=5
version_patch=3
version_patch=6
@@ -89,7 +89,9 @@ public final class FlowerRegistry implements IFlowerRegistry {
index = flowers.indexOf(newFlower);
if (index == -1) {
flowers.add(newFlower);
} else if (flowers.get(index).getWeight() > newFlower.getWeight()) {
} else if (flowers.get(index).getMeta() != newFlower.getMeta()) {
flowers.add(newFlower);
} else if (flowers.get(index).getWeight() < newFlower.getWeight() && flowers.get(index).getMeta() == newFlower.getMeta()) {
flowers.get(index).setWeight(newFlower.getWeight());
}
@@ -204,16 +206,6 @@ public final class FlowerRegistry implements IFlowerRegistry {
}
private void registerVanillaFlowers() {
// Register plantable plants
for (int meta = 0; meta <= 8; meta++) {
registerPlantableFlower(Blocks.red_flower, meta, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
}
registerPlantableFlower(Blocks.yellow_flower, 0, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerPlantableFlower(Blocks.brown_mushroom, 0, 1.0, FlowerManager.FlowerTypeMushrooms);
registerPlantableFlower(Blocks.red_mushroom, 0, 1.0, FlowerManager.FlowerTypeMushrooms);
registerPlantableFlower(Blocks.cactus, 0, 1.0, FlowerManager.FlowerTypeCacti);
// Register acceptable plants
registerAcceptableFlower(Blocks.red_flower, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerAcceptableFlower(Blocks.yellow_flower, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
@@ -233,6 +225,17 @@ public final class FlowerRegistry implements IFlowerRegistry {
registerAcceptableFlower(Blocks.double_plant, 1, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerAcceptableFlower(Blocks.double_plant, 4, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerAcceptableFlower(Blocks.double_plant, 5, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
// Register plantable plants
for (int meta = 0; meta <= 8; meta++) {
registerPlantableFlower(Blocks.red_flower, meta, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
}
registerPlantableFlower(Blocks.yellow_flower, 0, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerPlantableFlower(Blocks.brown_mushroom, 0, 1.0, FlowerManager.FlowerTypeMushrooms);
registerPlantableFlower(Blocks.red_mushroom, 0, 1.0, FlowerManager.FlowerTypeMushrooms);
registerPlantableFlower(Blocks.cactus, 0, 1.0, FlowerManager.FlowerTypeCacti);
}
private void registerVanillaGrowthRules() {
@@ -29,6 +29,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
@@ -126,7 +127,7 @@ public class TankManager extends ForwardingList<StandardTank> implements IFluidH
StandardTank tank = tanks.get(tankIndex);
FluidStack fluidStack = tank.getFluid();
if (fluidStack != null) {
data.writeShort(fluidStack.fluidID);
data.writeShort(fluidStack.getFluid().getID());
data.writeInt(fluidStack.amount);
data.writeInt(fluidStack.getFluid().getColor(fluidStack));
} else {
@@ -146,8 +147,11 @@ public class TankManager extends ForwardingList<StandardTank> implements IFluidH
}
StandardTank tank = tanks.get(tankIndex);
int fluidId = data.readShort();
if (fluidId != -1) {
tank.setFluid(new FluidStack(fluidId, data.readInt()));
Fluid fluid = FluidRegistry.getFluid(fluidId);
if (fluid != null) {
int amount = data.readInt();
FluidStack fluidStack = new FluidStack(fluid, amount);
tank.setFluid(fluidStack);
tank.colorCache = data.readInt();
} else {
tank.setFluid(null);
@@ -195,7 +199,7 @@ public class TankManager extends ForwardingList<StandardTank> implements IFluidH
int fluidId = -1;
int fluidAmount = 0;
if (fluidStack != null) {
fluidId = fluidStack.fluidID;
fluidId = fluidStack.getFluid().getID();
fluidAmount = fluidStack.amount;
}
player.sendProgressBarUpdate(container, tankIndex * NETWORK_DATA, fluidId);
@@ -203,7 +207,7 @@ public class TankManager extends ForwardingList<StandardTank> implements IFluidH
Proxies.net.sendToPlayer(packet, player);
} else if (fluidStack != null && prev != null) {
if (fluidStack.getFluid() != prev.getFluid()) {
player.sendProgressBarUpdate(container, tankIndex * NETWORK_DATA, fluidStack.fluidID);
player.sendProgressBarUpdate(container, tankIndex * NETWORK_DATA, fluidStack.getFluid().getID());
}
if (fluidStack.amount != prev.amount) {
PacketGuiInteger packet = new PacketGuiInteger(container.windowId, tankIndex * NETWORK_DATA + 1, fluidStack.amount);
@@ -227,33 +231,28 @@ public class TankManager extends ForwardingList<StandardTank> implements IFluidH
return;
}
StandardTank tank = tanks.get(tankIndex);
FluidStack fluidStack = tank.getFluid();
if (fluidStack == null) {
fluidStack = new FluidStack(-1, 0);
tank.setFluid(fluidStack);
}
int fluidId = fluidStack.fluidID;
int amount = fluidStack.amount;
int color = tank.colorCache;
boolean newLiquid = false;
switch (messageId % NETWORK_DATA) {
case 0:
fluidId = data;
newLiquid = true;
case 0: {
int amount = tank.getFluidAmount();
Fluid fluid = FluidRegistry.getFluid(data);
if (fluid != null) {
FluidStack fluidStack = new FluidStack(fluid, amount);
tank.setFluid(fluidStack);
}
}
case 1: {
FluidStack fluidStack = tank.getFluid();
if (fluidStack != null) {
fluidStack.amount = data;
}
break;
case 1:
amount = data;
break;
case 2:
color = data;
}
case 2: {
tank.colorCache = data;
break;
}
}
if (newLiquid) {
fluidStack = new FluidStack(fluidId, 0);
tank.setFluid(fluidStack);
}
fluidStack.amount = amount;
tank.colorCache = color;
}
@Override
@@ -58,7 +58,7 @@ public class ItemPipette extends ItemForestry implements IToolPipette {
return false;
}
return contents.fluidID > 0 && contents.amount >= limit;
return contents.getFluid().getID() > 0 && contents.amount >= limit;
}
public void addTooltip(List<String> list) {
@@ -108,7 +108,7 @@ public class ItemPipette extends ItemForestry implements IToolPipette {
filled = liquid.amount;
}
contained.contents = new FluidStack(liquid.fluidID, filled);
contained.contents = new FluidStack(liquid, filled);
filled = liquid.amount;
} else {
@@ -174,7 +174,7 @@ public class ItemPipette extends ItemForestry implements IToolPipette {
@Override
public FluidStack drain(ItemStack pipette, int maxDrain, boolean doDrain) {
PipetteContents contained = new PipetteContents(pipette.getTagCompound());
if (contained.contents == null || contained.contents.fluidID <= 0) {
if (contained.contents == null || contained.contents.getFluid().getID() <= 0) {
return null;
}
@@ -196,7 +196,7 @@ public class ItemPipette extends ItemForestry implements IToolPipette {
}
}
return new FluidStack(contained.contents.fluidID, drained);
return new FluidStack(contained.contents, drained);
}
@Override
@@ -15,7 +15,6 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Stack;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
@@ -23,7 +22,6 @@ import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
@@ -59,9 +57,9 @@ import buildcraft.api.statements.ITriggerExternal;
public class MachineBottler extends TilePowered implements ISidedInventory, ILiquidTankContainer {
/* CONSTANTS */
public static final short SLOT_RESOURCE = 0;
public static final short SLOT_PRODUCT = 1;
public static final short SLOT_CAN = 2;
public static final short SLOT_INPUT_EMPTY_CAN = 0;
public static final short SLOT_OUTPUT = 1;
public static final short SLOT_INPUT_FULL_CAN = 2;
public static final short CYCLES_FILLING_DEFAULT = 5;
@@ -98,7 +96,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
*/
public static Recipe findMatchingRecipe(FluidStack res, ItemStack empty) {
// We need both ingredients
if (res == null || empty == null) {
if (res == null || empty == null || !FluidHelper.isEmptyContainer(empty)) {
return null;
}
@@ -109,13 +107,11 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
}
// No recipe matched. See if the liquid dictionary has anything.
if (FluidHelper.isEmptyContainer(empty)) {
ItemStack filled = FluidHelper.getFilledContainer(res, empty);
if (filled != null) {
Recipe recipe = new Recipe(CYCLES_FILLING_DEFAULT, res, empty, filled);
recipes.add(recipe);
return recipe;
}
ItemStack filled = FluidHelper.getFilledContainer(res, empty);
if (filled != null) {
Recipe recipe = new Recipe(CYCLES_FILLING_DEFAULT, res, empty, filled);
recipes.add(recipe);
return recipe;
}
return null;
@@ -146,33 +142,14 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
public final StandardTank resourceTank;
private final TankManager tankManager;
private boolean productPending = false;
private Recipe currentRecipe;
private final Stack<ItemStack> pendingProducts = new Stack<ItemStack>();
private int fillingTime;
private int fillingTotalTime;
public MachineBottler() {
super(1100, 50, 4000);
setInternalInventory(new TileInventoryAdapter(this, 3, "Items") {
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
if (slotIndex == SLOT_RESOURCE) {
return FluidContainerRegistry.isEmptyContainer(itemStack);
} else if (slotIndex == SLOT_CAN) {
FluidStack fluidStack = FluidHelper.getFluidStackInContainer(itemStack);
return RecipeManager.isInput(fluidStack);
}
return false;
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
return slotIndex == SLOT_PRODUCT;
}
});
setInternalInventory(new BottlerInventoryAdapter(this));
setHints(Config.hints.get("bottler"));
resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY);
@@ -191,21 +168,8 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
nbttagcompound.setInteger("FillingTime", fillingTime);
nbttagcompound.setInteger("FillingTotalTime", fillingTotalTime);
nbttagcompound.setBoolean("ProductPending", productPending);
tankManager.writeTanksToNBT(nbttagcompound);
NBTTagList nbttaglist = new NBTTagList();
ItemStack[] offspring = pendingProducts.toArray(new ItemStack[pendingProducts.size()]);
for (int i = 0; i < offspring.length; i++) {
if (offspring[i] != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte) i);
offspring[i].writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
}
nbttagcompound.setTag("PendingProducts", nbttaglist);
}
@Override
@@ -214,16 +178,9 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
fillingTime = nbttagcompound.getInteger("FillingTime");
fillingTotalTime = nbttagcompound.getInteger("FillingTotalTime");
productPending = nbttagcompound.getBoolean("ProductPending");
tankManager.readTanksFromNBT(nbttagcompound);
NBTTagList nbttaglist = nbttagcompound.getTagList("PendingProducts", 10);
for (int i = 0; i < nbttaglist.tagCount(); i++) {
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
pendingProducts.add(ItemStack.loadItemStackFromNBT(nbttagcompound1));
}
checkRecipe();
}
@@ -233,75 +190,56 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
return;
}
IInventoryAdapter inventory = getInternalInventory();
// Check if we have suitable items waiting in the item slot
if (inventory.getStackInSlot(SLOT_CAN) != null) {
FluidHelper.drainContainers(tankManager, inventory, SLOT_CAN);
if (getStackInSlot(SLOT_INPUT_FULL_CAN) != null) {
FluidHelper.drainContainers(tankManager, this, SLOT_INPUT_FULL_CAN);
}
checkRecipe();
if (getErrorState() == EnumErrorCode.NORECIPE && currentRecipe != null) {
setErrorState(EnumErrorCode.OK);
}
}
@Override
public boolean workCycle() {
checkRecipe();
// If we add pending products, we skip to the next work cycle.
if (tryAddPending()) {
return false;
}
if (!pendingProducts.isEmpty()) {
return false;
}
// Continue work if nothing needs to be added
if (fillingTime <= 0) {
return false;
}
if (currentRecipe == null) {
setErrorState(EnumErrorCode.NORECIPE);
return false;
}
if (!InvTools.tryAddStack(this, currentRecipe.bottled, SLOT_OUTPUT, 1, true, false)) {
setErrorState(EnumErrorCode.NOSPACE);
return false;
}
fillingTime--;
// Still not done, return
if (fillingTime > 0) {
setErrorState(EnumErrorCode.OK);
return true;
}
// We are done, add products to queue and remove resources
pendingProducts.push(currentRecipe.bottled.copy());
FluidHelper.fillContainers(tankManager, this, SLOT_INPUT_EMPTY_CAN, SLOT_OUTPUT, currentRecipe.input.getFluid());
IInventoryAdapter inventory = getInternalInventory();
inventory.decrStackSize(SLOT_RESOURCE, 1);
resourceTank.drain(currentRecipe.input.amount, true);
checkRecipe();
resetRecipe();
while (tryAddPending()) {
;
}
return true;
}
public void checkRecipe() {
IInventoryAdapter inventory = getInternalInventory();
Recipe sameRec = RecipeManager.findMatchingRecipe(resourceTank.getFluid(), inventory.getStackInSlot(SLOT_RESOURCE));
ItemStack emptyCan = getStackInSlot(SLOT_INPUT_EMPTY_CAN);
Recipe recipe = RecipeManager.findMatchingRecipe(resourceTank.getFluid(), emptyCan);
if (sameRec == null) {
if (recipe == null) {
setErrorState(EnumErrorCode.NORECIPE);
} else {
setErrorState(EnumErrorCode.OK);
}
if (currentRecipe != sameRec) {
currentRecipe = sameRec;
if (currentRecipe != recipe) {
currentRecipe = recipe;
resetRecipe();
}
}
@@ -317,25 +255,6 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
fillingTotalTime = currentRecipe.cyclesPerUnit;
}
private boolean tryAddPending() {
if (pendingProducts.isEmpty()) {
return false;
}
ItemStack next = pendingProducts.peek();
if (addProduct(next, true)) {
pendingProducts.pop();
return true;
}
setErrorState(EnumErrorCode.NOSPACE);
return false;
}
private boolean addProduct(ItemStack product, boolean all) {
return InvTools.tryAddStack(getInternalInventory(), product, SLOT_PRODUCT, 1, all);
}
// / STATE INFORMATION
@Override
public boolean isWorking() {
@@ -345,11 +264,11 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
@Override
public boolean hasResourcesMin(float percentage) {
IInventoryAdapter inventory = getInternalInventory();
if (inventory.getStackInSlot(SLOT_RESOURCE) == null) {
if (inventory.getStackInSlot(SLOT_INPUT_EMPTY_CAN) == null) {
return false;
}
return ((float) inventory.getStackInSlot(SLOT_RESOURCE).stackSize / (float) inventory.getStackInSlot(SLOT_RESOURCE).getMaxStackSize()) > percentage;
return ((float) inventory.getStackInSlot(SLOT_INPUT_EMPTY_CAN).stackSize / (float) inventory.getStackInSlot(SLOT_INPUT_EMPTY_CAN).getMaxStackSize()) > percentage;
}
@Override
@@ -442,4 +361,25 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
return res;
}
private static class BottlerInventoryAdapter extends TileInventoryAdapter {
public BottlerInventoryAdapter(MachineBottler machineBottler) {
super(machineBottler, 3, "Items");
}
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
if (slotIndex == SLOT_INPUT_EMPTY_CAN) {
return FluidContainerRegistry.isEmptyContainer(itemStack);
} else if (slotIndex == SLOT_INPUT_FULL_CAN) {
FluidStack fluidStack = FluidHelper.getFluidStackInContainer(itemStack);
return RecipeManager.isInput(fluidStack);
}
return false;
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
return slotIndex == SLOT_OUTPUT;
}
}
}
@@ -242,7 +242,7 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui
// Start next cycle if enough bio mass is available
distillationTime = distillationTotalTime = resourceRequired;
resourceTank.drain(resourceRequired, true);
bufferedLiquid = new FluidStack(currentRecipe.input.fluidID, resourceRequired);
bufferedLiquid = new FluidStack(currentRecipe.input, resourceRequired);
setErrorState(EnumErrorCode.OK);
return true;
@@ -257,7 +257,7 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui
Recipe sameRec = RecipeManager.findMatchingRecipe(resourceTank.getFluid());
if (sameRec == null && bufferedLiquid != null && distillationTime > 0) {
sameRec = RecipeManager.findMatchingRecipe(new FluidStack(bufferedLiquid.fluidID, distillationTime));
sameRec = RecipeManager.findMatchingRecipe(new FluidStack(bufferedLiquid, distillationTime));
}
if (sameRec == null) {
@@ -27,9 +27,9 @@ public class ContainerBottler extends ContainerLiquidTanks {
this.tile = tile;
this.addSlotToContainer(new SlotFiltered(tile, MachineBottler.SLOT_RESOURCE, 116, 19));
this.addSlotToContainer(new SlotOutput(tile, MachineBottler.SLOT_PRODUCT, 116, 55));
this.addSlotToContainer(new SlotFiltered(tile, MachineBottler.SLOT_CAN, 26, 38));
this.addSlotToContainer(new SlotFiltered(tile, MachineBottler.SLOT_INPUT_EMPTY_CAN, 116, 19));
this.addSlotToContainer(new SlotOutput(tile, MachineBottler.SLOT_OUTPUT, 116, 55));
this.addSlotToContainer(new SlotFiltered(tile, MachineBottler.SLOT_INPUT_FULL_CAN, 26, 38));
int var3;
for (var3 = 0; var3 < 3; ++var3) {
@@ -54,7 +54,7 @@ public class PluginEnergy extends ForestryPlugin {
" X ",
"YVY",
'#', "ingotCopper",
'X', Blocks.glass,
'X', "blockGlass",
'Y', "gearCopper",
'V', Blocks.piston)));
definitionEngineBronze = ((BlockBase) ForestryBlock.engine.block()).addDefinition(new EngineDefinition(Defaults.DEFINITION_ENGINEBRONZE_META, "forestry.EngineBronze", EngineBronze.class,
@@ -64,7 +64,7 @@ public class PluginEnergy extends ForestryPlugin {
" X ",
"YVY",
'#', "ingotBronze",
'X', Blocks.glass,
'X', "blockGlass",
'Y', "gearBronze",
'V', Blocks.piston)));
@@ -76,9 +76,9 @@ public class PluginEnergy extends ForestryPlugin {
" X ",
"ZVY",
'#', "plankWood",
'X', Blocks.glass,
'X', "blockGlass",
'Y', Items.clock,
'Z', ForestryItem.gearCopper,
'Z', "gearCopper",
'V', Blocks.piston);
}