From 2eec01ad1cb0667680b13e30055b252d03020255 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Sun, 5 Jun 2022 19:01:15 +0200 Subject: [PATCH] Sundays' one-liners - Fixed ploughs destroying track marker blocks - Fixed track markers spawning block particle effects - Safety check for PSI updates - Fixed sliding doors not having correct rendering boundaries - Fixed PSI overstretching their model - Fixed bogeys being ignored by schematicannons - Fixed downward facing deployers not aiming correctly on trains - Fixed incorrect relative motion provided to mounted actors by trains - Basins now attempt to dump existing output content into newly created auto-outputs - Builders Tea can now be scooped out of basins manually - Basins now prioritise output tanks when filling held items - Fixed pulley contraptions not receiving light updates below y=0 --- .../actors/PloughMovementBehaviour.java | 3 ++ .../PortableStorageInterfaceTileEntity.java | 2 +- .../deployer/DeployerMovementBehaviour.java | 3 ++ .../AbstractContraptionEntity.java | 7 +++- .../pulley/PulleyLighter.java | 6 +-- .../fluids/actors/GenericItemFilling.java | 21 +++++++--- .../processing/BasinTileEntity.java | 42 ++++++++++++++++--- .../deco/SlidingDoorTileEntity.java | 6 +++ .../trains/track/FakeTrackBlock.java | 14 +++++++ .../trains/track/StandardBogeyBlock.java | 15 +++++-- 10 files changed, 98 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PloughMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PloughMovementBehaviour.java index 06fe4d036..462597266 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PloughMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PloughMovementBehaviour.java @@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.components.actors; import com.simibubi.create.content.contraptions.components.actors.PloughBlock.PloughFakePlayer; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.OrientedContraptionEntity; +import com.simibubi.create.content.logistics.trains.track.FakeTrackBlock; import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.core.BlockPos; @@ -84,6 +85,8 @@ public class PloughMovementBehaviour extends BlockBreakingMovementBehaviour { return false; if (state.getBlock() instanceof NetherPortalBlock) return false; + if (state.getBlock() instanceof FakeTrackBlock) + return false; return state.getCollisionShape(world, breakingPos) .isEmpty(); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceTileEntity.java index c710e34c3..9fe25d2b2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceTileEntity.java @@ -37,7 +37,7 @@ public abstract class PortableStorageInterfaceTileEntity extends SmartTileEntity } public void startTransferringTo(Contraption contraption, float distance) { - this.distance = distance; + this.distance = Math.min(2, distance); connectedEntity = contraption.entity; startConnecting(); notifyUpdate(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java index a67f352aa..f492814b3 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java @@ -21,6 +21,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Ori import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; import com.simibubi.create.content.logistics.item.filter.FilterItem; +import com.simibubi.create.content.logistics.trains.entity.CarriageContraptionEntity; import com.simibubi.create.content.schematics.ItemRequirement; import com.simibubi.create.content.schematics.SchematicWorld; import com.simibubi.create.content.schematics.filtering.SchematicInstances; @@ -92,6 +93,8 @@ public class DeployerMovementBehaviour implements MovementBehaviour { Vec3 initial = new Vec3(0, 0, 1); if (context.contraption.entity instanceof OrientedContraptionEntity oce) initial = VecHelper.rotate(initial, oce.getInitialYaw(), Axis.Y); + if (context.contraption.entity instanceof CarriageContraptionEntity cce) + initial = VecHelper.rotate(initial, 90, Axis.Y); facingVec = context.rotation.apply(initial); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java index 28d3cef60..1224e1656 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java @@ -432,7 +432,8 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit StructureBlockInfo blockInfo = pair.left; MovementBehaviour actor = AllMovementBehaviours.of(blockInfo.state); if (actor instanceof PortableStorageInterfaceMovement && isActorActive(context, actor)) - actor.visitNewPosition(context, new BlockPos(context.position)); + if (context.position != null) + actor.visitNewPosition(context, new BlockPos(context.position)); } } @@ -452,17 +453,19 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit return false; context.motion = actorPosition.subtract(previousPosition); + if (!level.isClientSide() && context.contraption.entity instanceof CarriageContraptionEntity cce && cce.getCarriage() != null) { Train train = cce.getCarriage().train; double actualSpeed = train.speedBeforeStall != null ? train.speedBeforeStall : train.speed; context.motion = context.motion.normalize() - .scale(actualSpeed); + .scale(Math.abs(actualSpeed)); } Vec3 relativeMotion = context.motion; relativeMotion = reverseRotation(relativeMotion, 1); context.relativeMotion = relativeMotion; + return !new BlockPos(previousPosition).equals(gridPosition) || (context.relativeMotion.length() > 0 || context.contraption instanceof CarriageContraption) && context.firstMovement; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyLighter.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyLighter.java index aedfcc667..01c9d289d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyLighter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyLighter.java @@ -20,13 +20,11 @@ public class PulleyLighter extends ContraptionLighter { Level world = contraption.entity.level; BlockPos.MutableBlockPos pos = contraption.anchor.mutable(); - while (!AllBlocks.ROPE_PULLEY.has(world.getBlockState(pos)) && pos.getY() < 256) { + while (!AllBlocks.ROPE_PULLEY.has(world.getBlockState(pos)) && pos.getY() < world.getMaxBuildHeight()) pos.move(0, 1, 0); - } bounds.translate(pos); - bounds.setMinY(1); // the super constructor will take care of making this 0 - + bounds.setMinY(world.getMinBuildHeight()); return bounds; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/GenericItemFilling.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/GenericItemFilling.java index b8cc74549..e6ce73c75 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/GenericItemFilling.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/GenericItemFilling.java @@ -1,6 +1,7 @@ package com.simibubi.create.content.contraptions.fluids.actors; import com.simibubi.create.AllFluids; +import com.simibubi.create.AllItems; import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler; import com.simibubi.create.foundation.fluid.FluidHelper; @@ -12,6 +13,7 @@ import net.minecraft.world.item.MilkBucketItem; import net.minecraft.world.item.alchemy.PotionUtils; import net.minecraft.world.item.alchemy.Potions; import net.minecraft.world.level.Level; +import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Fluids; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidStack; @@ -97,10 +99,14 @@ public class GenericItemFilling { } private static boolean canFillGlassBottleInternally(FluidStack availableFluid) { - return availableFluid.getFluid() - .isSame(Fluids.WATER) - || availableFluid.getFluid() - .isSame(AllFluids.POTION.get()); + Fluid fluid = availableFluid.getFluid(); + if (fluid.isSame(Fluids.WATER)) + return true; + if (fluid.isSame(AllFluids.POTION.get())) + return true; + if (fluid.isSame(AllFluids.TEA.get())) + return true; + return false; } private static boolean canFillBucketInternally(FluidStack availableFluid) { @@ -114,14 +120,17 @@ public class GenericItemFilling { if (stack.getItem() == Items.GLASS_BOTTLE && canFillGlassBottleInternally(toFill)) { ItemStack fillBottle = ItemStack.EMPTY; - if (FluidHelper.isWater(toFill.getFluid())) + Fluid fluid = toFill.getFluid(); + if (FluidHelper.isWater(fluid)) fillBottle = PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.WATER); + else if (fluid.isSame(AllFluids.TEA.get())) + fillBottle = AllItems.BUILDERS_TEA.asStack(); else fillBottle = PotionFluidHandler.fillBottle(stack, toFill); stack.shrink(1); return fillBottle; } - + ItemStack split = stack.copy(); split.setCount(1); LazyOptional capability = diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinTileEntity.java index a1d77e4e8..f2549660a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinTileEntity.java @@ -9,6 +9,7 @@ import java.util.Random; import javax.annotation.Nonnull; +import com.google.common.collect.ImmutableList; import com.simibubi.create.AllParticleTypes; import com.simibubi.create.AllTags; import com.simibubi.create.content.contraptions.components.mixer.MechanicalMixerTileEntity; @@ -135,7 +136,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor fluidCapability = LazyOptional.of(() -> { LazyOptional inputCap = inputTank.getCapability(); LazyOptional outputCap = outputTank.getCapability(); - return new CombinedTankWrapper(inputCap.orElse(null), outputCap.orElse(null)); + return new CombinedTankWrapper(outputCap.orElse(null), inputCap.orElse(null)); }); } @@ -275,8 +276,39 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor && preferredSpoutput != Direction.UP) newFacing = preferredSpoutput; - if (newFacing != currentFacing) - level.setBlockAndUpdate(worldPosition, blockState.setValue(BasinBlock.FACING, newFacing)); + if (newFacing == currentFacing) + return; + + level.setBlockAndUpdate(worldPosition, blockState.setValue(BasinBlock.FACING, newFacing)); + + if (newFacing.getAxis() + .isVertical()) + return; + + for (int slot = 0; slot < outputInventory.getSlots(); slot++) { + ItemStack extractItem = outputInventory.extractItem(slot, 64, true); + if (extractItem.isEmpty()) + continue; + if (acceptOutputs(ImmutableList.of(extractItem), Collections.emptyList(), true)) + acceptOutputs(ImmutableList.of(outputInventory.extractItem(slot, 64, false)), Collections.emptyList(), + false); + } + + IFluidHandler handler = outputTank.getCapability() + .orElse(null); + for (int slot = 0; slot < handler.getTanks(); slot++) { + FluidStack fs = handler.getFluidInTank(slot) + .copy(); + if (fs.isEmpty()) + continue; + if (acceptOutputs(Collections.emptyList(), ImmutableList.of(fs), true)) { + handler.drain(fs, FluidAction.EXECUTE); + acceptOutputs(Collections.emptyList(), ImmutableList.of(fs), false); + } + } + + notifyChangeOfContents(); + notifyUpdate(); } @Override @@ -664,8 +696,8 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor float angle = interval * (1 + currentSegment) + intervalOffset; Vec3 vec = centerOf.add(VecHelper.rotate(pointer, angle, Axis.Y)); level.addAlwaysVisibleParticle( - new FluidParticleData(AllParticleTypes.BASIN_FLUID.get(), tankSegment.getRenderedFluid()), - vec.x(), surface, vec.z(), 1, 0, 0); + new FluidParticleData(AllParticleTypes.BASIN_FLUID.get(), tankSegment.getRenderedFluid()), vec.x(), + surface, vec.z(), 1, 0, 0); currentSegment++; } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/deco/SlidingDoorTileEntity.java b/src/main/java/com/simibubi/create/content/curiosities/deco/SlidingDoorTileEntity.java index 7db098e14..c72e6a7fa 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/deco/SlidingDoorTileEntity.java +++ b/src/main/java/com/simibubi/create/content/curiosities/deco/SlidingDoorTileEntity.java @@ -14,6 +14,7 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.DoorBlock; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.AABB; public class SlidingDoorTileEntity extends SmartTileEntity { @@ -53,6 +54,11 @@ public class SlidingDoorTileEntity extends SmartTileEntity { showBlockModel(); } + @Override + protected AABB createRenderBoundingBox() { + return super.createRenderBoundingBox().inflate(1); + } + protected boolean isVisible(BlockState state) { return state.getOptionalValue(TrainDoorBlock.VISIBLE) .orElse(true); diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/track/FakeTrackBlock.java b/src/main/java/com/simibubi/create/content/logistics/trains/track/FakeTrackBlock.java index efbe36b27..cb69aba49 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/track/FakeTrackBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/track/FakeTrackBlock.java @@ -8,8 +8,11 @@ import com.simibubi.create.foundation.block.ProperWaterloggedBlock; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.EntityBlock; @@ -78,5 +81,16 @@ public class FakeTrackBlock extends Block implements EntityBlock, ProperWaterlog public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) { return AllTileEntities.FAKE_TRACK.create(pPos, pState); } + + @Override + public boolean addLandingEffects(BlockState state1, ServerLevel level, BlockPos pos, BlockState state2, + LivingEntity entity, int numberOfParticles) { + return true; + } + + @Override + public boolean addRunningEffects(BlockState state, Level level, BlockPos pos, Entity entity) { + return true; + } } diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/track/StandardBogeyBlock.java b/src/main/java/com/simibubi/create/content/logistics/trains/track/StandardBogeyBlock.java index 76a8bb429..1f61dd38e 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/track/StandardBogeyBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/track/StandardBogeyBlock.java @@ -13,6 +13,9 @@ import com.simibubi.create.content.contraptions.relays.elementary.ShaftBlock; import com.simibubi.create.content.logistics.trains.IBogeyBlock; import com.simibubi.create.content.logistics.trains.entity.BogeyInstance; import com.simibubi.create.content.logistics.trains.entity.CarriageBogey; +import com.simibubi.create.content.schematics.ISpecialBlockItemRequirement; +import com.simibubi.create.content.schematics.ItemRequirement; +import com.simibubi.create.content.schematics.ItemRequirement.ItemUseType; import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.block.ProperWaterloggedBlock; import com.simibubi.create.foundation.render.CachedBufferer; @@ -31,6 +34,7 @@ import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Rotation; +import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition.Builder; @@ -43,7 +47,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; public class StandardBogeyBlock extends Block - implements IBogeyBlock, ITE, ProperWaterloggedBlock { + implements IBogeyBlock, ITE, ProperWaterloggedBlock, ISpecialBlockItemRequirement { public static final EnumProperty AXIS = BlockStateProperties.HORIZONTAL_AXIS; private final boolean large; @@ -74,12 +78,12 @@ public class StandardBogeyBlock extends Block updateWater(pLevel, pState, pCurrentPos); return pState; } - + @Override public FluidState getFluidState(BlockState pState) { return fluidState(pState); } - + @Override public double getWheelPointSpacing() { return 2; @@ -228,4 +232,9 @@ public class StandardBogeyBlock extends Block return AllTileEntities.BOGEY.get(); } + @Override + public ItemRequirement getRequiredItems(BlockState state, BlockEntity te) { + return new ItemRequirement(ItemUseType.CONSUME, AllBlocks.RAILWAY_CASING.asStack()); + } + }