diff --git a/src/main/java/biomesoplenty/api/entity/BOPEntities.java b/src/main/java/biomesoplenty/api/entity/BOPEntities.java index 9abe3b7f5..f5d27ee78 100644 --- a/src/main/java/biomesoplenty/api/entity/BOPEntities.java +++ b/src/main/java/biomesoplenty/api/entity/BOPEntities.java @@ -7,9 +7,10 @@ ******************************************************************************/ package biomesoplenty.api.entity; +import biomesoplenty.common.entity.item.BoatEntityBOP; import net.minecraft.entity.EntityType; public class BOPEntities { - public static EntityType boat_bop; + public static EntityType boat_bop; } diff --git a/src/main/java/biomesoplenty/common/entity/item/BoatEntityBOP.java b/src/main/java/biomesoplenty/common/entity/item/BoatEntityBOP.java index a79d7a58e..6fb36264b 100644 --- a/src/main/java/biomesoplenty/common/entity/item/BoatEntityBOP.java +++ b/src/main/java/biomesoplenty/common/entity/item/BoatEntityBOP.java @@ -1,6 +1,7 @@ package biomesoplenty.common.entity.item; import biomesoplenty.api.block.BOPBlocks; +import biomesoplenty.api.entity.BOPEntities; import biomesoplenty.api.item.BOPItems; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -22,7 +23,6 @@ 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,6 +37,8 @@ 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; @@ -74,13 +76,13 @@ public class BoatEntityBOP extends Entity { private float rockingAngle; private float prevRockingAngle; - public BoatEntityBOP(EntityType p_i50129_1_, World p_i50129_2_) { + 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) { - this(EntityType.BOAT, worldIn); + this(BOPEntities.boat_bop, worldIn); this.setPosition(x, y, z); this.setMotion(Vec3d.ZERO); this.prevPosX = x; @@ -88,6 +90,10 @@ public class BoatEntityBOP extends Entity { this.prevPosZ = z; } + public BoatEntityBOP(FMLPlayMessages.SpawnEntity spawnEntity, World world) { + this(BOPEntities.boat_bop, world); + } + /** * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to * prevent them from trampling crops @@ -865,8 +871,9 @@ public class BoatEntityBOP extends Entity { this.backInputDown = p_184442_4_; } + @Override public IPacket createSpawnPacket() { - return new SSpawnObjectPacket(this); + return NetworkHooks.getEntitySpawningPacket(this); } // Forge: Fix MC-119811 by instantly completing lerp on board diff --git a/src/main/java/biomesoplenty/common/entity/item/BoatRendererBOP.java b/src/main/java/biomesoplenty/common/entity/item/BoatRendererBOP.java index e269fb3e9..5595e1910 100644 --- a/src/main/java/biomesoplenty/common/entity/item/BoatRendererBOP.java +++ b/src/main/java/biomesoplenty/common/entity/item/BoatRendererBOP.java @@ -3,8 +3,6 @@ package biomesoplenty.common.entity.item; import com.mojang.blaze3d.platform.GlStateManager; 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.entity.item.BoatEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; import net.minecraftforge.api.distmarker.Dist; diff --git a/src/main/java/biomesoplenty/common/item/BoatItemBOP.java b/src/main/java/biomesoplenty/common/item/BoatItemBOP.java index 3be69ca4f..8df265f9c 100644 --- a/src/main/java/biomesoplenty/common/item/BoatItemBOP.java +++ b/src/main/java/biomesoplenty/common/item/BoatItemBOP.java @@ -2,7 +2,6 @@ package biomesoplenty.common.item; import biomesoplenty.common.entity.item.BoatEntityBOP; import net.minecraft.entity.Entity; -import net.minecraft.entity.item.BoatEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -56,12 +55,8 @@ public class BoatItemBOP extends Item { if (raytraceresult.getType() == RayTraceResult.Type.BLOCK) { - //TODO: Fix boats and remove temporary vanilla boat spawn - BoatEntity boatentity = new BoatEntity(worldIn, raytraceresult.getHitVec().x, raytraceresult.getHitVec().y, raytraceresult.getHitVec().z); - boatentity.setBoatType(BoatEntity.Type.OAK); - - //BoatEntityBOP boatentity = new BoatEntityBOP(worldIn, raytraceresult.getHitVec().x, raytraceresult.getHitVec().y, raytraceresult.getHitVec().z); - //boatentity.setBoatType(this.type); + BoatEntityBOP boatentity = new BoatEntityBOP(worldIn, raytraceresult.getHitVec().x, raytraceresult.getHitVec().y, raytraceresult.getHitVec().z); + boatentity.setBoatType(this.type); boatentity.rotationYaw = playerIn.rotationYaw; if (!worldIn.isCollisionBoxesEmpty(boatentity, boatentity.getBoundingBox().grow(-0.1D))) { return new ActionResult<>(ActionResultType.FAIL, itemstack); diff --git a/src/main/java/biomesoplenty/init/ModEntities.java b/src/main/java/biomesoplenty/init/ModEntities.java index 5b515d90f..060ec97d0 100644 --- a/src/main/java/biomesoplenty/init/ModEntities.java +++ b/src/main/java/biomesoplenty/init/ModEntities.java @@ -19,13 +19,15 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.registries.ForgeRegistries; +import static biomesoplenty.core.BiomesOPlenty.MOD_ID; + public class ModEntities { public static void init() { - EntityType boat_bop = createEntity(BoatEntityBOP::new, EntityClassification.MISC, "boat_bop", 80, 3, true); - - BOPEntities.boat_bop = boat_bop; + 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.setRegistryName("boat_bop"); + ForgeRegistries.ENTITIES.register(BOPEntities.boat_bop); } public static EntityType createEntity(EntityType.IFactory factory, EntityClassification classification, String name, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates) @@ -40,6 +42,6 @@ public class ModEntities @OnlyIn(Dist.CLIENT) public static void registerRendering() { - RenderingRegistry.registerEntityRenderingHandler(BoatEntityBOP.class, manager -> new BoatRendererBOP(manager)); + RenderingRegistry.registerEntityRenderingHandler(BoatEntityBOP.class, BoatRendererBOP::new); } }