From e6fd621d3f00e4029ae9022f411936c7671b2d7f Mon Sep 17 00:00:00 2001 From: Prospector Date: Fri, 28 Feb 2020 17:40:25 -0800 Subject: [PATCH] Fix boats --- .../traverse/entity/TraverseEntities.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/terraformersmc/traverse/entity/TraverseEntities.java b/src/main/java/com/terraformersmc/traverse/entity/TraverseEntities.java index ba12158..d509069 100644 --- a/src/main/java/com/terraformersmc/traverse/entity/TraverseEntities.java +++ b/src/main/java/com/terraformersmc/traverse/entity/TraverseEntities.java @@ -14,8 +14,10 @@ import net.minecraft.item.ItemConvertible; import net.minecraft.item.ItemGroup; import net.minecraft.util.Identifier; +import net.minecraft.util.math.Vec3d; import net.minecraft.util.registry.Registry; +import java.util.Objects; import java.util.function.Supplier; public class TraverseEntities { @@ -29,10 +31,14 @@ private static EntityType registerBoat(String name, ItemCon Identifier id = new Identifier(Traverse.MOD_ID, name + "_boat"); Identifier skin = new Identifier(Traverse.MOD_ID, "textures/entity/boat/" + name + ".png"); Item item = Registry.register(Registry.ITEM, id, new TerraformBoatItem((world, x, y, z) -> { - TerraformBoatEntity entity = boatSupplier.get().create(world); - if (entity != null) { - entity.setPos(x, y, z); - } + TerraformBoatEntity entity = Objects.requireNonNull(boatSupplier.get().create(world), "null boat from EntityType::create"); + + entity.updatePosition(x, y, z); + entity.setVelocity(Vec3d.ZERO); + entity.prevX = x; + entity.prevY = y; + entity.prevZ = z; + return entity; }, new Item.Settings().maxCount(1).group(ItemGroup.TRANSPORTATION))); TerraformBoat boat = new TerraformBoat(item.asItem(), planks.asItem(), skin, vanilla);