mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-11 12:32:05 +01:00
Port recent changes to 1.16
This commit is contained in:
parent
f8fd6dbb66
commit
d3f03a57a9
6 changed files with 74 additions and 74 deletions
|
@ -20,10 +20,10 @@ import net.minecraft.block.material.PushReaction;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.IProjectile;
|
|
||||||
import net.minecraft.entity.item.HangingEntity;
|
import net.minecraft.entity.item.HangingEntity;
|
||||||
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
|
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.network.IPacket;
|
import net.minecraft.network.IPacket;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
@ -35,7 +35,7 @@ import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
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;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
@ -90,7 +90,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void removePassenger(Entity passenger) {
|
protected void removePassenger(Entity passenger) {
|
||||||
Vec3d transformedVector = getPassengerPosition(passenger, 1);
|
Vector3d transformedVector = getPassengerPosition(passenger, 1);
|
||||||
super.removePassenger(passenger);
|
super.removePassenger(passenger);
|
||||||
if (world.isRemote)
|
if (world.isRemote)
|
||||||
return;
|
return;
|
||||||
|
@ -107,13 +107,13 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
public void updatePassengerPosition(Entity passenger, IMoveCallback callback) {
|
public void updatePassengerPosition(Entity passenger, IMoveCallback callback) {
|
||||||
if (!isPassenger(passenger))
|
if (!isPassenger(passenger))
|
||||||
return;
|
return;
|
||||||
Vec3d transformedVector = getPassengerPosition(passenger, 1);
|
Vector3d transformedVector = getPassengerPosition(passenger, 1);
|
||||||
if (transformedVector == null)
|
if (transformedVector == null)
|
||||||
return;
|
return;
|
||||||
callback.accept(passenger, transformedVector.x, transformedVector.y, transformedVector.z);
|
callback.accept(passenger, transformedVector.x, transformedVector.y, transformedVector.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Vec3d getPassengerPosition(Entity passenger, float partialTicks) {
|
protected Vector3d getPassengerPosition(Entity passenger, float partialTicks) {
|
||||||
UUID id = passenger.getUniqueID();
|
UUID id = passenger.getUniqueID();
|
||||||
if (passenger instanceof OrientedContraptionEntity) {
|
if (passenger instanceof OrientedContraptionEntity) {
|
||||||
BlockPos localPos = contraption.getBearingPosOf(id);
|
BlockPos localPos = contraption.getBearingPosOf(id);
|
||||||
|
@ -128,8 +128,8 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
BlockPos seat = contraption.getSeatOf(id);
|
BlockPos seat = contraption.getSeatOf(id);
|
||||||
if (seat == null)
|
if (seat == null)
|
||||||
return null;
|
return null;
|
||||||
Vec3d transformedVector =
|
Vector3d transformedVector =
|
||||||
toGlobalVector(new Vec3d(seat).add(.5, passenger.getYOffset() + ySize - .15f, .5), partialTicks)
|
toGlobalVector(Vector3d.of(seat).add(.5, passenger.getYOffset() + ySize - .15f, .5), partialTicks)
|
||||||
.add(VecHelper.getCenterOf(BlockPos.ZERO))
|
.add(VecHelper.getCenterOf(BlockPos.ZERO))
|
||||||
.subtract(0.5, ySize, 0.5);
|
.subtract(0.5, ySize, 0.5);
|
||||||
return transformedVector;
|
return transformedVector;
|
||||||
|
@ -168,7 +168,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toDismount != null && !world.isRemote) {
|
if (toDismount != null && !world.isRemote) {
|
||||||
Vec3d transformedVector = getPassengerPosition(toDismount, 1);
|
Vector3d transformedVector = getPassengerPosition(toDismount, 1);
|
||||||
toDismount.stopRiding();
|
toDismount.stopRiding();
|
||||||
if (transformedVector != null)
|
if (transformedVector != null)
|
||||||
toDismount.setPositionAndUpdate(transformedVector.x, transformedVector.y, transformedVector.z);
|
toDismount.setPositionAndUpdate(transformedVector.x, transformedVector.y, transformedVector.z);
|
||||||
|
@ -180,8 +180,8 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3d toGlobalVector(Vec3d localVec, float partialTicks) {
|
public Vector3d toGlobalVector(Vector3d localVec, float partialTicks) {
|
||||||
Vec3d rotationOffset = VecHelper.getCenterOf(BlockPos.ZERO);
|
Vector3d rotationOffset = VecHelper.getCenterOf(BlockPos.ZERO);
|
||||||
localVec = localVec.subtract(rotationOffset);
|
localVec = localVec.subtract(rotationOffset);
|
||||||
localVec = applyRotation(localVec, partialTicks);
|
localVec = applyRotation(localVec, partialTicks);
|
||||||
localVec = localVec.add(rotationOffset)
|
localVec = localVec.add(rotationOffset)
|
||||||
|
@ -189,8 +189,8 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
return localVec;
|
return localVec;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3d toLocalVector(Vec3d globalVec, float partialTicks) {
|
public Vector3d toLocalVector(Vector3d globalVec, float partialTicks) {
|
||||||
Vec3d rotationOffset = VecHelper.getCenterOf(BlockPos.ZERO);
|
Vector3d rotationOffset = VecHelper.getCenterOf(BlockPos.ZERO);
|
||||||
globalVec = globalVec.subtract(getAnchorVec())
|
globalVec = globalVec.subtract(getAnchorVec())
|
||||||
.subtract(rotationOffset);
|
.subtract(rotationOffset);
|
||||||
globalVec = reverseRotation(globalVec, partialTicks);
|
globalVec = reverseRotation(globalVec, partialTicks);
|
||||||
|
@ -218,9 +218,9 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
|
|
||||||
protected abstract void tickContraption();
|
protected abstract void tickContraption();
|
||||||
|
|
||||||
public abstract Vec3d applyRotation(Vec3d localPos, float partialTicks);
|
public abstract Vector3d applyRotation(Vector3d localPos, float partialTicks);
|
||||||
|
|
||||||
public abstract Vec3d reverseRotation(Vec3d localPos, float partialTicks);
|
public abstract Vector3d reverseRotation(Vector3d localPos, float partialTicks);
|
||||||
|
|
||||||
public void tickActors() {
|
public void tickActors() {
|
||||||
boolean stalledPreviously = contraption.stalled;
|
boolean stalledPreviously = contraption.stalled;
|
||||||
|
@ -233,7 +233,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
BlockInfo blockInfo = pair.left;
|
BlockInfo blockInfo = pair.left;
|
||||||
MovementBehaviour actor = AllMovementBehaviours.of(blockInfo.state);
|
MovementBehaviour actor = AllMovementBehaviours.of(blockInfo.state);
|
||||||
|
|
||||||
Vec3d actorPosition = toGlobalVector(VecHelper.getCenterOf(blockInfo.pos)
|
Vector3d actorPosition = toGlobalVector(VecHelper.getCenterOf(blockInfo.pos)
|
||||||
.add(actor.getActiveAreaOffset(context)), 1);
|
.add(actor.getActiveAreaOffset(context)), 1);
|
||||||
BlockPos gridPosition = new BlockPos(actorPosition);
|
BlockPos gridPosition = new BlockPos(actorPosition);
|
||||||
boolean newPosVisited =
|
boolean newPosVisited =
|
||||||
|
@ -242,7 +242,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
context.rotation = v -> applyRotation(v, 1);
|
context.rotation = v -> applyRotation(v, 1);
|
||||||
context.position = actorPosition;
|
context.position = actorPosition;
|
||||||
|
|
||||||
Vec3d oldMotion = context.motion;
|
Vector3d oldMotion = context.motion;
|
||||||
if (!actor.isActive(context))
|
if (!actor.isActive(context))
|
||||||
continue;
|
continue;
|
||||||
if (newPosVisited && !context.stall) {
|
if (newPosVisited && !context.stall) {
|
||||||
|
@ -283,13 +283,13 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean shouldActorTrigger(MovementContext context, BlockInfo blockInfo, MovementBehaviour actor,
|
protected boolean shouldActorTrigger(MovementContext context, BlockInfo blockInfo, MovementBehaviour actor,
|
||||||
Vec3d actorPosition, BlockPos gridPosition) {
|
Vector3d actorPosition, BlockPos gridPosition) {
|
||||||
Vec3d previousPosition = context.position;
|
Vector3d previousPosition = context.position;
|
||||||
if (previousPosition == null)
|
if (previousPosition == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
context.motion = actorPosition.subtract(previousPosition);
|
context.motion = actorPosition.subtract(previousPosition);
|
||||||
Vec3d relativeMotion = context.motion;
|
Vector3d relativeMotion = context.motion;
|
||||||
relativeMotion = reverseRotation(relativeMotion, 1);
|
relativeMotion = reverseRotation(relativeMotion, 1);
|
||||||
context.relativeMotion = relativeMotion;
|
context.relativeMotion = relativeMotion;
|
||||||
return !new BlockPos(previousPosition).equals(gridPosition)
|
return !new BlockPos(previousPosition).equals(gridPosition)
|
||||||
|
@ -300,7 +300,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
setPosition(getX() + x, getY() + y, getZ() + z);
|
setPosition(getX() + x, getY() + y, getZ() + z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3d getAnchorVec() {
|
public Vector3d getAnchorVec() {
|
||||||
return getPositionVec();
|
return getPositionVec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,15 +316,15 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
AxisAlignedBB cbox = contraption.bounds;
|
AxisAlignedBB cbox = contraption.bounds;
|
||||||
if (cbox == null)
|
if (cbox == null)
|
||||||
return;
|
return;
|
||||||
Vec3d actualVec = getAnchorVec();
|
Vector3d actualVec = getAnchorVec();
|
||||||
setBoundingBox(cbox.offset(actualVec));
|
setBoundingBox(cbox.offset(actualVec));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float yawFromVector(Vec3d vec) {
|
public static float yawFromVector(Vector3d vec) {
|
||||||
return (float) ((3 * Math.PI / 2 + Math.atan2(vec.z, vec.x)) / Math.PI * 180);
|
return (float) ((3 * Math.PI / 2 + Math.atan2(vec.z, vec.x)) / Math.PI * 180);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float pitchFromVector(Vec3d vec) {
|
public static float pitchFromVector(Vector3d vec) {
|
||||||
return (float) ((Math.acos(vec.y)) / Math.PI * 180);
|
return (float) ((Math.acos(vec.y)) / Math.PI * 180);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,11 +398,11 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
removePassengers();
|
removePassengers();
|
||||||
|
|
||||||
for (Entity entity : collidingEntities) {
|
for (Entity entity : collidingEntities) {
|
||||||
Vec3d positionVec = getPositionVec();
|
Vector3d positionVec = getPositionVec();
|
||||||
Vec3d localVec = entity.getPositionVec()
|
Vector3d localVec = entity.getPositionVec()
|
||||||
.subtract(positionVec);
|
.subtract(positionVec);
|
||||||
localVec = reverseRotation(localVec, 1);
|
localVec = reverseRotation(localVec, 1);
|
||||||
Vec3d transformed = transform.apply(localVec);
|
Vector3d transformed = transform.apply(localVec);
|
||||||
entity.setPositionAndUpdate(transformed.x, transformed.y, transformed.z);
|
entity.setPositionAndUpdate(transformed.x, transformed.y, transformed.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -456,7 +456,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public CompoundNBT writeWithoutTypeId(CompoundNBT nbt) {
|
public CompoundNBT writeWithoutTypeId(CompoundNBT nbt) {
|
||||||
Vec3d vec = getPositionVec();
|
Vector3d vec = getPositionVec();
|
||||||
List<Entity> passengers = getPassengers();
|
List<Entity> passengers = getPassengers();
|
||||||
|
|
||||||
for (Entity entity : passengers) {
|
for (Entity entity : passengers) {
|
||||||
|
@ -464,7 +464,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
entity.removed = true;
|
entity.removed = true;
|
||||||
|
|
||||||
// Gather passengers into same chunk when saving
|
// Gather passengers into same chunk when saving
|
||||||
Vec3d prevVec = entity.getPositionVec();
|
Vector3d prevVec = entity.getPositionVec();
|
||||||
entity.setPos(vec.x, prevVec.y, vec.z);
|
entity.setPos(vec.x, prevVec.y, vec.z);
|
||||||
|
|
||||||
// Super requires all passengers to not be removed in order to write them to the
|
// Super requires all passengers to not be removed in order to write them to the
|
||||||
|
@ -478,14 +478,14 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
// Make sure nothing can move contraptions out of the way
|
// Make sure nothing can move contraptions out of the way
|
||||||
public void setMotion(Vec3d motionIn) {}
|
public void setMotion(Vector3d motionIn) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PushReaction getPushReaction() {
|
public PushReaction getPushReaction() {
|
||||||
return PushReaction.IGNORE;
|
return PushReaction.IGNORE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setContraptionMotion(Vec3d vec) {
|
public void setContraptionMotion(Vector3d vec) {
|
||||||
super.setMotion(vec);
|
super.setMotion(vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,16 +499,16 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3d getPrevPositionVec() {
|
public Vector3d getPrevPositionVec() {
|
||||||
return prevPosInvalid ? getPositionVec() : new Vec3d(prevPosX, prevPosY, prevPosZ);
|
return prevPosInvalid ? getPositionVec() : new Vector3d(prevPosX, prevPosY, prevPosZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract ContraptionRotationState getRotationState();
|
public abstract ContraptionRotationState getRotationState();
|
||||||
|
|
||||||
public Vec3d getContactPointMotion(Vec3d globalContactPoint) {
|
public Vector3d getContactPointMotion(Vector3d globalContactPoint) {
|
||||||
if (prevPosInvalid)
|
if (prevPosInvalid)
|
||||||
return Vec3d.ZERO;
|
return Vector3d.ZERO;
|
||||||
Vec3d contactPoint = toGlobalVector(toLocalVector(globalContactPoint, 0), 1);
|
Vector3d contactPoint = toGlobalVector(toLocalVector(globalContactPoint, 0), 1);
|
||||||
return contactPoint.subtract(globalContactPoint)
|
return contactPoint.subtract(globalContactPoint)
|
||||||
.add(getPositionVec().subtract(getPrevPositionVec()));
|
.add(getPositionVec().subtract(getPrevPositionVec()));
|
||||||
}
|
}
|
||||||
|
@ -526,7 +526,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
return false;
|
return false;
|
||||||
if (e instanceof SeatEntity)
|
if (e instanceof SeatEntity)
|
||||||
return false;
|
return false;
|
||||||
if (e instanceof IProjectile)
|
if (e instanceof ProjectileEntity)
|
||||||
return false;
|
return false;
|
||||||
if (e.getRidingEntity() != null)
|
if (e.getRidingEntity() != null)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
import net.minecraft.client.renderer.culling.ClippingHelperImpl;
|
import net.minecraft.client.renderer.culling.ClippingHelper;
|
||||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||||
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
@ -24,7 +24,7 @@ public abstract class AbstractContraptionEntityRenderer<C extends AbstractContra
|
||||||
protected abstract void transform(C contraptionEntity, float partialTicks, MatrixStack[] matrixStacks);
|
protected abstract void transform(C contraptionEntity, float partialTicks, MatrixStack[] matrixStacks);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldRender(C entity, ClippingHelperImpl p_225626_2_, double p_225626_3_, double p_225626_5_,
|
public boolean shouldRender(C entity, ClippingHelper p_225626_2_, double p_225626_3_, double p_225626_5_,
|
||||||
double p_225626_7_) {
|
double p_225626_7_) {
|
||||||
if (!super.shouldRender(entity, p_225626_2_, p_225626_3_, p_225626_5_, p_225626_7_))
|
if (!super.shouldRender(entity, p_225626_2_, p_225626_3_, p_225626_5_, p_225626_7_))
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -549,7 +549,7 @@ public abstract class Contraption {
|
||||||
|
|
||||||
stabilizedSubContraptions.clear();
|
stabilizedSubContraptions.clear();
|
||||||
NBTHelper.iterateCompoundList(nbt.getList("SubContraptions", NBT.TAG_COMPOUND), c -> stabilizedSubContraptions
|
NBTHelper.iterateCompoundList(nbt.getList("SubContraptions", NBT.TAG_COMPOUND), c -> stabilizedSubContraptions
|
||||||
.put(NBTUtil.readUniqueId(c.getCompound("Id")), BlockFace.fromNBT(c.getCompound("Location"))));
|
.put(c.getUniqueId("Id"), BlockFace.fromNBT(c.getCompound("Location"))));
|
||||||
|
|
||||||
storage.clear();
|
storage.clear();
|
||||||
NBTHelper.iterateCompoundList(nbt.getList("Storage", NBT.TAG_COMPOUND), c -> storage
|
NBTHelper.iterateCompoundList(nbt.getList("Storage", NBT.TAG_COMPOUND), c -> storage
|
||||||
|
|
|
@ -14,7 +14,7 @@ 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.Direction.Axis;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
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;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
@ -90,13 +90,13 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vec3d applyRotation(Vec3d localPos, float partialTicks) {
|
public Vector3d applyRotation(Vector3d localPos, float partialTicks) {
|
||||||
localPos = VecHelper.rotate(localPos, getAngle(partialTicks), rotationAxis);
|
localPos = VecHelper.rotate(localPos, getAngle(partialTicks), rotationAxis);
|
||||||
return localPos;
|
return localPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vec3d reverseRotation(Vec3d localPos, float partialTicks) {
|
public Vector3d reverseRotation(Vector3d localPos, float partialTicks) {
|
||||||
localPos = VecHelper.rotate(localPos, -getAngle(partialTicks), rotationAxis);
|
localPos = VecHelper.rotate(localPos, -getAngle(partialTicks), rotationAxis);
|
||||||
return localPos;
|
return localPos;
|
||||||
}
|
}
|
||||||
|
@ -143,9 +143,9 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
|
||||||
setPosition(getX(), getY(), getZ());
|
setPosition(getX(), getY(), getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3d motion = getMotion();
|
Vector3d motion = getMotion();
|
||||||
if (motion.length() < 1 / 4098f)
|
if (motion.length() < 1 / 4098f)
|
||||||
setMotion(Vec3d.ZERO);
|
setMotion(Vector3d.ZERO);
|
||||||
move(motion.x, motion.y, motion.z);
|
move(motion.x, motion.y, motion.z);
|
||||||
if (ContraptionCollider.collideBlocks(this))
|
if (ContraptionCollider.collideBlocks(this))
|
||||||
getController().collided();
|
getController().collided();
|
||||||
|
@ -153,7 +153,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean shouldActorTrigger(MovementContext context, BlockInfo blockInfo, MovementBehaviour actor,
|
protected boolean shouldActorTrigger(MovementContext context, BlockInfo blockInfo, MovementBehaviour actor,
|
||||||
Vec3d actorPosition, BlockPos gridPosition) {
|
Vector3d actorPosition, BlockPos gridPosition) {
|
||||||
if (super.shouldActorTrigger(context, blockInfo, actor, actorPosition, gridPosition))
|
if (super.shouldActorTrigger(context, blockInfo, actor, actorPosition, gridPosition))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -162,13 +162,13 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity {
|
||||||
return false;
|
return false;
|
||||||
BearingContraption bc = (BearingContraption) contraption;
|
BearingContraption bc = (BearingContraption) contraption;
|
||||||
Direction facing = bc.getFacing();
|
Direction facing = bc.getFacing();
|
||||||
Vec3d activeAreaOffset = actor.getActiveAreaOffset(context);
|
Vector3d activeAreaOffset = actor.getActiveAreaOffset(context);
|
||||||
if (!activeAreaOffset.mul(VecHelper.axisAlingedPlaneOf(new Vec3d(facing.getDirectionVec())))
|
if (!activeAreaOffset.mul(VecHelper.axisAlingedPlaneOf(Vector3d.of(facing.getDirectionVec())))
|
||||||
.equals(Vec3d.ZERO))
|
.equals(Vector3d.ZERO))
|
||||||
return false;
|
return false;
|
||||||
if (!VecHelper.onSameAxis(blockInfo.pos, BlockPos.ZERO, facing.getAxis()))
|
if (!VecHelper.onSameAxis(blockInfo.pos, BlockPos.ZERO, facing.getAxis()))
|
||||||
return false;
|
return false;
|
||||||
context.motion = new Vec3d(facing.getDirectionVec()).scale(angle - prevAngle);
|
context.motion = Vector3d.of(facing.getDirectionVec()).scale(angle - prevAngle);
|
||||||
context.relativeMotion = context.motion;
|
context.relativeMotion = context.motion;
|
||||||
int timer = context.data.getInt("StationaryTimer");
|
int timer = context.data.getInt("StationaryTimer");
|
||||||
if (timer > 0) {
|
if (timer > 0) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Direction.Axis;
|
import net.minecraft.util.Direction.Axis;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
|
||||||
private static final DataParameter<Optional<Direction>> INITIAL_ORIENTATION =
|
private static final DataParameter<Optional<Direction>> INITIAL_ORIENTATION =
|
||||||
EntityDataManager.createKey(OrientedContraptionEntity.class, CreateDataSerializers.OPTIONAL_DIRECTION);
|
EntityDataManager.createKey(OrientedContraptionEntity.class, CreateDataSerializers.OPTIONAL_DIRECTION);
|
||||||
|
|
||||||
protected Vec3d motionBeforeStall;
|
protected Vector3d motionBeforeStall;
|
||||||
protected boolean forceAngle;
|
protected boolean forceAngle;
|
||||||
private boolean isSerializingFurnaceCart;
|
private boolean isSerializingFurnaceCart;
|
||||||
private boolean attachedExtraInventories;
|
private boolean attachedExtraInventories;
|
||||||
|
@ -75,7 +75,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
|
||||||
|
|
||||||
public OrientedContraptionEntity(EntityType<?> type, World world) {
|
public OrientedContraptionEntity(EntityType<?> type, World world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
motionBeforeStall = Vec3d.ZERO;
|
motionBeforeStall = Vector3d.ZERO;
|
||||||
attachedExtraInventories = false;
|
attachedExtraInventories = false;
|
||||||
isSerializingFurnaceCart = false;
|
isSerializingFurnaceCart = false;
|
||||||
initialYawOffset = -1;
|
initialYawOffset = -1;
|
||||||
|
@ -156,10 +156,10 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
|
||||||
|
|
||||||
ListNBT vecNBT = compound.getList("CachedMotion", 6);
|
ListNBT vecNBT = compound.getList("CachedMotion", 6);
|
||||||
if (!vecNBT.isEmpty()) {
|
if (!vecNBT.isEmpty()) {
|
||||||
motionBeforeStall = new Vec3d(vecNBT.getDouble(0), vecNBT.getDouble(1), vecNBT.getDouble(2));
|
motionBeforeStall = new Vector3d(vecNBT.getDouble(0), vecNBT.getDouble(1), vecNBT.getDouble(2));
|
||||||
if (!motionBeforeStall.equals(Vec3d.ZERO))
|
if (!motionBeforeStall.equals(Vector3d.ZERO))
|
||||||
targetYaw = prevYaw = yaw += yawFromVector(motionBeforeStall);
|
targetYaw = prevYaw = yaw += yawFromVector(motionBeforeStall);
|
||||||
setMotion(Vec3d.ZERO);
|
setMotion(Vector3d.ZERO);
|
||||||
}
|
}
|
||||||
|
|
||||||
yaw = compound.getFloat("Yaw");
|
yaw = compound.getFloat("Yaw");
|
||||||
|
@ -189,7 +189,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
|
||||||
compound.putFloat("Pitch", pitch);
|
compound.putFloat("Pitch", pitch);
|
||||||
|
|
||||||
if (getCouplingId() != null)
|
if (getCouplingId() != null)
|
||||||
compound.put("OnCoupling", NBTUtil.writeUniqueId(getCouplingId()));
|
compound.putUniqueId("OnCoupling", getCouplingId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -210,7 +210,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vec3d applyRotation(Vec3d localPos, float partialTicks) {
|
public Vector3d applyRotation(Vector3d localPos, float partialTicks) {
|
||||||
localPos = VecHelper.rotate(localPos, getInitialYaw(), Axis.Y);
|
localPos = VecHelper.rotate(localPos, getInitialYaw(), Axis.Y);
|
||||||
localPos = VecHelper.rotate(localPos, getPitch(partialTicks), Axis.Z);
|
localPos = VecHelper.rotate(localPos, getPitch(partialTicks), Axis.Z);
|
||||||
localPos = VecHelper.rotate(localPos, getYaw(partialTicks), Axis.Y);
|
localPos = VecHelper.rotate(localPos, getYaw(partialTicks), Axis.Y);
|
||||||
|
@ -218,7 +218,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vec3d reverseRotation(Vec3d localPos, float partialTicks) {
|
public Vector3d reverseRotation(Vector3d localPos, float partialTicks) {
|
||||||
localPos = VecHelper.rotate(localPos, -getYaw(partialTicks), Axis.Y);
|
localPos = VecHelper.rotate(localPos, -getYaw(partialTicks), Axis.Y);
|
||||||
localPos = VecHelper.rotate(localPos, -getPitch(partialTicks), Axis.Z);
|
localPos = VecHelper.rotate(localPos, -getPitch(partialTicks), Axis.Z);
|
||||||
localPos = VecHelper.rotate(localPos, -getInitialYaw(), Axis.Y);
|
localPos = VecHelper.rotate(localPos, -getInitialYaw(), Axis.Y);
|
||||||
|
@ -280,7 +280,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
|
||||||
}
|
}
|
||||||
if (wasStalled && !isStalled) {
|
if (wasStalled && !isStalled) {
|
||||||
riding.setMotion(motionBeforeStall);
|
riding.setMotion(motionBeforeStall);
|
||||||
motionBeforeStall = Vec3d.ZERO;
|
motionBeforeStall = Vector3d.ZERO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,10 +306,10 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
|
||||||
if (coupledCarts == null)
|
if (coupledCarts == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Vec3d positionVec = coupledCarts.getFirst()
|
Vector3d positionVec = coupledCarts.getFirst()
|
||||||
.cart()
|
.cart()
|
||||||
.getPositionVec();
|
.getPositionVec();
|
||||||
Vec3d coupledVec = coupledCarts.getSecond()
|
Vector3d coupledVec = coupledCarts.getSecond()
|
||||||
.cart()
|
.cart()
|
||||||
.getPositionVec();
|
.getPositionVec();
|
||||||
|
|
||||||
|
@ -347,11 +347,11 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
boolean rotating = false;
|
boolean rotating = false;
|
||||||
Vec3d movementVector = riding.getMotion();
|
Vector3d movementVector = riding.getMotion();
|
||||||
|
|
||||||
if (!(riding instanceof AbstractMinecartEntity))
|
if (!(riding instanceof AbstractMinecartEntity))
|
||||||
movementVector = getPositionVec().subtract(prevPosX, prevPosY, prevPosZ);
|
movementVector = getPositionVec().subtract(prevPosX, prevPosY, prevPosZ);
|
||||||
Vec3d motion = movementVector.normalize();
|
Vector3d motion = movementVector.normalize();
|
||||||
|
|
||||||
if (!dataManager.get(INITIAL_ORIENTATION)
|
if (!dataManager.get(INITIAL_ORIENTATION)
|
||||||
.isPresent() && !world.isRemote) {
|
.isPresent() && !world.isRemote) {
|
||||||
|
@ -470,8 +470,8 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vec3d getAnchorVec() {
|
public Vector3d getAnchorVec() {
|
||||||
return new Vec3d(getX() - .5, getY(), getZ() - .5);
|
return new Vector3d(getX() - .5, getY(), getZ() - .5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,12 +3,12 @@ package com.simibubi.create.content.contraptions.components.structureMovement;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.culling.ClippingHelperImpl;
|
import net.minecraft.client.renderer.culling.ClippingHelper;
|
||||||
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
||||||
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.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
|
|
||||||
public class OrientedContraptionEntityRenderer extends AbstractContraptionEntityRenderer<OrientedContraptionEntity> {
|
public class OrientedContraptionEntityRenderer extends AbstractContraptionEntityRenderer<OrientedContraptionEntity> {
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ public class OrientedContraptionEntityRenderer extends AbstractContraptionEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldRender(OrientedContraptionEntity entity, ClippingHelperImpl p_225626_2_, double p_225626_3_,
|
public boolean shouldRender(OrientedContraptionEntity entity, ClippingHelper p_225626_2_, double p_225626_3_,
|
||||||
double p_225626_5_, double p_225626_7_) {
|
double p_225626_5_, double p_225626_7_) {
|
||||||
if (!super.shouldRender(entity, p_225626_2_, p_225626_3_, p_225626_5_, p_225626_7_))
|
if (!super.shouldRender(entity, p_225626_2_, p_225626_3_, p_225626_5_, p_225626_7_))
|
||||||
return false;
|
return false;
|
||||||
|
@ -59,7 +59,7 @@ public class OrientedContraptionEntityRenderer extends AbstractContraptionEntity
|
||||||
private void repositionOnContraption(OrientedContraptionEntity entity, float partialTicks,
|
private void repositionOnContraption(OrientedContraptionEntity entity, float partialTicks,
|
||||||
MatrixStack[] matrixStacks, Entity ridingEntity) {
|
MatrixStack[] matrixStacks, Entity ridingEntity) {
|
||||||
AbstractContraptionEntity parent = (AbstractContraptionEntity) ridingEntity;
|
AbstractContraptionEntity parent = (AbstractContraptionEntity) ridingEntity;
|
||||||
Vec3d passengerPosition = parent.getPassengerPosition(entity, partialTicks);
|
Vector3d passengerPosition = parent.getPassengerPosition(entity, partialTicks);
|
||||||
double x = passengerPosition.x - MathHelper.lerp(partialTicks, entity.lastTickPosX, entity.getX());
|
double x = passengerPosition.x - MathHelper.lerp(partialTicks, entity.lastTickPosX, entity.getX());
|
||||||
double y = passengerPosition.y - MathHelper.lerp(partialTicks, entity.lastTickPosY, entity.getY());
|
double y = passengerPosition.y - MathHelper.lerp(partialTicks, entity.lastTickPosY, entity.getY());
|
||||||
double z = passengerPosition.z - MathHelper.lerp(partialTicks, entity.lastTickPosZ, entity.getZ());
|
double z = passengerPosition.z - MathHelper.lerp(partialTicks, entity.lastTickPosZ, entity.getZ());
|
||||||
|
@ -74,11 +74,11 @@ public class OrientedContraptionEntityRenderer extends AbstractContraptionEntity
|
||||||
double cartX = MathHelper.lerp(partialTicks, cart.lastTickPosX, cart.getX());
|
double cartX = MathHelper.lerp(partialTicks, cart.lastTickPosX, cart.getX());
|
||||||
double cartY = MathHelper.lerp(partialTicks, cart.lastTickPosY, cart.getY());
|
double cartY = MathHelper.lerp(partialTicks, cart.lastTickPosY, cart.getY());
|
||||||
double cartZ = MathHelper.lerp(partialTicks, cart.lastTickPosZ, cart.getZ());
|
double cartZ = MathHelper.lerp(partialTicks, cart.lastTickPosZ, cart.getZ());
|
||||||
Vec3d cartPos = cart.getPos(cartX, cartY, cartZ);
|
Vector3d cartPos = cart.getPos(cartX, cartY, cartZ);
|
||||||
|
|
||||||
if (cartPos != null) {
|
if (cartPos != null) {
|
||||||
Vec3d cartPosFront = cart.getPosOffset(cartX, cartY, cartZ, (double) 0.3F);
|
Vector3d cartPosFront = cart.getPosOffset(cartX, cartY, cartZ, (double) 0.3F);
|
||||||
Vec3d cartPosBack = cart.getPosOffset(cartX, cartY, cartZ, (double) -0.3F);
|
Vector3d cartPosBack = cart.getPosOffset(cartX, cartY, cartZ, (double) -0.3F);
|
||||||
if (cartPosFront == null)
|
if (cartPosFront == null)
|
||||||
cartPosFront = cartPos;
|
cartPosFront = cartPos;
|
||||||
if (cartPosBack == null)
|
if (cartPosBack == null)
|
||||||
|
|
Loading…
Reference in a new issue