adapt without event

This commit is contained in:
Corail31 2019-07-29 14:04:20 +02:00
parent d7412bb750
commit c341b1d687

View file

@ -38,19 +38,12 @@ import net.minecraft.world.GameRules;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.network.FMLPlayMessages;
import net.minecraftforge.fml.network.NetworkHooks;
import javax.annotation.Nullable;
import java.util.List;
import static biomesoplenty.core.BiomesOPlenty.MOD_ID;
@Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE)
public class BoatEntityBOP extends Entity {
private static final DataParameter<Integer> TIME_SINCE_HIT = EntityDataManager.createKey(BoatEntityBOP.class, DataSerializers.VARINT);
private static final DataParameter<Integer> FORWARD_DIRECTION = EntityDataManager.createKey(BoatEntityBOP.class, DataSerializers.VARINT);
@ -102,15 +95,6 @@ public class BoatEntityBOP extends Entity {
this(BOPEntities.boat_bop, world);
}
@SubscribeEvent
public static void onRidden(TickEvent.PlayerTickEvent event) {
if (event.side == LogicalSide.CLIENT && event.phase == TickEvent.Phase.START && event.player.getRidingEntity() instanceof BoatEntityBOP) {
ClientPlayerEntity player = (ClientPlayerEntity) event.player;
((BoatEntityBOP)event.player.getRidingEntity()).updateInputs(player.movementInput.leftKeyDown, player.movementInput.rightKeyDown, player.movementInput.forwardKeyDown, player.movementInput.backKeyDown);
player.rowingBoat |= player.movementInput.leftKeyDown || player.movementInput.rightKeyDown || player.movementInput.forwardKeyDown || player.movementInput.backKeyDown;
}
}
/**
* returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
* prevent them from trampling crops
@ -289,6 +273,15 @@ public class BoatEntityBOP extends Entity {
*/
@Override
public void tick() {
if (this.world.isRemote) {
Entity rider = getControllingPassenger();
if (rider instanceof PlayerEntity) {
ClientPlayerEntity player = (ClientPlayerEntity) rider;
updateInputs(player.movementInput.leftKeyDown, player.movementInput.rightKeyDown, player.movementInput.forwardKeyDown, player.movementInput.backKeyDown);
player.rowingBoat |= player.movementInput.leftKeyDown || player.movementInput.rightKeyDown || player.movementInput.forwardKeyDown || player.movementInput.backKeyDown;
}
}
this.previousStatus = this.status;
this.status = this.getBoatStatus();
if (this.status != BoatEntityBOP.Status.UNDER_WATER && this.status != BoatEntityBOP.Status.UNDER_FLOWING_WATER) {