mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 23:47:38 +01:00
commit
360fd38d5d
6 changed files with 69 additions and 8 deletions
|
@ -435,6 +435,15 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
public void remove(boolean keepData) {
|
||||||
|
if (!world.isRemote && !removed && contraption != null) {
|
||||||
|
contraption.stop(world);
|
||||||
|
}
|
||||||
|
super.remove(keepData);
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract StructureTransform makeStructureTransform();
|
protected abstract StructureTransform makeStructureTransform();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -743,7 +743,6 @@ public abstract class Contraption {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addBlocksToWorld(World world, StructureTransform transform) {
|
public void addBlocksToWorld(World world, StructureTransform transform) {
|
||||||
stop(world);
|
|
||||||
for (boolean nonBrittles : Iterate.trueAndFalse) {
|
for (boolean nonBrittles : Iterate.trueAndFalse) {
|
||||||
for (BlockInfo block : blocks.values()) {
|
for (BlockInfo block : blocks.values()) {
|
||||||
if (nonBrittles == BlockMovementTraits.isBrittle(block.state))
|
if (nonBrittles == BlockMovementTraits.isBrittle(block.state))
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.simibubi.create.content.contraptions.components.structureMovement;
|
package com.simibubi.create.content.contraptions.components.structureMovement;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ public abstract class TranslatingContraption extends Contraption {
|
||||||
|
|
||||||
public Set<BlockPos> getColliders(World world, Direction movementDirection) {
|
public Set<BlockPos> getColliders(World world, Direction movementDirection) {
|
||||||
if (getBlocks() == null)
|
if (getBlocks() == null)
|
||||||
return null;
|
return Collections.EMPTY_SET;
|
||||||
if (cachedColliders == null || cachedColliderDirection != movementDirection) {
|
if (cachedColliders == null || cachedColliderDirection != movementDirection) {
|
||||||
cachedColliders = new HashSet<>();
|
cachedColliders = new HashSet<>();
|
||||||
cachedColliderDirection = movementDirection;
|
cachedColliderDirection = movementDirection;
|
||||||
|
|
|
@ -78,8 +78,10 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity impleme
|
||||||
else
|
else
|
||||||
sendData();
|
sendData();
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
if (getSpeed() != 0)
|
||||||
|
assemble();
|
||||||
}
|
}
|
||||||
assemble();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,9 +53,14 @@ public class PistonContraption extends TranslatingContraption {
|
||||||
public boolean assemble(World world, BlockPos pos) {
|
public boolean assemble(World world, BlockPos pos) {
|
||||||
if (!collectExtensions(world, pos, orientation))
|
if (!collectExtensions(world, pos, orientation))
|
||||||
return false;
|
return false;
|
||||||
|
int count = blocks.size();
|
||||||
if (!searchMovedStructure(world, anchor, retract ? orientation.getOpposite() : orientation))
|
if (!searchMovedStructure(world, anchor, retract ? orientation.getOpposite() : orientation))
|
||||||
return false;
|
return false;
|
||||||
bounds = bounds.union(pistonExtensionCollisionBox);
|
if (blocks.size() == count) { // no new blocks added
|
||||||
|
bounds = pistonExtensionCollisionBox;
|
||||||
|
} else {
|
||||||
|
bounds = bounds.union(pistonExtensionCollisionBox);
|
||||||
|
}
|
||||||
startMoving(world);
|
startMoving(world);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -112,8 +117,10 @@ public class PistonContraption extends TranslatingContraption {
|
||||||
anchor = pos.offset(direction, initialExtensionProgress + 1);
|
anchor = pos.offset(direction, initialExtensionProgress + 1);
|
||||||
extensionLength = extensionsInBack + extensionsInFront;
|
extensionLength = extensionsInBack + extensionsInFront;
|
||||||
initialExtensionProgress = extensionsInFront;
|
initialExtensionProgress = extensionsInFront;
|
||||||
pistonExtensionCollisionBox = new AxisAlignedBB(end.offset(direction, -extensionsInFront)
|
pistonExtensionCollisionBox = new AxisAlignedBB(
|
||||||
.subtract(anchor));
|
BlockPos.ZERO.offset(direction, -1),
|
||||||
|
BlockPos.ZERO.offset(direction, -extensionLength - 1)).expand(1,
|
||||||
|
1, 1);
|
||||||
|
|
||||||
if (extensionLength == 0)
|
if (extensionLength == 0)
|
||||||
return false;
|
return false;
|
||||||
|
@ -124,7 +131,7 @@ public class PistonContraption extends TranslatingContraption {
|
||||||
BlockPos relPos = pole.pos.offset(direction, -extensionsInFront);
|
BlockPos relPos = pole.pos.offset(direction, -extensionsInFront);
|
||||||
BlockPos localPos = relPos.subtract(anchor);
|
BlockPos localPos = relPos.subtract(anchor);
|
||||||
getBlocks().put(localPos, new BlockInfo(localPos, pole.state, null));
|
getBlocks().put(localPos, new BlockInfo(localPos, pole.state, null));
|
||||||
pistonExtensionCollisionBox = pistonExtensionCollisionBox.union(new AxisAlignedBB(localPos));
|
//pistonExtensionCollisionBox = pistonExtensionCollisionBox.union(new AxisAlignedBB(localPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -19,10 +19,16 @@ import com.simibubi.create.foundation.utility.Couple;
|
||||||
import com.simibubi.create.foundation.utility.Iterate;
|
import com.simibubi.create.foundation.utility.Iterate;
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.PoweredRailBlock;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
|
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
|
||||||
|
import net.minecraft.entity.item.minecart.MinecartEntity;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.nbt.NBTUtil;
|
import net.minecraft.nbt.NBTUtil;
|
||||||
|
import net.minecraft.tags.BlockTags;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.Constants.NBT;
|
import net.minecraftforge.common.util.Constants.NBT;
|
||||||
|
@ -78,8 +84,45 @@ public class MinecartController implements INBTSerializable<CompoundNBT> {
|
||||||
internalStall.booleanValue() || otherCart == null || !otherCart.isPresent() || otherCart.isStalled(false));
|
internalStall.booleanValue() || otherCart == null || !otherCart.isPresent() || otherCart.isStalled(false));
|
||||||
|
|
||||||
}));
|
}));
|
||||||
if (!world.isRemote)
|
if (!world.isRemote) {
|
||||||
setStalled(internalStall.booleanValue(), true);
|
setStalled(internalStall.booleanValue(), true);
|
||||||
|
disassemble(cart);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void disassemble(AbstractMinecartEntity cart) {
|
||||||
|
if (cart instanceof MinecartEntity) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<Entity> passengers = cart.getPassengers();
|
||||||
|
if (passengers.isEmpty() || !(passengers.get(0) instanceof AbstractContraptionEntity)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
World world = cart.world;
|
||||||
|
int i = MathHelper.floor(cart.getX());
|
||||||
|
int j = MathHelper.floor(cart.getY());
|
||||||
|
int k = MathHelper.floor(cart.getZ());
|
||||||
|
if (world.getBlockState(new BlockPos(i, j - 1, k))
|
||||||
|
.isIn(BlockTags.RAILS)) {
|
||||||
|
--j;
|
||||||
|
}
|
||||||
|
BlockPos blockpos = new BlockPos(i, j, k);
|
||||||
|
BlockState blockstate = world.getBlockState(blockpos);
|
||||||
|
if (cart.canUseRail() && blockstate.isIn(BlockTags.RAILS)
|
||||||
|
&& blockstate.getBlock() instanceof PoweredRailBlock
|
||||||
|
&& ((PoweredRailBlock) blockstate.getBlock())
|
||||||
|
.isActivatorRail()) {
|
||||||
|
if (cart.isBeingRidden()) {
|
||||||
|
cart.removePassengers();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cart.getRollingAmplitude() == 0) {
|
||||||
|
cart.setRollingDirection(-cart.getRollingDirection());
|
||||||
|
cart.setRollingAmplitude(10);
|
||||||
|
cart.setDamage(50.0F);
|
||||||
|
cart.velocityChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFullyCoupled() {
|
public boolean isFullyCoupled() {
|
||||||
|
|
Loading…
Reference in a new issue