mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-15 23:56:14 +01:00
Temporary fix for Forge 1.17 setRemoved() regression
This commit is contained in:
parent
b9310e93a9
commit
10f84bcd79
7 changed files with 66 additions and 16 deletions
|
@ -185,12 +185,17 @@ public class KineticTileEntity extends SmartTileEntity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRemoved() {
|
public void setRemoved() {
|
||||||
|
super.setRemoved();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setRemovedNotDueToChunkUnload() {
|
||||||
if (!level.isClientSide) {
|
if (!level.isClientSide) {
|
||||||
if (hasNetwork())
|
if (hasNetwork())
|
||||||
getOrCreateNetwork().remove(this);
|
getOrCreateNetwork().remove(this);
|
||||||
detachKinetics();
|
detachKinetics();
|
||||||
}
|
}
|
||||||
super.setRemoved();
|
super.setRemovedNotDueToChunkUnload();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -86,10 +86,15 @@ public class EngineTileEntity extends SmartTileEntity implements IInstanceRender
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRemoved() {
|
public void setRemoved() {
|
||||||
detachWheel();
|
|
||||||
super.setRemoved();
|
super.setRemoved();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setRemovedNotDueToChunkUnload() {
|
||||||
|
detachWheel();
|
||||||
|
super.setRemovedNotDueToChunkUnload();
|
||||||
|
}
|
||||||
|
|
||||||
protected void refreshWheelSpeed() {
|
protected void refreshWheelSpeed() {
|
||||||
if (poweredWheel == null)
|
if (poweredWheel == null)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -362,9 +362,14 @@ public class ClockworkBearingTileEntity extends KineticTileEntity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRemoved() {
|
public void setRemoved() {
|
||||||
|
super.setRemoved();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setRemovedNotDueToChunkUnload() {
|
||||||
if (!level.isClientSide)
|
if (!level.isClientSide)
|
||||||
disassemble();
|
disassemble();
|
||||||
super.setRemoved();
|
super.setRemovedNotDueToChunkUnload();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -59,9 +59,14 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRemoved() {
|
public void setRemoved() {
|
||||||
|
super.setRemoved();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setRemovedNotDueToChunkUnload() {
|
||||||
if (!level.isClientSide)
|
if (!level.isClientSide)
|
||||||
disassemble();
|
disassemble();
|
||||||
super.setRemoved();
|
super.setRemovedNotDueToChunkUnload();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -107,7 +107,7 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity
|
||||||
boolean contraptionPresent = movedContraption != null;
|
boolean contraptionPresent = movedContraption != null;
|
||||||
if (needsContraption && !contraptionPresent)
|
if (needsContraption && !contraptionPresent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float movementSpeed = getMovementSpeed();
|
float movementSpeed = getMovementSpeed();
|
||||||
float newOffset = offset + movementSpeed;
|
float newOffset = offset + movementSpeed;
|
||||||
if ((int) newOffset != (int) offset)
|
if ((int) newOffset != (int) offset)
|
||||||
|
@ -122,7 +122,7 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!contraptionPresent || !movedContraption.isStalled())
|
if (!contraptionPresent || !movedContraption.isStalled())
|
||||||
offset = newOffset;
|
offset = newOffset;
|
||||||
|
|
||||||
|
@ -173,10 +173,15 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRemoved() {
|
public void setRemoved() {
|
||||||
|
super.setRemoved();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setRemovedNotDueToChunkUnload() {
|
||||||
this.remove = true;
|
this.remove = true;
|
||||||
if (!level.isClientSide)
|
if (!level.isClientSide)
|
||||||
disassemble();
|
disassemble();
|
||||||
super.setRemoved();
|
super.setRemovedNotDueToChunkUnload();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -261,13 +266,13 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity
|
||||||
movedContraption.setContraptionMotion(Vec3.ZERO);
|
movedContraption.setContraptionMotion(Vec3.ZERO);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3 motion = getMotionVector();
|
Vec3 motion = getMotionVector();
|
||||||
movedContraption.setContraptionMotion(getMotionVector());
|
movedContraption.setContraptionMotion(getMotionVector());
|
||||||
movedContraption.move(motion.x, motion.y, motion.z);
|
movedContraption.move(motion.x, motion.y, motion.z);
|
||||||
return ContraptionCollider.collideBlocks(movedContraption);
|
return ContraptionCollider.collideBlocks(movedContraption);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void collided() {
|
protected void collided() {
|
||||||
if (level.isClientSide) {
|
if (level.isClientSide) {
|
||||||
waitingForSpeedChange = true;
|
waitingForSpeedChange = true;
|
||||||
|
|
|
@ -197,12 +197,17 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRemoved() {
|
public void setRemoved() {
|
||||||
onEmptied();
|
|
||||||
itemCapability.invalidate();
|
itemCapability.invalidate();
|
||||||
fluidCapability.invalidate();
|
fluidCapability.invalidate();
|
||||||
super.setRemoved();
|
super.setRemoved();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setRemovedNotDueToChunkUnload() {
|
||||||
|
onEmptied();
|
||||||
|
super.setRemovedNotDueToChunkUnload();
|
||||||
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, Direction side) {
|
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, Direction side) {
|
||||||
|
@ -288,7 +293,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
||||||
tryClearingSpoutputOverflow();
|
tryClearingSpoutputOverflow();
|
||||||
if (!contentsChanged)
|
if (!contentsChanged)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
contentsChanged = false;
|
contentsChanged = false;
|
||||||
getOperator().ifPresent(te -> te.basinChecker.scheduleUpdate());
|
getOperator().ifPresent(te -> te.basinChecker.scheduleUpdate());
|
||||||
|
|
||||||
|
@ -312,7 +317,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
||||||
Direction direction = blockState.getValue(BasinBlock.FACING);
|
Direction direction = blockState.getValue(BasinBlock.FACING);
|
||||||
BlockEntity te = level.getBlockEntity(worldPosition.below()
|
BlockEntity te = level.getBlockEntity(worldPosition.below()
|
||||||
.relative(direction));
|
.relative(direction));
|
||||||
|
|
||||||
FilteringBehaviour filter = null;
|
FilteringBehaviour filter = null;
|
||||||
InvManipulationBehaviour inserter = null;
|
InvManipulationBehaviour inserter = null;
|
||||||
if (te != null) {
|
if (te != null) {
|
||||||
|
@ -362,7 +367,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
||||||
update = true;
|
update = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetTank == null)
|
if (targetTank == null)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -459,7 +464,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
||||||
|
|
||||||
Direction direction = blockState.getValue(BasinBlock.FACING);
|
Direction direction = blockState.getValue(BasinBlock.FACING);
|
||||||
if (direction != Direction.DOWN) {
|
if (direction != Direction.DOWN) {
|
||||||
|
|
||||||
BlockEntity te = level.getBlockEntity(worldPosition.below()
|
BlockEntity te = level.getBlockEntity(worldPosition.below()
|
||||||
.relative(direction));
|
.relative(direction));
|
||||||
|
|
||||||
|
@ -472,7 +477,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
||||||
: te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, direction.getOpposite())
|
: te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, direction.getOpposite())
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
boolean externalTankNotPresent = targetTank == null;
|
boolean externalTankNotPresent = targetTank == null;
|
||||||
|
|
||||||
if (!outputItems.isEmpty() && targetInv == null)
|
if (!outputItems.isEmpty() && targetInv == null)
|
||||||
return false;
|
return false;
|
||||||
if (!outputFluids.isEmpty() && externalTankNotPresent) {
|
if (!outputFluids.isEmpty() && externalTankNotPresent) {
|
||||||
|
@ -484,7 +489,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
||||||
if (!acceptFluidOutputsIntoBasin(outputFluids, simulate, targetTank))
|
if (!acceptFluidOutputsIntoBasin(outputFluids, simulate, targetTank))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (simulate)
|
if (simulate)
|
||||||
return true;
|
return true;
|
||||||
for (ItemStack itemStack : outputItems) {
|
for (ItemStack itemStack : outputItems) {
|
||||||
|
|
|
@ -146,10 +146,30 @@ public abstract class SmartTileEntity extends SyncedTileEntity implements IParti
|
||||||
.reduce(ItemRequirement.NONE, (a, b) -> a.with(b.getRequiredItems()), (a, b) -> a.with(b));
|
.reduce(ItemRequirement.NONE, (a, b) -> a.with(b.getRequiredItems()), (a, b) -> a.with(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: Remove this hack once this issue is resolved: https://github.com/MinecraftForge/MinecraftForge/issues/8302
|
||||||
|
Once the PR linked in the issue is accepted, we should use the new method for determining whether setRemoved was
|
||||||
|
called due to a chunk unload or not, and remove this volatile workaround
|
||||||
|
*/
|
||||||
|
private boolean unloaded;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChunkUnloaded() {
|
||||||
|
super.onChunkUnloaded();
|
||||||
|
unloaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setRemovedNotDueToChunkUnload() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRemoved() {
|
public void setRemoved() {
|
||||||
forEachBehaviour(TileEntityBehaviour::remove);
|
forEachBehaviour(TileEntityBehaviour::remove);
|
||||||
super.setRemoved();
|
super.setRemoved();
|
||||||
|
|
||||||
|
if (!unloaded) {
|
||||||
|
setRemovedNotDueToChunkUnload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLazyTickRate(int slowTickRate) {
|
public void setLazyTickRate(int slowTickRate) {
|
||||||
|
|
Loading…
Reference in a new issue