E-Furnace speed choke on low power implemented. Dropper insertion non-experimental. Chimney Trunk placement restrictions fixed (issue #149). Crafting Table Hopper access fixed (issue #147). Added Door tags (issue #150).

This commit is contained in:
stfwi 2020-12-19 10:25:17 +01:00
parent 552acd6baa
commit d4d685693b
19 changed files with 311 additions and 151 deletions

View file

@ -35,6 +35,10 @@ mod:
@echo "[1.16] Building mod using gradle ..."
@$(GRADLE) build $(GRADLE_OPTS)
run:
@echo "[1.16] Run client ..."
@$(GRADLE) runClient
assets:
@echo "[1.16] Running asset generators ..."
@$(TASK) assets

View file

@ -5,4 +5,4 @@ version_minecraft=1.16.4
version_forge_minecraft=1.16.4-35.1.10
version_fml_mappings=20201028-1.16.3
version_jei=1.16.4:7.6.0.58
version_engineersdecor=1.1.5
version_engineersdecor=1.1.6-b1

View file

@ -1,7 +1,8 @@
{
"homepage": "https://www.curseforge.com/minecraft/mc-mods/engineers-decor/",
"1.16.4": {
"1.1.5": "[F] Fixed Crafting Table JEI storage slot count.\n[F] Fixed Factory Hopper removed item collection dupe bug (issue #146, thx FatheredPuma81).\n[F] Increased device GUI access ranges beyond the player block selection range.\n[A] Window placement handling improved.\n[M] Steel/Wood Pole and Double-T support placement improved (issue #139, thx Biviho).\n[M] Metal Sliding Door bottom/top shape when opened added.",
"1.1.6-b1": "[F] Fixed Metal Crafting Table Hopper access (issue #147, ty umerrr).\n[F] Fixed Dark Shingle Roof Chimney placement restriction (issue #149, thx WenXin20).\n[F] Door tags added for Wood Door and Metal Sliding Door (issue #150, thx WenXin20).\n[A] Electrical Furnace automatically chokes speed and power consumption when the internally stored power is below 20%.",
"1.1.5": "[R] Release build v1.1.5.\n[F] Fixed Crafting Table JEI storage slot count.\n[F] Fixed Factory Hopper removed item collection dupe bug (issue #146, thx FatheredPuma81).\n[F] Increased device GUI access ranges beyond the player block selection range.\n[A] Window placement handling improved.\n[M] Steel/Wood Pole and Double-T support placement improved (issue #139, thx Biviho).\n[M] Metal Sliding Door bottom/top shape when opened added.",
"1.1.4": "[R] Release build v1.1.4.\n[F] Solar Panel balancing threshold tuned.\n[F] Fixed Catwalk default state (issue #140, thx hvdklauw).\n[M] Updated lang ru_ru file (PR#137, Smollet777).\n[M] Factory Dropper: Added Ignore-External-Redstone mode.",
"1.1.4-b2": "[A] Steel Catwalks added (top and bottom aligned).\n[A] Steel Railings added.\n[F] Fixed Empty Fluid Barrel crafting crash (ty inflamedsebi).\n[A] Added Solar Panel power balancing.\n[M] GUI Button tooltip delay reduced to 800ms.\n[M] Hopper and Placer: Added \"Redstone ignored\" mode, changed icons from signal-like to Redstone-Torch-like.\n[M] Treated Wood Ladder now crafted from Old Industrial Wood, as Treated Wood Sticks now count as normal Sticks.",
"1.1.4-b1": "[U] Ported to 1.16.4.",
@ -21,6 +22,6 @@
},
"promos": {
"1.16.4-recommended": "1.1.5",
"1.16.4-latest": "1.1.5"
"1.16.4-latest": "1.1.6-b1"
}
}

View file

@ -11,7 +11,14 @@ Mod sources for Minecraft version 1.16.x.
## Version history
- v1.1.5 [F] Fixed Crafting Table JEI storage slot count.
- v1.1.6-b1 [F] Fixed Metal Crafting Table Hopper access (issue #147, ty umerrr).
[F] Fixed Dark Shingle Roof Chimney placement restriction (issue #149, thx WenXin20).
[F] Door tags added for Wood Door and Metal Sliding Door (issue #150, thx WenXin20).
[A] Electrical Furnace automatically chokes speed and power consumption when the internally
stored power is below 20%.
- v1.1.5 [R] Release build v1.1.5.
[F] Fixed Crafting Table JEI storage slot count.
[F] Fixed Factory Hopper removed item collection dupe bug (issue #146, thx FatheredPuma81).
[F] Increased device GUI access ranges beyond the player block selection range.
[A] Window placement handling improved.

View file

@ -678,7 +678,7 @@ public class ModConfig
// currently no file config planned
EdLabeledCrate.on_config(false);
EdFluidFunnel.on_config(with_experimental_features_); // @todo: double check for abuse as pump first
EdDropper.on_config(with_experimental_features_); // @todo: double check handler cross-mod-compat first
EdDropper.on_config(true);
EdFluidBarrel.on_config(12000, 1000);
// -----------------------------------------------------------------------------------------------------------------
{

View file

@ -259,7 +259,7 @@ public class ModContent
Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(2f, 15f).sound(SoundType.STONE)
)).setRegistryName(new ResourceLocation(MODID, "dark_shingle_roof_skylight"));
public static final EdRoofBlock DARK_CERAMIC_SHINGLE_ROOF_CHIMNEYTRUNK = (EdRoofBlock)(new EdRoofBlock(
public static final EdChimneyTrunkBlock DARK_CERAMIC_SHINGLE_ROOF_CHIMNEYTRUNK = (EdChimneyTrunkBlock)(new EdChimneyTrunkBlock(
DecorBlock.CFG_DEFAULT,
Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(2f, 15f).sound(SoundType.STONE),
VoxelShapes.create(Auxiliaries.getPixeledAABB(3, 0, 3, 13, 16, 13)),

View file

@ -17,8 +17,6 @@ import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
@ -50,8 +48,10 @@ public class EdChimneyBlock extends DecorBlock.Normal implements IDecorBlock
@Nullable
public BlockState getStateForPlacement(BlockItemUseContext context)
{
BlockState state = super.getStateForPlacement(context);
if(state==null) return state;
int p = context.getWorld().getRedstonePowerFromNeighbors(context.getPos());
return super.getStateForPlacement(context).with(POWER, p==0 ? 5 : p);
return state.with(POWER, p==0 ? 5 : p);
}
@Override

View file

@ -0,0 +1,36 @@
/*
* @file EdChimneyTrunkBlock.java
* @author Stefan Wilhelm (wile)
* @copyright (C) 2020 Stefan Wilhelm
* @license MIT (see https://opensource.org/licenses/MIT)
*
* Roof block with chimney trunk, only straight.
*/
package wile.engineersdecor.blocks;
import net.minecraft.block.*;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.properties.Half;
import net.minecraft.state.properties.StairsShape;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import javax.annotation.Nullable;
public class EdChimneyTrunkBlock extends EdRoofBlock implements IDecorBlock
{
public EdChimneyTrunkBlock(long config, Block.Properties properties)
{ super(config, properties.variableOpacity(), VoxelShapes.empty(), VoxelShapes.empty()); }
public EdChimneyTrunkBlock(long config, Block.Properties properties, VoxelShape add, VoxelShape cut)
{ super(config, properties, add, cut); }
@Override
@Nullable
public BlockState getStateForPlacement(BlockItemUseContext context)
{
BlockState state = super.getStateForPlacement(context);
return (state==null) ? (state) : (state.with(EdRoofBlock.SHAPE, StairsShape.STRAIGHT).with(EdRoofBlock.HALF, Half.BOTTOM));
}
}

View file

@ -51,6 +51,7 @@ import wile.engineersdecor.libmc.client.ContainerGui;
import wile.engineersdecor.libmc.detail.Auxiliaries;
import wile.engineersdecor.libmc.detail.Inventories;
import wile.engineersdecor.libmc.detail.Inventories.InventoryRange;
import wile.engineersdecor.libmc.detail.Inventories.StorageInventory;
import wile.engineersdecor.libmc.detail.Networking;
import wile.engineersdecor.libmc.detail.TooltipDisplay;
import wile.engineersdecor.libmc.detail.TooltipDisplay.TipRange;
@ -134,16 +135,16 @@ public class EdCraftingTable
if(!explosion) {
ItemStack stack = new ItemStack(this, 1);
CompoundNBT inventory_nbt = new CompoundNBT();
ItemStackHelper.saveAllItems(inventory_nbt, ((CraftingTableTileEntity)te).stacks, false);
((CraftingTableTileEntity)te).mainInventory().save(inventory_nbt, false);
if(!inventory_nbt.isEmpty()) {
CompoundNBT nbt = new CompoundNBT();
nbt.put("inventory", inventory_nbt);
stack.setTag(nbt);
}
((CraftingTableTileEntity) te).clear();
((CraftingTableTileEntity) te).mainInventory().clear();
stacks.add(stack);
} else {
for(ItemStack stack: ((CraftingTableTileEntity)te).stacks) {
for(ItemStack stack: ((CraftingTableTileEntity)te).mainInventory()) {
if(!stack.isEmpty()) stacks.add(stack);
}
((CraftingTableTileEntity)te).reset();
@ -156,38 +157,44 @@ public class EdCraftingTable
// Tile entity
//--------------------------------------------------------------------------------------------------------------------
public static class CraftingTableTileEntity extends TileEntity implements IInventory, INameable, INamedContainerProvider
public static class CraftingTableTileEntity extends TileEntity implements INameable, INamedContainerProvider
{
public static final int NUM_OF_STORAGE_SLOTS = 18;
public static final int NUM_OF_STORAGE_ROWS = 2;
public static final int NUM_OF_SLOTS = 9+NUM_OF_STORAGE_SLOTS;
protected NonNullList<ItemStack> stacks = NonNullList.<ItemStack>withSize(NUM_OF_SLOTS, ItemStack.EMPTY);
protected Inventories.StorageInventory inventory_ = new StorageInventory(this, NUM_OF_SLOTS, 1);
protected CompoundNBT history = new CompoundNBT();
public CraftingTableTileEntity()
{ this(ModContent.TET_CRAFTING_TABLE); }
public CraftingTableTileEntity(TileEntityType<?> te_type)
{ super(te_type); }
{
super(te_type);
inventory_.setCloseAction((player)->{
if(getWorld() instanceof World) {
BlockState state = getBlockState();
getWorld().notifyBlockUpdate(getPos(), state, state, 1|2|16);
}
});
}
public void reset()
{ stacks = NonNullList.<ItemStack>withSize(NUM_OF_SLOTS, ItemStack.EMPTY); }
{ inventory_.clear(); }
public void readnbt(CompoundNBT nbt)
{
reset();
ItemStackHelper.loadAllItems(nbt, this.stacks);
while(this.stacks.size() < NUM_OF_SLOTS) this.stacks.add(ItemStack.EMPTY);
history = nbt.getCompound("history");
}
{ reset(); inventory_.load(nbt); history = nbt.getCompound("history"); }
private void writenbt(CompoundNBT nbt)
{
ItemStackHelper.saveAllItems(nbt, this.stacks);
inventory_.save(nbt);
if(!history.isEmpty()) nbt.put("history", history);
}
public Inventories.StorageInventory mainInventory()
{ return inventory_; }
// TileEntity ------------------------------------------------------------------------------
@Override
@ -209,11 +216,7 @@ public class EdCraftingTable
@Override
public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) // on client
{
//@todo: check if that is still needed: super.read(pkt.getNbtCompound());
readnbt(pkt.getNbtCompound());
super.onDataPacket(net, pkt);
}
{ readnbt(pkt.getNbtCompound()); super.onDataPacket(net, pkt); }
@Override
public void handleUpdateTag(BlockState state, CompoundNBT tag) // on client
@ -245,68 +248,7 @@ public class EdCraftingTable
@Override
public Container createMenu( int id, PlayerInventory inventory, PlayerEntity player )
{ return new CraftingTableContainer(id, inventory, this, IWorldPosCallable.of(world, pos)); }
// IInventory ------------------------------------------------------------------------------
@Override
public int getSizeInventory()
{ return stacks.size(); }
@Override
public boolean isEmpty()
{ for(ItemStack stack: stacks) { if(!stack.isEmpty()) return false; } return true; }
@Override
public ItemStack getStackInSlot(int index)
{ return (index < getSizeInventory()) ? stacks.get(index) : ItemStack.EMPTY; }
@Override
public ItemStack decrStackSize(int index, int count)
{ return ItemStackHelper.getAndSplit(stacks, index, count); }
@Override
public ItemStack removeStackFromSlot(int index)
{ return ItemStackHelper.getAndRemove(stacks, index); }
@Override
public void setInventorySlotContents(int index, ItemStack stack)
{ stacks.set(index, stack); }
@Override
public int getInventoryStackLimit()
{ return 64; }
@Override
public void markDirty()
{ super.markDirty(); }
@Override
public boolean isUsableByPlayer(PlayerEntity player)
{ return ((getWorld().getTileEntity(getPos()) == this)) && (getPos().distanceSq(player.getPosition()) < 64); }
@Override
public void openInventory(PlayerEntity player)
{}
@Override
public void closeInventory(PlayerEntity player)
{
markDirty();
if(world instanceof World) {
BlockState state = world.getBlockState(pos);
world.notifyBlockUpdate(pos, state, state, 1|2);
}
}
@Override
public boolean isItemValidForSlot(int index, ItemStack stack)
{ return true; }
@Override
public void clear()
{ stacks.clear(); }
{ return new CraftingTableContainer(id, inventory, inventory_, IWorldPosCallable.of(world, pos)); }
}
//--------------------------------------------------------------------------------------------------------------------

View file

@ -28,8 +28,4 @@ public class EdDoorBlock extends StandardDoorBlock implements IDecorBlock
public EdDoorBlock(long config, Block.Properties properties)
{ super(config, properties); }
//@Override
//@SuppressWarnings("deprecation")
//public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context)
//{ return state.get(OPEN) ? VoxelShapes.empty() : super.getCollisionShape(state, world, pos, context); }
}

View file

@ -244,6 +244,7 @@ public class EdDropper
private int tick_timer_ = 0;
protected NonNullList<ItemStack> stacks_;
protected final InventoryRange storage_slot_range_;
protected final InventoryRange filter_slot_range_;
public static void on_config(int cooldown_ticks)
{
@ -258,6 +259,7 @@ public class EdDropper
super(te_type);
stacks_ = NonNullList.<ItemStack>withSize(NUM_OF_SLOTS, ItemStack.EMPTY);
storage_slot_range_ = new InventoryRange(this, INPUT_SLOTS_FIRST, INPUT_SLOTS_SIZE);
filter_slot_range_ = new InventoryRange(this, CTRL_SLOTS_FIRST, CTRL_SLOTS_SIZE);
reset_rtstate();
}
@ -596,6 +598,7 @@ public class EdDropper
if(--tick_timer_ > 0) return;
tick_timer_ = TICK_INTERVAL;
if(!(world.getBlockState(pos).getBlock() instanceof DropperBlock)) return;
if(storage_slot_range_.isEmpty()) return;
final boolean continuous_mode = (drop_logic_ & DROPLOGIC_CONTINUOUS)!=0;
boolean dirty = block_power_updated_;
boolean redstone_trigger = (block_power_signal_ && ((block_power_updated_) || (continuous_mode))) || ((drop_logic_ & DROPLOGIC_IGNORE_EXT)!=0);
@ -604,15 +607,10 @@ public class EdDropper
boolean trigger;
// Trigger logic
{
boolean droppable_slot_found = false;
for(int i=INPUT_SLOTS_FIRST; i<(INPUT_SLOTS_FIRST+INPUT_SLOTS_SIZE); ++i) {
if(stacks_.get(i).getCount() >= drop_count_) { droppable_slot_found = true; break; }
}
// From filters / inventory checks
{
int filter_nset = 0;
int last_filter_matches_[] = filter_matches_.clone();
boolean slot_assigned = false;
for(int ci=0; ci<CTRL_SLOTS_SIZE; ++ci) {
filter_matches_[ci] = 0;
final ItemStack cmp_stack = stacks_.get(CTRL_SLOTS_FIRST+ci);
@ -621,8 +619,7 @@ public class EdDropper
final int cmp_stack_count = cmp_stack.getCount();
int inventory_item_count = 0;
int slot = drop_slot_index_;
for(int i=INPUT_SLOTS_FIRST; i<(INPUT_SLOTS_FIRST+INPUT_SLOTS_SIZE); ++i) {
final ItemStack inp_stack = stacks_.get(slot);
for(final ItemStack inp_stack:storage_slot_range_) {
if(Inventories.areItemStacksDifferent(inp_stack, cmp_stack)) { slot = next_slot(slot); continue; }
inventory_item_count += inp_stack.getCount();
if(inventory_item_count < cmp_stack_count) { slot = next_slot(slot); continue; }
@ -648,7 +645,7 @@ public class EdDropper
trigger = redstone_trigger;
}
if(triggered_) { triggered_ = false; trigger = true; }
if(!droppable_slot_found) {
if(storage_slot_range_.stream().noneMatch(is->is.getCount() >= drop_count_)) {
if(open_timer_> 10) open_timer_ = 10; // override if dropping is not possible at all.
} else if(trigger || filter_trigger || redstone_trigger) {
open_timer_ = SHUTTER_CLOSE_DELAY;
@ -672,18 +669,16 @@ public class EdDropper
if(!filter_trigger) {
for(int i=0; i<INPUT_SLOTS_SIZE; ++i) {
if(drop_slot_index_ >= INPUT_SLOTS_SIZE) drop_slot_index_ = 0;
int ic = drop_slot_index_;
final int ic = drop_slot_index_;
drop_slot_index_ = next_slot(drop_slot_index_);
ItemStack ds = stacks_.get(ic);
if((!ds.isEmpty()) && (ds.getCount() >= drop_count_)) {
{
boolean skip_stack = false;
for(int ci = 0; (ci<CTRL_SLOTS_SIZE)&&(!skip_stack); ++ci) {
final ItemStack cmp_stack = stacks_.get(CTRL_SLOTS_FIRST+ci);
if(Inventories.areItemStacksIdentical(ds, cmp_stack)) skip_stack = true;
}
if(skip_stack) continue;
boolean skip_stack = false;
for(int ci = 0; (ci<CTRL_SLOTS_SIZE)&&(!skip_stack); ++ci) {
final ItemStack cmp_stack = stacks_.get(CTRL_SLOTS_FIRST+ci);
if(Inventories.areItemStacksIdentical(ds, cmp_stack)) skip_stack = true;
}
if(skip_stack) continue;
drop_stacks[0] = ds.split(drop_count_);
stacks_.set(ic, ds);
break;
@ -711,23 +706,31 @@ public class EdDropper
}
}
// drop action
Tuple<Boolean, List<ItemStack>> res = try_eject(world, pos, state.get(DropperBlock.FACING), drop_stacks, drop_speed_, drop_xdev_, drop_ydev_, drop_noise_);
final boolean dropped = res.getA();
final List<ItemStack> remaining = res.getB();
for(ItemStack st:remaining) {
if(!storage_slot_range_.insert(st).isEmpty()) ModEngineersDecor.logger().debug("NOT ALL NON-DROPPED ITEMS PUT BACK:" + st);
}
if(dropped || (!remaining.isEmpty())) dirty = true;
// cooldown
if(dropped) drop_timer_ = DROP_PERIOD_OFFSET + drop_period_ * 2; // 0.1s time base -> 100%===10s
// drop sound
if(dropped && ((drop_logic_ & DROPLOGIC_SILENT_DROP) == 0)) {
world.playSound(null, pos, SoundEvents.BLOCK_WOOD_HIT, SoundCategory.BLOCKS, 0.1f, 4f);
if(Arrays.stream(drop_stacks).allMatch(ItemStack::isEmpty)) {
// @todo: check if a re-stacking action is appropriate, or if players intentionally use the stack-in-place feature.
} else {
Tuple<Boolean, List<ItemStack>> res = try_eject(world, pos, state.get(DropperBlock.FACING), drop_stacks, drop_speed_, drop_xdev_, drop_ydev_, drop_noise_);
final boolean dropped = res.getA();
final List<ItemStack> remaining = res.getB();
for(ItemStack st:remaining) {
if(!storage_slot_range_.insert(st).isEmpty()) ModEngineersDecor.logger().debug("NOT ALL NON-DROPPED ITEMS PUT BACK:" + st);
}
if(dropped || (!remaining.isEmpty())) dirty = true;
// cooldown
if(dropped) drop_timer_ = DROP_PERIOD_OFFSET + drop_period_ * 2; // 0.1s time base -> 100%===10s
// drop sound
if(dropped && ((drop_logic_ & DROPLOGIC_SILENT_DROP) == 0)) {
world.playSound(null, pos, SoundEvents.BLOCK_WOOD_HIT, SoundCategory.BLOCKS, 0.1f, 4f);
}
}
// advance to next nonempty slot.
for(int i = 0; i < INPUT_SLOTS_SIZE; ++i) {
if(!stacks_.get(drop_slot_index_).isEmpty()) break;
drop_slot_index_ = next_slot(drop_slot_index_);
{
boolean found = false;
for(int i = 0; i < storage_slot_range_.size; ++i) {
if(!stacks_.get(drop_slot_index_).isEmpty()) { found=true; break; }
drop_slot_index_ = next_slot(drop_slot_index_);
}
if(!found) drop_slot_index_ = 0;
}
}
if(dirty) markDirty();

View file

@ -496,7 +496,7 @@ public class EdElectricalFurnace
} else if(energy_stored_ >= (MAX_ENERGY_BUFFER/2)) {
enabled_ = true;
}
if((!(stacks_.get(SMELTING_INPUT_SLOT_NO)).isEmpty()) && (enabled_) && (speed_>0) && (speed_<=MAX_SPEED_SETTING)) {
if((!(stacks_.get(SMELTING_INPUT_SLOT_NO)).isEmpty()) && (enabled_) && (speed_>0)) {
IRecipe last_recipe = currentRecipe();
updateCurrentRecipe();
if(currentRecipe() != last_recipe) {
@ -508,13 +508,14 @@ public class EdElectricalFurnace
// bypass
if(transferItems(SMELTING_INPUT_SLOT_NO, SMELTING_OUTPUT_SLOT_NO, 1)) dirty = true;
} else {
// smelt
// smelt, automatically choke speed on low power storage
final int speed = MathHelper.clamp((getEnergyStored()>getMaxEnergyStored()/5)? (speed_) : (1), 1, MAX_SPEED_SETTING);
if(!burning() && can_smelt) {
if(heat_up()) { dirty = true; update_blockstate = true; }
if(heat_up(speed)) { dirty = true; update_blockstate = true; }
}
if(burning() && can_smelt) {
if(heat_up()) dirty = true;
proc_time_elapsed_ += (int)(TICK_INTERVAL * proc_speed_percent_ * speed_setting_factor_[speed_] / 100);
if(heat_up(speed)) dirty = true;
proc_time_elapsed_ += (int)(TICK_INTERVAL * proc_speed_percent_ * speed_setting_factor_[speed] / 100);
if(proc_time_elapsed_ >= proc_time_needed_) {
proc_time_elapsed_ = 0;
proc_time_needed_ = getSmeltingTimeNeeded(world, stacks_.get(SMELTING_INPUT_SLOT_NO));
@ -626,9 +627,12 @@ public class EdElectricalFurnace
return dirty;
}
int energy_consumption()
private int energy_consumption()
{ return energy_consumption(speed_); }
private int energy_consumption(int speed)
{
switch(speed_) {
switch(speed) {
case 1: return energy_consumption_;
case 2: return energy_consumption_ * 2;
case 3: return energy_consumption_ * 4;
@ -636,9 +640,9 @@ public class EdElectricalFurnace
}
}
private boolean heat_up()
private boolean heat_up(int speed)
{
int p = energy_consumption();
int p = energy_consumption(speed);
if((p<=0) || (energy_stored_ < p)) return false;
if(burntime_left_ >= (HEAT_CAPACITY-HEAT_INCREMENT)) return false;
energy_stored_ -= p;
@ -806,7 +810,7 @@ public class EdElectricalFurnace
}
@Override
public void render/*render*/(MatrixStack mx, int mouseX, int mouseY, float partialTicks)
public void render(MatrixStack mx, int mouseX, int mouseY, float partialTicks)
{
renderBackground/*renderBackground*/(mx);
super.render(mx, mouseX, mouseY, partialTicks);
@ -845,7 +849,7 @@ public class EdElectricalFurnace
}
@Override
public boolean mouseClicked/*mouseClicked*/(double mouseX, double mouseY, int mouseButton)
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton)
{
tooltip_.resetTimer();
ElectricalFurnaceContainer container = (ElectricalFurnaceContainer)getContainer();

View file

@ -9,6 +9,7 @@
*/
package wile.engineersdecor.detail;
import net.minecraft.util.text.ITextComponent;
import wile.engineersdecor.ModEngineersDecor;
import wile.engineersdecor.blocks.EdCraftingTable;
import net.minecraft.client.renderer.*;
@ -44,10 +45,10 @@ public class ModRenderers
public InvisibleEntityRenderer(EntityRendererManager renderManagerIn)
{ super(renderManagerIn); }
public void func_225623_a_/*render*/(T p_225623_1_, float p_225623_2_, float p_225623_3_, MatrixStack p_225623_4_, IRenderTypeBuffer p_225623_5_, int p_225623_6_)
public void render(T entity, float entityYaw, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int packedLight)
{}
public Vector3d func_225627_b_/*likely getOffset*/(T p_225627_1_, float p_225627_2_)
public Vector3d getRenderOffset(T entity, float partialTicks)
{ return Vector3d.ZERO; }
@SuppressWarnings("deprecation")
@ -57,7 +58,7 @@ public class ModRenderers
protected boolean canRenderName(T entity)
{ return false; }
protected void func_225629_a_/*renderName/renderLabel*/(T p_225629_1_, String p_225629_2_, MatrixStack p_225629_3_, IRenderTypeBuffer p_225629_4_, int p_225629_5_)
protected void renderName(T entity, ITextComponent displayName, MatrixStack matrixStack, IRenderTypeBuffer buffer, int packedLight)
{}
}
@ -92,7 +93,7 @@ public class ModRenderers
long posrnd = te.getPos().toLong();
posrnd = (posrnd>>16)^(posrnd<<1);
for(int i=0; i<9; ++i) {
final ItemStack stack = te.getStackInSlot(i);
final ItemStack stack = te.mainInventory().getStackInSlot(i);
if(stack.isEmpty()) continue;
float prnd = ((float)(((Integer.rotateRight(stack.getItem().hashCode()^(int)posrnd,(stack.getCount()+i)&31)))&1023))/1024f;
float rndo = gap * ((prnd*0.1f)-0.05f);

View file

@ -137,14 +137,7 @@ public class StandardDoorBlock extends DoorBlock implements StandardBlocks.IStan
@Override
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit)
{
boolean open = !state.get(OPEN);
state = state.with(OPEN, open);
world.setBlockState(pos, state, 2|8);
sound(world, pos, open);
actuate_adjacent_wing(state, world, pos, open);
return ActionResultType.func_233537_a_(world.isRemote());
}
{ openDoor(world, state, pos, !state.get(OPEN)); return ActionResultType.func_233537_a_(world.isRemote()); }
@Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean isMoving)
@ -155,4 +148,15 @@ public class StandardDoorBlock extends DoorBlock implements StandardBlocks.IStan
actuate_adjacent_wing(state, world, pos, powered);
if(powered != state.get(OPEN)) sound(world, pos, powered);
}
@Override
public void openDoor(World world, BlockState state, BlockPos pos, boolean open)
{
if(!state.isIn(this) || (state.get(OPEN) == open)) return;
state = state.with(OPEN, open);
world.setBlockState(pos, state, 2|8);
sound(world, pos, open);
actuate_adjacent_wing(state, world, pos, open);
}
}

View file

@ -28,9 +28,12 @@ import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemHandlerHelper;
import net.minecraftforge.items.wrapper.InvWrapper;
import net.minecraftforge.items.wrapper.SidedInvWrapper;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
import java.util.function.BiPredicate;
import java.util.function.Consumer;
import java.util.stream.Stream;
public class Inventories
@ -113,7 +116,7 @@ public class Inventories
return remaining;
}
public static class InventoryRange implements IInventory
public static class InventoryRange implements IInventory, Iterable<ItemStack>
{
public final IInventory inventory;
public final int offset, size, num_rows;
@ -385,6 +388,141 @@ public class Inventories
public boolean move(final InventoryRange target_range)
{ return move(target_range, false, false, true); }
//------------------------------------------------------------------------------------------------------------------
public Stream<ItemStack> stream()
{ return java.util.stream.StreamSupport.stream(this.spliterator(), false); }
public Iterator<ItemStack> iterator()
{ return new InventoryRangeIterator(this); }
public static class InventoryRangeIterator implements Iterator<ItemStack>
{
private final InventoryRange parent_;
private int index = 0;
public InventoryRangeIterator(InventoryRange range)
{ parent_ = range; }
public boolean hasNext()
{ return index < parent_.size; }
public ItemStack next()
{
if(index >= parent_.size) throw new NoSuchElementException();
return parent_.getStackInSlot(index++);
}
}
}
//--------------------------------------------------------------------------------------------------------------------
public static class StorageInventory implements IInventory, Iterable<ItemStack>
{
protected final NonNullList<ItemStack> stacks_;
protected final TileEntity te_;
protected final int size_;
protected final int num_rows_;
protected int stack_limit_ = 64;
protected BiPredicate<Integer, ItemStack> validator_ = (index, stack)->true;
protected Consumer<PlayerEntity> open_action_ = (player)->{};
protected Consumer<PlayerEntity> close_action_ = (player)->{};
public StorageInventory(TileEntity te, int size, int num_rows)
{
te_ = te;
size_ = Math.max(size, 1);
stacks_ = NonNullList.<ItemStack>withSize(size_, ItemStack.EMPTY);
num_rows_ = MathHelper.clamp(num_rows, 1, size_);
}
public CompoundNBT save(CompoundNBT nbt)
{ return ItemStackHelper.saveAllItems(nbt, stacks_); }
public CompoundNBT save(CompoundNBT nbt, boolean save_empty)
{ return ItemStackHelper.saveAllItems(nbt, stacks_, save_empty); }
public StorageInventory load(CompoundNBT nbt)
{
ItemStackHelper.loadAllItems(nbt, stacks_);
while(stacks_.size() < size_) stacks_.add(ItemStack.EMPTY);
return this;
}
public NonNullList<ItemStack> stacks()
{ return stacks_; }
public StorageInventory setOpenAction(Consumer<PlayerEntity> fn)
{ open_action_ = fn; return this; }
public StorageInventory setCloseAction(Consumer<PlayerEntity> fn)
{ close_action_ = fn; return this; }
public StorageInventory setStackLimit(int max_slot_stack_size)
{ stack_limit_ = Math.max(max_slot_stack_size, 1); return this; }
// Iterable<ItemStack> ---------------------------------------------------------------------
public Iterator<ItemStack> iterator()
{ return stacks_.iterator(); }
public Stream<ItemStack> stream()
{ return stacks_.stream(); }
// IInventory ------------------------------------------------------------------------------
@Override
public int getSizeInventory()
{ return size_; }
@Override
public boolean isEmpty()
{ for(ItemStack stack: stacks_) { if(!stack.isEmpty()) return false; } return true; }
@Override
public ItemStack getStackInSlot(int index)
{ return (index < size_) ? stacks_.get(index) : ItemStack.EMPTY; }
@Override
public ItemStack decrStackSize(int index, int count)
{ return ItemStackHelper.getAndSplit(stacks_, index, count); }
@Override
public ItemStack removeStackFromSlot(int index)
{ return ItemStackHelper.getAndRemove(stacks_, index); }
@Override
public void setInventorySlotContents(int index, ItemStack stack)
{ stacks_.set(index, stack); }
@Override
public int getInventoryStackLimit()
{ return stack_limit_; }
@Override
public void markDirty()
{ te_.markDirty(); }
@Override
public boolean isUsableByPlayer(PlayerEntity player)
{ return ((te_.getWorld().getTileEntity(te_.getPos()) == te_)) && (te_.getPos().distanceSq(player.getPosition()) < 64); }
@Override
public void openInventory(PlayerEntity player)
{ open_action_.accept(player); }
@Override
public void closeInventory(PlayerEntity player)
{ markDirty(); close_action_.accept(player); }
@Override
public boolean isItemValidForSlot(int index, ItemStack stack)
{ return validator_.test(index, stack); }
@Override
public void clear()
{ stacks_.clear(); }
}
//--------------------------------------------------------------------------------------------------------------------

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"engineersdecor:metal_sliding_door"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"engineersdecor:old_industrial_wood_door"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"engineersdecor:metal_sliding_door"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"engineersdecor:old_industrial_wood_door"
]
}