Skip to content

Commit

Permalink
Wood Recipes and Boats (#1980)
Browse files Browse the repository at this point in the history
  • Loading branch information
YoungOnionMC authored Sep 19, 2024
1 parent 14e321a commit 95ca694
Show file tree
Hide file tree
Showing 27 changed files with 692 additions and 25 deletions.
6 changes: 6 additions & 0 deletions src/generated/resources/assets/gtceu/lang/en_ud.json
Original file line number Diff line number Diff line change
Expand Up @@ -2586,6 +2586,8 @@
"enchantment.gtceu.disjunction.desc": "˙sqoɯ pǝʇɐןǝɹ-ɹǝpuƎ oʇ ssǝuʍoןS puɐ ssǝuʞɐǝM sǝıןddⱯ",
"enchantment.gtceu.hard_hammer.desc": "˙ɹǝɯɯɐH ɥɔǝ⟘bǝɹ⅁ ɐ ɥʇıʍ pǝuıɯ ǝɹǝʍ ʎǝɥʇ ɟı sɐ sʞɔoןq sʞɐǝɹᗺ",
"enchantment.hard_hammer": "buıɹǝɯɯɐH",
"entity.gtceu.boat": "ʇɐoᗺ",
"entity.gtceu.chest_boat": "ʇɐoᗺ ʇsǝɥƆ",
"entity.gtceu.dynamite": "ǝʇıɯɐuʎᗡ",
"entity.gtceu.industrial_tnt": "⟘N⟘ ןɐıɹʇsnpuI",
"entity.gtceu.powderbarrel": "ןǝɹɹɐqɹǝpʍoԀ",
Expand Down Expand Up @@ -4716,6 +4718,8 @@
"item.gtceu.rotor_casting_mold.tooltip": "sɹoʇoᴚ buıʞɐɯ ɹoɟ pןoWㄥ§",
"item.gtceu.rotor_extruder_mold": ")ɹoʇoᴚ( pןoW ɹǝpnɹʇxƎ",
"item.gtceu.rotor_extruder_mold.tooltip": "sɹoʇoᴚ buıʞɐɯ ɹoɟ ǝdɐɥS ɹǝpnɹʇxƎㄥ§",
"item.gtceu.rubber_boat": "ʇɐoᗺ ɹǝqqnᴚ",
"item.gtceu.rubber_chest_boat": "ʇsǝɥƆ ɥʇıʍ ʇɐoᗺ ɹǝqqnᴚ",
"item.gtceu.rubber_gloves": "sǝʌoן⅁ ɹǝqqnᴚ",
"item.gtceu.salt_dust": "ʇןɐS",
"item.gtceu.saw_extruder_mold.tooltip": "sʍɐS buıʞɐɯ ɹoɟ ǝdɐɥS ɹǝpnɹʇxƎㄥ§",
Expand Down Expand Up @@ -4928,7 +4932,9 @@
"item.gtceu.tool.wrench.tooltip": "sǝuıɥɔɐW ǝןʇuɐɯsıp oʇ ʞɔıןɔ ʇɟǝן pןoH8§",
"item.gtceu.transistor": "ɹoʇsısuɐɹ⟘",
"item.gtceu.transistor.tooltip": "ʇuǝuodɯoƆ ɔıuoɹʇɔǝןƎ ɔısɐᗺㄥ§",
"item.gtceu.treated_wood_boat": "ʇɐoᗺ pooM pǝʇɐǝɹ⟘",
"item.gtceu.treated_wood_bolt": "ʞɔıʇS pooM pǝʇɐǝɹ⟘ ʇɹoɥS",
"item.gtceu.treated_wood_chest_boat": "ʇsǝɥƆ ɥʇıʍ ʇɐoᗺ pooM pǝʇɐǝɹ⟘",
"item.gtceu.treated_wood_dust": "dןnԀ pooM pǝʇɐǝɹ⟘",
"item.gtceu.treated_wood_plate": "ʞuɐןԀ pooM pǝʇɐǝɹ⟘",
"item.gtceu.treated_wood_rod": "ʞɔıʇS pooM pǝʇɐǝɹ⟘",
Expand Down
6 changes: 6 additions & 0 deletions src/generated/resources/assets/gtceu/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -2586,6 +2586,8 @@
"enchantment.gtceu.disjunction.desc": "Applies Weakness and Slowness to Ender-related mobs.",
"enchantment.gtceu.hard_hammer.desc": "Breaks blocks as if they were mined with a GregTech Hammer.",
"enchantment.hard_hammer": "Hammering",
"entity.gtceu.boat": "Boat",
"entity.gtceu.chest_boat": "Chest Boat",
"entity.gtceu.dynamite": "Dynamite",
"entity.gtceu.industrial_tnt": "Industrial TNT",
"entity.gtceu.powderbarrel": "Powderbarrel",
Expand Down Expand Up @@ -4716,6 +4718,8 @@
"item.gtceu.rotor_casting_mold.tooltip": "§7Mold for making Rotors",
"item.gtceu.rotor_extruder_mold": "Extruder Mold (Rotor)",
"item.gtceu.rotor_extruder_mold.tooltip": "§7Extruder Shape for making Rotors",
"item.gtceu.rubber_boat": "Rubber Boat",
"item.gtceu.rubber_chest_boat": "Rubber Boat with Chest",
"item.gtceu.rubber_gloves": "Rubber Gloves",
"item.gtceu.salt_dust": "Salt",
"item.gtceu.saw_extruder_mold.tooltip": "§7Extruder Shape for making Saws",
Expand Down Expand Up @@ -4928,7 +4932,9 @@
"item.gtceu.tool.wrench.tooltip": "§8Hold left click to dismantle Machines",
"item.gtceu.transistor": "Transistor",
"item.gtceu.transistor.tooltip": "§7Basic Electronic Component",
"item.gtceu.treated_wood_boat": "Treated Wood Boat",
"item.gtceu.treated_wood_bolt": "Short Treated Wood Stick",
"item.gtceu.treated_wood_chest_boat": "Treated Wood Boat with Chest",
"item.gtceu.treated_wood_dust": "Treated Wood Pulp",
"item.gtceu.treated_wood_plate": "Treated Wood Plank",
"item.gtceu.treated_wood_rod": "Treated Wood Stick",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "gtceu:item/rubber_boat"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "gtceu:item/rubber_chest_boat"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "gtceu:item/treated_wood_boat"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "gtceu:item/treated_wood_chest_boat"
}
}
14 changes: 14 additions & 0 deletions src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,27 @@
import com.gregtechceu.gtceu.api.gui.compass.GTRecipeViewCreator;
import com.gregtechceu.gtceu.api.gui.compass.MultiblockAction;
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.common.CommonProxy;
import com.gregtechceu.gtceu.common.data.GTBlockEntities;
import com.gregtechceu.gtceu.common.data.GTEntityTypes;
import com.gregtechceu.gtceu.common.data.GTParticleTypes;
import com.gregtechceu.gtceu.common.entity.GTBoat;
import com.gregtechceu.gtceu.utils.input.KeyBind;

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;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.client.event.RegisterGuiOverlaysEvent;
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
Expand Down Expand Up @@ -64,6 +69,15 @@ public void onRegisterEntityRenderers(EntityRenderersEvent.RegisterRenderers eve

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

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
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<GTBoat.BoatType, Pair<ResourceLocation, ListModel<Boat>>> 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<ResourceLocation, ListModel<Boat>> 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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,7 @@ public static ItemColor leavesItemColor() {
.tag(ItemTags.WOODEN_FENCES)
.build()
.register();

public static final BlockEntry<GTStandingSignBlock> TREATED_WOOD_SIGN = REGISTRATE
.block("treated_wood_sign", (p) -> new GTStandingSignBlock(p, TREATED_WOOD_TYPE))
.initialProperties(() -> Blocks.SPRUCE_SIGN)
Expand Down
16 changes: 13 additions & 3 deletions src/main/java/com/gregtechceu/gtceu/common/data/GTEntityTypes.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.gregtechceu.gtceu.common.data;

import com.gregtechceu.gtceu.common.entity.DynamiteEntity;
import com.gregtechceu.gtceu.common.entity.IndustrialTNTEntity;
import com.gregtechceu.gtceu.common.entity.PowderbarrelEntity;
import com.gregtechceu.gtceu.common.entity.*;

import net.minecraft.tags.EntityTypeTags;
import net.minecraft.world.entity.MobCategory;
Expand Down Expand Up @@ -32,5 +30,17 @@ public class GTEntityTypes {
.properties(builder -> builder.sized(0.98F, 0.98F).fireImmune().clientTrackingRange(10).updateInterval(10))
.register();

public static final EntityEntry<GTBoat> BOAT = REGISTRATE
.<GTBoat>entity("boat", GTBoat::new, MobCategory.MISC)
.lang("Boat")
.properties(builder -> builder.sized(1.375f, 0.5625f).clientTrackingRange(10))
.register();

public static final EntityEntry<GTChestBoat> CHEST_BOAT = REGISTRATE
.<GTChestBoat>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() {}
}
22 changes: 22 additions & 0 deletions src/main/java/com/gregtechceu/gtceu/common/data/GTItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.gregtechceu.gtceu.api.registry.registrate.CompassSection;
import com.gregtechceu.gtceu.api.registry.registrate.GTRegistrate;
import com.gregtechceu.gtceu.common.data.materials.GTFoods;
import com.gregtechceu.gtceu.common.entity.GTBoat;
import com.gregtechceu.gtceu.common.item.*;
import com.gregtechceu.gtceu.common.item.armor.*;
import com.gregtechceu.gtceu.common.item.tool.behavior.LighterBehavior;
Expand Down Expand Up @@ -2698,6 +2699,27 @@ public Component getItemName(ItemStack stack) {
public static ItemEntry<Item> BLACKLIGHT = REGISTRATE.item("blacklight", Item::new)
.onRegister(compassNode(GTCompassSections.MISC)).register();

public static ItemEntry<GTBoatItem> RUBBER_BOAT = REGISTRATE
.item("rubber_boat", p -> new GTBoatItem(false, GTBoat.BoatType.RUBBER, new Item.Properties()))
.lang("Rubber Boat")
.register();

public static ItemEntry<GTBoatItem> TREATED_WOOD_BOAT = REGISTRATE
.item("treated_wood_boat", p -> new GTBoatItem(false, GTBoat.BoatType.TREATED_WOOD, new Item.Properties()))
.lang("Treated Wood Boat")
.register();

public static ItemEntry<GTBoatItem> RUBBER_CHEST_BOAT = REGISTRATE
.item("rubber_chest_boat", p -> new GTBoatItem(true, GTBoat.BoatType.RUBBER, new Item.Properties()))
.lang("Rubber Boat with Chest")
.register();

public static ItemEntry<GTBoatItem> TREATED_WOOD_CHEST_BOAT = REGISTRATE
.item("treated_wood_chest_boat",
p -> new GTBoatItem(true, GTBoat.BoatType.TREATED_WOOD, new Item.Properties()))
.lang("Treated Wood Boat with Chest")
.register();

public static void init() {
generateMaterialItems();
generateTools();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public static void init() {
ingot.setIgnored(Iron, Items.IRON_INGOT);
ingot.setIgnored(Gold, Items.GOLD_INGOT);
ingot.setIgnored(Copper, Items.COPPER_INGOT);
ingot.setIgnored(Brick, Items.BRICK);
ingot.setIgnored(Wax, Items.HONEYCOMB);

nugget.setIgnored(Gold, Items.GOLD_NUGGET);
Expand Down
123 changes: 123 additions & 0 deletions src/main/java/com/gregtechceu/gtceu/common/entity/GTBoat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
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<? extends Boat> 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<ClientGamePacketListener> 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]);
}
}
}
Loading

0 comments on commit 95ca694

Please sign in to comment.