diff --git a/src/main/java/com/minelittlepony/unicopia/Debug.java b/src/main/java/com/minelittlepony/unicopia/Debug.java index b160070d..b4a19934 100644 --- a/src/main/java/com/minelittlepony/unicopia/Debug.java +++ b/src/main/java/com/minelittlepony/unicopia/Debug.java @@ -1,5 +1,30 @@ package com.minelittlepony.unicopia; +import com.minelittlepony.unicopia.entity.UEntities; + +import net.minecraft.entity.vehicle.BoatEntity; +import net.minecraft.world.World; + public interface Debug { - boolean DEBUG_SPELLBOOK_CHAPTERS = Boolean.getBoolean("unicopia.debug.spellbookChapters"); + boolean SPELLBOOK_CHAPTERS = Boolean.getBoolean("unicopia.debug.spellbookChapters"); + boolean CHECK_GAME_VALUES = Boolean.getBoolean("unicopia.debug.checkGameValues"); + + boolean[] TESTS_COMPLETE = {false}; + + static void runTests(World world) { + if (!CHECK_GAME_VALUES || TESTS_COMPLETE[0]) { + return; + } + TESTS_COMPLETE[0] = true; + + try { + for (var type : BoatEntity.Type.values()) { + var balloon = UEntities.AIR_BALLOON.create(world); + balloon.setBasketType(type); + balloon.asItem(); + } + } catch (Throwable t) { + throw new IllegalStateException("Tests failed", t); + } + } } diff --git a/src/main/java/com/minelittlepony/unicopia/Unicopia.java b/src/main/java/com/minelittlepony/unicopia/Unicopia.java index a284c33b..fd06e637 100644 --- a/src/main/java/com/minelittlepony/unicopia/Unicopia.java +++ b/src/main/java/com/minelittlepony/unicopia/Unicopia.java @@ -70,9 +70,12 @@ public class Unicopia implements ModInitializer { ((BlockDestructionManager.Source)w).getDestructionManager().tick(); ZapAppleStageStore.get(w).tick(); WeatherConditions.get(w).tick(); - if (Debug.DEBUG_SPELLBOOK_CHAPTERS) { + if (Debug.SPELLBOOK_CHAPTERS) { SpellbookChapterLoader.INSTANCE.sendUpdate(w.getServer()); } + if (Debug.CHECK_GAME_VALUES) { + Debug.runTests(w); + } }); NocturnalSleepManager.bootstrap(); diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookChapterList.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookChapterList.java index 72adc98c..3e91b7a1 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookChapterList.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookChapterList.java @@ -39,7 +39,7 @@ public class SpellbookChapterList { } public Chapter getCurrentChapter() { - if (Debug.DEBUG_SPELLBOOK_CHAPTERS) { + if (Debug.SPELLBOOK_CHAPTERS) { ClientChapters.getChapters().forEach(chapter -> { Optional.ofNullable(chapters.get(chapter.id())).flatMap(Chapter::content).ifPresent(old -> { chapter.content().ifPresent(neu -> neu.copyStateFrom(old)); diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookScreen.java index b8ca5d9e..3aa17195 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookScreen.java @@ -147,7 +147,7 @@ public class SpellbookScreen extends HandledScreen imple context.drawTexture(TEXTURE, x, y, 0, 0, backgroundWidth, backgroundHeight, 512, 256); - if (Debug.DEBUG_SPELLBOOK_CHAPTERS) { + if (Debug.SPELLBOOK_CHAPTERS) { clearAndInit(); } diff --git a/src/main/java/com/minelittlepony/unicopia/container/SpellbookChapterLoader.java b/src/main/java/com/minelittlepony/unicopia/container/SpellbookChapterLoader.java index 002a8d0a..20a928d6 100644 --- a/src/main/java/com/minelittlepony/unicopia/container/SpellbookChapterLoader.java +++ b/src/main/java/com/minelittlepony/unicopia/container/SpellbookChapterLoader.java @@ -71,7 +71,7 @@ public class SpellbookChapterLoader extends JsonDataLoader implements Identifiab LOGGER.error("Could not load spellbook chapters due to exception", e); } - if (Debug.DEBUG_SPELLBOOK_CHAPTERS) { + if (Debug.SPELLBOOK_CHAPTERS) { CompletableFuture.runAsync(() -> { try { Util.waitAndApply(executor -> reload(CompletableFuture::completedFuture, manager, profiler, profiler, Util.getMainWorkerExecutor(), executor)).get(); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/AirBalloonEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/AirBalloonEntity.java index 948431c6..83e198f8 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/AirBalloonEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/AirBalloonEntity.java @@ -6,6 +6,7 @@ import net.minecraft.entity.data.*; import net.minecraft.entity.mob.FlyingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.vehicle.BoatEntity; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.nbt.NbtCompound; @@ -31,6 +32,7 @@ import com.minelittlepony.unicopia.entity.collision.EntityCollisions; import com.minelittlepony.unicopia.entity.collision.MultiBox; import com.minelittlepony.unicopia.entity.duck.EntityDuck; import com.minelittlepony.unicopia.item.HotAirBalloonItem; +import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.server.world.WeatherConditions; public class AirBalloonEntity extends FlyingEntity implements EntityCollisions.ComplexCollidable, MultiBoundingBoxEntity { @@ -146,7 +148,6 @@ public class AirBalloonEntity extends FlyingEntity implements EntityCollisions.C @Override public void tick() { - this.shouldSave(); setAir(getMaxAir()); int boostTicks = getBoostTicks(); @@ -343,7 +344,8 @@ public class AirBalloonEntity extends FlyingEntity implements EntityCollisions.C return ActionResult.SUCCESS; } - if (stack.isOf(Items.LANTERN) && !hasBurner()) { + if ((stack.isOf(Items.LANTERN) || stack.isOf(Items.SOUL_LANTERN)) && !hasBurner()) { + setStackInHand(Hand.MAIN_HAND, stack.copyWithCount(1)); if (!player.getAbilities().creativeMode) { stack.decrement(1); } @@ -356,6 +358,33 @@ public class AirBalloonEntity extends FlyingEntity implements EntityCollisions.C return ActionResult.PASS; } + @Override + protected void dropInventory() { + ItemStack lantern = getStackInHand(Hand.MAIN_HAND); + setStackInHand(Hand.MAIN_HAND, ItemStack.EMPTY); + dropStack(lantern); + dropStack(getPickBlockStack()); + } + + @Override + public ItemStack getPickBlockStack() { + return asItem().getDefaultStack(); + } + + public Item asItem() { + return switch (getBasketType()) { + case SPRUCE -> UItems.SPRUCE_BASKET; + case BIRCH -> UItems.BIRCH_BASKET; + case JUNGLE -> UItems.JUNGLE_BASKET; + case ACACIA -> UItems.ACACIA_BASKET; + case CHERRY -> UItems.CHERRY_BASKET; + case DARK_OAK -> UItems.DARK_OAK_BASKET; + case MANGROVE -> UItems.MANGROVE_BASKET; + case BAMBOO -> UItems.BAMBOO_BASKET; + default -> UItems.OAK_BASKET; + }; + } + @Override public boolean isCollidable() { return true; @@ -424,7 +453,7 @@ public class AirBalloonEntity extends FlyingEntity implements EntityCollisions.C output.accept(VoxelShapes.cuboid(new Box(box.minX, box.minY, box.minZ, box.minX + wallThickness, wallheight, box.maxZ))); // top of balloon - if (hasBalloon()) { + if (hasBalloon() && getInflation() > 0) { output.accept(VoxelShapes.cuboid(getBalloonBoundingBox())); } } diff --git a/src/main/java/com/minelittlepony/unicopia/item/UItems.java b/src/main/java/com/minelittlepony/unicopia/item/UItems.java index 5e6a382d..233d42f8 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/UItems.java +++ b/src/main/java/com/minelittlepony/unicopia/item/UItems.java @@ -120,6 +120,15 @@ public interface UItems { Item SPELLBOOK = register("spellbook", new SpellbookItem(new Item.Settings().maxCount(1).rarity(Rarity.UNCOMMON)), ItemGroups.TOOLS); Item OAK_BASKET = register("oak_basket", new BasketItem(BoatEntity.Type.OAK, new Item.Settings().maxCount(1)), ItemGroups.FUNCTIONAL); + Item SPRUCE_BASKET = register("spruce_basket", new BasketItem(BoatEntity.Type.SPRUCE, new Item.Settings().maxCount(1)), ItemGroups.FUNCTIONAL); + Item BIRCH_BASKET = register("birch_basket", new BasketItem(BoatEntity.Type.BIRCH, new Item.Settings().maxCount(1)), ItemGroups.FUNCTIONAL); + Item JUNGLE_BASKET = register("jungle_basket", new BasketItem(BoatEntity.Type.JUNGLE, new Item.Settings().maxCount(1)), ItemGroups.FUNCTIONAL); + Item ACACIA_BASKET = register("acacia_basket", new BasketItem(BoatEntity.Type.ACACIA, new Item.Settings().maxCount(1)), ItemGroups.FUNCTIONAL); + Item CHERRY_BASKET = register("cherry_basket", new BasketItem(BoatEntity.Type.CHERRY, new Item.Settings().maxCount(1)), ItemGroups.FUNCTIONAL); + Item DARK_OAK_BASKET = register("dark_oak_basket", new BasketItem(BoatEntity.Type.DARK_OAK, new Item.Settings().maxCount(1)), ItemGroups.FUNCTIONAL); + Item MANGROVE_BASKET = register("mangrove_basket", new BasketItem(BoatEntity.Type.MANGROVE, new Item.Settings().maxCount(1)), ItemGroups.FUNCTIONAL); + Item BAMBOO_BASKET = register("bamboo_basket", new BasketItem(BoatEntity.Type.BAMBOO, new Item.Settings().maxCount(1)), ItemGroups.FUNCTIONAL); + Item GIANT_BALLOON = register("giant_balloon", new HotAirBalloonItem(new Item.Settings().maxCount(1)), ItemGroups.FUNCTIONAL); AmuletItem PEGASUS_AMULET = register("pegasus_amulet", new PegasusAmuletItem(new FabricItemSettings()