Merge pull request #906 from Snownee/mc1.15/dev

Bug fixes
This commit is contained in:
simibubi 2021-02-06 16:23:35 +01:00 committed by GitHub
commit 85110f3ce8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 72 additions and 33 deletions

View File

@ -183,7 +183,6 @@ public class DeployerTileEntity extends KineticTileEntity {
if (state == State.EXPANDING) { if (state == State.EXPANDING) {
if (boop) if (boop)
triggerBoop(); triggerBoop();
else
activate(); activate();
state = State.RETRACTING; state = State.RETRACTING;

View File

@ -82,7 +82,7 @@ public class AirCurrent {
protected void tickAffectedEntities(World world, Direction facing) { protected void tickAffectedEntities(World world, Direction facing) {
for (Iterator<Entity> iterator = caughtEntities.iterator(); iterator.hasNext();) { for (Iterator<Entity> iterator = caughtEntities.iterator(); iterator.hasNext();) {
Entity entity = iterator.next(); Entity entity = iterator.next();
if (!entity.getBoundingBox() if (!entity.isAlive() || !entity.getBoundingBox()
.intersects(bounds)) { .intersects(bounds)) {
iterator.remove(); iterator.remove();
continue; continue;

View File

@ -153,6 +153,8 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity {
for (ItemEntity itemEntity : world.getEntitiesWithinAABB(ItemEntity.class, for (ItemEntity itemEntity : world.getEntitiesWithinAABB(ItemEntity.class,
new AxisAlignedBB(pos.down()).shrink(.125f))) { new AxisAlignedBB(pos.down()).shrink(.125f))) {
if (!itemEntity.isAlive() || !itemEntity.onGround)
continue;
ItemStack stack = itemEntity.getItem(); ItemStack stack = itemEntity.getItem();
Optional<PressingRecipe> recipe = getRecipe(stack); Optional<PressingRecipe> recipe = getRecipe(stack);
if (!recipe.isPresent()) if (!recipe.isPresent())
@ -233,7 +235,7 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity {
for (Entity entity : world.getEntitiesWithinAABBExcludingEntity(null, bb)) { for (Entity entity : world.getEntitiesWithinAABBExcludingEntity(null, bb)) {
if (!(entity instanceof ItemEntity)) if (!(entity instanceof ItemEntity))
continue; continue;
if (!entity.isAlive()) if (!entity.isAlive() || !entity.onGround)
continue; continue;
ItemEntity itemEntity = (ItemEntity) entity; ItemEntity itemEntity = (ItemEntity) entity;
pressedItems.add(itemEntity.getItem()); pressedItems.add(itemEntity.getItem());

View File

@ -227,6 +227,12 @@ public class BlockMovementTraits {
if (state.getBlock() instanceof SailBlock) if (state.getBlock() instanceof SailBlock)
return facing.getAxis() == state.get(SailBlock.FACING) return facing.getAxis() == state.get(SailBlock.FACING)
.getAxis(); .getAxis();
if (AllBlocks.PISTON_EXTENSION_POLE.has(state))
return facing.getAxis() != state.get(BlockStateProperties.FACING)
.getAxis();
if (AllBlocks.MECHANICAL_PISTON_HEAD.has(state))
return facing.getAxis() != state.get(BlockStateProperties.FACING)
.getAxis();
return isBrittle(state); return isBrittle(state);
} }

View File

@ -63,6 +63,7 @@ import net.minecraft.block.ChestBlock;
import net.minecraft.block.DoorBlock; import net.minecraft.block.DoorBlock;
import net.minecraft.block.IWaterLoggable; import net.minecraft.block.IWaterLoggable;
import net.minecraft.block.PressurePlateBlock; import net.minecraft.block.PressurePlateBlock;
import net.minecraft.block.material.PushReaction;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.fluid.Fluids; import net.minecraft.fluid.Fluids;
import net.minecraft.fluid.IFluidState; import net.minecraft.fluid.IFluidState;
@ -139,7 +140,7 @@ public abstract class Contraption {
public abstract boolean assemble(World world, BlockPos pos); public abstract boolean assemble(World world, BlockPos pos);
protected abstract boolean canAxisBeStabilized(Axis axis); public abstract boolean canBeStabilized(Direction facing, BlockPos localPos);
protected abstract ContraptionType getType(); protected abstract ContraptionType getType();
@ -245,7 +246,7 @@ public abstract class Contraption {
fluidStorage.forEach((pos, mfs) -> mfs.tick(entity, pos, world.isRemote)); fluidStorage.forEach((pos, mfs) -> mfs.tick(entity, pos, world.isRemote));
} }
protected boolean moveBlock(World world, BlockPos pos, Direction forcedDirection, List<BlockPos> frontier, protected boolean moveBlock(World world, BlockPos pos, @Nullable Direction forcedDirection, List<BlockPos> frontier,
Set<BlockPos> visited) { Set<BlockPos> visited) {
visited.add(pos); visited.add(pos);
frontier.remove(pos); frontier.remove(pos);
@ -311,14 +312,13 @@ public abstract class Contraption {
Map<Direction, SuperGlueEntity> superglue = SuperGlueHandler.gatherGlue(world, pos); Map<Direction, SuperGlueEntity> superglue = SuperGlueHandler.gatherGlue(world, pos);
// Slime blocks and super glue drag adjacent blocks if possible // Slime blocks and super glue drag adjacent blocks if possible
boolean isStickyBlock = state.isStickyBlock();
for (Direction offset : Iterate.directions) { for (Direction offset : Iterate.directions) {
BlockPos offsetPos = pos.offset(offset); BlockPos offsetPos = pos.offset(offset);
BlockState blockState = world.getBlockState(offsetPos); BlockState blockState = world.getBlockState(offsetPos);
if (isAnchoringBlockAt(offsetPos)) if (isAnchoringBlockAt(offsetPos))
continue; continue;
if (!movementAllowed(world, offsetPos)) { if (!movementAllowed(world, offsetPos)) {
if (offset == forcedDirection && isStickyBlock) if (offset == forcedDirection)
return false; return false;
continue; continue;
} }
@ -328,8 +328,20 @@ public abstract class Contraption {
boolean blockAttachedTowardsFace = boolean blockAttachedTowardsFace =
BlockMovementTraits.isBlockAttachedTowards(world, offsetPos, blockState, offset.getOpposite()); BlockMovementTraits.isBlockAttachedTowards(world, offsetPos, blockState, offset.getOpposite());
boolean brittle = BlockMovementTraits.isBrittle(blockState); boolean brittle = BlockMovementTraits.isBrittle(blockState);
boolean canStick = !brittle && state.canStickTo(blockState) && blockState.canStickTo(state);
if (canStick) {
if (state.getPushReaction() == PushReaction.PUSH_ONLY || blockState.getPushReaction() == PushReaction.PUSH_ONLY) {
canStick = false;
}
if (BlockMovementTraits.notSupportive(state, offset)) {
canStick = false;
}
if (BlockMovementTraits.notSupportive(blockState, offset.getOpposite())) {
canStick = false;
}
}
if (!wasVisited && ((isStickyBlock && !brittle) || blockAttachedTowardsFace || faceHasGlue)) if (!wasVisited && (canStick || blockAttachedTowardsFace || faceHasGlue || (offset == forcedDirection && !BlockMovementTraits.notSupportive(state, forcedDirection))))
frontier.add(offsetPos); frontier.add(offsetPos);
if (faceHasGlue) if (faceHasGlue)
addGlue(superglue.get(offset)); addGlue(superglue.get(offset));
@ -418,7 +430,7 @@ public abstract class Contraption {
private void moveBearing(BlockPos pos, List<BlockPos> frontier, Set<BlockPos> visited, BlockState state) { private void moveBearing(BlockPos pos, List<BlockPos> frontier, Set<BlockPos> visited, BlockState state) {
Direction facing = state.get(MechanicalBearingBlock.FACING); Direction facing = state.get(MechanicalBearingBlock.FACING);
if (!canAxisBeStabilized(facing.getAxis())) { if (!canBeStabilized(facing, pos.subtract(anchor))) {
BlockPos offset = pos.offset(facing); BlockPos offset = pos.offset(facing);
if (!visited.contains(offset)) if (!visited.contains(offset))
frontier.add(offset); frontier.add(offset);

View File

@ -5,7 +5,6 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.gen.feature.template.Template.BlockInfo; import net.minecraft.world.gen.feature.template.Template.BlockInfo;
@ -48,7 +47,7 @@ public abstract class TranslatingContraption extends Contraption {
} }
@Override @Override
protected boolean canAxisBeStabilized(Axis axis) { public boolean canBeStabilized(Direction facing, BlockPos localPos) {
return false; return false;
} }

View File

@ -9,7 +9,6 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Con
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.gen.feature.template.Template.BlockInfo; import net.minecraft.world.gen.feature.template.Template.BlockInfo;
@ -84,8 +83,10 @@ public class BearingContraption extends Contraption {
} }
@Override @Override
protected boolean canAxisBeStabilized(Axis axis) { public boolean canBeStabilized(Direction facing, BlockPos localPos) {
return axis == facing.getAxis(); if (facing.getOpposite() == this.facing && BlockPos.ZERO.equals(localPos))
return false;
return facing.getAxis() == this.facing.getAxis();
} }
} }

View File

@ -12,7 +12,6 @@ import com.simibubi.create.foundation.utility.NBTHelper;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -110,15 +109,17 @@ public class ClockworkContraption extends Contraption {
@Override @Override
public void readNBT(World world, CompoundNBT tag, boolean spawnData) { public void readNBT(World world, CompoundNBT tag, boolean spawnData) {
facing = Direction.byIndex(tag.getInt("Facing")); facing = Direction.byIndex(tag.getInt("facing"));
handType = NBTHelper.readEnum(tag, "HandType", HandType.class); handType = NBTHelper.readEnum(tag, "HandType", HandType.class);
offset = tag.getInt("offset"); offset = tag.getInt("offset");
super.readNBT(world, tag, spawnData); super.readNBT(world, tag, spawnData);
} }
@Override @Override
protected boolean canAxisBeStabilized(Axis axis) { public boolean canBeStabilized(Direction facing, BlockPos localPos) {
return axis == facing.getAxis(); if (BlockPos.ZERO.equals(localPos) || BlockPos.ZERO.equals(localPos.offset(facing)))
return false;
return facing.getAxis() == this.facing.getAxis();
} }
public static enum HandType { public static enum HandType {

View File

@ -45,7 +45,7 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour {
AbstractContraptionEntity entity = context.contraption.entity; AbstractContraptionEntity entity = context.contraption.entity;
if (entity instanceof ControlledContraptionEntity) { if (entity instanceof ControlledContraptionEntity) {
ControlledContraptionEntity controlledCE = (ControlledContraptionEntity) entity; ControlledContraptionEntity controlledCE = (ControlledContraptionEntity) entity;
if (controlledCE.getRotationAxis() == axis) if (context.contraption.canBeStabilized(facing, context.localPos))
offset = -controlledCE.getAngle(renderPartialTicks); offset = -controlledCE.getAngle(renderPartialTicks);
} else if (entity instanceof OrientedContraptionEntity) { } else if (entity instanceof OrientedContraptionEntity) {

View File

@ -55,7 +55,7 @@ public class StabilizedContraption extends Contraption {
} }
@Override @Override
protected boolean canAxisBeStabilized(Axis axis) { public boolean canBeStabilized(Direction facing, BlockPos localPos) {
return false; return false;
} }

View File

@ -149,7 +149,7 @@ public class MountedContraption extends Contraption {
} }
@Override @Override
protected boolean canAxisBeStabilized(Axis axis) { public boolean canBeStabilized(Direction facing, BlockPos localPos) {
return true; return true;
} }

View File

@ -8,6 +8,7 @@ import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.CarpetBlock; import net.minecraft.block.CarpetBlock;
import net.minecraft.block.material.PushReaction;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.state.properties.PistonType; import net.minecraft.state.properties.PistonType;
@ -164,6 +165,8 @@ public class PistonContraption extends TranslatingContraption {
return true; return true;
if (!BlockMovementTraits.movementAllowed(world, currentPos)) if (!BlockMovementTraits.movementAllowed(world, currentPos))
return retracting; return retracting;
if (retracting && state.getPushReaction() == PushReaction.PUSH_ONLY)
return true;
frontier.add(currentPos); frontier.add(currentPos);
if (BlockMovementTraits.notSupportive(state, orientation)) if (BlockMovementTraits.notSupportive(state, orientation))
return true; return true;

View File

@ -48,6 +48,17 @@ public class PulleyTileEntity extends LinearActuatorTileEntity {
return; return;
if (speed == 0) if (speed == 0)
return; return;
int maxLength = AllConfigs.SERVER.kinetics.maxRopeLength.get();
int i = 1;
while (i <= maxLength) {
BlockPos ropePos = pos.down(i);
BlockState ropeState = world.getBlockState(ropePos);
if (!AllBlocks.ROPE.has(ropeState) && !AllBlocks.PULLEY_MAGNET.has(ropeState)) {
break;
}
++i;
}
offset = i - 1;
if (offset >= getExtensionRange() && getSpeed() > 0) if (offset >= getExtensionRange() && getSpeed() > 0)
return; return;
if (offset <= 0 && getSpeed() < 0) if (offset <= 0 && getSpeed() < 0)
@ -70,7 +81,7 @@ public class PulleyTileEntity extends LinearActuatorTileEntity {
if (!canAssembleStructure && getSpeed() > 0) if (!canAssembleStructure && getSpeed() > 0)
return; return;
for (int i = ((int) offset); i > 0; i--) { for (i = ((int) offset); i > 0; i--) {
BlockPos offset = pos.down(i); BlockPos offset = pos.down(i);
BlockState oldState = world.getBlockState(offset); BlockState oldState = world.getBlockState(offset);
if (oldState.getBlock() instanceof IWaterLoggable && oldState.has(BlockStateProperties.WATERLOGGED) if (oldState.getBlock() instanceof IWaterLoggable && oldState.has(BlockStateProperties.WATERLOGGED)

View File

@ -14,7 +14,6 @@ import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.material.Material;
import net.minecraft.block.material.MaterialColor; import net.minecraft.block.material.MaterialColor;
import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.BlockItemUseContext;
import net.minecraft.particles.RedstoneParticleData; import net.minecraft.particles.RedstoneParticleData;
@ -114,6 +113,7 @@ public class GaugeBlock extends DirectionalAxisKineticBlock {
return context.getFace(); return context.getFace();
} }
@Override
protected boolean getAxisAlignmentForPlacement(BlockItemUseContext context) { protected boolean getAxisAlignmentForPlacement(BlockItemUseContext context) {
return context.getPlacementHorizontalFacing().getAxis() != Axis.X; return context.getPlacementHorizontalFacing().getAxis() != Axis.X;
} }
@ -127,8 +127,7 @@ public class GaugeBlock extends DirectionalAxisKineticBlock {
return false; return false;
if (getRotationAxis(state) == Axis.Y && face != state.get(FACING)) if (getRotationAxis(state) == Axis.Y && face != state.get(FACING))
return false; return false;
BlockState blockState = world.getBlockState(pos.offset(face)); if (!Block.shouldSideBeRendered(state, world, pos, face)
if (Block.hasSolidSide(blockState, world, pos, face.getOpposite()) && blockState.getMaterial() != Material.GLASS
&& !(world instanceof WrappedWorld)) && !(world instanceof WrappedWorld))
return false; return false;
return true; return true;

View File

@ -223,6 +223,8 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
AxisAlignedBB searchArea = AxisAlignedBB searchArea =
new AxisAlignedBB(center.add(0, -bottomPullDistance - 0.5, 0), center.add(0, -0.5, 0)).grow(.45f); new AxisAlignedBB(center.add(0, -bottomPullDistance - 0.5, 0), center.add(0, -0.5, 0)).grow(.45f);
for (ItemEntity itemEntity : world.getEntitiesWithinAABB(ItemEntity.class, searchArea)) { for (ItemEntity itemEntity : world.getEntitiesWithinAABB(ItemEntity.class, searchArea)) {
if (!itemEntity.isAlive())
continue;
ItemStack entityItem = itemEntity.getItem(); ItemStack entityItem = itemEntity.getItem();
if (!canAcceptItem(entityItem)) if (!canAcceptItem(entityItem))
continue; continue;

View File

@ -48,6 +48,9 @@ public class ArmInteractionPointHandler {
World world = event.getWorld(); World world = event.getWorld();
if (!world.isRemote) if (!world.isRemote)
return; return;
PlayerEntity player = event.getPlayer();
if (player != null && player.isSpectator())
return;
ArmInteractionPoint selected = getSelected(pos); ArmInteractionPoint selected = getSelected(pos);
@ -60,7 +63,6 @@ public class ArmInteractionPointHandler {
} }
selected.cycleMode(); selected.cycleMode();
PlayerEntity player = event.getPlayer();
if (player != null) { if (player != null) {
String key = selected.mode == Mode.DEPOSIT ? "mechanical_arm.deposit_to" : "mechanical_arm.extract_from"; String key = selected.mode == Mode.DEPOSIT ? "mechanical_arm.deposit_to" : "mechanical_arm.extract_from";
TextFormatting colour = selected.mode == Mode.DEPOSIT ? TextFormatting.GOLD : TextFormatting.AQUA; TextFormatting colour = selected.mode == Mode.DEPOSIT ? TextFormatting.GOLD : TextFormatting.AQUA;

View File

@ -1,6 +1,7 @@
package com.simibubi.create.events; package com.simibubi.create.events;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.AllFluids; import com.simibubi.create.AllFluids;
import com.simibubi.create.Create; import com.simibubi.create.Create;
import com.simibubi.create.CreateClient; import com.simibubi.create.CreateClient;
@ -124,6 +125,7 @@ public class ClientEvents {
CreateClient.outliner.renderOutlines(ms, buffer); CreateClient.outliner.renderOutlines(ms, buffer);
// CollisionDebugger.render(ms, buffer); // CollisionDebugger.render(ms, buffer);
buffer.draw(); buffer.draw();
RenderSystem.enableCull();
ms.pop(); ms.pop();
} }

View File

@ -37,7 +37,7 @@ public class EdgeInteractionHandler {
Hand hand = event.getHand(); Hand hand = event.getHand();
ItemStack heldItem = player.getHeldItem(hand); ItemStack heldItem = player.getHeldItem(hand);
if (player.isSneaking()) if (player.isSneaking() || player.isSpectator())
return; return;
EdgeInteractionBehaviour behaviour = TileEntityBehaviour.get(world, pos, EdgeInteractionBehaviour.TYPE); EdgeInteractionBehaviour behaviour = TileEntityBehaviour.get(world, pos, EdgeInteractionBehaviour.TYPE);
if (behaviour == null) if (behaviour == null)

View File

@ -43,7 +43,7 @@ public class FilteringHandler {
PlayerEntity player = event.getPlayer(); PlayerEntity player = event.getPlayer();
Hand hand = event.getHand(); Hand hand = event.getHand();
if (player.isSneaking()) if (player.isSneaking() || player.isSpectator())
return; return;
FilteringBehaviour behaviour = TileEntityBehaviour.get(world, pos, FilteringBehaviour.TYPE); FilteringBehaviour behaviour = TileEntityBehaviour.get(world, pos, FilteringBehaviour.TYPE);
@ -75,12 +75,12 @@ public class FilteringHandler {
if (event.getSide() != LogicalSide.CLIENT) { if (event.getSide() != LogicalSide.CLIENT) {
if (!player.isCreative()) { if (!player.isCreative()) {
if (behaviour.getFilter()
.getItem() instanceof FilterItem)
player.inventory.placeItemBackInInventory(world, behaviour.getFilter());
if (toApply.getItem() instanceof FilterItem) if (toApply.getItem() instanceof FilterItem)
player.getHeldItem(hand) player.getHeldItem(hand)
.shrink(1); .shrink(1);
if (behaviour.getFilter()
.getItem() instanceof FilterItem)
player.inventory.placeItemBackInInventory(world, behaviour.getFilter());
} }
if (toApply.getItem() instanceof FilterItem) if (toApply.getItem() instanceof FilterItem)
toApply.setCount(1); toApply.setCount(1);

View File

@ -28,7 +28,7 @@ public class LinkHandler {
PlayerEntity player = event.getPlayer(); PlayerEntity player = event.getPlayer();
Hand hand = event.getHand(); Hand hand = event.getHand();
if (player.isSneaking()) if (player.isSneaking() || player.isSpectator())
return; return;
LinkBehaviour behaviour = TileEntityBehaviour.get(world, pos, LinkBehaviour.TYPE); LinkBehaviour behaviour = TileEntityBehaviour.get(world, pos, LinkBehaviour.TYPE);