Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

Commit

Permalink
Fix EIC piston reset
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba6000 authored and Dream-Master committed Nov 14, 2023
1 parent 229e453 commit f567bfd
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public GT_TileEntity_ElectricImplosionCompressor(String aName) {
.casingIndex(CASING_INDEX).dot(2).buildAndChain(
onElementPass(x -> ++x.mCasing, ofBlock(GregTech_API.sBlockCasings2, 0)),
onElementPass(x -> ++x.mCasing, ofBlock(GregTech_API.sBlockCasings3, 4))))
.addElement('N', new IStructureElement<GT_TileEntity_ElectricImplosionCompressor>() {
.addElement('N', new IStructureElement<>() {

// Much of this based on StructureUtility.ofBlocksTiered
private final List<Pair<Block, Integer>> tiers = getAllBlockTiers();
Expand Down Expand Up @@ -336,17 +336,17 @@ public boolean isCorrectMachinePart(ItemStack itemStack) {

@Override
public void stopMachine() {
this.resetPiston();
this.resetPiston(this.mBlockTier);
super.stopMachine();
}

private void resetPiston() {
private void resetPiston(int tier) {
if (!pistonEnabled) return;
IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity();
if (!aBaseMetaTileEntity.isServerSide()) return;
if (!this.piston) {
List<Pair<Block, Integer>> tiers = getAllBlockTiers();
Pair<Block, Integer> tieredBlock = tiers.get(Math.min(this.mBlockTier, tiers.size()) - 1);
Pair<Block, Integer> tieredBlock = tiers.get(Math.min(tier, tiers.size()) - 1);
this.chunkCoordinates.forEach(c -> {
// Don't replace real blocks in case user has placed something (e.g. tier upgrade)
if (aBaseMetaTileEntity.getWorld().isAirBlock(c.posX, c.posY, c.posZ)) {
Expand Down Expand Up @@ -407,6 +407,7 @@ public void loadNBTData(NBTTagCompound aNBT) {

@Override
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) {
int pistonTier = this.mBlockTier;
this.mCasing = 0;
int mMaxHatchTier = 0;
this.setBlockTier(0);
Expand All @@ -422,7 +423,7 @@ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack i
this.activatePiston();
return true;
}
this.resetPiston();
this.resetPiston(pistonTier);
return false;
}

Expand Down

0 comments on commit f567bfd

Please sign in to comment.