Merge pull request #321 from Snownee/fix-contraptions
More fixes to contraptions
This commit is contained in:
commit
2ab24eb69e
3 changed files with 21 additions and 9 deletions
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -519,16 +520,20 @@ public abstract class Contraption {
|
||||||
glueToRemove.forEach(SuperGlueEntity::remove);
|
glueToRemove.forEach(SuperGlueEntity::remove);
|
||||||
|
|
||||||
for (boolean brittles : Iterate.trueAndFalse) {
|
for (boolean brittles : Iterate.trueAndFalse) {
|
||||||
for (BlockInfo block : blocks.values()) {
|
for (Iterator<BlockInfo> iterator = blocks.values().iterator(); iterator.hasNext();) {
|
||||||
|
BlockInfo block = iterator.next();
|
||||||
if (brittles != BlockMovementTraits.isBrittle(block.state))
|
if (brittles != BlockMovementTraits.isBrittle(block.state))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BlockPos add = block.pos.add(anchor).add(offset);
|
BlockPos add = block.pos.add(anchor).add(offset);
|
||||||
if (customRemoval.test(add, block.state))
|
if (customRemoval.test(add, block.state))
|
||||||
continue;
|
continue;
|
||||||
|
Block blockIn = world.getBlockState(add).getBlock();
|
||||||
|
if (block.state.getBlock() != blockIn)
|
||||||
|
iterator.remove();
|
||||||
world.getWorld().removeTileEntity(add);
|
world.getWorld().removeTileEntity(add);
|
||||||
int flags = 67;
|
int flags = 67;
|
||||||
if (world.getBlockState(add).getBlock() instanceof DoorBlock)
|
if (blockIn instanceof DoorBlock)
|
||||||
flags = flags | 32 | 16;
|
flags = flags | 32 | 16;
|
||||||
world.setBlockState(add, Blocks.AIR.getDefaultState(), flags);
|
world.setBlockState(add, Blocks.AIR.getDefaultState(), flags);
|
||||||
}
|
}
|
||||||
|
@ -565,11 +570,15 @@ public abstract class Contraption {
|
||||||
state = state.with(SawBlock.RUNNING, false);
|
state = state.with(SawBlock.RUNNING, false);
|
||||||
|
|
||||||
BlockState blockState = world.getBlockState(targetPos);
|
BlockState blockState = world.getBlockState(targetPos);
|
||||||
if (blockState.getBlockHardness(world, targetPos) == -1)
|
if (blockState.getBlockHardness(world, targetPos) == -1
|
||||||
continue;
|
|| (state.getCollisionShape(world, targetPos).isEmpty()
|
||||||
if (state.getCollisionShape(world, targetPos).isEmpty()
|
&& !blockState.getCollisionShape(world, targetPos).isEmpty())) {
|
||||||
&& !blockState.getCollisionShape(world, targetPos).isEmpty())
|
if (targetPos.getY() == 0)
|
||||||
|
targetPos = targetPos.up();
|
||||||
|
world.playEvent(2001, targetPos, Block.getStateId(state));
|
||||||
|
Block.spawnDrops(state, world, targetPos, null);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
world.destroyBlock(targetPos, true);
|
world.destroyBlock(targetPos, true);
|
||||||
world.setBlockState(targetPos, state, 3 | BlockFlags.IS_MOVING);
|
world.setBlockState(targetPos, state, 3 | BlockFlags.IS_MOVING);
|
||||||
|
|
|
@ -13,6 +13,7 @@ import com.simibubi.create.modules.schematics.ISpecialEntityItemRequirement;
|
||||||
import com.simibubi.create.modules.schematics.ItemRequirement;
|
import com.simibubi.create.modules.schematics.ItemRequirement;
|
||||||
import com.simibubi.create.modules.schematics.ItemRequirement.ItemUseType;
|
import com.simibubi.create.modules.schematics.ItemRequirement.ItemUseType;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
@ -164,11 +165,13 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isValidFace(World world, BlockPos pos, Direction direction) {
|
public static boolean isValidFace(World world, BlockPos pos, Direction direction) {
|
||||||
|
BlockState state = world.getBlockState(pos);
|
||||||
|
if (BlockMovementTraits.isBlockAttachedTowards(state, direction))
|
||||||
|
return true;
|
||||||
if (!BlockMovementTraits.movementNecessary(world, pos))
|
if (!BlockMovementTraits.movementNecessary(world, pos))
|
||||||
return false;
|
return false;
|
||||||
if (BlockMovementTraits.notSupportive(world.getBlockState(pos), direction)) {
|
if (BlockMovementTraits.notSupportive(state, direction))
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class SuperGlueRenderer extends EntityRenderer<SuperGlueEntity> {
|
||||||
return false;
|
return false;
|
||||||
BlockPos pos = entity.hangingPosition;
|
BlockPos pos = entity.hangingPosition;
|
||||||
BlockPos pos2 = pos.offset(entity.getFacingDirection().getOpposite());
|
BlockPos pos2 = pos.offset(entity.getFacingDirection().getOpposite());
|
||||||
return !SuperGlueEntity.isValidFace(entity.world, pos2, entity.getFacingDirection()) || !SuperGlueEntity.isValidFace(entity.world, pos, entity.getFacingDirection().getOpposite());
|
return SuperGlueEntity.isValidFace(entity.world, pos2, entity.getFacingDirection()) != SuperGlueEntity.isValidFace(entity.world, pos, entity.getFacingDirection().getOpposite());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initQuads() {
|
private void initQuads() {
|
||||||
|
|
Loading…
Reference in a new issue