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
This commit is contained in:
simibubi 2022-06-05 19:01:15 +02:00
parent 7199ebfb6b
commit 2eec01ad1c
10 changed files with 98 additions and 21 deletions

View file

@ -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.actors.PloughBlock.PloughFakePlayer;
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.OrientedContraptionEntity; 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 com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -84,6 +85,8 @@ public class PloughMovementBehaviour extends BlockBreakingMovementBehaviour {
return false; return false;
if (state.getBlock() instanceof NetherPortalBlock) if (state.getBlock() instanceof NetherPortalBlock)
return false; return false;
if (state.getBlock() instanceof FakeTrackBlock)
return false;
return state.getCollisionShape(world, breakingPos) return state.getCollisionShape(world, breakingPos)
.isEmpty(); .isEmpty();
} }

View file

@ -37,7 +37,7 @@ public abstract class PortableStorageInterfaceTileEntity extends SmartTileEntity
} }
public void startTransferringTo(Contraption contraption, float distance) { public void startTransferringTo(Contraption contraption, float distance) {
this.distance = distance; this.distance = Math.min(2, distance);
connectedEntity = contraption.entity; connectedEntity = contraption.entity;
startConnecting(); startConnecting();
notifyUpdate(); notifyUpdate();

View file

@ -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.ActorInstance;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; 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.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.ItemRequirement;
import com.simibubi.create.content.schematics.SchematicWorld; import com.simibubi.create.content.schematics.SchematicWorld;
import com.simibubi.create.content.schematics.filtering.SchematicInstances; import com.simibubi.create.content.schematics.filtering.SchematicInstances;
@ -92,6 +93,8 @@ public class DeployerMovementBehaviour implements MovementBehaviour {
Vec3 initial = new Vec3(0, 0, 1); Vec3 initial = new Vec3(0, 0, 1);
if (context.contraption.entity instanceof OrientedContraptionEntity oce) if (context.contraption.entity instanceof OrientedContraptionEntity oce)
initial = VecHelper.rotate(initial, oce.getInitialYaw(), Axis.Y); 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); facingVec = context.rotation.apply(initial);
} }

View file

@ -432,6 +432,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
StructureBlockInfo blockInfo = pair.left; StructureBlockInfo blockInfo = pair.left;
MovementBehaviour actor = AllMovementBehaviours.of(blockInfo.state); MovementBehaviour actor = AllMovementBehaviours.of(blockInfo.state);
if (actor instanceof PortableStorageInterfaceMovement && isActorActive(context, actor)) if (actor instanceof PortableStorageInterfaceMovement && isActorActive(context, actor))
if (context.position != null)
actor.visitNewPosition(context, new BlockPos(context.position)); actor.visitNewPosition(context, new BlockPos(context.position));
} }
} }
@ -452,17 +453,19 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
return false; return false;
context.motion = actorPosition.subtract(previousPosition); context.motion = actorPosition.subtract(previousPosition);
if (!level.isClientSide() && context.contraption.entity instanceof CarriageContraptionEntity cce if (!level.isClientSide() && context.contraption.entity instanceof CarriageContraptionEntity cce
&& cce.getCarriage() != null) { && cce.getCarriage() != null) {
Train train = cce.getCarriage().train; Train train = cce.getCarriage().train;
double actualSpeed = train.speedBeforeStall != null ? train.speedBeforeStall : train.speed; double actualSpeed = train.speedBeforeStall != null ? train.speedBeforeStall : train.speed;
context.motion = context.motion.normalize() context.motion = context.motion.normalize()
.scale(actualSpeed); .scale(Math.abs(actualSpeed));
} }
Vec3 relativeMotion = context.motion; Vec3 relativeMotion = context.motion;
relativeMotion = reverseRotation(relativeMotion, 1); relativeMotion = reverseRotation(relativeMotion, 1);
context.relativeMotion = relativeMotion; context.relativeMotion = relativeMotion;
return !new BlockPos(previousPosition).equals(gridPosition) return !new BlockPos(previousPosition).equals(gridPosition)
|| (context.relativeMotion.length() > 0 || context.contraption instanceof CarriageContraption) || (context.relativeMotion.length() > 0 || context.contraption instanceof CarriageContraption)
&& context.firstMovement; && context.firstMovement;

View file

@ -20,13 +20,11 @@ public class PulleyLighter extends ContraptionLighter<PulleyContraption> {
Level world = contraption.entity.level; Level world = contraption.entity.level;
BlockPos.MutableBlockPos pos = contraption.anchor.mutable(); 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); pos.move(0, 1, 0);
}
bounds.translate(pos); bounds.translate(pos);
bounds.setMinY(1); // the super constructor will take care of making this 0 bounds.setMinY(world.getMinBuildHeight());
return bounds; return bounds;
} }
} }

View file

@ -1,6 +1,7 @@
package com.simibubi.create.content.contraptions.fluids.actors; package com.simibubi.create.content.contraptions.fluids.actors;
import com.simibubi.create.AllFluids; import com.simibubi.create.AllFluids;
import com.simibubi.create.AllItems;
import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler; import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler;
import com.simibubi.create.foundation.fluid.FluidHelper; 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.PotionUtils;
import net.minecraft.world.item.alchemy.Potions; import net.minecraft.world.item.alchemy.Potions;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.Fluids; import net.minecraft.world.level.material.Fluids;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
@ -97,10 +99,14 @@ public class GenericItemFilling {
} }
private static boolean canFillGlassBottleInternally(FluidStack availableFluid) { private static boolean canFillGlassBottleInternally(FluidStack availableFluid) {
return availableFluid.getFluid() Fluid fluid = availableFluid.getFluid();
.isSame(Fluids.WATER) if (fluid.isSame(Fluids.WATER))
|| availableFluid.getFluid() return true;
.isSame(AllFluids.POTION.get()); if (fluid.isSame(AllFluids.POTION.get()))
return true;
if (fluid.isSame(AllFluids.TEA.get()))
return true;
return false;
} }
private static boolean canFillBucketInternally(FluidStack availableFluid) { private static boolean canFillBucketInternally(FluidStack availableFluid) {
@ -114,8 +120,11 @@ public class GenericItemFilling {
if (stack.getItem() == Items.GLASS_BOTTLE && canFillGlassBottleInternally(toFill)) { if (stack.getItem() == Items.GLASS_BOTTLE && canFillGlassBottleInternally(toFill)) {
ItemStack fillBottle = ItemStack.EMPTY; 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); fillBottle = PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.WATER);
else if (fluid.isSame(AllFluids.TEA.get()))
fillBottle = AllItems.BUILDERS_TEA.asStack();
else else
fillBottle = PotionFluidHandler.fillBottle(stack, toFill); fillBottle = PotionFluidHandler.fillBottle(stack, toFill);
stack.shrink(1); stack.shrink(1);

View file

@ -9,6 +9,7 @@ import java.util.Random;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import com.google.common.collect.ImmutableList;
import com.simibubi.create.AllParticleTypes; import com.simibubi.create.AllParticleTypes;
import com.simibubi.create.AllTags; import com.simibubi.create.AllTags;
import com.simibubi.create.content.contraptions.components.mixer.MechanicalMixerTileEntity; import com.simibubi.create.content.contraptions.components.mixer.MechanicalMixerTileEntity;
@ -135,7 +136,7 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor
fluidCapability = LazyOptional.of(() -> { fluidCapability = LazyOptional.of(() -> {
LazyOptional<? extends IFluidHandler> inputCap = inputTank.getCapability(); LazyOptional<? extends IFluidHandler> inputCap = inputTank.getCapability();
LazyOptional<? extends IFluidHandler> outputCap = outputTank.getCapability(); LazyOptional<? extends IFluidHandler> 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) && preferredSpoutput != Direction.UP)
newFacing = preferredSpoutput; newFacing = preferredSpoutput;
if (newFacing != currentFacing) if (newFacing == currentFacing)
return;
level.setBlockAndUpdate(worldPosition, blockState.setValue(BasinBlock.FACING, newFacing)); 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 @Override
@ -664,8 +696,8 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor
float angle = interval * (1 + currentSegment) + intervalOffset; float angle = interval * (1 + currentSegment) + intervalOffset;
Vec3 vec = centerOf.add(VecHelper.rotate(pointer, angle, Axis.Y)); Vec3 vec = centerOf.add(VecHelper.rotate(pointer, angle, Axis.Y));
level.addAlwaysVisibleParticle( level.addAlwaysVisibleParticle(
new FluidParticleData(AllParticleTypes.BASIN_FLUID.get(), tankSegment.getRenderedFluid()), new FluidParticleData(AllParticleTypes.BASIN_FLUID.get(), tankSegment.getRenderedFluid()), vec.x(),
vec.x(), surface, vec.z(), 1, 0, 0); surface, vec.z(), 1, 0, 0);
currentSegment++; currentSegment++;
} }
} }

View file

@ -14,6 +14,7 @@ import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.DoorBlock; import net.minecraft.world.level.block.DoorBlock;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
public class SlidingDoorTileEntity extends SmartTileEntity { public class SlidingDoorTileEntity extends SmartTileEntity {
@ -53,6 +54,11 @@ public class SlidingDoorTileEntity extends SmartTileEntity {
showBlockModel(); showBlockModel();
} }
@Override
protected AABB createRenderBoundingBox() {
return super.createRenderBoundingBox().inflate(1);
}
protected boolean isVisible(BlockState state) { protected boolean isVisible(BlockState state) {
return state.getOptionalValue(TrainDoorBlock.VISIBLE) return state.getOptionalValue(TrainDoorBlock.VISIBLE)
.orElse(true); .orElse(true);

View file

@ -8,8 +8,11 @@ import com.simibubi.create.foundation.block.ProperWaterloggedBlock;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel; 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.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock; import net.minecraft.world.level.block.EntityBlock;
@ -79,4 +82,15 @@ public class FakeTrackBlock extends Block implements EntityBlock, ProperWaterlog
return AllTileEntities.FAKE_TRACK.create(pPos, 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;
}
} }

View file

@ -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.IBogeyBlock;
import com.simibubi.create.content.logistics.trains.entity.BogeyInstance; import com.simibubi.create.content.logistics.trains.entity.BogeyInstance;
import com.simibubi.create.content.logistics.trains.entity.CarriageBogey; 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.ITE;
import com.simibubi.create.foundation.block.ProperWaterloggedBlock; import com.simibubi.create.foundation.block.ProperWaterloggedBlock;
import com.simibubi.create.foundation.render.CachedBufferer; 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.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.Rotation; 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.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition.Builder; 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; import net.minecraftforge.api.distmarker.OnlyIn;
public class StandardBogeyBlock extends Block public class StandardBogeyBlock extends Block
implements IBogeyBlock, ITE<StandardBogeyTileEntity>, ProperWaterloggedBlock { implements IBogeyBlock, ITE<StandardBogeyTileEntity>, ProperWaterloggedBlock, ISpecialBlockItemRequirement {
public static final EnumProperty<Axis> AXIS = BlockStateProperties.HORIZONTAL_AXIS; public static final EnumProperty<Axis> AXIS = BlockStateProperties.HORIZONTAL_AXIS;
private final boolean large; private final boolean large;
@ -228,4 +232,9 @@ public class StandardBogeyBlock extends Block
return AllTileEntities.BOGEY.get(); return AllTileEntities.BOGEY.get();
} }
@Override
public ItemRequirement getRequiredItems(BlockState state, BlockEntity te) {
return new ItemRequirement(ItemUseType.CONSUME, AllBlocks.RAILWAY_CASING.asStack());
}
} }