From 8e4dcb958d94df15b4c396020cc7203f88d4b672 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Tue, 28 Dec 2021 13:04:22 +0100 Subject: [PATCH] Stonehedge - Fixed Harvesters hard-colliding with leaves when used with pistons, pulleys or a gantry carriage - Fixed kinetic tiles not marking chunks for saving when speed or stress changes - Dedicated Servers no longer create a resourcepack folder --- gradle.properties | 2 +- src/main/java/com/simibubi/create/Create.java | 4 +- .../com/simibubi/create/CreateClient.java | 3 + .../contraptions/base/KineticTileEntity.java | 3 + .../actors/HarvesterMovementBehaviour.java | 4 +- .../BlockMovementChecks.java | 6 ++ .../ContraptionCollider.java | 57 ++++++++++++------- src/main/resources/META-INF/mods.toml | 2 +- 8 files changed, 52 insertions(+), 29 deletions(-) diff --git a/gradle.properties b/gradle.properties index 784b6a0fe..738fb9ba8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ org.gradle.jvmargs = -Xmx3G org.gradle.daemon = false # mod version info -mod_version = 0.4a +mod_version = 0.4b minecraft_version = 1.18.1 forge_version = 39.0.8 diff --git a/src/main/java/com/simibubi/create/Create.java b/src/main/java/com/simibubi/create/Create.java index 5fcb90d8e..5a616dba1 100644 --- a/src/main/java/com/simibubi/create/Create.java +++ b/src/main/java/com/simibubi/create/Create.java @@ -58,7 +58,7 @@ public class Create { public static final String ID = "create"; public static final String NAME = "Create"; - public static final String VERSION = "0.4a"; + public static final String VERSION = "0.4b"; public static final Logger LOGGER = LogManager.getLogger(); @@ -125,8 +125,6 @@ public class Create { SchematicInstances.register(); BuiltinPotatoProjectileTypes.register(); - ShippedResourcePacks.extractFiles("Copper Legacy Pack"); - event.enqueueWork(() -> { AllTriggers.register(); SchematicProcessor.register(); diff --git a/src/main/java/com/simibubi/create/CreateClient.java b/src/main/java/com/simibubi/create/CreateClient.java index e0e0c7983..add42fd1f 100644 --- a/src/main/java/com/simibubi/create/CreateClient.java +++ b/src/main/java/com/simibubi/create/CreateClient.java @@ -25,6 +25,7 @@ import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.CreateContexts; import com.simibubi.create.foundation.render.SuperByteBufferCache; import com.simibubi.create.foundation.utility.ModelSwapper; +import com.simibubi.create.foundation.utility.ShippedResourcePacks; import com.simibubi.create.foundation.utility.ghost.GhostBlocks; import com.simibubi.create.foundation.utility.outliner.Outliner; @@ -81,6 +82,8 @@ public class CreateClient { BUFFER_CACHE.registerCompartment(SBBContraptionManager.CONTRAPTION, 20); BUFFER_CACHE.registerCompartment(WorldSectionElement.DOC_WORLD_SECTION, 20); + ShippedResourcePacks.extractFiles("Copper Legacy Pack"); + AllKeys.register(); // AllFluids.assignRenderLayers(); AllBlockPartials.init(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java index 5b78108e3..7fcf00893 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java @@ -151,6 +151,7 @@ public class KineticTileEntity extends SmartTileEntity this.stress = currentStress; this.networkSize = networkSize; boolean overStressed = maxStress < currentStress && StressImpact.isEnabled(); + setChanged(); if (overStressed != this.overStressed) { float prevSpeed = getSpeed(); @@ -181,6 +182,7 @@ public class KineticTileEntity extends SmartTileEntity boolean directionSwap = !fromOrToZero && Math.signum(previousSpeed) != Math.signum(getSpeed()); if (fromOrToZero || directionSwap) flickerTally = getFlickerScore() + 5; + setChanged(); } @Override @@ -324,6 +326,7 @@ public class KineticTileEntity extends SmartTileEntity getOrCreateNetwork().remove(this); network = networkIn; + setChanged(); if (networkIn == null) return; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java index f30b6f9c4..361d07b7a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java @@ -107,7 +107,7 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { world.setBlockAndUpdate(pos, cutCrop(world, pos, stateVisited)); } - private boolean isValidCrop(Level world, BlockPos pos, BlockState state) { + public boolean isValidCrop(Level world, BlockPos pos, BlockState state) { boolean harvestPartial = AllConfigs.SERVER.kinetics.harvestPartiallyGrown.get(); boolean replant = AllConfigs.SERVER.kinetics.harvesterReplants.get(); @@ -141,7 +141,7 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { return false; } - private boolean isValidOther(Level world, BlockPos pos, BlockState state) { + public boolean isValidOther(Level world, BlockPos pos, BlockState state) { if (state.getBlock() instanceof CropBlock) return false; if (state.getBlock() instanceof SugarCaneBlock) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementChecks.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementChecks.java index 53b24cac8..eee909ddb 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementChecks.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementChecks.java @@ -8,6 +8,7 @@ import com.simibubi.create.AllTags.AllBlockTags; import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.components.actors.AttachedActorBlock; import com.simibubi.create.content.contraptions.components.actors.HarvesterBlock; +import com.simibubi.create.content.contraptions.components.actors.PloughBlock; import com.simibubi.create.content.contraptions.components.actors.PortableStorageInterfaceBlock; import com.simibubi.create.content.contraptions.components.crank.HandCrankBlock; import com.simibubi.create.content.contraptions.components.fan.NozzleBlock; @@ -347,6 +348,11 @@ public class BlockMovementChecks { return state.getValue(BlockStateProperties.FACING) == facing; if (AllBlocks.MECHANICAL_BEARING.has(state)) return state.getValue(BlockStateProperties.FACING) == facing; + if (AllBlocks.MECHANICAL_HARVESTER.has(state)) + return state.getValue(HarvesterBlock.FACING) == facing; + if (AllBlocks.MECHANICAL_PLOUGH.has(state)) + return state.getValue(PloughBlock.FACING) == facing; + if (AllBlocks.CART_ASSEMBLER.has(state)) return Direction.DOWN == facing; if (AllBlocks.MECHANICAL_SAW.has(state)) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionCollider.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionCollider.java index 2d788c9a0..f0ed5828a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionCollider.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionCollider.java @@ -14,6 +14,7 @@ import com.google.common.base.Predicates; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllMovementBehaviours; import com.simibubi.create.content.contraptions.components.actors.BlockBreakingMovementBehaviour; +import com.simibubi.create.content.contraptions.components.actors.HarvesterMovementBehaviour; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity.ContraptionRotationState; import com.simibubi.create.content.contraptions.components.structureMovement.sync.ClientMotionPacket; import com.simibubi.create.foundation.collision.ContinuousOBBCollider.ContinuousSeparationManifold; @@ -242,10 +243,10 @@ public class ContraptionCollider { boolean hasNormal = !collisionNormal.equals(Vec3.ZERO); boolean anyCollision = hardCollision || temporalCollision; - if (bounce > 0 && hasNormal && anyCollision && bounceEntity(entity, collisionNormal, contraptionEntity, bounce)) { - entity.level.playSound(playerType == PlayerType.CLIENT ? (Player) entity : null, - entity.getX(), entity.getY(), entity.getZ(), SoundEvents.SLIME_BLOCK_FALL, - SoundSource.BLOCKS, .5f, 1); + if (bounce > 0 && hasNormal && anyCollision + && bounceEntity(entity, collisionNormal, contraptionEntity, bounce)) { + entity.level.playSound(playerType == PlayerType.CLIENT ? (Player) entity : null, entity.getX(), + entity.getY(), entity.getZ(), SoundEvents.SLIME_BLOCK_FALL, SoundSource.BLOCKS, .5f, 1); continue; } @@ -339,25 +340,30 @@ public class ContraptionCollider { return false; Vec3 contactPointMotion = contraption.getContactPointMotion(entity.position()); - Vec3 motion = entity.getDeltaMovement().subtract(contactPointMotion); - Vec3 deltav = normal.scale(factor*2*motion.dot(normal)); + Vec3 motion = entity.getDeltaMovement() + .subtract(contactPointMotion); + Vec3 deltav = normal.scale(factor * 2 * motion.dot(normal)); if (deltav.dot(deltav) < 0.1f) - return false; - entity.setDeltaMovement(entity.getDeltaMovement().subtract(deltav)); + return false; + entity.setDeltaMovement(entity.getDeltaMovement() + .subtract(deltav)); return true; } public static Vec3 getWorldToLocalTranslation(Entity entity, AbstractContraptionEntity contraptionEntity) { - return getWorldToLocalTranslation(entity, contraptionEntity.getAnchorVec(), contraptionEntity.getRotationState()); + return getWorldToLocalTranslation(entity, contraptionEntity.getAnchorVec(), + contraptionEntity.getRotationState()); } public static Vec3 getWorldToLocalTranslation(Entity entity, Vec3 anchorVec, ContraptionRotationState rotation) { return getWorldToLocalTranslation(entity, anchorVec, rotation.asMatrix(), rotation.getYawOffset()); } - public static Vec3 getWorldToLocalTranslation(Entity entity, Vec3 anchorVec, Matrix3d rotationMatrix, float yawOffset) { + public static Vec3 getWorldToLocalTranslation(Entity entity, Vec3 anchorVec, Matrix3d rotationMatrix, + float yawOffset) { Vec3 entityPosition = entity.position(); - Vec3 centerY = new Vec3(0, entity.getBoundingBox().getYsize() / 2, 0); + Vec3 centerY = new Vec3(0, entity.getBoundingBox() + .getYsize() / 2, 0); Vec3 position = entityPosition; position = position.add(centerY); position = position.subtract(VecHelper.CENTER_OF_ORIGIN); @@ -371,14 +377,16 @@ public class ContraptionCollider { } public static Vec3 getWorldToLocalTranslation(Vec3 entity, AbstractContraptionEntity contraptionEntity) { - return getWorldToLocalTranslation(entity, contraptionEntity.getAnchorVec(), contraptionEntity.getRotationState()); + return getWorldToLocalTranslation(entity, contraptionEntity.getAnchorVec(), + contraptionEntity.getRotationState()); } public static Vec3 getWorldToLocalTranslation(Vec3 inPos, Vec3 anchorVec, ContraptionRotationState rotation) { return getWorldToLocalTranslation(inPos, anchorVec, rotation.asMatrix(), rotation.getYawOffset()); } - public static Vec3 getWorldToLocalTranslation(Vec3 inPos, Vec3 anchorVec, Matrix3d rotationMatrix, float yawOffset) { + public static Vec3 getWorldToLocalTranslation(Vec3 inPos, Vec3 anchorVec, Matrix3d rotationMatrix, + float yawOffset) { Vec3 position = inPos; position = position.subtract(VecHelper.CENTER_OF_ORIGIN); position = position.subtract(anchorVec); @@ -436,8 +444,7 @@ public class ContraptionCollider { return entity instanceof LocalPlayer; } - private static List getPotentiallyCollidedShapes(Level world, Contraption contraption, - AABB localBB) { + private static List getPotentiallyCollidedShapes(Level world, Contraption contraption, AABB localBB) { double height = localBB.getYsize(); double width = localBB.getXsize(); @@ -536,16 +543,24 @@ public class ContraptionCollider { BlockState collidedState = world.getBlockState(colliderPos); StructureBlockInfo blockInfo = contraption.getBlocks() .get(pos); + boolean emptyCollider = collidedState.getCollisionShape(world, pos) + .isEmpty(); if (AllMovementBehaviours.contains(blockInfo.state.getBlock())) { MovementBehaviour movementBehaviour = AllMovementBehaviours.of(blockInfo.state.getBlock()); if (movementBehaviour instanceof BlockBreakingMovementBehaviour) { BlockBreakingMovementBehaviour behaviour = (BlockBreakingMovementBehaviour) movementBehaviour; - if (!behaviour.canBreak(world, colliderPos, collidedState) - && !collidedState.getCollisionShape(world, pos) - .isEmpty()) { + if (!behaviour.canBreak(world, colliderPos, collidedState) && !emptyCollider) + return true; + continue; + } + if (movementBehaviour instanceof HarvesterMovementBehaviour) { + HarvesterMovementBehaviour harvesterMovementBehaviour = + (HarvesterMovementBehaviour) movementBehaviour; + if (!harvesterMovementBehaviour.isValidCrop(world, colliderPos, collidedState) + && !harvesterMovementBehaviour.isValidOther(world, colliderPos, collidedState) + && !emptyCollider) return true; - } continue; } } @@ -556,9 +571,7 @@ public class ContraptionCollider { if (collidedState.getBlock() instanceof CocoaBlock) continue; if (!collidedState.getMaterial() - .isReplaceable() - && !collidedState.getCollisionShape(world, colliderPos) - .isEmpty()) { + .isReplaceable() && !emptyCollider) { return true; } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index d0c659484..bd4ff898d 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -5,7 +5,7 @@ license="MIT" [[mods]] modId="create" -version="0.4a" +version="0.4b" displayName="Create" #updateJSONURL="" displayURL="https://www.curseforge.com/minecraft/mc-mods/create"