From b6513a05b197c489d3337a5538ac2035ac2abdaf Mon Sep 17 00:00:00 2001 From: Adubbz Date: Thu, 26 Dec 2019 16:34:54 +1100 Subject: [PATCH] Now compiles --- .../common/block/MushroomBlockBOP.java | 5 +- .../common/block/SaplingBlockBOP.java | 23 +- .../common/entity/item/BoatEntityBOP.java | 380 +++++++++++------- .../common/entity/item/BoatModelBOP.java | 123 +++--- .../common/entity/item/BoatRendererBOP.java | 86 ++-- .../common/item/BoatItemBOP.java | 2 +- .../common/item/DispenserBoatBehaviorBOP.java | 2 +- .../java/biomesoplenty/init/ModEntities.java | 5 +- 8 files changed, 342 insertions(+), 284 deletions(-) diff --git a/src/main/java/biomesoplenty/common/block/MushroomBlockBOP.java b/src/main/java/biomesoplenty/common/block/MushroomBlockBOP.java index d9d24b35f..d038ef8ce 100644 --- a/src/main/java/biomesoplenty/common/block/MushroomBlockBOP.java +++ b/src/main/java/biomesoplenty/common/block/MushroomBlockBOP.java @@ -15,6 +15,7 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.world.server.ServerWorld; import java.util.Random; @@ -26,7 +27,7 @@ public class MushroomBlockBOP extends MushroomBlock } @Override - public void tick(BlockState state, World worldIn, BlockPos pos, Random random) + public void tick(BlockState state, ServerWorld world, BlockPos pos, Random random) { } @@ -40,7 +41,7 @@ public class MushroomBlockBOP extends MushroomBlock } @Override - public boolean generateBigMushroom(IWorld worldIn, BlockPos pos, BlockState state, Random rand) + public boolean func_226940_a_(ServerWorld p_226940_1_, BlockPos p_226940_2_, BlockState p_226940_3_, Random p_226940_4_) { return false; } diff --git a/src/main/java/biomesoplenty/common/block/SaplingBlockBOP.java b/src/main/java/biomesoplenty/common/block/SaplingBlockBOP.java index 31b9d7739..7013a7a01 100644 --- a/src/main/java/biomesoplenty/common/block/SaplingBlockBOP.java +++ b/src/main/java/biomesoplenty/common/block/SaplingBlockBOP.java @@ -20,6 +20,7 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; +import net.minecraft.world.server.ServerWorld; import java.util.Random; @@ -43,27 +44,27 @@ public class SaplingBlockBOP extends SaplingBlock implements IGrowable } @Override - public void tick(BlockState state, World worldIn, BlockPos pos, Random random) + public void tick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - super.tick(state, worldIn, pos, random); - if (!worldIn.isAreaLoaded(pos, 1)) return; // Forge: prevent loading unloaded chunks when checking neighbor's light - if (worldIn.getLight(pos.up()) >= 9 && random.nextInt(7) == 0) { - this.grow(worldIn, pos, state, random); + super.tick(state, world, pos, random); + if (!world.isAreaLoaded(pos, 1)) return; // Forge: prevent loading unloaded chunks when checking neighbor's light + if (world.getLight(pos.up()) >= 9 && random.nextInt(7) == 0) { + this.func_225535_a_(world, random, pos, state); } } @Override - public void grow(IWorld worldIn, BlockPos pos, BlockState state, Random rand) + public void func_225535_a_(ServerWorld world, Random rand, BlockPos pos, BlockState state) { if (state.get(STAGE) == 0) { - worldIn.setBlockState(pos, state.cycle(STAGE), 4); + world.setBlockState(pos, state.cycle(STAGE), 4); } else { - if (!net.minecraftforge.event.ForgeEventFactory.saplingGrowTree(worldIn, rand, pos)) return; - this.tree.spawn(worldIn, pos, state, rand); + if (!net.minecraftforge.event.ForgeEventFactory.saplingGrowTree(world, rand, pos)) return; + this.tree.growTree(world, world.getChunkProvider().getChunkGenerator(), pos, state, rand); } } @@ -84,9 +85,9 @@ public class SaplingBlockBOP extends SaplingBlock implements IGrowable } @Override - public void grow(World worldIn, Random rand, BlockPos pos, BlockState state) + public void func_226942_a_(ServerWorld world, BlockPos pos, BlockState state, Random rand) { - this.grow(worldIn, pos, state, rand); + this.func_225535_a_(world, rand, pos, state); } @Override diff --git a/src/main/java/biomesoplenty/common/entity/item/BoatEntityBOP.java b/src/main/java/biomesoplenty/common/entity/item/BoatEntityBOP.java index ad51a1148..5c5d6c67c 100644 --- a/src/main/java/biomesoplenty/common/entity/item/BoatEntityBOP.java +++ b/src/main/java/biomesoplenty/common/entity/item/BoatEntityBOP.java @@ -23,6 +23,7 @@ import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.network.play.client.CSteerBoatPacket; +import net.minecraft.network.play.server.SSpawnObjectPacket; import net.minecraft.particles.ParticleTypes; import net.minecraft.tags.FluidTags; import net.minecraft.util.*; @@ -37,13 +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.fml.network.FMLPlayMessages; -import net.minecraftforge.fml.network.NetworkHooks; import javax.annotation.Nullable; import java.util.List; -public class BoatEntityBOP extends BoatEntity { +public class BoatEntityBOP extends BoatEntity +{ private static final DataParameter TIME_SINCE_HIT = EntityDataManager.createKey(BoatEntityBOP.class, DataSerializers.VARINT); private static final DataParameter FORWARD_DIRECTION = EntityDataManager.createKey(BoatEntityBOP.class, DataSerializers.VARINT); private static final DataParameter DAMAGE_TAKEN = EntityDataManager.createKey(BoatEntityBOP.class, DataSerializers.FLOAT); @@ -55,14 +55,20 @@ public class BoatEntityBOP extends BoatEntity { private float momentum; private float outOfControlTicks; private float deltaRotation; + private int lerpSteps; + private double lerpX; + private double lerpY; + private double lerpZ; + private double lerpYaw; + private double lerpPitch; private boolean leftInputDown; private boolean rightInputDown; private boolean forwardInputDown; private boolean backInputDown; private double waterLevel; private float boatGlide; - private Status status; - private Status previousStatus; + private BoatEntityBOP.Status status; + private BoatEntityBOP.Status previousStatus; private double lastYd; private boolean rocking; private boolean field_203060_aN; @@ -70,12 +76,14 @@ public class BoatEntityBOP extends BoatEntity { private float rockingAngle; private float prevRockingAngle; - public BoatEntityBOP(EntityType entityType, World world) { - super(entityType, world); + public BoatEntityBOP(EntityType p_i50129_1_, World p_i50129_2_) + { + super(p_i50129_1_, p_i50129_2_); this.preventEntitySpawning = true; } - public BoatEntityBOP(World worldIn, double x, double y, double z) { + public BoatEntityBOP(World worldIn, double x, double y, double z) + { this(BOPEntities.boat_bop, worldIn); this.setPosition(x, y, z); this.setMotion(Vec3d.ZERO); @@ -84,26 +92,26 @@ public class BoatEntityBOP extends BoatEntity { this.prevPosZ = z; } - public BoatEntityBOP(FMLPlayMessages.SpawnEntity spawnEntity, World world) { + public BoatEntityBOP(World world) + { this(BOPEntities.boat_bop, world); } @Override - protected void registerData() { + protected void registerData() + { this.dataManager.register(TIME_SINCE_HIT, 0); this.dataManager.register(FORWARD_DIRECTION, 1); this.dataManager.register(DAMAGE_TAKEN, 0.0F); - this.dataManager.register(BOAT_TYPE, Type.FIR.ordinal()); + this.dataManager.register(BOAT_TYPE, BoatEntityBOP.Type.FIR.ordinal()); this.dataManager.register(field_199704_e, false); this.dataManager.register(field_199705_f, false); this.dataManager.register(ROCKING_TICKS, 0); } - /** - * Called when the entity is attacked. - */ @Override - public boolean attackEntityFrom(DamageSource source, float amount) { + public boolean attackEntityFrom(DamageSource source, float amount) + { if (this.isInvulnerableTo(source)) { return false; } else if (!this.world.isRemote && !this.removed) { @@ -114,7 +122,7 @@ public class BoatEntityBOP extends BoatEntity { this.setTimeSinceHit(10); this.setDamageTaken(this.getDamageTaken() + amount * 10.0F); this.markVelocityChanged(); - boolean flag = source.getTrueSource() instanceof PlayerEntity && ((PlayerEntity) source.getTrueSource()).abilities.isCreativeMode; + boolean flag = source.getTrueSource() instanceof PlayerEntity && ((PlayerEntity)source.getTrueSource()).abilities.isCreativeMode; if (flag || this.getDamageTaken() > 40.0F) { if (!flag && this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) { this.entityDropItem(this.getItemBoat()); @@ -122,6 +130,7 @@ public class BoatEntityBOP extends BoatEntity { this.remove(); } + return true; } } else { @@ -130,7 +139,8 @@ public class BoatEntityBOP extends BoatEntity { } @Override - public void onEnterBubbleColumnWithAirAbove(boolean downwards) { + public void onEnterBubbleColumnWithAirAbove(boolean downwards) + { if (!this.world.isRemote) { this.rocking = true; this.field_203060_aN = downwards; @@ -138,15 +148,19 @@ public class BoatEntityBOP extends BoatEntity { this.setRockingTicks(60); } } - this.world.addParticle(ParticleTypes.SPLASH, this.posX + (double) this.rand.nextFloat(), this.posY + 0.7D, this.posZ + (double) this.rand.nextFloat(), 0.0D, 0.0D, 0.0D); + + this.world.addParticle(ParticleTypes.SPLASH, this.func_226277_ct_() + (double)this.rand.nextFloat(), this.func_226278_cu_() + 0.7D, this.func_226281_cx_() + (double)this.rand.nextFloat(), 0.0D, 0.0D, 0.0D); if (this.rand.nextInt(20) == 0) { - this.world.playSound(this.posX, this.posY, this.posZ, this.getSplashSound(), this.getSoundCategory(), 1.0F, 0.8F + 0.4F * this.rand.nextFloat(), false); + this.world.playSound(this.func_226277_ct_(), this.func_226278_cu_(), this.func_226281_cx_(), this.getSplashSound(), this.getSoundCategory(), 1.0F, 0.8F + 0.4F * this.rand.nextFloat(), false); } + } @Override - public Item getItemBoat() { - switch (this.getBoatModel()) { + public Item getItemBoat() + { + switch (this.getBoatTypeBOP()) + { case FIR: default: return BOPItems.fir_boat; @@ -173,25 +187,38 @@ public class BoatEntityBOP extends BoatEntity { } } - /** - * Setups the entity to do the hurt animation. Only used by packets in multiplayer. - */ @Override @OnlyIn(Dist.CLIENT) - public void performHurtAnimation() { + public void performHurtAnimation() + { this.setForwardDirection(-this.getForwardDirection()); this.setTimeSinceHit(10); this.setDamageTaken(this.getDamageTaken() * 11.0F); } - /** - * Called to update the entity's position/logic. - */ @Override - public void tick() { + public boolean canBeCollidedWith() + { + return !this.removed; + } + + @Override + @OnlyIn(Dist.CLIENT) + public void setPositionAndRotationDirect(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean teleport) { + this.lerpX = x; + this.lerpY = y; + this.lerpZ = z; + this.lerpYaw = (double)yaw; + this.lerpPitch = (double)pitch; + this.lerpSteps = 10; + } + + @Override + public void tick() + { this.previousStatus = this.status; this.status = this.getBoatStatus(); - if (this.status != Status.UNDER_WATER && this.status != Status.UNDER_FLOWING_WATER) { + if (this.status != BoatEntityBOP.Status.UNDER_WATER && this.status != BoatEntityBOP.Status.UNDER_FLOWING_WATER) { this.outOfControlTicks = 0.0F; } else { ++this.outOfControlTicks; @@ -209,17 +236,15 @@ public class BoatEntityBOP extends BoatEntity { this.setDamageTaken(this.getDamageTaken() - 1.0F); } - this.prevPosX = this.getPositionVector().getX(); - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; - // !!! this is the super of BoatEntity !!! if (!this.world.isRemote) { - this.setFlag(6, this.isGlowing()); + this.setFlag(6, this.func_225510_bt_()); } - baseTick(); - super.tickLerp(); + this.baseTick(); + /// + + this.tickLerp(); if (this.canPassengerSteer()) { if (this.getPassengers().isEmpty() || !(this.getPassengers().get(0) instanceof PlayerEntity)) { this.setPaddleState(false, false); @@ -238,30 +263,30 @@ public class BoatEntityBOP extends BoatEntity { this.updateRocking(); - for (int i = 0; i <= 1; ++i) { + for(int i = 0; i <= 1; ++i) { if (this.getPaddleState(i)) { - if (!this.isSilent() && (double) (this.paddlePositions[i] % ((float) Math.PI * 2F)) <= (double) ((float) Math.PI / 4F) && ((double) this.paddlePositions[i] + (double) ((float) Math.PI / 8F)) % (double) ((float) Math.PI * 2F) >= (double) ((float) Math.PI / 4F)) { + if (!this.isSilent() && (double)(this.paddlePositions[i] % ((float)Math.PI * 2F)) <= (double)((float)Math.PI / 4F) && ((double)this.paddlePositions[i] + (double)((float)Math.PI / 8F)) % (double)((float)Math.PI * 2F) >= (double)((float)Math.PI / 4F)) { SoundEvent soundevent = this.getPaddleSound(); if (soundevent != null) { Vec3d vec3d = this.getLook(1.0F); double d0 = i == 1 ? -vec3d.z : vec3d.z; double d1 = i == 1 ? vec3d.x : -vec3d.x; - this.world.playSound((PlayerEntity) null, this.posX + d0, this.posY, this.posZ + d1, soundevent, this.getSoundCategory(), 1.0F, 0.8F + 0.4F * this.rand.nextFloat()); + this.world.playSound((PlayerEntity)null, this.func_226277_ct_() + d0, this.func_226278_cu_(), this.func_226281_cx_() + d1, soundevent, this.getSoundCategory(), 1.0F, 0.8F + 0.4F * this.rand.nextFloat()); } } - this.paddlePositions[i] = (float) ((double) this.paddlePositions[i] + (double) ((float) Math.PI / 8F)); + this.paddlePositions[i] = (float)((double)this.paddlePositions[i] + (double)((float)Math.PI / 8F)); } else { this.paddlePositions[i] = 0.0F; } } this.doBlockCollisions(); - List list = this.world.getEntitiesInAABBexcluding(this, this.getBoundingBox().grow((double) 0.2F, (double) -0.01F, (double) 0.2F), EntityPredicates.pushableBy(this)); + List list = this.world.getEntitiesInAABBexcluding(this, this.getBoundingBox().grow((double)0.2F, (double)-0.01F, (double)0.2F), EntityPredicates.pushableBy(this)); if (!list.isEmpty()) { boolean flag = !this.world.isRemote && !(this.getControllingPassenger() instanceof PlayerEntity); - for (int j = 0; j < list.size(); ++j) { + for(int j = 0; j < list.size(); ++j) { Entity entity = list.get(j); if (!entity.isPassenger(this)) { if (flag && this.getPassengers().size() < 2 && !entity.isPassenger() && entity.getWidth() < this.getWidth() && entity instanceof LivingEntity && !(entity instanceof WaterMobEntity) && !(entity instanceof PlayerEntity)) { @@ -272,9 +297,11 @@ public class BoatEntityBOP extends BoatEntity { } } } + } - private void updateRocking() { + private void updateRocking() + { if (this.world.isRemote) { int i = this.getRockingTicks(); if (i > 0) { @@ -285,7 +312,7 @@ public class BoatEntityBOP extends BoatEntity { this.rockingIntensity = MathHelper.clamp(this.rockingIntensity, 0.0F, 1.0F); this.prevRockingAngle = this.rockingAngle; - this.rockingAngle = 10.0F * (float) Math.sin((double) (0.5F * (float) this.world.getGameTime())) * this.rockingIntensity; + this.rockingAngle = 10.0F * (float)Math.sin((double)(0.5F * (float)this.world.getGameTime())) * this.rockingIntensity; } else { if (!this.rocking) { this.setRockingTicks(0); @@ -310,12 +337,14 @@ public class BoatEntityBOP extends BoatEntity { this.rocking = false; } } + } @Override @Nullable - protected SoundEvent getPaddleSound() { - switch (this.getBoatStatus()) { + protected SoundEvent getPaddleSound() + { + switch(this.getBoatStatus()) { case IN_WATER: case UNDER_WATER: case UNDER_FLOWING_WATER: @@ -329,40 +358,62 @@ public class BoatEntityBOP extends BoatEntity { } @Override - public void setPaddleState(boolean left, boolean right) { + protected void tickLerp() + { + if (this.canPassengerSteer()) { + this.lerpSteps = 0; + this.setPacketCoordinates(this.func_226277_ct_(), this.func_226278_cu_(), this.func_226281_cx_()); + } + + if (this.lerpSteps > 0) { + double d0 = this.func_226277_ct_() + (this.lerpX - this.func_226277_ct_()) / (double)this.lerpSteps; + double d1 = this.func_226278_cu_() + (this.lerpY - this.func_226278_cu_()) / (double)this.lerpSteps; + double d2 = this.func_226281_cx_() + (this.lerpZ - this.func_226281_cx_()) / (double)this.lerpSteps; + double d3 = MathHelper.wrapDegrees(this.lerpYaw - (double)this.rotationYaw); + this.rotationYaw = (float)((double)this.rotationYaw + d3 / (double)this.lerpSteps); + this.rotationPitch = (float)((double)this.rotationPitch + (this.lerpPitch - (double)this.rotationPitch) / (double)this.lerpSteps); + --this.lerpSteps; + this.setPosition(d0, d1, d2); + this.setRotation(this.rotationYaw, this.rotationPitch); + } + } + + @Override + public void setPaddleState(boolean left, boolean right) + { this.dataManager.set(field_199704_e, left); this.dataManager.set(field_199705_f, right); } @Override @OnlyIn(Dist.CLIENT) - public float getRowingTime(int side, float limbSwing) { - return this.getPaddleState(side) ? (float) MathHelper.clampedLerp((double) this.paddlePositions[side] - (double) ((float) Math.PI / 8F), (double) this.paddlePositions[side], (double) limbSwing) : 0.0F; + public float getRowingTime(int side, float limbSwing) + { + return this.getPaddleState(side) ? (float)MathHelper.clampedLerp((double)this.paddlePositions[side] - (double)((float)Math.PI / 8F), (double)this.paddlePositions[side], (double)limbSwing) : 0.0F; } - /** - * Determines whether the boat is in water, gliding on land, or in air - */ - private Status getBoatStatus() { - Status boatentity$status = this.getUnderwaterStatus(); - if (boatentity$status != null) { + private BoatEntityBOP.Status getBoatStatus() + { + BoatEntityBOP.Status BoatEntityBOP$status = this.getUnderwaterStatus(); + if (BoatEntityBOP$status != null) { this.waterLevel = this.getBoundingBox().maxY; - return boatentity$status; + return BoatEntityBOP$status; } else if (this.checkInWater()) { - return Status.IN_WATER; + return BoatEntityBOP.Status.IN_WATER; } else { float f = this.getBoatGlide(); if (f > 0.0F) { this.boatGlide = f; - return Status.ON_LAND; + return BoatEntityBOP.Status.ON_LAND; } else { - return Status.IN_AIR; + return BoatEntityBOP.Status.IN_AIR; } } } @Override - public float getWaterLevelAbove() { + public float getWaterLevelAbove() + { AxisAlignedBB axisalignedbb = this.getBoundingBox(); int i = MathHelper.floor(axisalignedbb.minX); int j = MathHelper.ceil(axisalignedbb.maxX); @@ -371,17 +422,17 @@ public class BoatEntityBOP extends BoatEntity { int i1 = MathHelper.floor(axisalignedbb.minZ); int j1 = MathHelper.ceil(axisalignedbb.maxZ); - try (BlockPos.PooledMutable blockpos$pooledmutableblockpos = BlockPos.PooledMutable.retain()) { + try (BlockPos.PooledMutable blockpos$pooledmutable = BlockPos.PooledMutable.retain()) { label161: - for (int k1 = k; k1 < l; ++k1) { + for(int k1 = k; k1 < l; ++k1) { float f = 0.0F; - for (int l1 = i; l1 < j; ++l1) { - for (int i2 = i1; i2 < j1; ++i2) { - blockpos$pooledmutableblockpos.setPos(l1, k1, i2); - IFluidState ifluidstate = this.world.getFluidState(blockpos$pooledmutableblockpos); + for(int l1 = i; l1 < j; ++l1) { + for(int i2 = i1; i2 < j1; ++i2) { + blockpos$pooledmutable.setPos(l1, k1, i2); + IFluidState ifluidstate = this.world.getFluidState(blockpos$pooledmutable); if (ifluidstate.isTagged(FluidTags.WATER)) { - f = Math.max(f, ifluidstate.getActualHeight(this.world, blockpos$pooledmutableblockpos)); + f = Math.max(f, ifluidstate.getActualHeight(this.world, blockpos$pooledmutable)); } if (f >= 1.0F) { @@ -391,12 +442,12 @@ public class BoatEntityBOP extends BoatEntity { } if (f < 1.0F) { - float f2 = (float) blockpos$pooledmutableblockpos.getY() + f; + float f2 = (float)blockpos$pooledmutable.getY() + f; return f2; } } - float f1 = (float) (l + 1); + float f1 = (float)(l + 1); return f1; } } @@ -404,7 +455,6 @@ public class BoatEntityBOP extends BoatEntity { /** * Decides how much the boat should be gliding on the land (based on any slippery blocks) */ - @Override public float getBoatGlide() { AxisAlignedBB axisalignedbb = this.getBoundingBox(); AxisAlignedBB axisalignedbb1 = new AxisAlignedBB(axisalignedbb.minX, axisalignedbb.minY - 0.001D, axisalignedbb.minZ, axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ); @@ -418,17 +468,17 @@ public class BoatEntityBOP extends BoatEntity { float f = 0.0F; int k1 = 0; - try (BlockPos.PooledMutable blockpos$pooledmutableblockpos = BlockPos.PooledMutable.retain()) { - for (int l1 = i; l1 < j; ++l1) { - for (int i2 = i1; i2 < j1; ++i2) { + try (BlockPos.PooledMutable blockpos$pooledmutable = BlockPos.PooledMutable.retain()) { + for(int l1 = i; l1 < j; ++l1) { + for(int i2 = i1; i2 < j1; ++i2) { int j2 = (l1 != i && l1 != j - 1 ? 0 : 1) + (i2 != i1 && i2 != j1 - 1 ? 0 : 1); if (j2 != 2) { - for (int k2 = k; k2 < l; ++k2) { + for(int k2 = k; k2 < l; ++k2) { if (j2 <= 0 || k2 != k && k2 != l - 1) { - blockpos$pooledmutableblockpos.setPos(l1, k2, i2); - BlockState blockstate = this.world.getBlockState(blockpos$pooledmutableblockpos); - if (!(blockstate.getBlock() instanceof LilyPadBlock) && VoxelShapes.compare(blockstate.getCollisionShape(this.world, blockpos$pooledmutableblockpos).withOffset((double) l1, (double) k2, (double) i2), voxelshape, IBooleanFunction.AND)) { - f += blockstate.getSlipperiness(this.world, blockpos$pooledmutableblockpos, this); + blockpos$pooledmutable.setPos(l1, k2, i2); + BlockState blockstate = this.world.getBlockState(blockpos$pooledmutable); + if (!(blockstate.getBlock() instanceof LilyPadBlock) && VoxelShapes.compare(blockstate.getCollisionShape(this.world, blockpos$pooledmutable).withOffset((double)l1, (double)k2, (double)i2), voxelshape, IBooleanFunction.AND)) { + f += blockstate.getSlipperiness(this.world, blockpos$pooledmutable, this); ++k1; } } @@ -438,7 +488,7 @@ public class BoatEntityBOP extends BoatEntity { } } - return f / (float) k1; + return f / (float)k1; } private boolean checkInWater() { @@ -452,16 +502,16 @@ public class BoatEntityBOP extends BoatEntity { boolean flag = false; this.waterLevel = Double.MIN_VALUE; - try (BlockPos.PooledMutable blockpos$pooledmutableblockpos = BlockPos.PooledMutable.retain()) { - for (int k1 = i; k1 < j; ++k1) { - for (int l1 = k; l1 < l; ++l1) { - for (int i2 = i1; i2 < j1; ++i2) { - blockpos$pooledmutableblockpos.setPos(k1, l1, i2); - IFluidState ifluidstate = this.world.getFluidState(blockpos$pooledmutableblockpos); + try (BlockPos.PooledMutable blockpos$pooledmutable = BlockPos.PooledMutable.retain()) { + for(int k1 = i; k1 < j; ++k1) { + for(int l1 = k; l1 < l; ++l1) { + for(int i2 = i1; i2 < j1; ++i2) { + blockpos$pooledmutable.setPos(k1, l1, i2); + IFluidState ifluidstate = this.world.getFluidState(blockpos$pooledmutable); if (ifluidstate.isTagged(FluidTags.WATER)) { - float f = (float) l1 + ifluidstate.getActualHeight(this.world, blockpos$pooledmutableblockpos); - this.waterLevel = Math.max((double) f, this.waterLevel); - flag |= axisalignedbb.minY < (double) f; + float f = (float)l1 + ifluidstate.getActualHeight(this.world, blockpos$pooledmutable); + this.waterLevel = Math.max((double)f, this.waterLevel); + flag |= axisalignedbb.minY < (double)f; } } } @@ -475,7 +525,7 @@ public class BoatEntityBOP extends BoatEntity { * Decides whether the boat is currently underwater. */ @Nullable - private Status getUnderwaterStatus() { + private BoatEntityBOP.Status getUnderwaterStatus() { AxisAlignedBB axisalignedbb = this.getBoundingBox(); double d0 = axisalignedbb.maxY + 0.001D; int i = MathHelper.floor(axisalignedbb.minX); @@ -486,15 +536,16 @@ public class BoatEntityBOP extends BoatEntity { int j1 = MathHelper.ceil(axisalignedbb.maxZ); boolean flag = false; - try (BlockPos.PooledMutable blockpos$pooledmutableblockpos = BlockPos.PooledMutable.retain()) { - for (int k1 = i; k1 < j; ++k1) { - for (int l1 = k; l1 < l; ++l1) { - for (int i2 = i1; i2 < j1; ++i2) { - blockpos$pooledmutableblockpos.setPos(k1, l1, i2); - IFluidState ifluidstate = this.world.getFluidState(blockpos$pooledmutableblockpos); - if (ifluidstate.isTagged(FluidTags.WATER) && d0 < (double) ((float) blockpos$pooledmutableblockpos.getY() + ifluidstate.getActualHeight(this.world, blockpos$pooledmutableblockpos))) { + try (BlockPos.PooledMutable blockpos$pooledmutable = BlockPos.PooledMutable.retain()) { + for(int k1 = i; k1 < j; ++k1) { + for(int l1 = k; l1 < l; ++l1) { + for(int i2 = i1; i2 < j1; ++i2) { + blockpos$pooledmutable.setPos(k1, l1, i2); + IFluidState ifluidstate = this.world.getFluidState(blockpos$pooledmutable); + if (ifluidstate.isTagged(FluidTags.WATER) && d0 < (double)((float)blockpos$pooledmutable.getY() + ifluidstate.getActualHeight(this.world, blockpos$pooledmutable))) { if (!ifluidstate.isSource()) { - return Status.UNDER_FLOWING_WATER; + BoatEntityBOP.Status BoatEntityBOP$status = BoatEntityBOP.Status.UNDER_FLOWING_WATER; + return BoatEntityBOP$status; } flag = true; @@ -504,36 +555,36 @@ public class BoatEntityBOP extends BoatEntity { } } - return flag ? Status.UNDER_WATER : null; + return flag ? BoatEntityBOP.Status.UNDER_WATER : null; } /** * Update the boat's speed, based on momentum. */ private void updateMotion() { - double gravity = (double) -0.04F; - double d1 = this.hasNoGravity() ? 0.0D : gravity; + double d0 = (double)-0.04F; + double d1 = this.hasNoGravity() ? 0.0D : (double)-0.04F; double d2 = 0.0D; this.momentum = 0.05F; - if (this.previousStatus == Status.IN_AIR && this.status != Status.IN_AIR && this.status != Status.ON_LAND) { - this.waterLevel = this.getBoundingBox().minY + (double) this.getHeight(); - this.setPosition(this.posX, (double) (this.getWaterLevelAbove() - this.getHeight()) + 0.101D, this.posZ); + if (this.previousStatus == BoatEntityBOP.Status.IN_AIR && this.status != BoatEntityBOP.Status.IN_AIR && this.status != BoatEntityBOP.Status.ON_LAND) { + this.waterLevel = this.func_226283_e_(1.0D); + this.setPosition(this.func_226277_ct_(), (double)(this.getWaterLevelAbove() - this.getHeight()) + 0.101D, this.func_226281_cx_()); this.setMotion(this.getMotion().mul(1.0D, 0.0D, 1.0D)); this.lastYd = 0.0D; - this.status = Status.IN_WATER; + this.status = BoatEntityBOP.Status.IN_WATER; } else { - if (this.status == Status.IN_WATER) { - d2 = (this.waterLevel - this.getBoundingBox().minY) / (double) this.getHeight(); + if (this.status == BoatEntityBOP.Status.IN_WATER) { + d2 = (this.waterLevel - this.func_226278_cu_()) / (double)this.getHeight(); this.momentum = 0.9F; - } else if (this.status == Status.UNDER_FLOWING_WATER) { + } else if (this.status == BoatEntityBOP.Status.UNDER_FLOWING_WATER) { d1 = -7.0E-4D; this.momentum = 0.9F; - } else if (this.status == Status.UNDER_WATER) { - d2 = (double) 0.01F; + } else if (this.status == BoatEntityBOP.Status.UNDER_WATER) { + d2 = (double)0.01F; this.momentum = 0.45F; - } else if (this.status == Status.IN_AIR) { + } else if (this.status == BoatEntityBOP.Status.IN_AIR) { this.momentum = 0.9F; - } else if (this.status == Status.ON_LAND) { + } else if (this.status == BoatEntityBOP.Status.ON_LAND) { this.momentum = this.boatGlide; if (this.getControllingPassenger() instanceof PlayerEntity) { this.boatGlide /= 2.0F; @@ -541,13 +592,14 @@ public class BoatEntityBOP extends BoatEntity { } Vec3d vec3d = this.getMotion(); - this.setMotion(vec3d.x * (double) this.momentum, vec3d.y + d1, vec3d.z * (double) this.momentum); + this.setMotion(vec3d.x * (double)this.momentum, vec3d.y + d1, vec3d.z * (double)this.momentum); this.deltaRotation *= this.momentum; if (d2 > 0.0D) { Vec3d vec3d1 = this.getMotion(); this.setMotion(vec3d1.x, (vec3d1.y + d2 * 0.06153846016296973D) * 0.75D, vec3d1.z); } } + } private void controlBoat() { @@ -574,16 +626,15 @@ public class BoatEntityBOP extends BoatEntity { f -= 0.005F; } - this.setMotion(this.getMotion().add((double) (MathHelper.sin(-this.rotationYaw * ((float) Math.PI / 180F)) * f), 0.0D, (double) (MathHelper.cos(this.rotationYaw * ((float) Math.PI / 180F)) * f))); + this.setMotion(this.getMotion().add((double)(MathHelper.sin(-this.rotationYaw * ((float)Math.PI / 180F)) * f), 0.0D, (double)(MathHelper.cos(this.rotationYaw * ((float)Math.PI / 180F)) * f))); this.setPaddleState(this.rightInputDown && !this.leftInputDown || this.forwardInputDown, this.leftInputDown && !this.rightInputDown || this.forwardInputDown); } } - @Override public void updatePassenger(Entity passenger) { if (this.isPassenger(passenger)) { float f = 0.0F; - float f1 = (float) ((this.removed ? (double) 0.01F : this.getMountedYOffset()) + passenger.getYOffset()); + float f1 = (float)((this.removed ? (double)0.01F : this.getMountedYOffset()) + passenger.getYOffset()); if (this.getPassengers().size() > 1) { int i = this.getPassengers().indexOf(passenger); if (i == 0) { @@ -593,27 +644,27 @@ public class BoatEntityBOP extends BoatEntity { } if (passenger instanceof AnimalEntity) { - f = (float) ((double) f + 0.2D); + f = (float)((double)f + 0.2D); } } - Vec3d vec3d = (new Vec3d((double) f, 0.0D, 0.0D)).rotateYaw(-this.rotationYaw * ((float) Math.PI / 180F) - ((float) Math.PI / 2F)); - passenger.setPosition(this.posX + vec3d.x, this.posY + (double) f1, this.posZ + vec3d.z); + Vec3d vec3d = (new Vec3d((double)f, 0.0D, 0.0D)).rotateYaw(-this.rotationYaw * ((float)Math.PI / 180F) - ((float)Math.PI / 2F)); + passenger.setPosition(this.func_226277_ct_() + vec3d.x, this.func_226278_cu_() + (double)f1, this.func_226281_cx_() + vec3d.z); passenger.rotationYaw += this.deltaRotation; passenger.setRotationYawHead(passenger.getRotationYawHead() + this.deltaRotation); this.applyYawToEntity(passenger); if (passenger instanceof AnimalEntity && this.getPassengers().size() > 1) { int j = passenger.getEntityId() % 2 == 0 ? 90 : 270; - passenger.setRenderYawOffset(((AnimalEntity) passenger).renderYawOffset + (float) j); - passenger.setRotationYawHead(passenger.getRotationYawHead() + (float) j); + passenger.setRenderYawOffset(((AnimalEntity)passenger).renderYawOffset + (float)j); + passenger.setRotationYawHead(passenger.getRotationYawHead() + (float)j); } + } } /** * Applies this boat's yaw to the given entity. Used to update the orientation of its passenger. */ - @Override protected void applyYawToEntity(Entity entityToUpdate) { entityToUpdate.setRenderYawOffset(this.rotationYaw); float f = MathHelper.wrapDegrees(entityToUpdate.rotationYaw - this.rotationYaw); @@ -626,28 +677,33 @@ public class BoatEntityBOP extends BoatEntity { /** * Applies this entity's orientation (pitch/yaw) to another entity. Used to update passenger orientation. */ - @Override @OnlyIn(Dist.CLIENT) public void applyOrientationToEntity(Entity entityToUpdate) { this.applyYawToEntity(entityToUpdate); } - @Override protected void writeAdditional(CompoundNBT compound) { - compound.putString("Type", this.getBoatModel().getName()); + compound.putString("Type", this.getBoatType().getName()); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ - @Override protected void readAdditional(CompoundNBT compound) { if (compound.contains("Type", 8)) { - setBoatModel(Type.getTypeFromString(compound.getString("Type"))); + this.setBoatType(BoatEntityBOP.Type.getTypeFromString(compound.getString("Type"))); + } + + } + + public boolean processInitialInteract(PlayerEntity player, Hand hand) { + if (player.func_226563_dT_()) { + return false; + } else { + return !this.world.isRemote && this.outOfControlTicks < 60.0F ? player.startRiding(this) : false; } } - @Override protected void updateFallState(double y, boolean onGroundIn, BlockState state, BlockPos pos) { this.lastYd = this.getMotion().y; if (!this.isPassenger()) { @@ -658,15 +714,15 @@ public class BoatEntityBOP extends BoatEntity { return; } - this.fall(this.fallDistance, 1.0F); + this.func_225503_b_(this.fallDistance, 1.0F); if (!this.world.isRemote && !this.removed) { this.remove(); if (this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) { - for (int i = 0; i < 3; ++i) { - this.entityDropItem(this.getBoatModel().asPlank()); + for(int i = 0; i < 3; ++i) { + this.entityDropItem(this.getBoatType().asPlank()); } - for (int j = 0; j < 2; ++j) { + for(int j = 0; j < 2; ++j) { this.entityDropItem(Items.STICK); } } @@ -675,12 +731,12 @@ public class BoatEntityBOP extends BoatEntity { this.fallDistance = 0.0F; } else if (!this.world.getFluidState((new BlockPos(this)).down()).isTagged(FluidTags.WATER) && y < 0.0D) { - this.fallDistance = (float) ((double) this.fallDistance - y); + this.fallDistance = (float)((double)this.fallDistance - y); } + } } - @Override public boolean getPaddleState(int side) { return this.dataManager.get(side == 0 ? field_199704_e : field_199705_f) && this.getControllingPassenger() != null; } @@ -688,7 +744,6 @@ public class BoatEntityBOP extends BoatEntity { /** * Sets the damage taken from the last hit. */ - @Override public void setDamageTaken(float damageTaken) { this.dataManager.set(DAMAGE_TAKEN, damageTaken); } @@ -696,7 +751,6 @@ public class BoatEntityBOP extends BoatEntity { /** * Gets the damage taken from the last hit. */ - @Override public float getDamageTaken() { return this.dataManager.get(DAMAGE_TAKEN); } @@ -704,7 +758,6 @@ public class BoatEntityBOP extends BoatEntity { /** * Sets the time to count down from since the last time entity was hit. */ - @Override public void setTimeSinceHit(int timeSinceHit) { this.dataManager.set(TIME_SINCE_HIT, timeSinceHit); } @@ -712,7 +765,6 @@ public class BoatEntityBOP extends BoatEntity { /** * Gets the time since the last hit. */ - @Override public int getTimeSinceHit() { return this.dataManager.get(TIME_SINCE_HIT); } @@ -725,7 +777,6 @@ public class BoatEntityBOP extends BoatEntity { return this.dataManager.get(ROCKING_TICKS); } - @Override @OnlyIn(Dist.CLIENT) public float getRockingAngle(float partialTicks) { return MathHelper.lerp(partialTicks, this.prevRockingAngle, this.rockingAngle); @@ -734,7 +785,6 @@ public class BoatEntityBOP extends BoatEntity { /** * Sets the forward direction of the entity. */ - @Override public void setForwardDirection(int forwardDirection) { this.dataManager.set(FORWARD_DIRECTION, forwardDirection); } @@ -742,20 +792,33 @@ public class BoatEntityBOP extends BoatEntity { /** * Gets the forward direction of the entity. */ - @Override public int getForwardDirection() { return this.dataManager.get(FORWARD_DIRECTION); } - public void setBoatModel(Type boatType) { + public void setBoatType(BoatEntityBOP.Type boatType) { this.dataManager.set(BOAT_TYPE, boatType.ordinal()); } - public Type getBoatModel() { - return Type.byId(this.dataManager.get(BOAT_TYPE)); + public BoatEntityBOP.Type getBoatTypeBOP() + { + return BoatEntityBOP.Type.byId(this.dataManager.get(BOAT_TYPE)); + } + + protected boolean canFitPassenger(Entity passenger) { + return this.getPassengers().size() < 2 && !this.areEyesInFluid(FluidTags.WATER); + } + + /** + * For vehicles, the first passenger is generally considered the controller and "drives" the vehicle. For example, + * Pigs, Horses, and Boats are generally "steered" by the controlling passenger. + */ + @Nullable + public Entity getControllingPassenger() { + List list = this.getPassengers(); + return list.isEmpty() ? null : list.get(0); } - @Override @OnlyIn(Dist.CLIENT) public void updateInputs(boolean p_184442_1_, boolean p_184442_2_, boolean p_184442_3_, boolean p_184442_4_) { this.leftInputDown = p_184442_1_; @@ -764,9 +827,16 @@ public class BoatEntityBOP extends BoatEntity { this.backInputDown = p_184442_4_; } - @Override public IPacket createSpawnPacket() { - return NetworkHooks.getEntitySpawningPacket(this); + return new SSpawnObjectPacket(this); + } + + public static enum Status { + IN_WATER, + UNDER_WATER, + UNDER_FLOWING_WATER, + ON_LAND, + IN_AIR; } public enum Type { @@ -808,22 +878,22 @@ public class BoatEntityBOP extends BoatEntity { * @return */ public static Type byId(int id) { - Type[] aboatentity$type = values(); - if (id < 0 || id >= aboatentity$type.length) { + Type[] aBoatEntityBOP$type = values(); + if (id < 0 || id >= aBoatEntityBOP$type.length) { id = 0; } - return aboatentity$type[id]; + return aBoatEntityBOP$type[id]; } public static Type getTypeFromString(String nameIn) { - Type[] aboatentity$type = values(); + Type[] aBoatEntityBOP$type = values(); - for (int i = 0; i < aboatentity$type.length; ++i) { - if (aboatentity$type[i].getName().equals(nameIn)) { - return aboatentity$type[i]; + for (int i = 0; i < aBoatEntityBOP$type.length; ++i) { + if (aBoatEntityBOP$type[i].getName().equals(nameIn)) { + return aBoatEntityBOP$type[i]; } } - return aboatentity$type[0]; + return aBoatEntityBOP$type[0]; } } } \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/entity/item/BoatModelBOP.java b/src/main/java/biomesoplenty/common/entity/item/BoatModelBOP.java index 9cfbe49c6..1ed05ac85 100644 --- a/src/main/java/biomesoplenty/common/entity/item/BoatModelBOP.java +++ b/src/main/java/biomesoplenty/common/entity/item/BoatModelBOP.java @@ -1,44 +1,44 @@ package biomesoplenty.common.entity.item; -import com.mojang.blaze3d.platform.GlStateManager; -import net.minecraft.client.renderer.entity.model.EntityModel; -import net.minecraft.client.renderer.entity.model.RendererModel; -import net.minecraft.entity.Entity; +import com.google.common.collect.ImmutableList; +import net.minecraft.client.renderer.entity.model.SegmentedModel; +import net.minecraft.client.renderer.model.ModelRenderer; import net.minecraft.util.math.MathHelper; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -@OnlyIn(Dist.CLIENT) -public class BoatModelBOP extends EntityModel { - private final RendererModel[] field_78103_a = new RendererModel[5]; - private final RendererModel[] paddles = new RendererModel[2]; - private final RendererModel noWater; +import java.util.Arrays; - public BoatModelBOP() { - this.field_78103_a[0] = (new RendererModel(this, 0, 0)).setTextureSize(128, 64); - this.field_78103_a[1] = (new RendererModel(this, 0, 19)).setTextureSize(128, 64); - this.field_78103_a[2] = (new RendererModel(this, 0, 27)).setTextureSize(128, 64); - this.field_78103_a[3] = (new RendererModel(this, 0, 35)).setTextureSize(128, 64); - this.field_78103_a[4] = (new RendererModel(this, 0, 43)).setTextureSize(128, 64); +// Much care has been put into copying and pasting this, as you can tell +@OnlyIn(Dist.CLIENT) +public class BoatModelBOP extends SegmentedModel +{ + private final ModelRenderer[] paddles = new ModelRenderer[2]; + private final ModelRenderer noWater; + private final ImmutableList field_228243_f_; + + public BoatModelBOP() + { + ModelRenderer[] amodelrenderer = new ModelRenderer[]{(new ModelRenderer(this, 0, 0)).setTextureSize(128, 64), (new ModelRenderer(this, 0, 19)).setTextureSize(128, 64), (new ModelRenderer(this, 0, 27)).setTextureSize(128, 64), (new ModelRenderer(this, 0, 35)).setTextureSize(128, 64), (new ModelRenderer(this, 0, 43)).setTextureSize(128, 64)}; int i = 32; int j = 6; int k = 20; int l = 4; int i1 = 28; - this.field_78103_a[0].addBox(-14.0F, -9.0F, -3.0F, 28, 16, 3, 0.0F); - this.field_78103_a[0].setRotationPoint(0.0F, 3.0F, 1.0F); - this.field_78103_a[1].addBox(-13.0F, -7.0F, -1.0F, 18, 6, 2, 0.0F); - this.field_78103_a[1].setRotationPoint(-15.0F, 4.0F, 4.0F); - this.field_78103_a[2].addBox(-8.0F, -7.0F, -1.0F, 16, 6, 2, 0.0F); - this.field_78103_a[2].setRotationPoint(15.0F, 4.0F, 0.0F); - this.field_78103_a[3].addBox(-14.0F, -7.0F, -1.0F, 28, 6, 2, 0.0F); - this.field_78103_a[3].setRotationPoint(0.0F, 4.0F, -9.0F); - this.field_78103_a[4].addBox(-14.0F, -7.0F, -1.0F, 28, 6, 2, 0.0F); - this.field_78103_a[4].setRotationPoint(0.0F, 4.0F, 9.0F); - this.field_78103_a[0].rotateAngleX = ((float)Math.PI / 2F); - this.field_78103_a[1].rotateAngleY = ((float)Math.PI * 1.5F); - this.field_78103_a[2].rotateAngleY = ((float)Math.PI / 2F); - this.field_78103_a[3].rotateAngleY = (float)Math.PI; + amodelrenderer[0].func_228301_a_(-14.0F, -9.0F, -3.0F, 28.0F, 16.0F, 3.0F, 0.0F); + amodelrenderer[0].setRotationPoint(0.0F, 3.0F, 1.0F); + amodelrenderer[1].func_228301_a_(-13.0F, -7.0F, -1.0F, 18.0F, 6.0F, 2.0F, 0.0F); + amodelrenderer[1].setRotationPoint(-15.0F, 4.0F, 4.0F); + amodelrenderer[2].func_228301_a_(-8.0F, -7.0F, -1.0F, 16.0F, 6.0F, 2.0F, 0.0F); + amodelrenderer[2].setRotationPoint(15.0F, 4.0F, 0.0F); + amodelrenderer[3].func_228301_a_(-14.0F, -7.0F, -1.0F, 28.0F, 6.0F, 2.0F, 0.0F); + amodelrenderer[3].setRotationPoint(0.0F, 4.0F, -9.0F); + amodelrenderer[4].func_228301_a_(-14.0F, -7.0F, -1.0F, 28.0F, 6.0F, 2.0F, 0.0F); + amodelrenderer[4].setRotationPoint(0.0F, 4.0F, 9.0F); + amodelrenderer[0].rotateAngleX = ((float)Math.PI / 2F); + amodelrenderer[1].rotateAngleY = ((float)Math.PI * 1.5F); + amodelrenderer[2].rotateAngleY = ((float)Math.PI / 2F); + amodelrenderer[3].rotateAngleY = (float)Math.PI; this.paddles[0] = this.makePaddle(true); this.paddles[0].setRotationPoint(3.0F, -5.0F, 9.0F); this.paddles[1] = this.makePaddle(false); @@ -46,51 +46,54 @@ public class BoatModelBOP extends EntityModel { this.paddles[1].rotateAngleY = (float)Math.PI; this.paddles[0].rotateAngleZ = 0.19634955F; this.paddles[1].rotateAngleZ = 0.19634955F; - this.noWater = (new RendererModel(this, 0, 0)).setTextureSize(128, 64); - this.noWater.addBox(-14.0F, -9.0F, -3.0F, 28, 16, 3, 0.0F); + this.noWater = (new ModelRenderer(this, 0, 0)).setTextureSize(128, 64); + this.noWater.func_228301_a_(-14.0F, -9.0F, -3.0F, 28.0F, 16.0F, 3.0F, 0.0F); this.noWater.setRotationPoint(0.0F, -3.0F, 1.0F); this.noWater.rotateAngleX = ((float)Math.PI / 2F); + ImmutableList.Builder builder = ImmutableList.builder(); + builder.addAll(Arrays.asList(amodelrenderer)); + builder.addAll(Arrays.asList(this.paddles)); + this.field_228243_f_ = builder.build(); } - public void render(BoatEntityBOP entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - GlStateManager.rotatef(90.0F, 0.0F, 1.0F, 0.0F); - this.setRotationAngles(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); - - for(int i = 0; i < 5; ++i) { - this.field_78103_a[i].render(scale); - } - - this.renderPaddle(entityIn, 0, scale, limbSwing); - this.renderPaddle(entityIn, 1, scale, limbSwing); + @Override + public void func_225597_a_(BoatEntityBOP p_225597_1_, float p_225597_2_, float p_225597_3_, float p_225597_4_, float p_225597_5_, float p_225597_6_) + { + this.func_228244_a_(p_225597_1_, 0, p_225597_2_); + this.func_228244_a_(p_225597_1_, 1, p_225597_2_); } - public void renderMultipass(Entity entityIn, float partialTicks, float p_187054_3_, float p_187054_4_, float p_187054_5_, float p_187054_6_, float scale) { - GlStateManager.rotatef(90.0F, 0.0F, 1.0F, 0.0F); - GlStateManager.colorMask(false, false, false, false); - this.noWater.render(scale); - GlStateManager.colorMask(true, true, true, true); + @Override + public ImmutableList func_225601_a_() + { + return this.field_228243_f_; } - protected RendererModel makePaddle(boolean p_187056_1_) { - RendererModel renderermodel = (new RendererModel(this, 62, p_187056_1_ ? 0 : 20)).setTextureSize(128, 64); + public ModelRenderer func_228245_c_() + { + return this.noWater; + } + + protected ModelRenderer makePaddle(boolean p_187056_1_) + { + ModelRenderer modelrenderer = (new ModelRenderer(this, 62, p_187056_1_ ? 0 : 20)).setTextureSize(128, 64); int i = 20; int j = 7; int k = 6; float f = -5.0F; - renderermodel.addBox(-1.0F, 0.0F, -5.0F, 2, 2, 18); - renderermodel.addBox(p_187056_1_ ? -1.001F : 0.001F, -3.0F, 8.0F, 1, 6, 7); - return renderermodel; + modelrenderer.func_228300_a_(-1.0F, 0.0F, -5.0F, 2.0F, 2.0F, 18.0F); + modelrenderer.func_228300_a_(p_187056_1_ ? -1.001F : 0.001F, -3.0F, 8.0F, 1.0F, 6.0F, 7.0F); + return modelrenderer; } - protected void renderPaddle(BoatEntityBOP boat, int paddle, float scale, float limbSwing) { - float f = boat.getRowingTime(paddle, limbSwing); - RendererModel renderermodel = this.paddles[paddle]; - renderermodel.rotateAngleX = (float) MathHelper.clampedLerp((double)(-(float)Math.PI / 3F), (double)-0.2617994F, (double)((MathHelper.sin(-f) + 1.0F) / 2.0F)); - renderermodel.rotateAngleY = (float)MathHelper.clampedLerp((double)(-(float)Math.PI / 4F), (double)((float)Math.PI / 4F), (double)((MathHelper.sin(-f + 1.0F) + 1.0F) / 2.0F)); - if (paddle == 1) { - renderermodel.rotateAngleY = (float)Math.PI - renderermodel.rotateAngleY; + protected void func_228244_a_(BoatEntityBOP p_228244_1_, int p_228244_2_, float p_228244_3_) + { + float f = p_228244_1_.getRowingTime(p_228244_2_, p_228244_3_); + ModelRenderer modelrenderer = this.paddles[p_228244_2_]; + modelrenderer.rotateAngleX = (float)MathHelper.clampedLerp((double)(-(float)Math.PI / 3F), (double)-0.2617994F, (double)((MathHelper.sin(-f) + 1.0F) / 2.0F)); + modelrenderer.rotateAngleY = (float)MathHelper.clampedLerp((double)(-(float)Math.PI / 4F), (double)((float)Math.PI / 4F), (double)((MathHelper.sin(-f + 1.0F) + 1.0F) / 2.0F)); + if (p_228244_2_ == 1) { + modelrenderer.rotateAngleY = (float)Math.PI - modelrenderer.rotateAngleY; } - - renderermodel.render(scale); } } \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/entity/item/BoatRendererBOP.java b/src/main/java/biomesoplenty/common/entity/item/BoatRendererBOP.java index 16ee56759..0155a9093 100644 --- a/src/main/java/biomesoplenty/common/entity/item/BoatRendererBOP.java +++ b/src/main/java/biomesoplenty/common/entity/item/BoatRendererBOP.java @@ -1,85 +1,67 @@ package biomesoplenty.common.entity.item; +import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.platform.GlStateManager; +import com.mojang.blaze3d.vertex.IVertexBuilder; +import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.Quaternion; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererManager; +import net.minecraft.client.renderer.entity.model.BoatModel; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.entity.item.BoatEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) -public class BoatRendererBOP extends EntityRenderer { +public class BoatRendererBOP extends EntityRenderer +{ private static final ResourceLocation[] BOAT_TEXTURES = new ResourceLocation[]{new ResourceLocation("biomesoplenty:textures/entity/boat/fir.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/redwood.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/cherry.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/mahogany.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/jacaranda.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/palm.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/willow.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/dead.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/magic.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/umbran.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/hellbark.png")}; protected final BoatModelBOP field_76998_a = new BoatModelBOP(); - public BoatRendererBOP(EntityRendererManager renderManagerIn) { + public BoatRendererBOP(EntityRendererManager renderManagerIn) + { super(renderManagerIn); this.shadowSize = 0.8F; } @Override - public void doRender(BoatEntityBOP entity, double x, double y, double z, float entityYaw, float partialTicks) { - GlStateManager.pushMatrix(); - this.setupTranslation(x, y, z); - this.setupRotation(entity, entityYaw, partialTicks); - this.bindEntityTexture(entity); - if (this.renderOutlines) { - GlStateManager.enableColorMaterial(); - GlStateManager.setupSolidRenderingTextureCombine(this.getTeamColor(entity)); - } - - this.field_76998_a.render(entity, partialTicks, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); - if (this.renderOutlines) { - GlStateManager.tearDownSolidRenderingTextureCombine(); - GlStateManager.disableColorMaterial(); - } - - GlStateManager.popMatrix(); - super.doRender(entity, x, y, z, entityYaw, partialTicks); - } - - public void setupRotation(BoatEntityBOP entityIn, float entityYaw, float partialTicks) { - GlStateManager.rotatef(180.0F - entityYaw, 0.0F, 1.0F, 0.0F); - float f = (float)entityIn.getTimeSinceHit() - partialTicks; - float f1 = entityIn.getDamageTaken() - partialTicks; + public void func_225623_a_(BoatEntityBOP p_225623_1_, float p_225623_2_, float p_225623_3_, MatrixStack p_225623_4_, IRenderTypeBuffer p_225623_5_, int p_225623_6_) + { + p_225623_4_.func_227860_a_(); + p_225623_4_.func_227861_a_(0.0D, 0.375D, 0.0D); + p_225623_4_.func_227863_a_(Vector3f.field_229181_d_.func_229187_a_(180.0F - p_225623_2_)); + float f = (float)p_225623_1_.getTimeSinceHit() - p_225623_3_; + float f1 = p_225623_1_.getDamageTaken() - p_225623_3_; if (f1 < 0.0F) { f1 = 0.0F; } if (f > 0.0F) { - GlStateManager.rotatef(MathHelper.sin(f) * f * f1 / 10.0F * (float)entityIn.getForwardDirection(), 1.0F, 0.0F, 0.0F); + p_225623_4_.func_227863_a_(Vector3f.field_229179_b_.func_229187_a_(MathHelper.sin(f) * f * f1 / 10.0F * (float)p_225623_1_.getForwardDirection())); } - float f2 = entityIn.getRockingAngle(partialTicks); + float f2 = p_225623_1_.getRockingAngle(p_225623_3_); if (!MathHelper.epsilonEquals(f2, 0.0F)) { - GlStateManager.rotatef(entityIn.getRockingAngle(partialTicks), 1.0F, 0.0F, 1.0F); + p_225623_4_.func_227863_a_(new Quaternion(new Vector3f(1.0F, 0.0F, 1.0F), p_225623_1_.getRockingAngle(p_225623_3_), true)); } - GlStateManager.scalef(-1.0F, -1.0F, 1.0F); + p_225623_4_.func_227862_a_(-1.0F, -1.0F, 1.0F); + p_225623_4_.func_227863_a_(Vector3f.field_229181_d_.func_229187_a_(90.0F)); + this.field_76998_a.func_225597_a_(p_225623_1_, p_225623_3_, 0.0F, -0.1F, 0.0F, 0.0F); + IVertexBuilder ivertexbuilder = p_225623_5_.getBuffer(this.field_76998_a.func_228282_a_(this.getEntityTexture(p_225623_1_))); + this.field_76998_a.func_225598_a_(p_225623_4_, ivertexbuilder, p_225623_6_, OverlayTexture.field_229196_a_, 1.0F, 1.0F, 1.0F, 1.0F); + IVertexBuilder ivertexbuilder1 = p_225623_5_.getBuffer(RenderType.func_228651_i_()); + this.field_76998_a.func_228245_c_().func_228308_a_(p_225623_4_, ivertexbuilder1, p_225623_6_, OverlayTexture.field_229196_a_); + p_225623_4_.func_227865_b_(); + super.func_225623_a_(p_225623_1_, p_225623_2_, p_225623_3_, p_225623_4_, p_225623_5_, p_225623_6_); } - public void setupTranslation(double x, double y, double z) { - GlStateManager.translatef((float)x, (float)y + 0.375F, (float)z); - } - - @Override - protected ResourceLocation getEntityTexture(BoatEntityBOP entity) { - return BOAT_TEXTURES[entity.getBoatModel().ordinal()]; - } - - @Override - public boolean isMultipass() { - return true; - } - - @Override - public void renderMultipass(BoatEntityBOP entityIn, double x, double y, double z, float entityYaw, float partialTicks) { - GlStateManager.pushMatrix(); - this.setupTranslation(x, y, z); - this.setupRotation(entityIn, entityYaw, partialTicks); - this.bindEntityTexture(entityIn); - this.field_76998_a.renderMultipass(entityIn, partialTicks, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); - GlStateManager.popMatrix(); + public ResourceLocation getEntityTexture(BoatEntityBOP entity) { + return BOAT_TEXTURES[entity.getBoatType().ordinal()]; } } \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/item/BoatItemBOP.java b/src/main/java/biomesoplenty/common/item/BoatItemBOP.java index 0281c977c..42c3628d5 100644 --- a/src/main/java/biomesoplenty/common/item/BoatItemBOP.java +++ b/src/main/java/biomesoplenty/common/item/BoatItemBOP.java @@ -58,7 +58,7 @@ public class BoatItemBOP extends Item { if (raytraceresult.getType() == RayTraceResult.Type.BLOCK) { BoatEntityBOP boatentity = new BoatEntityBOP(worldIn, raytraceresult.getHitVec().x, raytraceresult.getHitVec().y, raytraceresult.getHitVec().z); - boatentity.setBoatModel(this.type); + boatentity.setBoatType(this.type); boatentity.rotationYaw = playerIn.rotationYaw; if (!worldIn.func_226665_a__(boatentity, boatentity.getBoundingBox().grow(-0.1D))) { return new ActionResult<>(ActionResultType.FAIL, itemstack); diff --git a/src/main/java/biomesoplenty/common/item/DispenserBoatBehaviorBOP.java b/src/main/java/biomesoplenty/common/item/DispenserBoatBehaviorBOP.java index 0e1fb119c..47e7d22e9 100644 --- a/src/main/java/biomesoplenty/common/item/DispenserBoatBehaviorBOP.java +++ b/src/main/java/biomesoplenty/common/item/DispenserBoatBehaviorBOP.java @@ -35,7 +35,7 @@ public class DispenserBoatBehaviorBOP extends DefaultDispenseItemBehavior { adjustY = 0d; } BoatEntityBOP boat = new BoatEntityBOP(world, x, y + adjustY, z); - boat.setBoatModel(this.type); + boat.setBoatType(this.type); boat.rotationYaw = direction.getHorizontalAngle(); world.addEntity(boat); stack.shrink(1); diff --git a/src/main/java/biomesoplenty/init/ModEntities.java b/src/main/java/biomesoplenty/init/ModEntities.java index c0cbfde8c..ca2e1bea1 100644 --- a/src/main/java/biomesoplenty/init/ModEntities.java +++ b/src/main/java/biomesoplenty/init/ModEntities.java @@ -13,6 +13,7 @@ import biomesoplenty.common.entity.item.BoatRendererBOP; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityClassification; import net.minecraft.entity.EntityType; +import net.minecraft.entity.item.BoatEntity; import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -30,7 +31,7 @@ public class ModEntities @SubscribeEvent public static void registerEntities(RegistryEvent.Register> event) { - BOPEntities.boat_bop = EntityType.Builder.create(BoatEntityBOP::new, EntityClassification.MISC).setTrackingRange(80).setUpdateInterval(3).setShouldReceiveVelocityUpdates(true).size(1.375f, 0.5625f).setCustomClientFactory(BoatEntityBOP::new).build(MOD_ID + ":boat_bop"); + BOPEntities.boat_bop = EntityType.Builder.create(BoatEntityBOP::new, EntityClassification.MISC).setTrackingRange(80).setUpdateInterval(3).setShouldReceiveVelocityUpdates(true).size(1.375f, 0.5625f).setCustomClientFactory((spawnEntity, world) -> new BoatEntityBOP(world)).build(MOD_ID + ":boat_bop"); BOPEntities.boat_bop.setRegistryName("boat_bop"); ForgeRegistries.ENTITIES.register(BOPEntities.boat_bop); } @@ -47,6 +48,6 @@ public class ModEntities @OnlyIn(Dist.CLIENT) public static void registerRendering() { - RenderingRegistry.registerEntityRenderingHandler(BoatEntityBOP.class, BoatRendererBOP::new); + RenderingRegistry.registerEntityRenderingHandler((EntityType)BOPEntities.boat_bop, BoatRendererBOP::new); } }