mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-15 15:03:59 +01:00
ForgeCraft Playtesting, Part II
- Fixed server dist crash in entity belt movement - Fixed client crash when saving a schematic without giving it a name
This commit is contained in:
parent
69cbfff8ed
commit
db2b8dd197
@ -72,8 +72,8 @@ public class BeltMovementHandler {
|
|||||||
TileEntity tileEntityBelowPassenger = world.getTileEntity(entityIn.getBlockPos());
|
TileEntity tileEntityBelowPassenger = world.getTileEntity(entityIn.getBlockPos());
|
||||||
BlockState blockState = info.lastCollidedState;
|
BlockState blockState = info.lastCollidedState;
|
||||||
Direction movementFacing =
|
Direction movementFacing =
|
||||||
Direction.getFacingFromAxisDirection(blockState.get(BlockStateProperties.HORIZONTAL_FACING).getAxis(),
|
Direction.getFacingFromAxisDirection(blockState.get(BlockStateProperties.HORIZONTAL_FACING)
|
||||||
beltTe.getSpeed() < 0 ? POSITIVE : NEGATIVE);
|
.getAxis(), beltTe.getSpeed() < 0 ? POSITIVE : NEGATIVE);
|
||||||
|
|
||||||
boolean collidedWithBelt = te instanceof BeltTileEntity;
|
boolean collidedWithBelt = te instanceof BeltTileEntity;
|
||||||
boolean betweenBelts = tileEntityBelowPassenger instanceof BeltTileEntity && tileEntityBelowPassenger != te;
|
boolean betweenBelts = tileEntityBelowPassenger instanceof BeltTileEntity && tileEntityBelowPassenger != te;
|
||||||
@ -84,7 +84,8 @@ public class BeltMovementHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Too slow
|
// Too slow
|
||||||
boolean notHorizontal = beltTe.getBlockState().get(BeltBlock.SLOPE) != BeltSlope.HORIZONTAL;
|
boolean notHorizontal = beltTe.getBlockState()
|
||||||
|
.get(BeltBlock.SLOPE) != BeltSlope.HORIZONTAL;
|
||||||
if (Math.abs(beltTe.getSpeed()) < 1)
|
if (Math.abs(beltTe.getSpeed()) < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -104,11 +105,14 @@ public class BeltMovementHandler {
|
|||||||
float movementSpeed = beltTe.getBeltMovementSpeed();
|
float movementSpeed = beltTe.getBeltMovementSpeed();
|
||||||
final Direction movementDirection = Direction.getFacingFromAxis(axis == Axis.X ? NEGATIVE : POSITIVE, axis);
|
final Direction movementDirection = Direction.getFacingFromAxis(axis == Axis.X ? NEGATIVE : POSITIVE, axis);
|
||||||
|
|
||||||
Vector3i centeringDirection =
|
Vector3i centeringDirection = Direction.getFacingFromAxis(POSITIVE, beltFacing.rotateY()
|
||||||
Direction.getFacingFromAxis(POSITIVE, beltFacing.rotateY().getAxis()).getDirectionVec();
|
.getAxis())
|
||||||
Vector3d movement = Vector3d.of(movementDirection.getDirectionVec()).scale(movementSpeed);
|
.getDirectionVec();
|
||||||
|
Vector3d movement = Vector3d.of(movementDirection.getDirectionVec())
|
||||||
|
.scale(movementSpeed);
|
||||||
|
|
||||||
double diffCenter = axis == Axis.Z ? (pos.getX() + .5f - entityIn.getX()) : (pos.getZ() + .5f - entityIn.getZ());
|
double diffCenter =
|
||||||
|
axis == Axis.Z ? (pos.getX() + .5f - entityIn.getX()) : (pos.getZ() + .5f - entityIn.getZ());
|
||||||
if (Math.abs(diffCenter) > 48 / 64f)
|
if (Math.abs(diffCenter) > 48 / 64f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -116,7 +120,8 @@ public class BeltMovementHandler {
|
|||||||
float top = 13 / 16f;
|
float top = 13 / 16f;
|
||||||
boolean onSlope = notHorizontal && (part == BeltPart.MIDDLE || part == BeltPart.PULLEY
|
boolean onSlope = notHorizontal && (part == BeltPart.MIDDLE || part == BeltPart.PULLEY
|
||||||
|| part == (slope == BeltSlope.UPWARD ? BeltPart.END : BeltPart.START) && entityIn.getY() - pos.getY() < top
|
|| part == (slope == BeltSlope.UPWARD ? BeltPart.END : BeltPart.START) && entityIn.getY() - pos.getY() < top
|
||||||
|| part == (slope == BeltSlope.UPWARD ? BeltPart.START : BeltPart.END) && entityIn.getY() - pos.getY() > top);
|
|| part == (slope == BeltSlope.UPWARD ? BeltPart.START : BeltPart.END)
|
||||||
|
&& entityIn.getY() - pos.getY() > top);
|
||||||
|
|
||||||
boolean movingDown = onSlope && slope == (movementFacing == beltFacing ? BeltSlope.DOWNWARD : BeltSlope.UPWARD);
|
boolean movingDown = onSlope && slope == (movementFacing == beltFacing ? BeltSlope.DOWNWARD : BeltSlope.UPWARD);
|
||||||
boolean movingUp = onSlope && slope == (movementFacing == beltFacing ? BeltSlope.UPWARD : BeltSlope.DOWNWARD);
|
boolean movingUp = onSlope && slope == (movementFacing == beltFacing ? BeltSlope.UPWARD : BeltSlope.DOWNWARD);
|
||||||
@ -132,7 +137,8 @@ public class BeltMovementHandler {
|
|||||||
if (movingDown)
|
if (movingDown)
|
||||||
movement = movement.add(0, -Math.abs(axis.getCoordinate(movement.x, movement.y, movement.z)), 0);
|
movement = movement.add(0, -Math.abs(axis.getCoordinate(movement.x, movement.y, movement.z)), 0);
|
||||||
|
|
||||||
Vector3d centering = Vector3d.of(centeringDirection).scale(diffCenter * Math.min(Math.abs(movementSpeed), .1f) * 4);
|
Vector3d centering = Vector3d.of(centeringDirection)
|
||||||
|
.scale(diffCenter * Math.min(Math.abs(movementSpeed), .1f) * 4);
|
||||||
movement = movement.add(centering);
|
movement = movement.add(centering);
|
||||||
|
|
||||||
float step = entityIn.stepHeight;
|
float step = entityIn.stepHeight;
|
||||||
@ -141,11 +147,12 @@ public class BeltMovementHandler {
|
|||||||
|
|
||||||
// Entity Collisions
|
// Entity Collisions
|
||||||
if (Math.abs(movementSpeed) < .5f) {
|
if (Math.abs(movementSpeed) < .5f) {
|
||||||
Vector3d checkDistance = movement.normalize().scale(0.5);
|
Vector3d checkDistance = movement.normalize()
|
||||||
|
.scale(0.5);
|
||||||
AxisAlignedBB bb = entityIn.getBoundingBox();
|
AxisAlignedBB bb = entityIn.getBoundingBox();
|
||||||
AxisAlignedBB checkBB = new AxisAlignedBB(bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ);
|
AxisAlignedBB checkBB = new AxisAlignedBB(bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ);
|
||||||
checkBB = checkBB.offset(checkDistance).grow(-Math.abs(checkDistance.x), -Math.abs(checkDistance.y),
|
checkBB = checkBB.offset(checkDistance)
|
||||||
-Math.abs(checkDistance.z));
|
.grow(-Math.abs(checkDistance.x), -Math.abs(checkDistance.y), -Math.abs(checkDistance.z));
|
||||||
List<Entity> list = world.getEntitiesWithinAABBExcludingEntity(entityIn, checkBB);
|
List<Entity> list = world.getEntitiesWithinAABBExcludingEntity(entityIn, checkBB);
|
||||||
list.removeIf(e -> shouldIgnoreBlocking(entityIn, e));
|
list.removeIf(e -> shouldIgnoreBlocking(entityIn, e));
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
@ -173,7 +180,8 @@ public class BeltMovementHandler {
|
|||||||
entityIn.stepHeight = step;
|
entityIn.stepHeight = step;
|
||||||
|
|
||||||
boolean movedPastEndingSlope = onSlope && (AllBlocks.BELT.has(world.getBlockState(entityIn.getBlockPos()))
|
boolean movedPastEndingSlope = onSlope && (AllBlocks.BELT.has(world.getBlockState(entityIn.getBlockPos()))
|
||||||
|| AllBlocks.BELT.has(world.getBlockState(entityIn.getBlockPos().down())));
|
|| AllBlocks.BELT.has(world.getBlockState(entityIn.getBlockPos()
|
||||||
|
.down())));
|
||||||
|
|
||||||
if (movedPastEndingSlope && !movingDown && Math.abs(movementSpeed) > 0)
|
if (movedPastEndingSlope && !movingDown && Math.abs(movementSpeed) > 0)
|
||||||
entityIn.setPosition(entityIn.getX(), entityIn.getY() + movement.y, entityIn.getZ());
|
entityIn.setPosition(entityIn.getX(), entityIn.getY() + movement.y, entityIn.getZ());
|
||||||
@ -188,7 +196,17 @@ public class BeltMovementHandler {
|
|||||||
return true;
|
return true;
|
||||||
if (other instanceof HangingEntity)
|
if (other instanceof HangingEntity)
|
||||||
return true;
|
return true;
|
||||||
return me.isRidingOrBeingRiddenBy(other);
|
return isRidingOrBeingRiddenBy(me, other);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isRidingOrBeingRiddenBy(Entity me, Entity other) {
|
||||||
|
for (Entity entity : me.getPassengers()) {
|
||||||
|
if (entity.equals(other))
|
||||||
|
return true;
|
||||||
|
if (isRidingOrBeingRiddenBy(entity, other))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,7 @@ public class SchematicAndQuillHandler {
|
|||||||
t.takeBlocksFromWorld(Minecraft.getInstance().world, origin, bounds, true, Blocks.AIR);
|
t.takeBlocksFromWorld(Minecraft.getInstance().world, origin, bounds, true, Blocks.AIR);
|
||||||
|
|
||||||
if (string.isEmpty())
|
if (string.isEmpty())
|
||||||
string = Lang.translate("schematicAndQuill.fallbackName").getUnformattedComponentText();
|
string = Lang.translate("schematicAndQuill.fallbackName").getString();
|
||||||
|
|
||||||
String folderPath = "schematics";
|
String folderPath = "schematics";
|
||||||
FilesHelper.createFolderIfMissing(folderPath);
|
FilesHelper.createFolderIfMissing(folderPath);
|
||||||
|
@ -71,7 +71,7 @@ public class Label extends AbstractSimiWidget {
|
|||||||
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
|
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
|
||||||
if (!visible)
|
if (!visible)
|
||||||
return;
|
return;
|
||||||
if (text == null || text.toString().isEmpty())
|
if (text == null || text.getString().isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RenderSystem.color4f(1, 1, 1, 1);
|
RenderSystem.color4f(1, 1, 1, 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user