mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 07:27:15 +01:00
Locally sourced arms
- Mechanical arms now serialize target positions in relative coordinates
This commit is contained in:
parent
64b2c61389
commit
fa6bac2bfc
4 changed files with 23 additions and 25 deletions
|
@ -83,6 +83,12 @@ public class ContraptionCollider {
|
|||
PlayerType playerType = getPlayerType(entity);
|
||||
if (playerType == PlayerType.REMOTE)
|
||||
continue;
|
||||
|
||||
if (playerType == PlayerType.SERVER && entity instanceof ServerPlayerEntity) {
|
||||
((ServerPlayerEntity) entity).connection.floatingTickCount = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (playerType == PlayerType.CLIENT)
|
||||
if (skipClientPlayer)
|
||||
continue;
|
||||
|
@ -193,7 +199,7 @@ public class ContraptionCollider {
|
|||
totalResponse = VecHelper.rotate(totalResponse, yawOffset, Axis.Y);
|
||||
rotationMatrix.transpose();
|
||||
|
||||
if (temporalCollision && playerType != PlayerType.SERVER) {
|
||||
if (temporalCollision) {
|
||||
double idealVerticalMotion = motionResponse.y;
|
||||
if (idealVerticalMotion != entityMotion.y) {
|
||||
entity.setMotion(entityMotion.mul(1, 0, 1)
|
||||
|
@ -223,11 +229,6 @@ public class ContraptionCollider {
|
|||
if (!hardCollision && surfaceCollision.isFalse())
|
||||
continue;
|
||||
|
||||
if (playerType == PlayerType.SERVER && entity instanceof ServerPlayerEntity) {
|
||||
((ServerPlayerEntity) entity).connection.floatingTickCount = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
Vec3d allowedMovement = getAllowedMovement(totalResponse, entity);
|
||||
entity.setPosition(entityPosition.x + allowedMovement.x, entityPosition.y + allowedMovement.y,
|
||||
entityPosition.z + allowedMovement.z);
|
||||
|
@ -242,12 +243,10 @@ public class ContraptionCollider {
|
|||
contraptionEntity.collidingEntities.put(entity, new MutableInt(0));
|
||||
if (entity instanceof ItemEntity)
|
||||
entityMotion = entityMotion.mul(.5f, 1, .5f);
|
||||
if (playerType != PlayerType.SERVER) {
|
||||
contactPointMotion = contraptionEntity.getContactPointMotion(entityPosition);
|
||||
allowedMovement = getAllowedMovement(contactPointMotion, entity);
|
||||
entity.setPosition(entityPosition.x + allowedMovement.x,
|
||||
entityPosition.y, entityPosition.z + allowedMovement.z);
|
||||
}
|
||||
contactPointMotion = contraptionEntity.getContactPointMotion(entityPosition);
|
||||
allowedMovement = getAllowedMovement(contactPointMotion, entity);
|
||||
entity.setPosition(entityPosition.x + allowedMovement.x, entityPosition.y,
|
||||
entityPosition.z + allowedMovement.z);
|
||||
}
|
||||
|
||||
entity.setMotion(entityMotion);
|
||||
|
@ -260,8 +259,7 @@ public class ContraptionCollider {
|
|||
float limbSwing = MathHelper.sqrt(d0 * d0 + d1 * d1) * 4.0F;
|
||||
if (limbSwing > 1.0F)
|
||||
limbSwing = 1.0F;
|
||||
AllPackets.channel
|
||||
.sendToServer(new ClientMotionPacket(entityMotion, true, limbSwing));
|
||||
AllPackets.channel.sendToServer(new ClientMotionPacket(entityMotion, true, limbSwing));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -177,16 +177,16 @@ public abstract class ArmInteractionPoint {
|
|||
return point;
|
||||
}
|
||||
|
||||
CompoundNBT serialize() {
|
||||
CompoundNBT serialize(BlockPos anchor) {
|
||||
CompoundNBT nbt = new CompoundNBT();
|
||||
nbt.put("Pos", NBTUtil.writeBlockPos(pos));
|
||||
nbt.put("Pos", NBTUtil.writeBlockPos(pos.subtract(anchor)));
|
||||
NBTHelper.writeEnum(nbt, "Mode", mode);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
static ArmInteractionPoint deserialize(IBlockReader world, CompoundNBT nbt) {
|
||||
static ArmInteractionPoint deserialize(IBlockReader world, BlockPos anchor, CompoundNBT nbt) {
|
||||
BlockPos pos = NBTUtil.readBlockPos(nbt.getCompound("Pos"));
|
||||
ArmInteractionPoint interactionPoint = createAt(world, pos);
|
||||
ArmInteractionPoint interactionPoint = createAt(world, pos.add(anchor));
|
||||
if (interactionPoint == null)
|
||||
return null;
|
||||
interactionPoint.mode = NBTHelper.readEnum(nbt, "Mode", Mode.class);
|
||||
|
|
|
@ -37,7 +37,7 @@ public class ArmPlacementPacket extends SimplePacketBase {
|
|||
CompoundNBT nbt = new CompoundNBT();
|
||||
ListNBT pointsNBT = new ListNBT();
|
||||
points.stream()
|
||||
.map(ArmInteractionPoint::serialize)
|
||||
.map(aip -> aip.serialize(pos))
|
||||
.forEach(pointsNBT::add);
|
||||
nbt.put("Points", pointsNBT);
|
||||
buffer.writeCompoundTag(nbt);
|
||||
|
|
|
@ -366,10 +366,10 @@ public class ArmTileEntity extends KineticTileEntity {
|
|||
return;
|
||||
inputs.clear();
|
||||
outputs.clear();
|
||||
|
||||
|
||||
boolean hasBlazeBurner = false;
|
||||
for (INBT inbt : interactionPointTag) {
|
||||
ArmInteractionPoint point = ArmInteractionPoint.deserialize(world, (CompoundNBT) inbt);
|
||||
ArmInteractionPoint point = ArmInteractionPoint.deserialize(world, pos, (CompoundNBT) inbt);
|
||||
if (point == null)
|
||||
continue;
|
||||
if (point.mode == Mode.DEPOSIT)
|
||||
|
@ -378,14 +378,14 @@ public class ArmTileEntity extends KineticTileEntity {
|
|||
inputs.add(point);
|
||||
hasBlazeBurner |= point instanceof ArmInteractionPoint.BlazeBurner;
|
||||
}
|
||||
|
||||
|
||||
if (!world.isRemote) {
|
||||
if (outputs.size() >= 10)
|
||||
AllTriggers.triggerForNearbyPlayers(AllTriggers.ARM_MANY_TARGETS, world, pos, 5);
|
||||
if (hasBlazeBurner)
|
||||
AllTriggers.triggerForNearbyPlayers(AllTriggers.ARM_BLAZE_BURNER, world, pos, 5);
|
||||
}
|
||||
|
||||
|
||||
updateInteractionPoints = false;
|
||||
sendData();
|
||||
markDirty();
|
||||
|
@ -401,10 +401,10 @@ public class ArmTileEntity extends KineticTileEntity {
|
|||
} else {
|
||||
ListNBT pointsNBT = new ListNBT();
|
||||
inputs.stream()
|
||||
.map(ArmInteractionPoint::serialize)
|
||||
.map(aip -> aip.serialize(pos))
|
||||
.forEach(pointsNBT::add);
|
||||
outputs.stream()
|
||||
.map(ArmInteractionPoint::serialize)
|
||||
.map(aip -> aip.serialize(pos))
|
||||
.forEach(pointsNBT::add);
|
||||
compound.put("InteractionPoints", pointsNBT);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue