From 78b1360149b61c27f46998ef1ac2677303ce76b5 Mon Sep 17 00:00:00 2001 From: screret <68943070+screret@users.noreply.github.com> Date: Tue, 24 Sep 2024 09:41:28 +0300 Subject: [PATCH] Wood Recipes and Boats (#1980) --- gradle/wrapper/gradle-wrapper.properties | 2 +- .../gregtechceu/gtceu/client/ClientProxy.java | 12 -- .../renderer/entity/GTBoatRenderer.java | 60 --------- .../gtceu/common/entity/GTBoat.java | 123 ------------------ .../gtceu/common/entity/GTChestBoat.java | 71 ---------- .../gtceu/common/item/GTBoatItem.java | 91 ------------- .../item/GTBoatItemDispenseBehaviour.java | 72 ---------- .../gtceu/data/entity/GTEntityTypes.java | 12 -- .../gtceu/data/enumproxy/GTEnumProxies.java | 29 +++++ .../gregtechceu/gtceu/data/item/GTItems.java | 17 +-- .../data/recipe/misc/WoodMachineRecipes.java | 1 + .../resources/META-INF/accesstransformer.cfg | 2 +- .../resources/META-INF/enum_extensions.json | 22 ++++ .../boat/{rubber_boat.png => rubber.png} | Bin .../{treated_boat.png => treated_wood.png} | Bin .../rubber.png} | Bin .../treated_wood.png} | Bin .../templates/META-INF/neoforge.mods.toml | 1 + 18 files changed, 64 insertions(+), 451 deletions(-) delete mode 100644 src/main/java/com/gregtechceu/gtceu/client/renderer/entity/GTBoatRenderer.java delete mode 100644 src/main/java/com/gregtechceu/gtceu/common/entity/GTBoat.java delete mode 100644 src/main/java/com/gregtechceu/gtceu/common/entity/GTChestBoat.java delete mode 100644 src/main/java/com/gregtechceu/gtceu/common/item/GTBoatItem.java delete mode 100644 src/main/java/com/gregtechceu/gtceu/common/item/GTBoatItemDispenseBehaviour.java create mode 100644 src/main/java/com/gregtechceu/gtceu/data/enumproxy/GTEnumProxies.java create mode 100644 src/main/resources/META-INF/enum_extensions.json rename src/main/resources/assets/gtceu/textures/entity/boat/{rubber_boat.png => rubber.png} (100%) rename src/main/resources/assets/gtceu/textures/entity/boat/{treated_boat.png => treated_wood.png} (100%) rename src/main/resources/assets/gtceu/textures/entity/{boat/rubber_chest_boat.png => chest_boat/rubber.png} (100%) rename src/main/resources/assets/gtceu/textures/entity/{boat/treated_chest_boat.png => chest_boat/treated_wood.png} (100%) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0d1842103b..e1adfb4938 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java b/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java index 9d766c5166..ab2486488c 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java +++ b/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java @@ -10,7 +10,6 @@ import com.gregtechceu.gtceu.api.worldgen.bedrockfluid.BedrockFluidDefinition; import com.gregtechceu.gtceu.api.worldgen.bedrockore.BedrockOreDefinition; import com.gregtechceu.gtceu.client.particle.HazardParticle; -import com.gregtechceu.gtceu.client.renderer.entity.GTBoatRenderer; import com.gregtechceu.gtceu.client.renderer.entity.GTExplosiveRenderer; import com.gregtechceu.gtceu.client.renderer.item.GTItemBarRenderer; import com.gregtechceu.gtceu.data.blockentity.GTBlockEntities; @@ -21,8 +20,6 @@ import com.lowdragmc.lowdraglib.gui.compass.CompassManager; import com.lowdragmc.lowdraglib.gui.compass.component.RecipeComponent; -import net.minecraft.client.model.BoatModel; -import net.minecraft.client.model.ChestBoatModel; import net.minecraft.client.renderer.blockentity.HangingSignRenderer; import net.minecraft.client.renderer.blockentity.SignRenderer; import net.minecraft.client.renderer.entity.ThrownItemRenderer; @@ -71,15 +68,6 @@ public static void onRegisterEntityRenderers(EntityRenderersEvent.RegisterRender event.registerBlockEntityRenderer(GTBlockEntities.GT_SIGN.get(), SignRenderer::new); event.registerBlockEntityRenderer(GTBlockEntities.GT_HANGING_SIGN.get(), HangingSignRenderer::new); - - event.registerEntityRenderer(GTEntityTypes.BOAT.get(), c -> new GTBoatRenderer(c, false)); - event.registerEntityRenderer(GTEntityTypes.CHEST_BOAT.get(), c -> new GTBoatRenderer(c, true)); - - for (var type : GTBoat.BoatType.values()) { - ForgeHooksClient.registerLayerDefinition(GTBoatRenderer.getBoatModelName(type), BoatModel::createBodyModel); - ForgeHooksClient.registerLayerDefinition(GTBoatRenderer.getChestBoatModelName(type), - ChestBoatModel::createBodyModel); - } } public static void onRegisterItemDecorations(RegisterItemDecorationsEvent event) { diff --git a/src/main/java/com/gregtechceu/gtceu/client/renderer/entity/GTBoatRenderer.java b/src/main/java/com/gregtechceu/gtceu/client/renderer/entity/GTBoatRenderer.java deleted file mode 100644 index f5b3d71d55..0000000000 --- a/src/main/java/com/gregtechceu/gtceu/client/renderer/entity/GTBoatRenderer.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.gregtechceu.gtceu.client.renderer.entity; - -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.common.entity.GTBoat; -import com.gregtechceu.gtceu.common.entity.GTChestBoat; - -import net.minecraft.client.model.BoatModel; -import net.minecraft.client.model.ChestBoatModel; -import net.minecraft.client.model.ListModel; -import net.minecraft.client.model.geom.ModelLayerLocation; -import net.minecraft.client.model.geom.ModelPart; -import net.minecraft.client.renderer.entity.BoatRenderer; -import net.minecraft.client.renderer.entity.EntityRendererProvider; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.entity.vehicle.Boat; - -import com.google.common.collect.ImmutableMap; -import com.mojang.datafixers.util.Pair; - -import java.util.Map; -import java.util.stream.Stream; - -public class GTBoatRenderer extends BoatRenderer { - - private final Map>> boats; - - public GTBoatRenderer(EntityRendererProvider.Context context, boolean chestBoat) { - super(context, chestBoat); - boats = Stream.of(GTBoat.BoatType.values()).collect(ImmutableMap.toImmutableMap(k -> k, - (m) -> Pair.of(new ResourceLocation(GTCEu.MOD_ID, - getTextureLocation(m, chestBoat)), createBoatModel(context, m, chestBoat)))); - } - - @Override - public Pair> getModelWithLocation(Boat boat) { - if (boat instanceof GTChestBoat gtcb) { - return this.boats.get(gtcb.getBoatType()); - } else - return this.boats.get(((GTBoat) boat).getBoatType()); - } - - private static String getTextureLocation(GTBoat.BoatType type, boolean chest) { - return chest ? "textures/entity/boat/" + type.getName() + "_chest_boat.png" : - "textures/entity/boat/" + type.getName() + "_boat.png"; - } - - private BoatModel createBoatModel(EntityRendererProvider.Context context, GTBoat.BoatType type, boolean chest) { - ModelLayerLocation modelLoc = chest ? getChestBoatModelName(type) : getBoatModelName(type); - ModelPart part = context.bakeLayer(modelLoc); - return chest ? new ChestBoatModel(part) : new BoatModel(part); - } - - public static ModelLayerLocation getChestBoatModelName(GTBoat.BoatType type) { - return new ModelLayerLocation(new ResourceLocation(GTCEu.MOD_ID, "chest_boat/" + type.getName()), "main"); - } - - public static ModelLayerLocation getBoatModelName(GTBoat.BoatType type) { - return new ModelLayerLocation(new ResourceLocation(GTCEu.MOD_ID, "boat/" + type.getName()), "main"); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/common/entity/GTBoat.java b/src/main/java/com/gregtechceu/gtceu/common/entity/GTBoat.java deleted file mode 100644 index 6986a26b67..0000000000 --- a/src/main/java/com/gregtechceu/gtceu/common/entity/GTBoat.java +++ /dev/null @@ -1,123 +0,0 @@ -package com.gregtechceu.gtceu.common.entity; - -import com.gregtechceu.gtceu.common.data.GTBlocks; -import com.gregtechceu.gtceu.common.data.GTEntityTypes; -import com.gregtechceu.gtceu.common.data.GTItems; - -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.Component; -import net.minecraft.network.protocol.Packet; -import net.minecraft.network.protocol.game.ClientGamePacketListener; -import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.vehicle.Boat; -import net.minecraft.world.item.Item; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; - -import org.jetbrains.annotations.Nullable; - -import java.util.Arrays; - -public class GTBoat extends Boat { - - public GTBoat(EntityType entityType, Level level) { - super(entityType, level); - this.blocksBuilding = true; - } - - public GTBoat(Level level, double x, double y, double z) { - super(GTEntityTypes.BOAT.get(), level); - this.setPos(x, y, z); - this.xo = x; - this.yo = y; - this.zo = z; - } - - @Nullable - @Override - public Component getCustomName() { - return super.getCustomName(); - } - - @Override - public Packet getAddEntityPacket() { - return new ClientboundAddEntityPacket(this); - } - - @Override - protected void addAdditionalSaveData(CompoundTag compound) { - compound.putString("Type", getBoatType().getName()); - } - - @Override - protected void readAdditionalSaveData(CompoundTag compound) { - if (compound.contains("Type")) { - entityData.set(DATA_ID_TYPE, BoatType.byName(compound.getString("Type")).ordinal()); - } - } - - @Override - public Item getDropItem() { - return switch (BoatType.byId(this.entityData.get(DATA_ID_TYPE))) { - case RUBBER -> GTItems.RUBBER_BOAT.get(); - case TREATED_WOOD -> GTItems.TREATED_WOOD_BOAT.get(); - }; - } - - public void setBoatType(BoatType type) { - this.entityData.set(DATA_ID_TYPE, type.ordinal()); - } - - public BoatType getBoatType() { - return BoatType.byId(entityData.get(DATA_ID_TYPE)); - } - - @Override - public void setVariant(Type variant) {} - - @Override - public Type getVariant() { - return Type.OAK; - } - - public enum BoatType { - - RUBBER("rubber", GTBlocks.RUBBER_PLANK.get()), - TREATED_WOOD("treated", GTBlocks.TREATED_WOOD_PLANK.get()); - - private final String name; - private final Block planks; - - private static final BoatType[] VALUES = values(); - - private BoatType(String name, Block planks) { - this.name = name; - this.planks = planks; - } - - public String getName() { - return this.name; - } - - public Block getPlanks() { - return this.planks; - } - - public String toString() { - return this.name; - } - - /** - * Get a boat type by its enum ordinal - */ - public static BoatType byId(int id) { - if (id < 0 || id >= VALUES.length) id = 0; - return VALUES[id]; - } - - public static BoatType byName(String name) { - return Arrays.stream(VALUES).filter(type -> type.getName().equals(name)).findFirst().orElse(VALUES[0]); - } - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/common/entity/GTChestBoat.java b/src/main/java/com/gregtechceu/gtceu/common/entity/GTChestBoat.java deleted file mode 100644 index 81825a0b61..0000000000 --- a/src/main/java/com/gregtechceu/gtceu/common/entity/GTChestBoat.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.gregtechceu.gtceu.common.entity; - -import com.gregtechceu.gtceu.common.data.GTEntityTypes; -import com.gregtechceu.gtceu.common.data.GTItems; - -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.protocol.Packet; -import net.minecraft.network.protocol.game.ClientGamePacketListener; -import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.vehicle.Boat; -import net.minecraft.world.entity.vehicle.ChestBoat; -import net.minecraft.world.item.Item; -import net.minecraft.world.level.Level; - -public class GTChestBoat extends ChestBoat { - - public GTChestBoat(EntityType entityType, Level level) { - super(entityType, level); - this.blocksBuilding = true; - } - - public GTChestBoat(Level level, double x, double y, double z) { - super(GTEntityTypes.CHEST_BOAT.get(), level); - this.setPos(x, y, z); - this.xo = x; - this.yo = y; - this.zo = z; - } - - @Override - public Packet getAddEntityPacket() { - return new ClientboundAddEntityPacket(this); - } - - @Override - protected void addAdditionalSaveData(CompoundTag compound) { - compound.putString("Type", getBoatType().getName()); - } - - @Override - protected void readAdditionalSaveData(CompoundTag compound) { - if (compound.contains("Type")) { - entityData.set(DATA_ID_TYPE, GTBoat.BoatType.byName(compound.getString("Type")).ordinal()); - } - } - - @Override - public Item getDropItem() { - return switch (GTBoat.BoatType.byId(this.entityData.get(DATA_ID_TYPE))) { - case RUBBER -> GTItems.RUBBER_CHEST_BOAT.get(); - case TREATED_WOOD -> GTItems.TREATED_WOOD_CHEST_BOAT.get(); - }; - } - - public void setBoatType(GTBoat.BoatType type) { - this.entityData.set(DATA_ID_TYPE, type.ordinal()); - } - - public GTBoat.BoatType getBoatType() { - return GTBoat.BoatType.byId(entityData.get(DATA_ID_TYPE)); - } - - @Override - public void setVariant(Type variant) {} - - @Override - public Type getVariant() { - return Type.OAK; - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/common/item/GTBoatItem.java b/src/main/java/com/gregtechceu/gtceu/common/item/GTBoatItem.java deleted file mode 100644 index 945cc8a009..0000000000 --- a/src/main/java/com/gregtechceu/gtceu/common/item/GTBoatItem.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.gregtechceu.gtceu.common.item; - -import com.gregtechceu.gtceu.common.entity.GTBoat; -import com.gregtechceu.gtceu.common.entity.GTChestBoat; - -import net.minecraft.stats.Stats; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResultHolder; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntitySelector; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.entity.vehicle.Boat; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.ClipContext; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.DispenserBlock; -import net.minecraft.world.level.gameevent.GameEvent; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.HitResult; -import net.minecraft.world.phys.Vec3; - -import java.util.List; -import java.util.function.Predicate; - -public class GTBoatItem extends Item { - - private static final Predicate ENTITY_PREDICATE = EntitySelector.NO_SPECTATORS.and(Entity::isPickable); - private final GTBoat.BoatType type; - private final boolean hasChest; - - public GTBoatItem(boolean hasChest, GTBoat.BoatType type, Item.Properties properties) { - super(properties); - this.hasChest = hasChest; - this.type = type; - DispenserBlock.registerBehavior(this, new GTBoatItemDispenseBehaviour(type, hasChest)); - } - - public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { - ItemStack itemstack = player.getItemInHand(hand); - HitResult hitresult = getPlayerPOVHitResult(level, player, ClipContext.Fluid.ANY); - if (hitresult.getType() == HitResult.Type.MISS) { - return InteractionResultHolder.pass(itemstack); - } else { - Vec3 vec3 = player.getViewVector(1.0F); - double d0 = 5.0; - List list = level.getEntities(player, - player.getBoundingBox().expandTowards(vec3.scale(5.0)).inflate(1.0), ENTITY_PREDICATE); - if (!list.isEmpty()) { - Vec3 vec31 = player.getEyePosition(); - for (Entity e : list) { - AABB aabb = e.getBoundingBox().inflate((double) e.getPickRadius()); - if (aabb.contains(vec31)) { - return InteractionResultHolder.pass(itemstack); - } - } - } - - if (hitresult.getType() == HitResult.Type.BLOCK) { - Boat boat; - if (hasChest) { - boat = new GTChestBoat(level, hitresult.getLocation().x, hitresult.getLocation().y, - hitresult.getLocation().z); - ((GTChestBoat) boat).setBoatType(type); - } else { - boat = new GTBoat(level, hitresult.getLocation().x, hitresult.getLocation().y, - hitresult.getLocation().z); - ((GTBoat) boat).setBoatType(type); - } - - boat.setYRot(player.getYRot()); - if (!level.noCollision(boat, boat.getBoundingBox())) { - return InteractionResultHolder.fail(itemstack); - } else { - if (!level.isClientSide) { - level.addFreshEntity(boat); - level.gameEvent(player, GameEvent.ENTITY_PLACE, hitresult.getLocation()); - if (!player.getAbilities().instabuild) { - itemstack.shrink(1); - } - } - - player.awardStat(Stats.ITEM_USED.get(this)); - return InteractionResultHolder.sidedSuccess(itemstack, level.isClientSide()); - } - } else { - return InteractionResultHolder.pass(itemstack); - } - } - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/common/item/GTBoatItemDispenseBehaviour.java b/src/main/java/com/gregtechceu/gtceu/common/item/GTBoatItemDispenseBehaviour.java deleted file mode 100644 index edad373466..0000000000 --- a/src/main/java/com/gregtechceu/gtceu/common/item/GTBoatItemDispenseBehaviour.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.gregtechceu.gtceu.common.item; - -import com.gregtechceu.gtceu.common.entity.GTBoat; -import com.gregtechceu.gtceu.common.entity.GTChestBoat; - -import net.minecraft.core.BlockPos; -import net.minecraft.core.BlockSource; -import net.minecraft.core.Direction; -import net.minecraft.core.dispenser.DefaultDispenseItemBehavior; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.vehicle.Boat; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.DispenserBlock; - -public class GTBoatItemDispenseBehaviour extends DefaultDispenseItemBehavior { - - private final DefaultDispenseItemBehavior defaultDispenseItemBehavior = new DefaultDispenseItemBehavior(); - private final GTBoat.BoatType type; - private final boolean isChestBoat; - - public GTBoatItemDispenseBehaviour(GTBoat.BoatType type) { - this(type, false); - } - - public GTBoatItemDispenseBehaviour(GTBoat.BoatType type, boolean isChestBoat) { - this.type = type; - this.isChestBoat = isChestBoat; - } - - public ItemStack execute(BlockSource source, ItemStack stack) { - Direction direction = (Direction) source.getBlockState().getValue(DispenserBlock.FACING); - Level level = source.getLevel(); - double d0 = 0.5625 + (double) EntityType.BOAT.getWidth() / 2.0; - double d1 = source.x() + (double) direction.getStepX() * d0; - double d2 = source.y() + (double) ((float) direction.getStepY() * 1.125F); - double d3 = source.z() + (double) direction.getStepZ() * d0; - BlockPos blockpos = source.getPos().relative(direction); - - Boat boat; - if (isChestBoat) { - boat = new GTChestBoat(level, d0, d1, d2); - ((GTChestBoat) boat).setBoatType(type); - } else { - boat = new GTBoat(level, d0, d1, d2); - ((GTBoat) boat).setBoatType(type); - } - - boat.setYRot(direction.toYRot()); - double d4; - if (((Boat) boat).canBoatInFluid(level.getFluidState(blockpos))) { - d4 = 1.0; - } else { - if (!level.getBlockState(blockpos).isAir() || - !((Boat) boat).canBoatInFluid(level.getFluidState(blockpos.below()))) { - return this.defaultDispenseItemBehavior.dispense(source, stack); - } - - d4 = 0.0; - } - - ((Boat) boat).setPos(d1, d2 + d4, d3); - level.addFreshEntity((Entity) boat); - stack.shrink(1); - return stack; - } - - protected void playSound(BlockSource source) { - source.getLevel().levelEvent(1000, source.getPos(), 0); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/data/entity/GTEntityTypes.java b/src/main/java/com/gregtechceu/gtceu/data/entity/GTEntityTypes.java index 4584bc598a..7c7e426118 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/entity/GTEntityTypes.java +++ b/src/main/java/com/gregtechceu/gtceu/data/entity/GTEntityTypes.java @@ -30,17 +30,5 @@ public class GTEntityTypes { .properties(builder -> builder.sized(0.98F, 0.98F).fireImmune().clientTrackingRange(10).updateInterval(10)) .register(); - public static final EntityEntry BOAT = REGISTRATE - .entity("boat", GTBoat::new, MobCategory.MISC) - .lang("Boat") - .properties(builder -> builder.sized(1.375f, 0.5625f).clientTrackingRange(10)) - .register(); - - public static final EntityEntry CHEST_BOAT = REGISTRATE - .entity("chest_boat", GTChestBoat::new, MobCategory.MISC) - .lang("Chest Boat") - .properties(builder -> builder.sized(1.375f, 0.5625f).clientTrackingRange(10)) - .register(); - public static void init() {} } diff --git a/src/main/java/com/gregtechceu/gtceu/data/enumproxy/GTEnumProxies.java b/src/main/java/com/gregtechceu/gtceu/data/enumproxy/GTEnumProxies.java new file mode 100644 index 0000000000..1d817fe2ae --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/data/enumproxy/GTEnumProxies.java @@ -0,0 +1,29 @@ +package com.gregtechceu.gtceu.data.enumproxy; + +import com.gregtechceu.gtceu.data.block.GTBlocks; +import com.gregtechceu.gtceu.data.item.GTItems; +import net.minecraft.world.entity.vehicle.Boat; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.Block; +import net.neoforged.fml.common.asm.enumextension.EnumProxy; + +import java.util.function.Supplier; + +@SuppressWarnings({ "Convert2MethodRef", "FunctionalExpressionCanBeFolded" }) +public class GTEnumProxies { + + public static final EnumProxy RUBBER_BOAT_PROXY = new EnumProxy<>(Boat.Type.class, + (Supplier) () -> GTBlocks.RUBBER_PLANK.get(), "gtceu:rubber", + (Supplier) () -> GTItems.RUBBER_BOAT.get(), + (Supplier) () -> GTItems.RUBBER_CHEST_BOAT.get(), + (Supplier) () -> Items.STICK, + false); + + public static final EnumProxy TREATED_WOOD_BOAT_PROXY = new EnumProxy<>(Boat.Type.class, + (Supplier) () -> GTBlocks.TREATED_WOOD_PLANK.get(), "gtceu:treated_wood", + (Supplier) () -> GTItems.TREATED_WOOD_BOAT.get(), + (Supplier) () -> GTItems.TREATED_WOOD_CHEST_BOAT.get(), + (Supplier) () -> Items.STICK, + false); +} diff --git a/src/main/java/com/gregtechceu/gtceu/data/item/GTItems.java b/src/main/java/com/gregtechceu/gtceu/data/item/GTItems.java index 083d2f08a1..87042e7a58 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/item/GTItems.java +++ b/src/main/java/com/gregtechceu/gtceu/data/item/GTItems.java @@ -40,6 +40,7 @@ import com.gregtechceu.gtceu.data.compass.GTCompassNodes; import com.gregtechceu.gtceu.data.compass.GTCompassSections; import com.gregtechceu.gtceu.data.cover.GTCovers; +import com.gregtechceu.gtceu.data.enumproxy.GTEnumProxies; import com.gregtechceu.gtceu.data.lang.LangHandler; import com.gregtechceu.gtceu.data.material.GTFoods; import com.gregtechceu.gtceu.data.material.GTMaterials; @@ -2756,24 +2757,24 @@ public Component getItemName(ItemStack stack) { public static ItemEntry BLACKLIGHT = REGISTRATE.item("blacklight", Item::new) .onRegister(compassNode(GTCompassSections.MISC)).register(); - public static ItemEntry RUBBER_BOAT = REGISTRATE - .item("rubber_boat", p -> new GTBoatItem(false, GTBoat.BoatType.RUBBER, new Item.Properties())) + public static ItemEntry RUBBER_BOAT = REGISTRATE + .item("rubber_boat", p -> new BoatItem(false, GTEnumProxies.RUBBER_BOAT_PROXY.getValue(), new Item.Properties())) .lang("Rubber Boat") .register(); - public static ItemEntry TREATED_WOOD_BOAT = REGISTRATE - .item("treated_wood_boat", p -> new GTBoatItem(false, GTBoat.BoatType.TREATED_WOOD, new Item.Properties())) + public static ItemEntry TREATED_WOOD_BOAT = REGISTRATE + .item("treated_wood_boat", p -> new BoatItem(false, GTEnumProxies.TREATED_WOOD_BOAT_PROXY.getValue(), new Item.Properties())) .lang("Treated Wood Boat") .register(); - public static ItemEntry RUBBER_CHEST_BOAT = REGISTRATE - .item("rubber_chest_boat", p -> new GTBoatItem(true, GTBoat.BoatType.RUBBER, new Item.Properties())) + public static ItemEntry RUBBER_CHEST_BOAT = REGISTRATE + .item("rubber_chest_boat", p -> new BoatItem(true, GTEnumProxies.RUBBER_BOAT_PROXY.getValue(), new Item.Properties())) .lang("Rubber Boat with Chest") .register(); - public static ItemEntry TREATED_WOOD_CHEST_BOAT = REGISTRATE + public static ItemEntry TREATED_WOOD_CHEST_BOAT = REGISTRATE .item("treated_wood_chest_boat", - p -> new GTBoatItem(true, GTBoat.BoatType.TREATED_WOOD, new Item.Properties())) + p -> new BoatItem(true, GTEnumProxies.TREATED_WOOD_BOAT_PROXY.getValue(), new Item.Properties())) .lang("Treated Wood Boat with Chest") .register(); diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/WoodMachineRecipes.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/WoodMachineRecipes.java index d07e84eb2d..08d19a9db9 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/WoodMachineRecipes.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/WoodMachineRecipes.java @@ -9,6 +9,7 @@ import com.gregtechceu.gtceu.api.tag.TagUtil; import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.data.block.GTBlocks; +import com.gregtechceu.gtceu.data.item.GTItems; import com.gregtechceu.gtceu.data.material.GTMaterials; import com.gregtechceu.gtceu.data.recipe.VanillaRecipeHelper; import com.gregtechceu.gtceu.data.recipe.WoodTypeEntry; diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 861d54252d..8aacc1f5a2 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -21,7 +21,7 @@ public net.minecraft.world.entity.item.ItemEntity pickupDelay public net.minecraft.server.network.ServerGamePacketListenerImpl aboveGroundTickCount public net.minecraft.world.entity.Entity setSharedFlag(IZ)V -public net.minecraft.world.entity.vehicle.Boat f_38285_ # DATA_ID_TYPE +public net.minecraft.world.entity.vehicle.Boat DATA_ID_TYPE # for AE2 to be able to load (idk why but it needs these?) public net.minecraft.world.level.block.Blocks always(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)Z diff --git a/src/main/resources/META-INF/enum_extensions.json b/src/main/resources/META-INF/enum_extensions.json new file mode 100644 index 0000000000..42383ec292 --- /dev/null +++ b/src/main/resources/META-INF/enum_extensions.json @@ -0,0 +1,22 @@ +{ + "entries": [ + { + "enum": "net/minecraft/world/entity/vehicle/Boat$Type", + "name": "GTCEU_RUBBER", + "constructor": "(Ljava/util/function/Supplier;Ljava/lang/String;Ljava/util/function/Supplier;Ljava/util/function/Supplier;Ljava/util/function/Supplier;Z)V", + "parameters": { + "class": "com/gregtechceu/gtceu/data/enumproxy/GTEnumProxies", + "field": "RUBBER_BOAT_PROXY" + } + }, + { + "enum": "net/minecraft/world/entity/vehicle/Boat$Type", + "name": "GTCEU_TREATED_WOOD", + "constructor": "(Ljava/util/function/Supplier;Ljava/lang/String;Ljava/util/function/Supplier;Ljava/util/function/Supplier;Ljava/util/function/Supplier;Z)V", + "parameters": { + "class": "com/gregtechceu/gtceu/data/enumproxy/GTEnumProxies", + "field": "TREATED_WOOD_BOAT_PROXY" + } + } + ] +} diff --git a/src/main/resources/assets/gtceu/textures/entity/boat/rubber_boat.png b/src/main/resources/assets/gtceu/textures/entity/boat/rubber.png similarity index 100% rename from src/main/resources/assets/gtceu/textures/entity/boat/rubber_boat.png rename to src/main/resources/assets/gtceu/textures/entity/boat/rubber.png diff --git a/src/main/resources/assets/gtceu/textures/entity/boat/treated_boat.png b/src/main/resources/assets/gtceu/textures/entity/boat/treated_wood.png similarity index 100% rename from src/main/resources/assets/gtceu/textures/entity/boat/treated_boat.png rename to src/main/resources/assets/gtceu/textures/entity/boat/treated_wood.png diff --git a/src/main/resources/assets/gtceu/textures/entity/boat/rubber_chest_boat.png b/src/main/resources/assets/gtceu/textures/entity/chest_boat/rubber.png similarity index 100% rename from src/main/resources/assets/gtceu/textures/entity/boat/rubber_chest_boat.png rename to src/main/resources/assets/gtceu/textures/entity/chest_boat/rubber.png diff --git a/src/main/resources/assets/gtceu/textures/entity/boat/treated_chest_boat.png b/src/main/resources/assets/gtceu/textures/entity/chest_boat/treated_wood.png similarity index 100% rename from src/main/resources/assets/gtceu/textures/entity/boat/treated_chest_boat.png rename to src/main/resources/assets/gtceu/textures/entity/chest_boat/treated_wood.png diff --git a/src/main/templates/META-INF/neoforge.mods.toml b/src/main/templates/META-INF/neoforge.mods.toml index 29ea121f0a..358953559c 100644 --- a/src/main/templates/META-INF/neoforge.mods.toml +++ b/src/main/templates/META-INF/neoforge.mods.toml @@ -12,6 +12,7 @@ description = "${mod_description}" logoFile = "icon.png" displayURL = "${mod_url}" credits = "GregoriusT, Mr_Touchyou, Zerrens for making GregTech and textures, the GT5u authors and maintainers for providing the original code, and the community." +enumExtensions="META-INF/enum_extensions.json" [[mixins]] config="${mod_id}.mixins.json"