Fixed Factory Hopper UI element events.

This commit is contained in:
stfwi 2021-09-01 20:28:23 +02:00
parent e252a0464e
commit 2e341ef659
10 changed files with 44 additions and 30 deletions

View file

@ -4,4 +4,4 @@ org.gradle.jvmargs=-Xmx8G
version_minecraft=1.17.1 version_minecraft=1.17.1
version_forge_minecraft=1.17.1-37.0.51 version_forge_minecraft=1.17.1-37.0.51
version_jei=1.17.1:8.0.0.15 version_jei=1.17.1:8.0.0.15
version_engineersdecor=1.1.17-b2 version_engineersdecor=1.1.17-b3

View file

@ -1,6 +1,7 @@
{ {
"homepage": "https://www.curseforge.com/minecraft/mc-mods/engineers-decor/", "homepage": "https://www.curseforge.com/minecraft/mc-mods/engineers-decor/",
"1.17.1": { "1.17.1": {
"1.1.17-b3": "[F] Fixed Factory Hopper GUI element events.",
"1.1.17-b2": "[F] Updated to Forge 1.17.1-37.0.51 to fix `ToolType not found` startup crash.\n[A] JEI plugin enabled.\n[A] Dark Shingle Roof recipe variant added.", "1.1.17-b2": "[F] Updated to Forge 1.17.1-37.0.51 to fix `ToolType not found` startup crash.\n[A] JEI plugin enabled.\n[A] Dark Shingle Roof recipe variant added.",
"1.1.17-b1": "[U] Initial MC 1.17.1 port.\n[M] Clinker Brick textures adapted to contemporary MC textures.\n[D] Gas Concrete dropped (Rebar Concrete suffices for texture variation).\n[D] Treated Wood Side Table dropped.\n[M] Updated zh_cn (PR#183, Lyaiya).", "1.1.17-b1": "[U] Initial MC 1.17.1 port.\n[M] Clinker Brick textures adapted to contemporary MC textures.\n[D] Gas Concrete dropped (Rebar Concrete suffices for texture variation).\n[D] Treated Wood Side Table dropped.\n[M] Updated zh_cn (PR#183, Lyaiya).",
"1.1.14": "[R] Release build v1.1.14.", "1.1.14": "[R] Release build v1.1.14.",
@ -42,6 +43,6 @@
}, },
"promos": { "promos": {
"1.17.1-recommended": "1.1.14", "1.17.1-recommended": "1.1.14",
"1.17.1-latest": "1.1.17-b2" "1.17.1-latest": "1.1.17-b3"
} }
} }

View file

@ -11,6 +11,8 @@ Mod sources for Minecraft version 1.16.x.
## Version history ## Version history
- v1.1.17-b3 [F] Fixed Factory Hopper GUI element events.
- v1.1.17-b2 [F] Updated to Forge 1.17.1-37.0.51 to fix `ToolType not found` startup crash. - v1.1.17-b2 [F] Updated to Forge 1.17.1-37.0.51 to fix `ToolType not found` startup crash.
[A] JEI plugin enabled. [A] JEI plugin enabled.
[A] Dark Shingle Roof recipe variant added. [A] Dark Shingle Roof recipe variant added.

View file

@ -331,8 +331,8 @@ public class EdCraftingTable
inventory_ = block_inventory; inventory_ = block_inventory;
inventory_.startOpen(player_); inventory_.startOpen(player_);
Level world = player_.level; Level world = player_.level;
if((inventory_ instanceof StorageInventory) && ((((StorageInventory)inventory_).getTileEntity()) instanceof CraftingTableTileEntity)) { if((inventory_ instanceof StorageInventory) && ((((StorageInventory)inventory_).getTileEntity()) instanceof final CraftingTableTileEntity te)) {
te_ = (CraftingTableTileEntity)(((StorageInventory)inventory_).getTileEntity()); te_ = te;
} else { } else {
te_ = null; te_ = null;
} }

View file

