Place & Crash

- Fixed some incompatibilities between kinetic blocks and schematic tools
This commit is contained in:
simibubi 2020-05-09 19:17:51 +02:00
parent 32cce4e9b9
commit 1fe647b16e
5 changed files with 19 additions and 5 deletions

View file

@ -1,6 +1,7 @@
package com.simibubi.create.modules.contraptions.components.contraptions.bearing; package com.simibubi.create.modules.contraptions.components.contraptions.bearing;
import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.utility.WrappedWorld;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -43,15 +44,18 @@ public class MechanicalBearingBlock extends BearingBlock implements ITE<Mechanic
@Override @Override
public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) {
if (worldIn instanceof WrappedWorld)
return;
withTileEntityDo(worldIn, pos, MechanicalBearingTileEntity::neighbourChanged); withTileEntityDo(worldIn, pos, MechanicalBearingTileEntity::neighbourChanged);
} }
@Override @Override
public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) { boolean isMoving) {
if (worldIn instanceof WrappedWorld)
return;
if (worldIn.isRemote) if (worldIn.isRemote)
return; return;
withTileEntityDo(worldIn, pos, MechanicalBearingTileEntity::neighbourChanged); withTileEntityDo(worldIn, pos, MechanicalBearingTileEntity::neighbourChanged);
} }

View file

@ -62,6 +62,9 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity imp
} }
public void neighbourChanged() { public void neighbourChanged() {
if (!hasWorld())
return;
boolean shouldWindmill = world.isBlockPowered(pos); boolean shouldWindmill = world.isBlockPowered(pos);
if (shouldWindmill == isWindmill) if (shouldWindmill == isWindmill)
return; return;

View file

@ -1,6 +1,7 @@
package com.simibubi.create.modules.contraptions.components.fan; package com.simibubi.create.modules.contraptions.components.fan;
import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.utility.WrappedWorld;
import com.simibubi.create.modules.contraptions.base.DirectionalKineticBlock; import com.simibubi.create.modules.contraptions.base.DirectionalKineticBlock;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -50,6 +51,8 @@ public class EncasedFanBlock extends DirectionalKineticBlock implements ITE<Enca
} }
protected void blockUpdate(BlockState state, World worldIn, BlockPos pos) { protected void blockUpdate(BlockState state, World worldIn, BlockPos pos) {
if (worldIn instanceof WrappedWorld)
return;
notifyFanTile(worldIn, pos); notifyFanTile(worldIn, pos);
if (worldIn.isRemote) if (worldIn.isRemote)
return; return;

View file

@ -4,6 +4,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.utility.AllShapes; import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.foundation.utility.WrappedWorld;
import net.minecraft.block.AbstractFurnaceBlock; import net.minecraft.block.AbstractFurnaceBlock;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -53,6 +54,8 @@ public class FurnaceEngineBlock extends EngineBlock implements ITE<FurnaceEngine
public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) { boolean isMoving) {
super.neighborChanged(state, worldIn, pos, blockIn, fromPos, isMoving); super.neighborChanged(state, worldIn, pos, blockIn, fromPos, isMoving);
if (worldIn instanceof WrappedWorld)
return;
if (worldIn.isRemote) if (worldIn.isRemote)
return; return;

View file

@ -170,7 +170,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC
public void read(CompoundNBT compound) { public void read(CompoundNBT compound) {
inventory.deserializeNBT(compound.getCompound("Inventory")); inventory.deserializeNBT(compound.getCompound("Inventory"));
if (compound.contains("Running")) if (compound.contains("CurrentPos"))
currentPos = NBTUtil.readBlockPos(compound.getCompound("CurrentPos")); currentPos = NBTUtil.readBlockPos(compound.getCompound("CurrentPos"));
readClientUpdate(compound); readClientUpdate(compound);
@ -249,6 +249,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC
if (state == State.RUNNING) { if (state == State.RUNNING) {
compound.putBoolean("Running", true); compound.putBoolean("Running", true);
if (currentPos != null)
compound.put("CurrentPos", NBTUtil.writeBlockPos(currentPos)); compound.put("CurrentPos", NBTUtil.writeBlockPos(currentPos));
} }