1.12: E-Furnace hopper detection/config fix.

This commit is contained in:
stfwi 2020-04-18 14:08:27 +02:00
parent 76384d1126
commit dea1363f8e
2 changed files with 25 additions and 16 deletions

View file

@ -9,6 +9,8 @@
package wile.engineersdecor.blocks; package wile.engineersdecor.blocks;
import net.minecraft.init.Blocks;
import wile.engineersdecor.ModContent;
import wile.engineersdecor.ModEngineersDecor; import wile.engineersdecor.ModEngineersDecor;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
@ -333,12 +335,14 @@ public class BlockDecorFurnaceElectrical extends BlockDecorFurnace
private static int transfer_energy_consumption_ = DEFAULT_SCALED_ENERGY_CONSUMPTION/8; private static int transfer_energy_consumption_ = DEFAULT_SCALED_ENERGY_CONSUMPTION/8;
private static int proc_speed_percent_ = DEFAULT_SPEED_PERCENT; private static int proc_speed_percent_ = DEFAULT_SPEED_PERCENT;
private static double speed_setting_factor_[] = {0.0, 1.0, 1.5, 2.0}; private static double speed_setting_factor_[] = {0.0, 1.0, 1.5, 2.0};
private static boolean with_automatic_inventory_pulling_ = false;
public static void on_config(int speed_percent, int standard_energy_per_tick) public static void on_config(int speed_percent, int standard_energy_per_tick, boolean with_automatic_inventory_pulling)
{ {
proc_speed_percent_ = MathHelper.clamp(speed_percent, 10, 500); proc_speed_percent_ = MathHelper.clamp(speed_percent, 10, 500);
energy_consumption_ = MathHelper.clamp(standard_energy_per_tick, 10, 256) * HEAT_INCREMENT * proc_speed_percent_ / 100; energy_consumption_ = MathHelper.clamp(standard_energy_per_tick, 10, 256) * HEAT_INCREMENT * proc_speed_percent_ / 100;
transfer_energy_consumption_ = MathHelper.clamp(energy_consumption_/8, 8, HEAT_INCREMENT); transfer_energy_consumption_ = MathHelper.clamp(energy_consumption_/8, 8, HEAT_INCREMENT);
with_automatic_inventory_pulling_ = with_automatic_inventory_pulling;
ModEngineersDecor.logger.info("Config electrical furnace speed:" + proc_speed_percent_ + ", power consumption:" + energy_consumption_); ModEngineersDecor.logger.info("Config electrical furnace speed:" + proc_speed_percent_ + ", power consumption:" + energy_consumption_);
} }
@ -657,6 +661,9 @@ public class BlockDecorFurnaceElectrical extends BlockDecorFurnace
// ITickable ------------------------------------------------------------------------------------ // ITickable ------------------------------------------------------------------------------------
private boolean is_accepted_hopper(final ItemStack stack)
{ return (stack.getItem() == Item.getItemFromBlock(Blocks.HOPPER)) || (stack.getItem() == Item.getItemFromBlock(ModContent.FACTORY_HOPPER)); }
private boolean adjacent_inventory_shift(boolean inp, boolean out) private boolean adjacent_inventory_shift(boolean inp, boolean out)
{ {
boolean dirty = false; boolean dirty = false;
@ -675,20 +682,22 @@ public class BlockDecorFurnaceElectrical extends BlockDecorFurnace
dirty = true; dirty = true;
} }
} }
if(inp && (stacks_.get(FIFO_INPUT_1_SLOT_NO).isEmpty())) { if(with_automatic_inventory_pulling_ || is_accepted_hopper(stacks_.get(SMELTING_AUX_SLOT_NO))) {
TileEntity te = world.getTileEntity(pos.offset(inp_facing)); if(inp && (stacks_.get(FIFO_INPUT_1_SLOT_NO).isEmpty())) {
if((te!=null) && (te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, out_facing))) { TileEntity te = world.getTileEntity(pos.offset(inp_facing));
IItemHandler hnd = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, out_facing); if((te!=null) && (te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, out_facing))) {
for(int i=0; i< hnd.getSlots(); ++i) { IItemHandler hnd = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, out_facing);
ItemStack adj_stack = hnd.getStackInSlot(i); for(int i=0; i< hnd.getSlots(); ++i) {
if(!adj_stack.isEmpty()) { ItemStack adj_stack = hnd.getStackInSlot(i);
ItemStack my_stack = adj_stack.copy(); if(!adj_stack.isEmpty()) {
if(my_stack.getCount() > getInventoryStackLimit()) my_stack.setCount(getInventoryStackLimit()); ItemStack my_stack = adj_stack.copy();
adj_stack.shrink(my_stack.getCount()); if(my_stack.getCount() > getInventoryStackLimit()) my_stack.setCount(getInventoryStackLimit());
stacks_.set(FIFO_INPUT_1_SLOT_NO, my_stack); adj_stack.shrink(my_stack.getCount());
energy_stored_ -= transfer_energy_consumption_; stacks_.set(FIFO_INPUT_1_SLOT_NO, my_stack);
dirty = true; energy_stored_ -= transfer_energy_consumption_;
break; dirty = true;
break;
}
} }
} }
} }

View file

@ -617,7 +617,7 @@ public class ModConfig
BlockDecorLadder.on_config(optout.without_ladder_speed_boost); BlockDecorLadder.on_config(optout.without_ladder_speed_boost);
BlockDecorCraftingTable.on_config(optout.without_crafting_table_history, false, tweaks.with_crafting_quickmove_buttons, tweaks.without_crafting_mouse_scrolling); BlockDecorCraftingTable.on_config(optout.without_crafting_table_history, false, tweaks.with_crafting_quickmove_buttons, tweaks.without_crafting_mouse_scrolling);
BlockDecorPipeValve.on_config(tweaks.pipevalve_max_flowrate, tweaks.pipevalve_redstone_slope); BlockDecorPipeValve.on_config(tweaks.pipevalve_max_flowrate, tweaks.pipevalve_redstone_slope);
BlockDecorFurnaceElectrical.BTileEntity.on_config(tweaks.e_furnace_speed_percent, tweaks.e_furnace_power_consumption); BlockDecorFurnaceElectrical.BTileEntity.on_config(tweaks.e_furnace_speed_percent, tweaks.e_furnace_power_consumption, false);
BlockDecorSolarPanel.BTileEntity.on_config(tweaks.solar_panel_peak_power); BlockDecorSolarPanel.BTileEntity.on_config(tweaks.solar_panel_peak_power);
BlockDecorBreaker.BTileEntity.on_config(tweaks.block_breaker_power_consumption, tweaks.block_breaker_reluctance, tweaks.block_breaker_min_breaking_time, tweaks.block_breaker_requires_power); BlockDecorBreaker.BTileEntity.on_config(tweaks.block_breaker_power_consumption, tweaks.block_breaker_reluctance, tweaks.block_breaker_min_breaking_time, tweaks.block_breaker_requires_power);
BlockDecorTreeCutter.BTileEntity.on_config(tweaks.tree_cuttter_energy_consumption, tweaks.tree_cuttter_cutting_time_needed, tweaks.tree_cuttter_requires_power); BlockDecorTreeCutter.BTileEntity.on_config(tweaks.tree_cuttter_energy_consumption, tweaks.tree_cuttter_cutting_time_needed, tweaks.tree_cuttter_requires_power);