mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-15 23:53:41 +01:00
Merge remote-tracking branch 'origin/mc1.15/dev' into mc1.15/dev
This commit is contained in:
commit
240510e3ee
8 changed files with 63 additions and 33 deletions
|
@ -1,10 +1,11 @@
|
||||||
package com.simibubi.create.content.contraptions.components.actors;
|
package com.simibubi.create.content.contraptions.components.actors;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.RenderedContraption;
|
|
||||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
|
|
||||||
|
@ -17,8 +18,6 @@ import net.minecraft.world.World;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class DrillMovementBehaviour extends BlockBreakingMovementBehaviour {
|
public class DrillMovementBehaviour extends BlockBreakingMovementBehaviour {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -461,6 +461,8 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
|
||||||
if (!ticking)
|
if (!ticking)
|
||||||
contraption.stop(world);
|
contraption.stop(world);
|
||||||
}
|
}
|
||||||
|
if (contraption != null)
|
||||||
|
contraption.onEntityRemoved(this);
|
||||||
super.remove(keepData);
|
super.remove(keepData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,7 @@ public abstract class Contraption {
|
||||||
private Map<BlockPos, Entity> initialPassengers;
|
private Map<BlockPos, Entity> initialPassengers;
|
||||||
private List<BlockFace> pendingSubContraptions;
|
private List<BlockFace> pendingSubContraptions;
|
||||||
|
|
||||||
private CompletableFuture<List<AxisAlignedBB>> simplifiedEntityColliderProvider;
|
private CompletableFuture<Void> simplifiedEntityColliderProvider;
|
||||||
|
|
||||||
// Client
|
// Client
|
||||||
public Map<BlockPos, TileEntity> presentTileEntities;
|
public Map<BlockPos, TileEntity> presentTileEntities;
|
||||||
|
@ -193,6 +193,7 @@ public abstract class Contraption {
|
||||||
String type = nbt.getString("Type");
|
String type = nbt.getString("Type");
|
||||||
Contraption contraption = ContraptionType.fromType(type);
|
Contraption contraption = ContraptionType.fromType(type);
|
||||||
contraption.readNBT(world, nbt, spawnData);
|
contraption.readNBT(world, nbt, spawnData);
|
||||||
|
contraption.world = new ContraptionWorld(world, contraption);
|
||||||
contraption.gatherBBsOffThread();
|
contraption.gatherBBsOffThread();
|
||||||
return contraption;
|
return contraption;
|
||||||
}
|
}
|
||||||
|
@ -260,6 +261,13 @@ public abstract class Contraption {
|
||||||
gatherBBsOffThread();
|
gatherBBsOffThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onEntityRemoved(AbstractContraptionEntity entity) {
|
||||||
|
if (simplifiedEntityColliderProvider != null) {
|
||||||
|
simplifiedEntityColliderProvider.cancel(false);
|
||||||
|
simplifiedEntityColliderProvider = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void onEntityInitialize(World world, AbstractContraptionEntity contraptionEntity) {
|
public void onEntityInitialize(World world, AbstractContraptionEntity contraptionEntity) {
|
||||||
if (world.isRemote)
|
if (world.isRemote)
|
||||||
return;
|
return;
|
||||||
|
@ -282,15 +290,6 @@ public abstract class Contraption {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEntityTick(World world) {
|
public void onEntityTick(World world) {
|
||||||
if (simplifiedEntityColliderProvider != null && simplifiedEntityColliderProvider.isDone()) {
|
|
||||||
try {
|
|
||||||
simplifiedEntityColliders = Optional.of(simplifiedEntityColliderProvider.join());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
simplifiedEntityColliderProvider = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
fluidStorage.forEach((pos, mfs) -> mfs.tick(entity, pos, world.isRemote));
|
fluidStorage.forEach((pos, mfs) -> mfs.tick(entity, pos, world.isRemote));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1182,18 +1181,24 @@ public abstract class Contraption {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void gatherBBsOffThread() {
|
private void gatherBBsOffThread() {
|
||||||
|
getContraptionWorld();
|
||||||
simplifiedEntityColliderProvider = CompletableFuture.supplyAsync(() -> {
|
simplifiedEntityColliderProvider = CompletableFuture.supplyAsync(() -> {
|
||||||
VoxelShape combinedShape = VoxelShapes.empty();
|
VoxelShape combinedShape = VoxelShapes.empty();
|
||||||
for (Entry<BlockPos, BlockInfo> entry : blocks.entrySet()) {
|
for (Entry<BlockPos, BlockInfo> entry : blocks.entrySet()) {
|
||||||
BlockInfo info = entry.getValue();
|
BlockInfo info = entry.getValue();
|
||||||
BlockPos localPos = entry.getKey();
|
BlockPos localPos = entry.getKey();
|
||||||
VoxelShape collisionShape = info.state.getCollisionShape(this.world, localPos);
|
VoxelShape collisionShape = info.state.getCollisionShape(world, localPos);
|
||||||
if (collisionShape.isEmpty())
|
if (collisionShape.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
combinedShape = VoxelShapes.combineAndSimplify(combinedShape,
|
combinedShape = VoxelShapes.combine(combinedShape,
|
||||||
collisionShape.withOffset(localPos.getX(), localPos.getY(), localPos.getZ()), IBooleanFunction.OR);
|
collisionShape.withOffset(localPos.getX(), localPos.getY(), localPos.getZ()), IBooleanFunction.OR);
|
||||||
}
|
}
|
||||||
return combinedShape.toBoundingBoxList();
|
return combinedShape.simplify()
|
||||||
|
.toBoundingBoxList();
|
||||||
|
})
|
||||||
|
.thenAccept(r -> {
|
||||||
|
simplifiedEntityColliders = Optional.of(r);
|
||||||
|
simplifiedEntityColliderProvider = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,6 @@ public class ContraptionCollider {
|
||||||
motion = rotationMatrix.transform(motion);
|
motion = rotationMatrix.transform(motion);
|
||||||
|
|
||||||
// Use simplified bbs when present
|
// Use simplified bbs when present
|
||||||
// TODO: is it worth filtering out far away bbs?
|
|
||||||
final Vec3d motionCopy = motion;
|
final Vec3d motionCopy = motion;
|
||||||
List<AxisAlignedBB> collidableBBs = contraption.simplifiedEntityColliders.orElseGet(() -> {
|
List<AxisAlignedBB> collidableBBs = contraption.simplifiedEntityColliders.orElseGet(() -> {
|
||||||
|
|
||||||
|
@ -147,7 +146,17 @@ public class ContraptionCollider {
|
||||||
|
|
||||||
for (AxisAlignedBB bb : collidableBBs) {
|
for (AxisAlignedBB bb : collidableBBs) {
|
||||||
Vec3d currentResponse = collisionResponse.getValue();
|
Vec3d currentResponse = collisionResponse.getValue();
|
||||||
obb.setCenter(obbCenter.add(currentResponse));
|
Vec3d currentCenter = obbCenter.add(currentResponse);
|
||||||
|
|
||||||
|
if (Math.abs(currentCenter.x - bb.getCenter().x) - entityBounds.getXSize() - 1 > bb.getXSize() / 2)
|
||||||
|
continue;
|
||||||
|
if (Math.abs((currentCenter.y + motion.y) - bb.getCenter().y) - entityBounds.getYSize()
|
||||||
|
- 1 > bb.getYSize() / 2)
|
||||||
|
continue;
|
||||||
|
if (Math.abs(currentCenter.z - bb.getCenter().z) - entityBounds.getZSize() - 1 > bb.getZSize() / 2)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
obb.setCenter(currentCenter);
|
||||||
ContinuousSeparationManifold intersect = obb.intersect(bb, motion);
|
ContinuousSeparationManifold intersect = obb.intersect(bb, motion);
|
||||||
|
|
||||||
if (intersect == null)
|
if (intersect == null)
|
||||||
|
|
|
@ -101,6 +101,11 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity
|
||||||
public void onSpeedChanged(float prevSpeed) {
|
public void onSpeedChanged(float prevSpeed) {
|
||||||
super.onSpeedChanged(prevSpeed);
|
super.onSpeedChanged(prevSpeed);
|
||||||
assembleNextTick = true;
|
assembleNextTick = true;
|
||||||
|
|
||||||
|
if (movedContraption != null && Math.signum(prevSpeed) != Math.signum(getSpeed()) && prevSpeed != 0) {
|
||||||
|
movedContraption.getContraption()
|
||||||
|
.stop(world);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getAngularSpeed() {
|
public float getAngularSpeed() {
|
||||||
|
|
|
@ -69,6 +69,8 @@ public class GantryContraptionEntity extends AbstractContraptionEntity {
|
||||||
if (!isStalled() && ticksExisted > 2)
|
if (!isStalled() && ticksExisted > 2)
|
||||||
move(movementVec.x, movementVec.y, movementVec.z);
|
move(movementVec.x, movementVec.y, movementVec.z);
|
||||||
|
|
||||||
|
if (Math.signum(prevAxisMotion) != Math.signum(axisMotion) && prevAxisMotion != 0)
|
||||||
|
contraption.stop(world);
|
||||||
if (!world.isRemote && (prevAxisMotion != axisMotion || ticksExisted % 3 == 0))
|
if (!world.isRemote && (prevAxisMotion != axisMotion || ticksExisted % 3 == 0))
|
||||||
sendPacket();
|
sendPacket();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,8 @@ 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.Vec3d;
|
||||||
|
|
||||||
public abstract class LinearActuatorTileEntity extends KineticTileEntity implements IControlContraption, IDisplayAssemblyExceptions {
|
public abstract class LinearActuatorTileEntity extends KineticTileEntity
|
||||||
|
implements IControlContraption, IDisplayAssemblyExceptions {
|
||||||
|
|
||||||
public float offset;
|
public float offset;
|
||||||
public boolean running;
|
public boolean running;
|
||||||
|
@ -147,6 +148,11 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity impleme
|
||||||
super.onSpeedChanged(prevSpeed);
|
super.onSpeedChanged(prevSpeed);
|
||||||
assembleNextTick = true;
|
assembleNextTick = true;
|
||||||
waitingForSpeedChange = false;
|
waitingForSpeedChange = false;
|
||||||
|
|
||||||
|
if (movedContraption != null && Math.signum(prevSpeed) != Math.signum(getSpeed()) && prevSpeed != 0) {
|
||||||
|
movedContraption.getContraption()
|
||||||
|
.stop(world);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -31,8 +31,8 @@ public class TreeFertilizerItem extends Item {
|
||||||
return ActionResultType.SUCCESS;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
TreesDreamWorld world = new TreesDreamWorld((ServerWorld) context.getWorld());
|
|
||||||
BlockPos saplingPos = context.getPos();
|
BlockPos saplingPos = context.getPos();
|
||||||
|
TreesDreamWorld world = new TreesDreamWorld((ServerWorld) context.getWorld(), saplingPos);
|
||||||
|
|
||||||
for (BlockPos pos : BlockPos.getAllInBoxMutable(-1, 0, -1, 1, 0, 1)) {
|
for (BlockPos pos : BlockPos.getAllInBoxMutable(-1, 0, -1, 1, 0, 1)) {
|
||||||
if (context.getWorld()
|
if (context.getWorld()
|
||||||
|
@ -45,8 +45,8 @@ public class TreeFertilizerItem extends Item {
|
||||||
state.with(SaplingBlock.STAGE, 1));
|
state.with(SaplingBlock.STAGE, 1));
|
||||||
|
|
||||||
for (BlockPos pos : world.blocksAdded.keySet()) {
|
for (BlockPos pos : world.blocksAdded.keySet()) {
|
||||||
BlockPos actualPos = pos.add(saplingPos)
|
BlockPos actualPos = pos.add(saplingPos).down(10);
|
||||||
.down(10);
|
BlockState newState = world.blocksAdded.get(pos);
|
||||||
|
|
||||||
// Don't replace Bedrock
|
// Don't replace Bedrock
|
||||||
if (context.getWorld()
|
if (context.getWorld()
|
||||||
|
@ -54,21 +54,15 @@ public class TreeFertilizerItem extends Item {
|
||||||
.getBlockHardness(context.getWorld(), actualPos) == -1)
|
.getBlockHardness(context.getWorld(), actualPos) == -1)
|
||||||
continue;
|
continue;
|
||||||
// Don't replace solid blocks with leaves
|
// Don't replace solid blocks with leaves
|
||||||
if (!world.getBlockState(pos)
|
if (!newState.isNormalCube(world, pos)
|
||||||
.isNormalCube(world, pos)
|
|
||||||
&& !context.getWorld()
|
&& !context.getWorld()
|
||||||
.getBlockState(actualPos)
|
.getBlockState(actualPos)
|
||||||
.getCollisionShape(context.getWorld(), actualPos)
|
.getCollisionShape(context.getWorld(), actualPos)
|
||||||
.isEmpty())
|
.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
if (world.getBlockState(pos)
|
|
||||||
.getBlock() == Blocks.GRASS_BLOCK
|
|
||||||
|| world.getBlockState(pos)
|
|
||||||
.getBlock() == Blocks.PODZOL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
context.getWorld()
|
context.getWorld()
|
||||||
.setBlockState(actualPos, world.getBlockState(pos));
|
.setBlockState(actualPos, newState);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.getPlayer() != null && !context.getPlayer()
|
if (context.getPlayer() != null && !context.getPlayer()
|
||||||
|
@ -83,18 +77,26 @@ public class TreeFertilizerItem extends Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TreesDreamWorld extends PlacementSimulationServerWorld {
|
private class TreesDreamWorld extends PlacementSimulationServerWorld {
|
||||||
|
private final BlockState soil;
|
||||||
|
|
||||||
protected TreesDreamWorld(ServerWorld wrapped) {
|
protected TreesDreamWorld(ServerWorld wrapped, BlockPos saplingPos) {
|
||||||
super(wrapped);
|
super(wrapped);
|
||||||
|
soil = wrapped.getBlockState(saplingPos.down());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlockState(BlockPos pos) {
|
public BlockState getBlockState(BlockPos pos) {
|
||||||
if (pos.getY() <= 9)
|
if (pos.getY() <= 9)
|
||||||
return Blocks.GRASS_BLOCK.getDefaultState();
|
return soil;
|
||||||
return super.getBlockState(pos);
|
return super.getBlockState(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBlockState(BlockPos pos, BlockState newState, int flags) {
|
||||||
|
if (newState.getBlock() == Blocks.PODZOL)
|
||||||
|
return true;
|
||||||
|
return super.setBlockState(pos, newState, flags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue