|
23 | 23 | import com.railwayteam.railways.mixin_interfaces.ICarriageConductors;
|
24 | 24 | import com.railwayteam.railways.registry.CRBlocks;
|
25 | 25 | import com.railwayteam.railways.registry.CREntities;
|
| 26 | +import com.simibubi.create.AllItems; |
26 | 27 | import com.simibubi.create.Create;
|
| 28 | +import com.simibubi.create.content.contraptions.Contraption; |
27 | 29 | import com.simibubi.create.content.kinetics.deployer.DeployerFakePlayer;
|
28 | 30 | import com.simibubi.create.content.trains.entity.Carriage;
|
| 31 | +import com.simibubi.create.content.trains.entity.CarriageContraption; |
| 32 | +import com.simibubi.create.content.trains.entity.CarriageContraptionEntity; |
29 | 33 | import com.simibubi.create.content.trains.entity.Train;
|
30 | 34 | import com.simibubi.create.content.trains.schedule.Schedule;
|
31 | 35 | import com.simibubi.create.content.trains.schedule.ScheduleEntry;
|
| 36 | +import com.simibubi.create.content.trains.schedule.ScheduleItem; |
32 | 37 | import com.simibubi.create.content.trains.schedule.condition.ScheduledDelay;
|
33 | 38 | import com.simibubi.create.content.trains.schedule.destination.DestinationInstruction;
|
34 | 39 | import com.simibubi.create.content.trains.station.GlobalStation;
|
35 | 40 | import com.simibubi.create.content.trains.station.StationBlock;
|
36 | 41 | import com.simibubi.create.content.trains.station.StationBlockEntity;
|
| 42 | +import net.createmod.catnip.data.Couple; |
37 | 43 | import net.createmod.catnip.math.VecHelper;
|
38 | 44 | import net.minecraft.core.BlockPos;
|
39 | 45 | import net.minecraft.nbt.CompoundTag;
|
|
45 | 51 | import net.minecraft.world.InteractionHand;
|
46 | 52 | import net.minecraft.world.InteractionResult;
|
47 | 53 | import net.minecraft.world.entity.Entity;
|
| 54 | +import net.minecraft.world.entity.LivingEntity; |
48 | 55 | import net.minecraft.world.entity.item.ItemEntity;
|
49 | 56 | import net.minecraft.world.entity.player.Player;
|
50 | 57 | import net.minecraft.world.item.ItemStack;
|
|
58 | 65 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
59 | 66 |
|
60 | 67 | import java.util.ArrayList;
|
| 68 | +import java.util.List; |
61 | 69 | import java.util.UUID;
|
62 | 70 | import java.util.concurrent.atomic.AtomicBoolean;
|
63 | 71 |
|
@@ -231,6 +239,29 @@ private void deployersAssemble(BlockState pState, Level pLevel, BlockPos pPos, P
|
231 | 239 | }
|
232 | 240 | }
|
233 | 241 |
|
| 242 | + @Inject(method = "use", at = @At("HEAD"), cancellable = true, remap = true) |
| 243 | + private void deployerGiveSchedule(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHit, CallbackInfoReturnable<InteractionResult> cir) { |
| 244 | + ItemStack item = pPlayer.getItemInHand(pHand); |
| 245 | + if (!pLevel.isClientSide && pPlayer instanceof DeployerFakePlayer && pLevel.getBlockEntity(pPos) instanceof StationBlockEntity stationBe) { |
| 246 | + if (stationBe.getStation() != null && stationBe.getStation().getPresentTrain() != null) { |
| 247 | + Train train = stationBe.getStation().getPresentTrain(); |
| 248 | + if (train.runtime.getSchedule() == null) { |
| 249 | + Schedule schedule = ScheduleItem.getSchedule(item); |
| 250 | + if(schedule == null || schedule.entries.isEmpty()) |
| 251 | + return; |
| 252 | + |
| 253 | + train.runtime.setSchedule(schedule, false); |
| 254 | + item.shrink(1); |
| 255 | + pPlayer.setItemInHand(pHand, item.isEmpty() ? ItemStack.EMPTY : item); |
| 256 | + cir.setReturnValue(InteractionResult.SUCCESS); |
| 257 | + } else if(item.isEmpty()) { |
| 258 | + pPlayer.setItemInHand(pHand, train.runtime.returnSchedule()); |
| 259 | + cir.setReturnValue(InteractionResult.SUCCESS); |
| 260 | + } |
| 261 | + } |
| 262 | + } |
| 263 | + } |
| 264 | + |
234 | 265 | private boolean disassembleAndEnterMode(ServerPlayer sender, StationBlockEntity te) {
|
235 | 266 | GlobalStation station = te.getStation();
|
236 | 267 | if (station != null) {
|
|
0 commit comments