mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Added drops for the hot air balloon
This commit is contained in:
parent
d27aaac04e
commit
31375f5c2d
7 changed files with 74 additions and 8 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -147,7 +147,7 @@ public class SpellbookScreen extends HandledScreen<SpellbookScreenHandler> imple
|
|||
|
||||
context.drawTexture(TEXTURE, x, y, 0, 0, backgroundWidth, backgroundHeight, 512, 256);
|
||||
|
||||
if (Debug.DEBUG_SPELLBOOK_CHAPTERS) {
|
||||
if (Debug.SPELLBOOK_CHAPTERS) {
|
||||
clearAndInit();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue