Taller stations

- Updates to station and signal assets by Kryppers
- Modified stations to behave like depots in their item handling
This commit is contained in:
simibubi 2022-05-06 22:04:36 +02:00
parent 3a84808379
commit 0745e44518
15 changed files with 224 additions and 281 deletions

View file

@ -249,7 +249,7 @@ public class AllShapes {
.build(), .build(),
DEPOT = shape(CASING_11PX.get(Direction.UP)).add(1, 11, 1, 15, 13, 15) DEPOT = shape(CASING_11PX.get(Direction.UP)).add(1, 11, 1, 15, 13, 15)
.build(), .build(),
STATION = shape(0, 0, 0, 16, 2, 16).add(1, 0, 1, 15, 8, 15) STATION = shape(0, 0, 0, 16, 2, 16).add(1, 0, 1, 15, 13, 15)
.build() .build()
; ;

View file

@ -3,6 +3,7 @@ package com.simibubi.create.content.logistics.block.depot;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.function.Supplier; import java.util.function.Supplier;
@ -51,6 +52,8 @@ public class DepotBehaviour extends TileEntityBehaviour {
Supplier<Integer> maxStackSize; Supplier<Integer> maxStackSize;
Supplier<Boolean> canAcceptItems; Supplier<Boolean> canAcceptItems;
Predicate<Direction> canFunnelsPullFrom; Predicate<Direction> canFunnelsPullFrom;
Consumer<ItemStack> onHeldInserted;
Predicate<ItemStack> acceptedItems;
boolean allowMerge; boolean allowMerge;
public DepotBehaviour(SmartTileEntity te) { public DepotBehaviour(SmartTileEntity te) {
@ -58,6 +61,9 @@ public class DepotBehaviour extends TileEntityBehaviour {
maxStackSize = () -> 64; maxStackSize = () -> 64;
canAcceptItems = () -> true; canAcceptItems = () -> true;
canFunnelsPullFrom = $ -> true; canFunnelsPullFrom = $ -> true;
acceptedItems = $ -> true;
onHeldInserted = $ -> {
};
incoming = new ArrayList<>(); incoming = new ArrayList<>();
itemHandler = new DepotItemHandler(this); itemHandler = new DepotItemHandler(this);
lazyItemHandler = LazyOptional.of(() -> itemHandler); lazyItemHandler = LazyOptional.of(() -> itemHandler);
@ -72,6 +78,16 @@ public class DepotBehaviour extends TileEntityBehaviour {
allowMerge = true; allowMerge = true;
} }
public DepotBehaviour withCallback(Consumer<ItemStack> changeListener) {
onHeldInserted = changeListener;
return this;
}
public DepotBehaviour onlyAccepts(Predicate<ItemStack> filter) {
acceptedItems = filter;
return this;
}
@Override @Override
public void tick() { public void tick() {
super.tick(); super.tick();
@ -245,6 +261,8 @@ public class DepotBehaviour extends TileEntityBehaviour {
public ItemStack insert(TransportedItemStack heldItem, boolean simulate) { public ItemStack insert(TransportedItemStack heldItem, boolean simulate) {
if (!canAcceptItems.get()) if (!canAcceptItems.get())
return heldItem.stack; return heldItem.stack;
if (!acceptedItems.test(heldItem.stack))
return heldItem.stack;
if (canMergeItems()) { if (canMergeItems()) {
int remainingSpace = getRemainingSpace(); int remainingSpace = getRemainingSpace();
@ -285,6 +303,7 @@ public class DepotBehaviour extends TileEntityBehaviour {
AllSoundEvents.DEPOT_PLOP.playOnServer(getWorld(), getPos()); AllSoundEvents.DEPOT_PLOP.playOnServer(getWorld(), getPos());
} }
this.heldItem = heldItem; this.heldItem = heldItem;
onHeldInserted.accept(heldItem.stack);
} }
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
@ -385,4 +404,8 @@ public class DepotBehaviour extends TileEntityBehaviour {
return TYPE; return TYPE;
} }
public boolean isItemValid(ItemStack stack) {
return acceptedItems.test(stack);
}
} }

View file

@ -66,7 +66,7 @@ public class DepotItemHandler implements IItemHandler {
@Override @Override
public boolean isItemValid(int slot, ItemStack stack) { public boolean isItemValid(int slot, ItemStack stack) {
return slot == MAIN_SLOT; return slot == MAIN_SLOT && te.isItemValid(stack);
} }
} }

View file

@ -96,7 +96,8 @@ public abstract class ArmInteractionPoint {
public static void addPoint(ArmInteractionPoint instance, Supplier<ArmInteractionPoint> factory) { public static void addPoint(ArmInteractionPoint instance, Supplier<ArmInteractionPoint> factory) {
if (POINTS.containsKey(instance)) if (POINTS.containsKey(instance))
Create.LOGGER.warn("Point for " + instance.getClass().getSimpleName() + " was overridden"); Create.LOGGER.warn("Point for " + instance.getClass()
.getSimpleName() + " was overridden");
POINTS.put(instance, factory); POINTS.put(instance, factory);
} }
@ -223,7 +224,8 @@ public abstract class ArmInteractionPoint {
@Override @Override
protected Vec3 getInteractionPositionVector() { protected Vec3 getInteractionPositionVector() {
return Vec3.atLowerCornerOf(pos).add(.5f, 1, .5f); return Vec3.atLowerCornerOf(pos)
.add(.5f, 1, .5f);
} }
} }
@ -232,12 +234,14 @@ public abstract class ArmInteractionPoint {
@Override @Override
protected Vec3 getInteractionPositionVector() { protected Vec3 getInteractionPositionVector() {
return Vec3.atLowerCornerOf(pos).add(.5f, 14 / 16f, .5f); return Vec3.atLowerCornerOf(pos)
.add(.5f, 14 / 16f, .5f);
} }
@Override @Override
protected boolean isValid(BlockGetter reader, BlockPos pos, BlockState state) { protected boolean isValid(BlockGetter reader, BlockPos pos, BlockState state) {
return AllBlocks.DEPOT.has(state) || AllBlocks.WEIGHTED_EJECTOR.has(state); return AllBlocks.DEPOT.has(state) || AllBlocks.WEIGHTED_EJECTOR.has(state)
|| AllBlocks.TRACK_STATION.has(state);
} }
} }
@ -274,7 +278,8 @@ public abstract class ArmInteractionPoint {
@Override @Override
protected Vec3 getInteractionPositionVector() { protected Vec3 getInteractionPositionVector() {
return Vec3.atLowerCornerOf(pos).add(.5f, 13 / 16f, .5f); return Vec3.atLowerCornerOf(pos)
.add(.5f, 13 / 16f, .5f);
} }
@Override @Override
@ -305,8 +310,8 @@ public abstract class ArmInteractionPoint {
@Override @Override
protected Vec3 getInteractionPositionVector() { protected Vec3 getInteractionPositionVector() {
return super.getInteractionPositionVector() return super.getInteractionPositionVector().add(Vec3.atLowerCornerOf(getInteractionDirection().getNormal())
.add(Vec3.atLowerCornerOf(getInteractionDirection().getNormal()).scale(.65f)); .scale(.65f));
} }
} }
@ -326,7 +331,8 @@ public abstract class ArmInteractionPoint {
@Override @Override
protected ItemStack insert(Level world, ItemStack stack, boolean simulate) { protected ItemStack insert(Level world, ItemStack stack, boolean simulate) {
ItemStack input = stack.copy(); ItemStack input = stack.copy();
InteractionResultHolder<ItemStack> res = BlazeBurnerBlock.tryInsert(state, world, pos, input, false, false, simulate); InteractionResultHolder<ItemStack> res =
BlazeBurnerBlock.tryInsert(state, world, pos, input, false, false, simulate);
ItemStack remainder = res.getObject(); ItemStack remainder = res.getObject();
if (input.isEmpty()) { if (input.isEmpty()) {
return remainder; return remainder;
@ -370,8 +376,8 @@ public abstract class ArmInteractionPoint {
@Override @Override
protected Vec3 getInteractionPositionVector() { protected Vec3 getInteractionPositionVector() {
return super.getInteractionPositionVector() return super.getInteractionPositionVector().add(Vec3.atLowerCornerOf(getInteractionDirection().getNormal())
.add(Vec3.atLowerCornerOf(getInteractionDirection().getNormal()).scale(.5f)); .scale(.5f));
} }
} }
@ -486,7 +492,8 @@ public abstract class ArmInteractionPoint {
protected Vec3 getInteractionPositionVector() { protected Vec3 getInteractionPositionVector() {
return VecHelper.getCenterOf(pos) return VecHelper.getCenterOf(pos)
.add(Vec3.atLowerCornerOf(FunnelBlock.getFunnelFacing(state) .add(Vec3.atLowerCornerOf(FunnelBlock.getFunnelFacing(state)
.getNormal()).scale(-.15f)); .getNormal())
.scale(-.15f));
} }
@Override @Override
@ -510,7 +517,8 @@ public abstract class ArmInteractionPoint {
FilteringBehaviour filtering = TileEntityBehaviour.get(world, pos, FilteringBehaviour.TYPE); FilteringBehaviour filtering = TileEntityBehaviour.get(world, pos, FilteringBehaviour.TYPE);
InvManipulationBehaviour inserter = TileEntityBehaviour.get(world, pos, InvManipulationBehaviour.TYPE); InvManipulationBehaviour inserter = TileEntityBehaviour.get(world, pos, InvManipulationBehaviour.TYPE);
BlockState state = world.getBlockState(pos); BlockState state = world.getBlockState(pos);
if (state.getOptionalValue(BlockStateProperties.POWERED).orElse(false)) if (state.getOptionalValue(BlockStateProperties.POWERED)
.orElse(false))
return stack; return stack;
if (inserter == null) if (inserter == null)
return stack; return stack;
@ -535,7 +543,8 @@ public abstract class ArmInteractionPoint {
protected boolean isValid(BlockGetter reader, BlockPos pos, BlockState state) { protected boolean isValid(BlockGetter reader, BlockPos pos, BlockState state) {
return state.getBlock() instanceof AbstractFunnelBlock return state.getBlock() instanceof AbstractFunnelBlock
&& !(state.hasProperty(FunnelBlock.EXTRACTING) && state.getValue(FunnelBlock.EXTRACTING)) && !(state.hasProperty(FunnelBlock.EXTRACTING) && state.getValue(FunnelBlock.EXTRACTING))
&& !(state.hasProperty(BeltFunnelBlock.SHAPE) && state.getValue(BeltFunnelBlock.SHAPE) == Shape.PUSHING); && !(state.hasProperty(BeltFunnelBlock.SHAPE)
&& state.getValue(BeltFunnelBlock.SHAPE) == Shape.PUSHING);
} }
@Override @Override

View file

@ -4,6 +4,7 @@ import com.simibubi.create.AllItems;
import com.simibubi.create.AllShapes; import com.simibubi.create.AllShapes;
import com.simibubi.create.AllSoundEvents; import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.AllTileEntities; import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.logistics.block.depot.SharedDepotBlockMethods;
import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.gui.ScreenOpener; import com.simibubi.create.foundation.gui.ScreenOpener;
@ -12,6 +13,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -61,6 +63,17 @@ public class StationBlock extends Block implements ITE<StationTileEntity> {
super.fillItemCategory(pTab, pItems); super.fillItemCategory(pTab, pItems);
} }
@Override
public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
SharedDepotBlockMethods.onReplaced(state, worldIn, pos, newState, isMoving);
}
@Override
public void updateEntityAfterFallOn(BlockGetter worldIn, Entity entityIn) {
super.updateEntityAfterFallOn(worldIn, entityIn);
SharedDepotBlockMethods.onLanded(worldIn, entityIn);
}
@Override @Override
public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand,
BlockHitResult pHit) { BlockHitResult pHit) {
@ -79,7 +92,8 @@ public class StationBlock extends Block implements ITE<StationTileEntity> {
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
pPlayer.getInventory() pPlayer.getInventory()
.placeItemBackInInventory(autoSchedule.copy()); .placeItemBackInInventory(autoSchedule.copy());
station.autoSchedule.setStackInSlot(0, ItemStack.EMPTY); station.depotBehaviour.removeHeldItem();
station.notifyUpdate();
AllSoundEvents.playItemPickup(pPlayer); AllSoundEvents.playItemPickup(pPlayer);
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
}); });

View file

@ -2,11 +2,10 @@ package com.simibubi.create.content.logistics.trains.management.edgePoint.statio
import com.jozufozu.flywheel.core.PartialModel; import com.jozufozu.flywheel.core.PartialModel;
import com.jozufozu.flywheel.util.transform.Transform; import com.jozufozu.flywheel.util.transform.Transform;
import com.jozufozu.flywheel.util.transform.TransformStack;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Vector3f;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.logistics.block.depot.DepotRenderer;
import com.simibubi.create.content.logistics.trains.ITrackBlock; import com.simibubi.create.content.logistics.trains.ITrackBlock;
import com.simibubi.create.content.logistics.trains.management.edgePoint.TrackTargetingBehaviour; import com.simibubi.create.content.logistics.trains.management.edgePoint.TrackTargetingBehaviour;
import com.simibubi.create.content.logistics.trains.management.edgePoint.TrackTargetingBehaviour.RenderedTrackOverlayType; import com.simibubi.create.content.logistics.trains.management.edgePoint.TrackTargetingBehaviour.RenderedTrackOverlayType;
@ -14,23 +13,17 @@ import com.simibubi.create.foundation.render.CachedBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
public class StationRenderer extends SafeTileEntityRenderer<StationTileEntity> { public class StationRenderer extends SafeTileEntityRenderer<StationTileEntity> {
@ -44,10 +37,8 @@ public class StationRenderer extends SafeTileEntityRenderer<StationTileEntity> {
TrackTargetingBehaviour<GlobalStation> target = te.edgePoint; TrackTargetingBehaviour<GlobalStation> target = te.edgePoint;
BlockPos targetPosition = target.getGlobalPosition(); BlockPos targetPosition = target.getGlobalPosition();
Level level = te.getLevel(); Level level = te.getLevel();
ItemStack autoSchedule = te.getAutoSchedule();
if (!autoSchedule.isEmpty()) DepotRenderer.renderItemsOf(te, partialTicks, ms, buffer, light, overlay, te.depotBehaviour);
renderItem(autoSchedule, te, partialTicks, ms, buffer, light, overlay);
BlockState trackState = level.getBlockState(targetPosition); BlockState trackState = level.getBlockState(targetPosition);
Block block = trackState.getBlock(); Block block = trackState.getBlock();
@ -114,31 +105,6 @@ public class StationRenderer extends SafeTileEntityRenderer<StationTileEntity> {
ms.popPose(); ms.popPose();
} }
public static void renderItem(ItemStack itemStack, StationTileEntity te, float partialTicks, PoseStack ms,
MultiBufferSource buffer, int light, int overlay) {
ItemRenderer itemRenderer = Minecraft.getInstance()
.getItemRenderer();
TransformStack msr = TransformStack.cast(ms);
ms.pushPose();
msr.centre();
Entity renderViewEntity = Minecraft.getInstance().cameraEntity;
if (renderViewEntity != null) {
Vec3 positionVec = renderViewEntity.position();
Vec3 vectorForOffset = Vec3.atCenterOf(te.getBlockPos());
Vec3 diff = vectorForOffset.subtract(positionVec);
float yRot = (float) (Mth.atan2(diff.x, diff.z) + Math.PI);
ms.mulPose(Vector3f.YP.rotation(yRot));
}
ms.translate(0, 10 / 32d, 0);
ms.scale(.75f, .75f, .75f);
itemRenderer.renderStatic(itemStack, TransformType.FIXED, light, overlay, ms, buffer, 0);
ms.popPose();
}
public static void renderFlag(PartialModel flag, StationTileEntity te, float partialTicks, PoseStack ms, public static void renderFlag(PartialModel flag, StationTileEntity te, float partialTicks, PoseStack ms,
MultiBufferSource buffer, int light, int overlay) { MultiBufferSource buffer, int light, int overlay) {
if (!te.resolveFlagAngle()) if (!te.resolveFlagAngle())
@ -161,11 +127,12 @@ public class StationRenderer extends SafeTileEntityRenderer<StationTileEntity> {
progress += (Math.sin(wiggleProgress * (2 * Mth.PI) * 4) / 8f) / Math.max(1, 8f * wiggleProgress); progress += (Math.sin(wiggleProgress * (2 * Mth.PI) * 4) / 8f) / Math.max(1, 8f * wiggleProgress);
} }
float nudge = 1 / 512f;
flag.centre() flag.centre()
.rotateY(yRot) .rotateY(yRot)
.translate(1 / 64f, 4.5f / 16f, flipped ? 13.5f / 16f : 2.5f / 16f) .translate(nudge, 9.5f / 16f, flipped ? 14f / 16f - nudge : 2f / 16f + nudge)
.unCentre() .unCentre()
.rotateX((flipped ? 1 : -1) * (progress * 60 + 300)); .rotateX((flipped ? 1 : -1) * (progress * 90 + 270));
} }
@Override @Override

View file

@ -16,6 +16,7 @@ import com.simibubi.create.AllItems;
import com.simibubi.create.AllSoundEvents; import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.Create; import com.simibubi.create.Create;
import com.simibubi.create.content.contraptions.components.structureMovement.AssemblyException; import com.simibubi.create.content.contraptions.components.structureMovement.AssemblyException;
import com.simibubi.create.content.logistics.block.depot.DepotBehaviour;
import com.simibubi.create.content.logistics.trains.IBogeyBlock; import com.simibubi.create.content.logistics.trains.IBogeyBlock;
import com.simibubi.create.content.logistics.trains.ITrackBlock; import com.simibubi.create.content.logistics.trains.ITrackBlock;
import com.simibubi.create.content.logistics.trains.TrackEdge; import com.simibubi.create.content.logistics.trains.TrackEdge;
@ -64,9 +65,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemStackHandler;
import net.minecraftforge.network.PacketDistributor; import net.minecraftforge.network.PacketDistributor;
public class StationTileEntity extends SmartTileEntity { public class StationTileEntity extends SmartTileEntity {
@ -76,8 +74,7 @@ public class StationTileEntity extends SmartTileEntity {
protected int failedCarriageIndex; protected int failedCarriageIndex;
protected AssemblyException lastException; protected AssemblyException lastException;
protected IItemHandlerModifiable autoSchedule; protected DepotBehaviour depotBehaviour;
protected LazyOptional<IItemHandler> capability;
// for display // for display
UUID imminentTrain; UUID imminentTrain;
@ -95,16 +92,16 @@ public class StationTileEntity extends SmartTileEntity {
setLazyTickRate(20); setLazyTickRate(20);
lastException = null; lastException = null;
failedCarriageIndex = -1; failedCarriageIndex = -1;
autoSchedule = new StationInventory();
capability = LazyOptional.of(() -> autoSchedule);
flag = LerpedFloat.linear() flag = LerpedFloat.linear()
.startWithValue(0); .startWithValue(0);
} }
@Override @Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) { public void addBehaviours(List<TileEntityBehaviour> behaviours) {
edgePoint = new TrackTargetingBehaviour<>(this, EdgePointType.STATION); behaviours.add(edgePoint = new TrackTargetingBehaviour<>(this, EdgePointType.STATION));
behaviours.add(edgePoint); behaviours.add(depotBehaviour = new DepotBehaviour(this).onlyAccepts(AllItems.SCHEDULE::isIn)
.withCallback(s -> applyAutoSchedule()));
depotBehaviour.addSubBehaviours(behaviours);
} }
@Override @Override
@ -114,8 +111,6 @@ public class StationTileEntity extends SmartTileEntity {
super.read(tag, clientPacket); super.read(tag, clientPacket);
invalidateRenderBoundingBox(); invalidateRenderBoundingBox();
autoSchedule.setStackInSlot(0, ItemStack.of(tag.getCompound("HeldItem")));
if (!clientPacket) if (!clientPacket)
return; return;
if (!tag.contains("ImminentTrain")) { if (!tag.contains("ImminentTrain")) {
@ -138,8 +133,6 @@ public class StationTileEntity extends SmartTileEntity {
protected void write(CompoundTag tag, boolean clientPacket) { protected void write(CompoundTag tag, boolean clientPacket) {
AssemblyException.write(tag, lastException); AssemblyException.write(tag, lastException);
tag.putInt("FailedCarriageIndex", failedCarriageIndex); tag.putInt("FailedCarriageIndex", failedCarriageIndex);
tag.put("HeldItem", autoSchedule.getStackInSlot(0)
.serializeNBT());
super.write(tag, clientPacket); super.write(tag, clientPacket);
@ -620,13 +613,13 @@ public class StationTileEntity extends SmartTileEntity {
} }
public ItemStack getAutoSchedule() { public ItemStack getAutoSchedule() {
return autoSchedule.getStackInSlot(0); return depotBehaviour.getHeldItemStack();
} }
@Override @Override
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) { public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) {
if (isItemHandlerCap(cap)) if (isItemHandlerCap(cap))
return capability.cast(); return depotBehaviour.getItemCapability(cap, side);
return super.getCapability(cap, side); return super.getCapability(cap, side);
} }
@ -649,7 +642,7 @@ public class StationTileEntity extends SmartTileEntity {
if (!(level instanceof ServerLevel server)) if (!(level instanceof ServerLevel server))
return; return;
Vec3 v = Vec3.atCenterOf(worldPosition); Vec3 v = Vec3.atBottomCenterOf(worldPosition.above());
server.sendParticles(ParticleTypes.HAPPY_VILLAGER, v.x, v.y, v.z, 8, 0.35, 0.05, 0.35, 1); server.sendParticles(ParticleTypes.HAPPY_VILLAGER, v.x, v.y, v.z, 8, 0.35, 0.05, 0.35, 1);
server.sendParticles(ParticleTypes.END_ROD, v.x, v.y + .25f, v.z, 10, 0.05, 1, 0.05, 0.005f); server.sendParticles(ParticleTypes.END_ROD, v.x, v.y + .25f, v.z, 10, 0.05, 1, 0.05, 0.005f);
} }
@ -684,23 +677,4 @@ public class StationTileEntity extends SmartTileEntity {
return true; return true;
} }
private class StationInventory extends ItemStackHandler {
public StationInventory() {
super(1);
}
@Override
protected void onContentsChanged(int slot) {
applyAutoSchedule();
sendData();
}
@Override
public boolean isItemValid(int slot, ItemStack stack) {
return super.isItemValid(slot, stack) && AllItems.SCHEDULE.isIn(stack);
}
}
} }

View file

@ -1,45 +1,40 @@
{ {
"credit": "Made with Blockbench", "credit": "Made with Blockbench",
"parent": "block/block",
"textures": { "textures": {
"6": "create:block/bogey/frame", "0": "create:block/station",
"1_1": "create:block/signal_box_top", "particle": "create:block/station"
"particle": "create:block/signal_box",
"1_0": "create:block/signal_box"
}, },
"elements": [ "elements": [
{
"from": [1, 6, 1],
"to": [15, 8, 15],
"faces": {
"north": {"uv": [0, 14, 16, 16], "texture": "#1_0"},
"east": {"uv": [0, 14, 16, 16], "texture": "#1_0"},
"south": {"uv": [0, 14, 16, 16], "texture": "#1_0"},
"west": {"uv": [0, 14, 16, 16], "texture": "#1_0"},
"up": {"uv": [1, 1, 15, 15], "texture": "#1_1"}
}
},
{ {
"from": [1, 2, 1], "from": [1, 2, 1],
"to": [15, 6, 15], "to": [15, 13, 15],
"faces": { "faces": {
"north": {"uv": [0, 4, 7, 6], "texture": "#6"}, "north": {"uv": [0.5, 1.5, 7.5, 7], "texture": "#0"},
"east": {"uv": [0, 4, 7, 6], "texture": "#6"}, "east": {"uv": [0.5, 1.5, 7.5, 7], "texture": "#0"},
"south": {"uv": [0, 4, 7, 6], "texture": "#6"}, "south": {"uv": [0.5, 1.5, 7.5, 7], "texture": "#0"},
"west": {"uv": [0, 4, 7, 6], "texture": "#6"} "west": {"uv": [0.5, 1.5, 7.5, 7], "texture": "#0"},
"up": {"uv": [8.5, 0.5, 15.5, 7.5], "texture": "#0"}
} }
}, },
{ {
"from": [0, 0, 0], "from": [0, 0, 0],
"to": [16, 2, 16], "to": [16, 2, 16],
"faces": { "faces": {
"north": {"uv": [0, 14, 16, 16], "texture": "#1_0"}, "north": {"uv": [0, 7, 8, 8], "texture": "#0"},
"east": {"uv": [0, 14, 16, 16], "texture": "#1_0"}, "east": {"uv": [8, 7, 0, 8], "texture": "#0"},
"south": {"uv": [0, 14, 16, 16], "texture": "#1_0"}, "south": {"uv": [0, 7, 8, 8], "texture": "#0"},
"west": {"uv": [0, 14, 16, 16], "texture": "#1_0"}, "west": {"uv": [0, 7, 8, 8], "texture": "#0"},
"up": {"uv": [0, 0, 16, 16], "texture": "#1_1"}, "up": {"uv": [0, 8, 8, 16], "texture": "#0"},
"down": {"uv": [0, 0, 16, 16], "texture": "#1_1"} "down": {"uv": [8, 8, 16, 16], "texture": "#0"}
} }
} }
],
"groups": [
{
"name": "Base",
"origin": [8, 8, 8],
"color": 0,
"children": [0, 1]
}
] ]
} }

View file

@ -1,76 +1,43 @@
{ {
"credit": "Made with Blockbench", "credit": "Made with Blockbench",
"parent": "block/block",
"ambientocclusion": false,
"texture_size": [32, 32],
"textures": { "textures": {
"2": "create:entity/blueprint_small", "0": "create:block/station",
"6": "create:block/bogey/frame", "1": "create:entity/blueprint_small",
"particle": "create:block/signal_box", "particle": "create:block/station"
"1_0": "create:block/signal_box"
}, },
"elements": [ "elements": [
{ {
"from": [0, 1, -1], "name": "Flag Pole",
"to": [1, 13, 1],
"faces": {
"north": {"uv": [3.5, 7, 4, 13], "texture": "#6"},
"east": {"uv": [4.5, 7, 3.5, 13], "texture": "#6"},
"south": {"uv": [4, 7, 4.5, 13], "texture": "#6"},
"west": {"uv": [3.5, 7, 4.5, 13], "texture": "#6"},
"up": {"uv": [3.5, 7.5, 4.5, 7], "rotation": 90, "texture": "#6"}
}
},
{
"from": [0, -1, -1], "from": [0, -1, -1],
"to": [1, 1, 1], "to": [1, 13, 1],
"rotation": {"angle": 0, "axis": "x", "origin": [14, 0, 0]},
"faces": { "faces": {
"north": {"uv": [4, 7, 3.5, 8], "texture": "#6"}, "north": {"uv": [0.5, 1, 7.5, 1.5], "rotation": 90, "texture": "#0"},
"east": {"uv": [4.5, 7, 3.5, 8], "texture": "#6"}, "east": {"uv": [0.5, 0.5, 7.5, 1.5], "rotation": 90, "texture": "#0"},
"south": {"uv": [4.5, 7, 4, 8], "texture": "#6"}, "south": {"uv": [0.5, 0.5, 7.5, 1], "rotation": 90, "texture": "#0"},
"west": {"uv": [4.5, 7, 3.5, 8], "texture": "#6"}, "west": {"uv": [0.5, 0.5, 7.5, 1.5], "rotation": 90, "texture": "#0"},
"down": {"uv": [3.5, 8, 4.5, 7.5], "rotation": 270, "texture": "#6"} "up": {"uv": [7.5, 0.5, 7, 1.5], "rotation": 180, "texture": "#0"},
"down": {"uv": [1, 0.5, 0.5, 1.5], "texture": "#0"}
} }
}, },
{ {
"from": [0.5, 9, -7], "name": "Flag",
"to": [0.5, 13, 0], "from": [0.5, 9, -6.5],
"to": [0.5, 13, -0.5],
"rotation": {"angle": 0, "axis": "x", "origin": [14, 0, 0]},
"faces": { "faces": {
"east": {"uv": [1, 9, 5, 2], "rotation": 90, "texture": "#2"}, "east": {"uv": [2, 1, 6, 7], "rotation": 270, "texture": "#1"},
"west": {"uv": [1, 2, 5, 9], "rotation": 90, "texture": "#2"}, "west": {"uv": [2, 1, 6, 7], "rotation": 90, "texture": "#1"}
"down": {"uv": [0, 14, 4, 14], "rotation": 270, "texture": "#1_0"}
} }
} }
], ],
"display": { "display": {},
"thirdperson_righthand": { "groups": [
"rotation": [75, 45, 0], {
"translation": [0, 2.5, 0], "name": "Flag",
"scale": [0.375, 0.375, 0.375] "origin": [8, 8, 8],
}, "color": 0,
"thirdperson_lefthand": { "children": [0, 1]
"rotation": [75, 45, 0],
"translation": [0, 2.5, 0],
"scale": [0.375, 0.375, 0.375]
},
"firstperson_righthand": {
"rotation": [0, 45, 0],
"scale": [0.4, 0.4, 0.4]
},
"firstperson_lefthand": {
"rotation": [0, 225, 0],
"scale": [0.4, 0.4, 0.4]
},
"ground": {
"translation": [0, 3, 0],
"scale": [0.25, 0.25, 0.25]
},
"gui": {
"rotation": [30, 225, 0],
"scale": [0.625, 0.625, 0.625]
},
"fixed": {
"scale": [0.5, 0.5, 0.5]
} }
} ]
} }

View file

@ -1,43 +1,43 @@
{ {
"credit": "Made with Blockbench", "credit": "Made with Blockbench",
"parent": "block/block",
"textures": { "textures": {
"2": "create:block/indicator/0", "0": "create:block/station",
"6": "create:block/bogey/frame", "1": "create:block/indicator/0",
"particle": "create:block/signal_box", "particle": "create:block/station"
"1_0": "create:block/signal_box"
}, },
"elements": [ "elements": [
{ {
"from": [0, 1, -1], "name": "Flag Pole",
"to": [1, 13, 1],
"faces": {
"north": {"uv": [3.5, 7, 4, 13], "texture": "#6"},
"east": {"uv": [4.5, 7, 3.5, 13], "texture": "#6"},
"south": {"uv": [4, 7, 4.5, 13], "texture": "#6"},
"west": {"uv": [3.5, 7, 4.5, 13], "texture": "#6"},
"up": {"uv": [3.5, 7.5, 4.5, 7], "rotation": 90, "texture": "#6"}
}
},
{
"from": [0, -1, -1], "from": [0, -1, -1],
"to": [1, 1, 1], "to": [1, 13, 1],
"rotation": {"angle": 0, "axis": "x", "origin": [14, 0, 0]},
"faces": { "faces": {
"north": {"uv": [4, 7, 3.5, 8], "texture": "#6"}, "north": {"uv": [0.5, 1, 7.5, 1.5], "rotation": 90, "texture": "#0"},
"east": {"uv": [4.5, 7, 3.5, 8], "texture": "#6"}, "east": {"uv": [0.5, 0.5, 7.5, 1.5], "rotation": 90, "texture": "#0"},
"south": {"uv": [4.5, 7, 4, 8], "texture": "#6"}, "south": {"uv": [0.5, 0.5, 7.5, 1], "rotation": 90, "texture": "#0"},
"west": {"uv": [4.5, 7, 3.5, 8], "texture": "#6"}, "west": {"uv": [0.5, 0.5, 7.5, 1.5], "rotation": 90, "texture": "#0"},
"down": {"uv": [3.5, 8, 4.5, 7.5], "rotation": 270, "texture": "#6"} "up": {"uv": [7.5, 0.5, 7, 1.5], "rotation": 180, "texture": "#0"},
"down": {"uv": [1, 0.5, 0.5, 1.5], "texture": "#0"}
} }
}, },
{ {
"from": [0.5, 9, -7], "name": "Flag",
"to": [0.5, 13, 0], "from": [0.5, 9, -6.5],
"to": [0.5, 13, -0.5],
"rotation": {"angle": 0, "axis": "x", "origin": [14, 0, 0]},
"faces": { "faces": {
"east": {"uv": [0, 0, 4, 7], "rotation": 90, "texture": "#2"}, "east": {"uv": [0, 0, 4, 6], "rotation": 270, "texture": "#1"},
"west": {"uv": [0, 0, 4, 7], "rotation": 270, "texture": "#2"}, "west": {"uv": [0, 0, 4, 6], "rotation": 90, "texture": "#1"}
"down": {"uv": [0, 14, 4, 14], "rotation": 270, "texture": "#1_0"}
} }
} }
],
"display": {},
"groups": [
{
"name": "Flag",
"origin": [8, 8, 8],
"color": 0,
"children": [0, 1]
}
] ]
} }

View file

@ -1,43 +1,43 @@
{ {
"credit": "Made with Blockbench", "credit": "Made with Blockbench",
"parent": "block/block",
"textures": { "textures": {
"2": "create:block/indicator/6", "0": "create:block/station",
"6": "create:block/bogey/frame", "1": "create:block/indicator/6",
"particle": "create:block/signal_box", "particle": "create:block/station"
"1_0": "create:block/signal_box"
}, },
"elements": [ "elements": [
{ {
"from": [0, 1, -1], "name": "Flag Pole",
"to": [1, 13, 1],
"faces": {
"north": {"uv": [3.5, 7, 4, 13], "texture": "#6"},
"east": {"uv": [4.5, 7, 3.5, 13], "texture": "#6"},
"south": {"uv": [4, 7, 4.5, 13], "texture": "#6"},
"west": {"uv": [3.5, 7, 4.5, 13], "texture": "#6"},
"up": {"uv": [3.5, 7.5, 4.5, 7], "rotation": 90, "texture": "#6"}
}
},
{
"from": [0, -1, -1], "from": [0, -1, -1],
"to": [1, 1, 1], "to": [1, 13, 1],
"rotation": {"angle": 0, "axis": "x", "origin": [14, 0, 0]},
"faces": { "faces": {
"north": {"uv": [4, 7, 3.5, 8], "texture": "#6"}, "north": {"uv": [0.5, 1, 7.5, 1.5], "rotation": 90, "texture": "#0"},
"east": {"uv": [4.5, 7, 3.5, 8], "texture": "#6"}, "east": {"uv": [0.5, 0.5, 7.5, 1.5], "rotation": 90, "texture": "#0"},
"south": {"uv": [4.5, 7, 4, 8], "texture": "#6"}, "south": {"uv": [0.5, 0.5, 7.5, 1], "rotation": 90, "texture": "#0"},
"west": {"uv": [4.5, 7, 3.5, 8], "texture": "#6"}, "west": {"uv": [0.5, 0.5, 7.5, 1.5], "rotation": 90, "texture": "#0"},
"down": {"uv": [3.5, 8, 4.5, 7.5], "rotation": 270, "texture": "#6"} "up": {"uv": [7.5, 0.5, 7, 1.5], "rotation": 180, "texture": "#0"},
"down": {"uv": [1, 0.5, 0.5, 1.5], "texture": "#0"}
} }
}, },
{ {
"from": [0.5, 9, -7], "name": "Flag",
"to": [0.5, 13, 0], "from": [0.5, 9, -6.5],
"to": [0.5, 13, -0.5],
"rotation": {"angle": 0, "axis": "x", "origin": [14, 0, 0]},
"faces": { "faces": {
"east": {"uv": [0, 0, 4, 7], "rotation": 90, "texture": "#2"}, "east": {"uv": [0, 0, 4, 6], "rotation": 270, "texture": "#1"},
"west": {"uv": [0, 0, 4, 7], "rotation": 270, "texture": "#2"}, "west": {"uv": [0, 0, 4, 6], "rotation": 90, "texture": "#1"}
"down": {"uv": [0, 14, 4, 14], "rotation": 270, "texture": "#1_0"}
} }
} }
],
"display": {},
"groups": [
{
"name": "Flag",
"origin": [8, 8, 8],
"color": 0,
"children": [0, 1]
}
] ]
} }

View file

@ -1,76 +1,56 @@
{ {
"credit": "Made with Blockbench", "credit": "Made with Blockbench",
"parent": "block/block",
"textures": { "textures": {
"2": "create:block/indicator/6", "0": "create:block/station",
"6": "create:block/bogey/frame", "1": "create:block/indicator/6",
"1_1": "create:block/signal_box_top", "particle": "create:block/station"
"particle": "create:block/signal_box",
"1_0": "create:block/signal_box"
}, },
"elements": [ "elements": [
{
"from": [1, 6, 1],
"to": [15, 8, 15],
"faces": {
"north": {"uv": [0, 14, 16, 16], "texture": "#1_0"},
"east": {"uv": [0, 14, 16, 16], "texture": "#1_0"},
"south": {"uv": [0, 14, 16, 16], "texture": "#1_0"},
"west": {"uv": [0, 14, 16, 16], "texture": "#1_0"},
"up": {"uv": [1, 1, 15, 15], "texture": "#1_1"}
}
},
{ {
"from": [1, 2, 1], "from": [1, 2, 1],
"to": [15, 6, 15], "to": [15, 13, 15],
"faces": { "faces": {
"north": {"uv": [0, 4, 7, 6], "texture": "#6"}, "north": {"uv": [0.5, 1.5, 7.5, 7], "texture": "#0"},
"east": {"uv": [0, 4, 7, 6], "texture": "#6"}, "east": {"uv": [0.5, 1.5, 7.5, 7], "texture": "#0"},
"south": {"uv": [0, 4, 7, 6], "texture": "#6"}, "south": {"uv": [0.5, 1.5, 7.5, 7], "texture": "#0"},
"west": {"uv": [0, 4, 7, 6], "texture": "#6"} "west": {"uv": [0.5, 1.5, 7.5, 7], "texture": "#0"},
"up": {"uv": [8.5, 0.5, 15.5, 7.5], "texture": "#0"}
} }
}, },
{ {
"from": [0, 0, 0], "from": [0, 0, 0],
"to": [16, 2, 16], "to": [16, 2, 16],
"faces": { "faces": {
"north": {"uv": [0, 14, 16, 16], "texture": "#1_0"}, "north": {"uv": [0, 7, 8, 8], "texture": "#0"},
"east": {"uv": [0, 14, 16, 16], "texture": "#1_0"}, "east": {"uv": [8, 7, 0, 8], "texture": "#0"},
"south": {"uv": [0, 14, 16, 16], "texture": "#1_0"}, "south": {"uv": [0, 7, 8, 8], "texture": "#0"},
"west": {"uv": [0, 14, 16, 16], "texture": "#1_0"}, "west": {"uv": [0, 7, 8, 8], "texture": "#0"},
"up": {"uv": [0, 0, 16, 16], "texture": "#1_1"}, "up": {"uv": [0, 8, 8, 16], "texture": "#0"},
"down": {"uv": [0, 0, 16, 16], "texture": "#1_1"} "down": {"uv": [8, 8, 16, 16], "texture": "#0"}
} }
}, },
{ {
"from": [15, 5.5, 12.5], "name": "Flag Pole",
"to": [16, 17.5, 14.5], "from": [15, 8.5, 13],
"to": [16, 22.5, 15],
"rotation": {"angle": 0, "axis": "x", "origin": [14, 8.5, 14]},
"faces": { "faces": {
"north": {"uv": [3.5, 7, 4, 13], "texture": "#6"}, "north": {"uv": [0.5, 0.5, 7.5, 1], "rotation": 270, "texture": "#0"},
"east": {"uv": [4.5, 7, 3.5, 13], "texture": "#6"}, "east": {"uv": [0.5, 0.5, 7.5, 1.5], "rotation": 270, "texture": "#0"},
"south": {"uv": [4, 7, 4.5, 13], "texture": "#6"}, "south": {"uv": [0.5, 0.5, 7.5, 1], "rotation": 270, "texture": "#0"},
"west": {"uv": [3.5, 7, 4.5, 13], "texture": "#6"}, "west": {"uv": [0.5, 0.5, 7.5, 1.5], "rotation": 90, "texture": "#0"},
"up": {"uv": [3.5, 7.5, 4.5, 7], "rotation": 90, "texture": "#6"} "up": {"uv": [7.5, 0.5, 7, 1.5], "rotation": 180, "texture": "#0"},
"down": {"uv": [1, 0.5, 0.5, 1.5], "texture": "#0"}
} }
}, },
{ {
"from": [15, 3.5, 12.5], "name": "Flag",
"to": [16, 5.5, 14.5], "from": [15.5, 18.5, 7.5],
"to": [15.5, 22.5, 13.5],
"rotation": {"angle": 0, "axis": "x", "origin": [14, 8.5, 14]},
"faces": { "faces": {
"north": {"uv": [4, 7, 3.5, 8], "texture": "#6"}, "east": {"uv": [0, 0, 4, 6], "rotation": 270, "texture": "#1"},
"east": {"uv": [4.5, 7, 3.5, 8], "texture": "#6"}, "west": {"uv": [0, 0, 4, 6], "rotation": 90, "texture": "#1"}
"south": {"uv": [4.5, 7, 4, 8], "texture": "#6"},
"west": {"uv": [4.5, 7, 3.5, 8], "texture": "#6"},
"down": {"uv": [3.5, 8, 4.5, 7.5], "rotation": 270, "texture": "#6"}
}
},
{
"from": [15.5, 13.5, 6.5],
"to": [15.5, 17.5, 13.5],
"faces": {
"east": {"uv": [0, 0, 4, 7], "rotation": 90, "texture": "#2"},
"west": {"uv": [0, 0, 4, 7], "rotation": 270, "texture": "#2"},
"down": {"uv": [0, 14, 4, 14], "rotation": 270, "texture": "#1_0"}
} }
} }
], ],
@ -104,5 +84,19 @@
"fixed": { "fixed": {
"scale": [0.5, 0.5, 0.5] "scale": [0.5, 0.5, 0.5]
} }
} },
"groups": [
{
"name": "Base",
"origin": [8, 8, 8],
"color": 0,
"children": [0, 1]
},
{
"name": "Flag",
"origin": [8, 8, 8],
"color": 0,
"children": [2, 3]
}
]
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 308 B

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 284 B

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB