use of mods.railcraft.common.carts.EntityCartBed in project Railcraft by Railcraft.
the class PacketKeyPress method readData.
@Override
public void readData(RailcraftInputStream data) throws IOException {
int type = data.readByte();
binding = VALUES[type];
if (!(player.getRidingEntity() instanceof EntityMinecart))
return;
EntityMinecart cart = (EntityMinecart) player.getRidingEntity();
GameProfile gameProfile = player.getGameProfile();
switch(binding) {
case LOCOMOTIVE_REVERSE:
EntityLocomotive.applyAction(gameProfile, cart, false, loco -> loco.setReverse(!loco.isReverse()));
break;
case LOCOMOTIVE_INCREASE_SPEED:
EntityLocomotive.applyAction(gameProfile, cart, false, EntityLocomotive::increaseSpeed);
break;
case LOCOMOTIVE_DECREASE_SPEED:
EntityLocomotive.applyAction(gameProfile, cart, false, EntityLocomotive::decreaseSpeed);
break;
case LOCOMOTIVE_MODE_CHANGE:
EntityLocomotive.applyAction(gameProfile, cart, false, loco -> {
EntityLocomotive.LocoMode mode = loco.getMode();
if (mode == EntityLocomotive.LocoMode.RUNNING)
loco.setMode(EntityLocomotive.LocoMode.IDLE);
else
loco.setMode(EntityLocomotive.LocoMode.RUNNING);
});
break;
case LOCOMOTIVE_WHISTLE:
EntityLocomotive.applyAction(gameProfile, cart, true, EntityLocomotive::whistle);
break;
case BED_CART_SLEEP:
Entity ridden = player.getRidingEntity();
if (ridden instanceof EntityCartBed) {
((EntityCartBed) ridden).attemptSleep();
}
break;
}
}
Aggregations