@ -735,7 +735,8 @@ public class EdDropper
@Override @Override
public void onClientPacketReceived(int windowId, Player player, CompoundTag nbt) public void onClientPacketReceived(int windowId, Player player, CompoundTag nbt)
{ {
if((!(inventory_ instanceof StorageInventory)) || (!(((StorageInventory)inventory_).getTileEntity() instanceof DropperTileEntity))) return; if(!(inventory_ instanceof Inventories.StorageInventory)) return;
if(!(((Inventories.StorageInventory)inventory_).getTileEntity() instanceof final DropperTileEntity te)) return;
if(nbt.contains("action")) { if(nbt.contains("action")) {
boolean changed = false; boolean changed = false;
final int slotId = nbt.contains("slot") ? nbt.getInt("slot") : -1; final int slotId = nbt.contains("slot") ? nbt.getInt("slot") : -1;
@ -754,7 +755,6 @@ public class EdDropper
broadcastChanges(); broadcastChanges();
} }
} else { } else {
DropperTileEntity te = (DropperTileEntity)((StorageInventory)inventory_).getTileEntity();
if(nbt.contains("drop_speed")) te.drop_speed_ = Mth.clamp(nbt.getInt("drop_speed"), 0, 100); if(nbt.contains("drop_speed")) te.drop_speed_ = Mth.clamp(nbt.getInt("drop_speed"), 0, 100);
if(nbt.contains("drop_xdev")) te.drop_xdev_ = Mth.clamp(nbt.getInt("drop_xdev"), -100, 100); if(nbt.contains("drop_xdev")) te.drop_xdev_ = Mth.clamp(nbt.getInt("drop_xdev"), -100, 100);
if(nbt.contains("drop_ydev")) te.drop_ydev_ = Mth.clamp(nbt.getInt("drop_ydev"), -100, 100); if(nbt.contains("drop_ydev")) te.drop_ydev_ = Mth.clamp(nbt.getInt("drop_ydev"), -100, 100);

View file

@ -716,8 +716,8 @@ public class EdElectricalFurnace
protected void checkTakeAchievements(ItemStack stack) protected void checkTakeAchievements(ItemStack stack)
{ {
stack.onCraftedBy(player_.level, player_, removeCount); stack.onCraftedBy(player_.level, player_, removeCount);
if((!player_.level.isClientSide()) && (inventory_ instanceof StorageInventory)) { if((!player_.level.isClientSide()) && (inventory_ instanceof StorageInventory) &&
ElectricalFurnaceTileEntity te = (ElectricalFurnaceTileEntity)(((StorageInventory)inventory_).getTileEntity()); (((StorageInventory)inventory_).getTileEntity()) instanceof final ElectricalFurnaceTileEntity te) {
int xp = te.consumeSmeltingExperience(stack); int xp = te.consumeSmeltingExperience(stack);
while(xp > 0) { while(xp > 0) {
int k = ExperienceOrb.getExperienceValue(xp); int k = ExperienceOrb.getExperienceValue(xp);
@ -838,7 +838,7 @@ public class EdElectricalFurnace
public void onClientPacketReceived(int windowId, Player player, CompoundTag nbt) public void onClientPacketReceived(int windowId, Player player, CompoundTag nbt)
{ {
if(!(inventory_ instanceof StorageInventory)) return; if(!(inventory_ instanceof StorageInventory)) return;
ElectricalFurnaceTileEntity te = (ElectricalFurnaceTileEntity)(((StorageInventory)inventory_).getTileEntity()); if(!((((StorageInventory)inventory_).getTileEntity()) instanceof final ElectricalFurnaceTileEntity te)) return;
if(nbt.contains("speed")) te.speed_ = Mth.clamp(nbt.getInt("speed"), 0, ElectricalFurnaceTileEntity.MAX_SPEED_SETTING); if(nbt.contains("speed")) te.speed_ = Mth.clamp(nbt.getInt("speed"), 0, ElectricalFurnaceTileEntity.MAX_SPEED_SETTING);
te.setChanged(); te.setChanged();
} }

View file

@ -706,8 +706,9 @@ public class EdFurnace
protected void checkTakeAchievements(ItemStack stack) protected void checkTakeAchievements(ItemStack stack)
{ {
stack.onCraftedBy(player_.level, player_, removeCount); stack.onCraftedBy(player_.level, player_, removeCount);
if((!player_.level.isClientSide()) && (inventory_ instanceof StorageInventory)) { if((!player_.level.isClientSide()) && (inventory_ instanceof StorageInventory) &&
FurnaceTileEntity te = (FurnaceTileEntity)(((StorageInventory)inventory_).getTileEntity()); ((((StorageInventory)inventory_).getTileEntity()) instanceof final FurnaceTileEntity te)
) {
int xp = te.consumeSmeltingExperience(stack); int xp = te.consumeSmeltingExperience(stack);
while(xp > 0) { while(xp > 0) {
int k = ExperienceOrb.getExperienceValue(xp); int k = ExperienceOrb.getExperienceValue(xp);

View file

@ -716,7 +716,8 @@ public class EdHopper
@Override @Override
public void onClientPacketReceived(int windowId, Player player, CompoundTag nbt) public void onClientPacketReceived(int windowId, Player player, CompoundTag nbt)
{ {
if(!(inventory_ instanceof HopperTileEntity te)) return; if(!(inventory_ instanceof Inventories.StorageInventory)) return;
if(!((((((Inventories.StorageInventory)inventory_).getTileEntity())) instanceof final EdHopper.HopperTileEntity te))) return;
if(nbt.contains("xsize")) te.transfer_count_ = Mth.clamp(nbt.getInt("xsize"), 1, HopperTileEntity.MAX_TRANSFER_COUNT); if(nbt.contains("xsize")) te.transfer_count_ = Mth.clamp(nbt.getInt("xsize"), 1, HopperTileEntity.MAX_TRANSFER_COUNT);
if(nbt.contains("period")) te.transfer_period_ = Mth.clamp(nbt.getInt("period"), 0, 100); if(nbt.contains("period")) te.transfer_period_ = Mth.clamp(nbt.getInt("period"), 0, 100);
if(nbt.contains("range")) te.collection_range_ = Mth.clamp(nbt.getInt("range"), 0, HopperTileEntity.MAX_COLLECTION_RANGE); if(nbt.contains("range")) te.collection_range_ = Mth.clamp(nbt.getInt("range"), 0, HopperTileEntity.MAX_COLLECTION_RANGE);

View file

@ -223,7 +223,7 @@ public class EdMineralSmelter
public static final int MAX_ENERGY_BUFFER = 32000; public static final int MAX_ENERGY_BUFFER = 32000;
public static final int MAX_ENERGY_TRANSFER = 8192; public static final int MAX_ENERGY_TRANSFER = 8192;
public static final int DEFAULT_ENERGY_CONSUMPTION = 92; public static final int DEFAULT_ENERGY_CONSUMPTION = 92;
public static final int DEFAULT_HEATUP_RATE = 2; // -> 50s for one smelting process public static final int DEFAULT_HEATUP_RATE = 10; //2; // -> 50s for one smelting process
public static final int PHASE_WARMUP = 0; public static final int PHASE_WARMUP = 0;
public static final int PHASE_HOT = 1; public static final int PHASE_HOT = 1;
public static final int PHASE_MAGMABLOCK = 2; public static final int PHASE_MAGMABLOCK = 2;
@ -267,7 +267,7 @@ public class EdMineralSmelter
.setStackLimit(1) .setStackLimit(1)
.setValidator((index,stack)-> ((index==1) || ((index==0) && accepts_input(stack)))) .setValidator((index,stack)-> ((index==1) || ((index==0) && accepts_input(stack))))
.setSlotChangeAction((slot,stack)->{ .setSlotChangeAction((slot,stack)->{
System.out.println("slot"+slot+"<<"+stack); //System.out.println("slot"+slot+"<<"+stack);
}); });
item_handler_ = Inventories.MappedItemHandler.createGenericHandler( item_handler_ = Inventories.MappedItemHandler.createGenericHandler(
main_inventory_, main_inventory_,
@ -329,10 +329,15 @@ public class EdMineralSmelter
return stack; return stack;
} }
protected void drain_lava_bucket()
{
}
protected void reset_process() protected void reset_process()
{ {
main_inventory_.setItem(0, ItemStack.EMPTY); main_inventory_.setItem(0, ItemStack.EMPTY);
main_inventory_.setItem(1, ItemStack.EMPTY); main_inventory_.setItem(1, ItemStack.EMPTY);
tank_.clear();
force_block_update_ = true; force_block_update_ = true;
tick_timer_ = 0; tick_timer_ = 0;
progress_ = 0; progress_ = 0;
@ -396,14 +401,14 @@ public class EdMineralSmelter
boolean dirty = false; boolean dirty = false;
final int last_phase = phase(); final int last_phase = phase();
final ItemStack istack = main_inventory_.getItem(0); final ItemStack istack = main_inventory_.getItem(0);
if(istack.isEmpty() && tank_.isEmpty()) { if(istack.isEmpty() && (tank_.getFluidAmount()<1000)) {
progress_ = 0; progress_ = 0;
} else if((battery_.isEmpty()) || (level.hasNeighborSignal(worldPosition))) { } else if((battery_.isEmpty()) || (level.hasNeighborSignal(worldPosition))) {
progress_ = Mth.clamp(progress_-cooldown_rate, 0,100); progress_ = Mth.clamp(progress_-cooldown_rate, 0,100);
} else if(progress_ >= 100) { } else if(progress_ >= 100) {
progress_ = 100; progress_ = 100;
if(!battery_.draw(energy_consumption*TICK_INTERVAL/20)) battery_.clear(); if(!battery_.draw(energy_consumption*TICK_INTERVAL/20)) battery_.clear();
} else { } else if((phase()>=PHASE_LAVA) || (!istack.isEmpty())) {
if(!battery_.draw(energy_consumption*TICK_INTERVAL)) battery_.clear(); if(!battery_.draw(energy_consumption*TICK_INTERVAL)) battery_.clear();
progress_ = Mth.clamp(progress_+heatup_rate, 0, 100); progress_ = Mth.clamp(progress_+heatup_rate, 0, 100);
} }
@ -447,9 +452,13 @@ public class EdMineralSmelter
// Cool-down to prev phase happened. // Cool-down to prev phase happened.
switch(new_phase) { switch(new_phase) {
case PHASE_MAGMABLOCK -> { case PHASE_MAGMABLOCK -> {
if(tank_.getFluidAmount() < 1000) {
reset_process();
} else {
main_inventory_.setItem(0, (tank_.getFluidAmount() >= MAX_BUCKET_EXTRACT_FLUID_LEVEL) ? (MAGMA_STACK.copy()) : (ItemStack.EMPTY)); main_inventory_.setItem(0, (tank_.getFluidAmount() >= MAX_BUCKET_EXTRACT_FLUID_LEVEL) ? (MAGMA_STACK.copy()) : (ItemStack.EMPTY));
main_inventory_.setItem(1, main_inventory_.getItem(0).copy()); main_inventory_.setItem(1, main_inventory_.getItem(0).copy());
tank_.clear(); tank_.clear();
}
level.playSound(null, worldPosition, SoundEvents.LAVA_EXTINGUISH, SoundSource.BLOCKS, 0.5f, 1.1f); level.playSound(null, worldPosition, SoundEvents.LAVA_EXTINGUISH, SoundSource.BLOCKS, 0.5f, 1.1f);
dirty = true; dirty = true;
} }
@ -466,20 +475,19 @@ public class EdMineralSmelter
level.playSound(null, worldPosition, SoundEvents.LAVA_EXTINGUISH, SoundSource.BLOCKS, 0.3f, 0.7f); level.playSound(null, worldPosition, SoundEvents.LAVA_EXTINGUISH, SoundSource.BLOCKS, 0.3f, 0.7f);
} }
} }
} else if((phase()==PHASE_LAVA) && fluid_extraction_possible()) { } else if((phase()==PHASE_LAVA) && (tank_.getFluidAmount()>0)) {
// Phase unchanged, fluid transfer check. // Phase unchanged, fluid transfer check.
final IFluidHandler fh = Fluidics.handler(level, getBlockPos().below(), Direction.UP); FluidStack fs = tank_.getFluid().copy();
if(fh != null) { if(fs.getAmount() > 100) fs.setAmount(100);
int n = fh.fill(LAVA_BUCKET_FLUID_STACK.copy(), IFluidHandler.FluidAction.SIMULATE); final int n = Fluidics.fill(level, getBlockPos().below(), Direction.UP, fs);
if(n >= LAVA_BUCKET_FLUID_STACK.getAmount()/2) {
n = fh.fill(LAVA_BUCKET_FLUID_STACK.copy(), IFluidHandler.FluidAction.EXECUTE);
if(n > 0) { if(n > 0) {
tank_.drain(n);
if(tank_.isEmpty()) {
reset_process(); reset_process();
level.playSound(null, worldPosition, SoundEvents.LAVA_EXTINGUISH, SoundSource.BLOCKS, 0.3f, 0.7f); level.playSound(null, worldPosition, SoundEvents.LAVA_EXTINGUISH, SoundSource.BLOCKS, 0.3f, 0.7f);
} }
} }
} }
}
// Block state // Block state
if((force_block_update_ || (state.getValue(MineralSmelterBlock.PHASE) != new_phase))) { if((force_block_update_ || (state.getValue(MineralSmelterBlock.PHASE) != new_phase))) {
state = state.setValue(MineralSmelterBlock.PHASE, new_phase); state = state.setValue(MineralSmelterBlock.PHASE, new_phase);

View file

@ -652,7 +652,8 @@ public class EdPlacer
@Override @Override
public void onClientPacketReceived(int windowId, Player player, CompoundTag nbt) public void onClientPacketReceived(int windowId, Player player, CompoundTag nbt)
{ {
if((!(inventory_ instanceof Inventories.StorageInventory)) || (!((((Inventories.StorageInventory)inventory_).getTileEntity()) instanceof PlacerTileEntity te))) return; if(!(inventory_ instanceof Inventories.StorageInventory)) return;
if(!((((Inventories.StorageInventory)inventory_).getTileEntity()) instanceof PlacerTileEntity te)) return;
if(nbt.contains("action")) { if(nbt.contains("action")) {
final int slotId = nbt.contains("slot") ? nbt.getInt("slot") : -1; final int slotId = nbt.contains("slot") ? nbt.getInt("slot") : -1;
boolean changed = false; boolean changed = false;