Merge pull request #1425 from Corail31/BOP-1.14.x-9.x.x

fix custom boats
This commit is contained in:
Adubbz 2019-07-29 18:15:30 +10:00 committed by GitHub
commit 8c4c64d559
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 18 deletions

View file

@ -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<BoatEntityBOP> boat_bop;
}

View file

@ -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<BoatEntityBOP> 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

View file

@ -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;

View file

@ -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);

View file

@ -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<BoatEntityBOP> boat_bop = createEntity(BoatEntityBOP::new, EntityClassification.MISC, "boat_bop", 80, 3, true);
BOPEntities.boat_bop = boat_bop;
BOPEntities.boat_bop = EntityType.Builder.<BoatEntityBOP>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 <T extends Entity> EntityType<T> createEntity(EntityType.IFactory<T> 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);
}
}