diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..9bbc975c Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..37f853b1 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index f5feea6d..faf93008 100644 --- a/gradlew +++ b/gradlew @@ -86,8 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s -' "$PWD" ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -206,7 +205,7 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. diff --git a/src/main/java/com/drmangotea/tfmg/TFMG.java b/src/main/java/com/drmangotea/tfmg/TFMG.java index 9a5aa3c6..cd1eae20 100644 --- a/src/main/java/com/drmangotea/tfmg/TFMG.java +++ b/src/main/java/com/drmangotea/tfmg/TFMG.java @@ -1,9 +1,6 @@ package com.drmangotea.tfmg; -import com.drmangotea.tfmg.base.TFMGBoilerHeaters; -import com.drmangotea.tfmg.base.TFMGContraptions; -import com.drmangotea.tfmg.base.TFMGCreativeTabs; -import com.drmangotea.tfmg.base.TFMGRegistrate; +import com.drmangotea.tfmg.base.*; import com.drmangotea.tfmg.content.electricity.base.ElectricNetworkManager; import com.drmangotea.tfmg.content.engines.fuels.BaseFuelTypes; import com.drmangotea.tfmg.content.items.weapons.explosives.thermite_grenades.fire.TFMGColoredFires; @@ -15,7 +12,10 @@ import com.drmangotea.tfmg.content.decoration.pipes.TFMGPipes; import com.drmangotea.tfmg.registry.*; import com.drmangotea.tfmg.worldgen.TFMGFeatures; import com.mojang.logging.LogUtils; -import com.simibubi.create.AllSoundEvents; +import com.simibubi.create.foundation.item.ItemDescription; +import com.simibubi.create.foundation.item.KineticStats; +import com.simibubi.create.foundation.item.TooltipModifier; +import net.createmod.catnip.lang.FontHelper; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.RenderType; import net.minecraft.resources.ResourceLocation; @@ -32,6 +32,7 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.RegisterEvent; import org.slf4j.Logger; +import static net.createmod.catnip.lang.FontHelper.styleFromColor; @SuppressWarnings("removal") @@ -48,17 +49,27 @@ public class TFMG { public static final TFMGRegistrate REGISTRATE = TFMGRegistrate.create(); + public static final FontHelper.Palette TFMG_PALETTE = new FontHelper.Palette(styleFromColor(0x4c5155), styleFromColor(0x838c8a)); + + static { + REGISTRATE.setTooltipModifierFactory((item) -> (new ItemDescription.Modifier(item, TFMG_PALETTE)).andThen(TooltipModifier.mapNull(KineticStats.create(item)))); + //.andThen(TooltipModifier.mapNull(CableTypeStats.create(item))) (save this for whenever the fuck I figure out what resistivity is meant to do) + } + public TFMG() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); REGISTRATE.registerEventListeners(modEventBus); + TFMGRegistries.register(); TFMGSoundEvents.prepare(); TFMGPipes.init(); TFMGBlocks.init(); TFMGBlockEntities.init(); TFMGItems.init(); + TFMGElectrodes.register(); + TFMGCableTypes.register(); TFMGEntityTypes.init(); TFMGPartialModels.init(); diff --git a/src/main/java/com/drmangotea/tfmg/base/TFMGRegistrate.java b/src/main/java/com/drmangotea/tfmg/base/TFMGRegistrate.java index c5bef84a..2b21c497 100644 --- a/src/main/java/com/drmangotea/tfmg/base/TFMGRegistrate.java +++ b/src/main/java/com/drmangotea/tfmg/base/TFMGRegistrate.java @@ -2,6 +2,10 @@ package com.drmangotea.tfmg.base; import com.drmangotea.tfmg.TFMG; import com.drmangotea.tfmg.base.fluid.GasFluidType; +import com.drmangotea.tfmg.content.electricity.connection.cable_type.CableType; +import com.drmangotea.tfmg.content.electricity.connection.cable_type.CableTypeBuilder; +import com.drmangotea.tfmg.content.machinery.vat.electrode_holder.electrode.Electrode; +import com.drmangotea.tfmg.content.machinery.vat.electrode_holder.electrode.ElectrodeBuilder; import com.simibubi.create.content.fluids.VirtualFluid; import com.simibubi.create.foundation.data.CreateRegistrate; import com.simibubi.create.foundation.data.VirtualFluidBuilder; @@ -9,8 +13,8 @@ import com.simibubi.create.foundation.item.ItemDescription; import com.simibubi.create.foundation.item.KineticStats; import com.simibubi.create.foundation.item.TooltipModifier; import com.tterrag.registrate.builders.FluidBuilder; +import com.tterrag.registrate.util.nullness.NonNullFunction; import net.createmod.catnip.lang.FontHelper; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.*; import net.minecraftforge.registries.ForgeRegistries; @@ -60,4 +64,35 @@ public class TFMGRegistrate extends CreateRegistrate { return TFMG.REGISTRATE.get(name+"_bucket", ForgeRegistries.ITEMS.getRegistryKey()).get(); } + public CableTypeBuilder cableType(NonNullFunction factory) { + return cableType((TFMGRegistrate) self(), factory); + } + + public CableTypeBuilder cableType(String name, NonNullFunction factory) { + return cableType((TFMGRegistrate) self(), name, factory); + } + + public CableTypeBuilder cableType(P parent, NonNullFunction factory) { + return cableType(parent, currentName(), factory); + } + + public CableTypeBuilder cableType(P parent, String name, NonNullFunction factory) { + return entry(name, callback -> CableTypeBuilder.create(this, parent, name, callback, factory)); + } + + public ElectrodeBuilder electrode(NonNullFunction factory) { + return electrode((TFMGRegistrate) self(), factory); + } + + public ElectrodeBuilder electrode(String name, NonNullFunction factory) { + return electrode((TFMGRegistrate) self(), name, factory); + } + + public ElectrodeBuilder electrode(P parent, NonNullFunction factory) { + return electrode(parent, currentName(), factory); + } + + public ElectrodeBuilder electrode(P parent, String name, NonNullFunction factory) { + return entry(name, callback -> ElectrodeBuilder.create(this, parent, name, callback, factory)); + } } diff --git a/src/main/java/com/drmangotea/tfmg/base/TFMGRegistries.java b/src/main/java/com/drmangotea/tfmg/base/TFMGRegistries.java new file mode 100644 index 00000000..48978b95 --- /dev/null +++ b/src/main/java/com/drmangotea/tfmg/base/TFMGRegistries.java @@ -0,0 +1,23 @@ +package com.drmangotea.tfmg.base; + +import com.drmangotea.tfmg.TFMG; +import com.drmangotea.tfmg.content.electricity.connection.cable_type.CableType; +import com.drmangotea.tfmg.content.machinery.vat.electrode_holder.electrode.Electrode; +import net.minecraft.core.Registry; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.registries.RegistryBuilder; + +import java.util.HashMap; +import java.util.Map; + +public class TFMGRegistries { + public static final Map registeredCableTypes = new HashMap<>(); + public static final Map registeredElectrodes = new HashMap<>(); + + public static final ResourceKey> CABLE_TYPE = TFMG.REGISTRATE.makeRegistry("cable_type", () -> new RegistryBuilder().hasTags().allowModification().setDefaultKey(TFMG.asResource("empty"))); + public static final ResourceKey> ELECTRODE = TFMG.REGISTRATE.makeRegistry("electrode", () -> new RegistryBuilder().hasTags().allowModification().setDefaultKey(TFMG.asResource("none"))); + + public static void register() { + } +} diff --git a/src/main/java/com/drmangotea/tfmg/base/TFMGUtils.java b/src/main/java/com/drmangotea/tfmg/base/TFMGUtils.java index ee1fef6d..1875d823 100644 --- a/src/main/java/com/drmangotea/tfmg/base/TFMGUtils.java +++ b/src/main/java/com/drmangotea/tfmg/base/TFMGUtils.java @@ -4,7 +4,9 @@ package com.drmangotea.tfmg.base; import com.drmangotea.tfmg.TFMG; import com.drmangotea.tfmg.base.spark.ElectricSparkParticle; import com.drmangotea.tfmg.base.spark.Spark; +import com.drmangotea.tfmg.content.electricity.connection.cable_type.CableType; import com.drmangotea.tfmg.content.electricity.connection.cables.CablePos; +import com.drmangotea.tfmg.content.machinery.vat.electrode_holder.electrode.Electrode; import com.drmangotea.tfmg.registry.TFMGEntityTypes; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; @@ -22,6 +24,7 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; import net.minecraft.util.Mth; @@ -381,5 +384,11 @@ public class TFMGUtils { vertexConsumer.vertex(matrix4f, x + p_174319_, y + thickness - p_174318_ + pain, z - p_174320_).color(red, green, blue, 1.0F).uv2(k).endVertex(); } + public static Electrode getElectrode(ResourceLocation name) { + return TFMGRegistries.registeredElectrodes.get(name); + } + public static CableType getCableType(ResourceLocation name) { + return TFMGRegistries.registeredCableTypes.get(name); + } } diff --git a/src/main/java/com/drmangotea/tfmg/config/TFMGConfigs.java b/src/main/java/com/drmangotea/tfmg/config/TFMGConfigs.java index ed8ab701..b2e4fb3a 100644 --- a/src/main/java/com/drmangotea/tfmg/config/TFMGConfigs.java +++ b/src/main/java/com/drmangotea/tfmg/config/TFMGConfigs.java @@ -1,7 +1,7 @@ package com.drmangotea.tfmg.config; +import com.drmangotea.tfmg.content.electricity.connection.cable_type.ResistivityValues; import com.simibubi.create.api.stress.BlockStressValues; -import com.simibubi.create.infrastructure.config.CCommon; import net.createmod.catnip.config.ConfigBase; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -58,6 +58,8 @@ public class TFMGConfigs { TFMGStress stress = TFMGConfigs.server().stressValues; BlockStressValues.IMPACTS.registerProvider(stress::getImpact); BlockStressValues.CAPACITIES.registerProvider(stress::getCapacity); + TFMGResistivity resistivity = server().resistivityValues; + ResistivityValues.RESISTIVITIES.registerProvider(resistivity::getResistivity); } @SubscribeEvent diff --git a/src/main/java/com/drmangotea/tfmg/config/TFMGResistivity.java b/src/main/java/com/drmangotea/tfmg/config/TFMGResistivity.java new file mode 100644 index 00000000..5540b9b6 --- /dev/null +++ b/src/main/java/com/drmangotea/tfmg/config/TFMGResistivity.java @@ -0,0 +1,63 @@ +package com.drmangotea.tfmg.config; + +import com.drmangotea.tfmg.TFMG; +import com.drmangotea.tfmg.content.electricity.connection.cable_type.CableType; +import com.drmangotea.tfmg.content.electricity.connection.cable_type.CableTypeBuilder; +import com.tterrag.registrate.util.nullness.NonNullUnaryOperator; +import it.unimi.dsi.fastutil.objects.Object2DoubleMap; +import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap; +import net.createmod.catnip.config.ConfigBase; +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.common.ForgeConfigSpec; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; +import java.util.function.DoubleSupplier; + +public class TFMGResistivity extends ConfigBase { + // bump this version to reset configured values. + private static final int VERSION = 2; + + // IDs need to be used since configs load before registration + + private static final Object2DoubleMap DEFAULT_RESISTIVITIES = new Object2DoubleOpenHashMap<>(); + + protected final Map> resistivities = new HashMap<>(); + + @Override + public void registerAll(ForgeConfigSpec.Builder builder) { + builder.comment(".", Comments.resistivity).push("resistivity"); + DEFAULT_RESISTIVITIES.forEach((id, value) -> this.resistivities.put(id, builder.define(id.getPath(), value))); + builder.pop(); + } + + @Override + public String getName() { + return "resistivityValues.v" + VERSION; + } + + @Nullable + public DoubleSupplier getResistivity(CableType cableType) { + ResourceLocation id = cableType.getKey(); + ForgeConfigSpec.ConfigValue value = this.resistivities.get(id); + return value == null ? null : value::get; + } + + public static NonNullUnaryOperator> setNoResistivity() { + return setResistivity(0); + } + + public static NonNullUnaryOperator> setResistivity(double value) { + return builder -> { + //assertFromCreate(builder); + ResourceLocation id = TFMG.asResource(builder.getName()); + DEFAULT_RESISTIVITIES.put(id, value); + return builder; + }; + } + + private static class Comments { + static String resistivity = "Configure the individual resistivity of cable types."; + } +} diff --git a/src/main/java/com/drmangotea/tfmg/config/TFMGServerConfig.java b/src/main/java/com/drmangotea/tfmg/config/TFMGServerConfig.java index 99a3ee77..b4bd7a09 100644 --- a/src/main/java/com/drmangotea/tfmg/config/TFMGServerConfig.java +++ b/src/main/java/com/drmangotea/tfmg/config/TFMGServerConfig.java @@ -7,7 +7,8 @@ public class TFMGServerConfig extends ConfigBase { - public final TFMGStress stressValues = nested(0, TFMGStress::new, "Fine tune the kinetic stats of individual components"); + public final TFMGStress stressValues = nested(1, TFMGStress::new, "Fine tune the kinetic stats of individual components"); + public final TFMGResistivity resistivityValues = nested(0, TFMGResistivity::new, "Fine tune the resistivity stats of individual cable types"); @Override public String getName() { diff --git a/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cable_type/CableType.java b/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cable_type/CableType.java new file mode 100644 index 00000000..7050cb9c --- /dev/null +++ b/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cable_type/CableType.java @@ -0,0 +1,69 @@ +package com.drmangotea.tfmg.content.electricity.connection.cable_type; + +import com.drmangotea.tfmg.registry.TFMGItems; +import com.tterrag.registrate.util.entry.ItemEntry; +import net.minecraft.Util; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; + +public class CableType { + private String descriptionId; + private final ResourceLocation id; + private final int color; + private final ItemEntry spool; + + public CableType(Properties properties) { + this.id = properties.id; + this.color = properties.color; + this.spool = properties.spool; + } + + public int getColor() { + return this.color; + } + + public ItemEntry getSpool() { + return this.spool; + } + + public String getOrCreateDescriptionId() { + if (this.descriptionId == null) { + this.descriptionId = Util.makeDescriptionId("cable_type", getKey()); + } + + return this.descriptionId; + } + + public String getDescriptionId() { + return this.getOrCreateDescriptionId(); + } + + public Component getDisplayName() { + return Component.translatable(this.getOrCreateDescriptionId()); + } + + public ResourceLocation getKey() { + return this.id; + } + + public static class Properties { + private ResourceLocation id; + + int color = 0xffffff; + ItemEntry spool = TFMGItems.COPPER_SPOOL; + + public Properties color(int color) { + this.color = color; + return this; + } + + public Properties spool(ItemEntry spool) { + this.spool = spool; + return this; + } + + public Properties(ResourceLocation id) { + this.id = id; + } + } +} diff --git a/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cable_type/CableTypeBuilder.java b/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cable_type/CableTypeBuilder.java new file mode 100644 index 00000000..8253de23 --- /dev/null +++ b/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cable_type/CableTypeBuilder.java @@ -0,0 +1,66 @@ +package com.drmangotea.tfmg.content.electricity.connection.cable_type; + +import com.drmangotea.tfmg.base.TFMGRegistries; +import com.tterrag.registrate.AbstractRegistrate; +import com.tterrag.registrate.builders.AbstractBuilder; +import com.tterrag.registrate.builders.BuilderCallback; +import com.tterrag.registrate.util.entry.RegistryEntry; +import com.tterrag.registrate.util.nullness.NonNullFunction; +import com.tterrag.registrate.util.nullness.NonNullSupplier; +import com.tterrag.registrate.util.nullness.NonNullUnaryOperator; +import com.tterrag.registrate.util.nullness.NonnullType; +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.registries.RegistryObject; + +public class CableTypeBuilder extends AbstractBuilder> { + + public static CableTypeBuilder create(AbstractRegistrate owner, P parent, String name, BuilderCallback callback, NonNullFunction factory) { + return new CableTypeBuilder<>(owner, parent, name, callback, factory); + } + + private final NonNullFunction factory; + + private NonNullSupplier initialProperties = () -> new CableType.Properties(new ResourceLocation(getOwner().getModid(), getName())); + private NonNullFunction propertiesCallback = NonNullUnaryOperator.identity(); + + public CableTypeBuilder(AbstractRegistrate owner, P parent, String name, BuilderCallback callback, NonNullFunction factory) { + super(owner, parent, name, callback, TFMGRegistries.CABLE_TYPE); + this.factory = factory; + } + + public CableTypeBuilder properties(NonNullUnaryOperator func) { + propertiesCallback = propertiesCallback.andThen(func); + return this; + } + + public CableTypeBuilder initialProperties(NonNullSupplier properties) { + initialProperties = properties; + return this; + } + + public CableTypeBuilder defaultLang() { + return lang(CableType::getDescriptionId); + } + + public CableTypeBuilder lang(String name) { + return lang(CableType::getDescriptionId, name); + } + + @Override + protected @NonnullType T createEntry() { + CableType.Properties properties = this.initialProperties.get(); + properties = propertiesCallback.apply(properties); + return factory.apply(properties); + } + + @Override + protected RegistryEntry createEntryWrapper(RegistryObject delegate) { + return new CableTypeEntry<>(getOwner(), delegate); + } + + @Override + public CableTypeEntry register() { + TFMGRegistries.registeredCableTypes.put(new ResourceLocation(getOwner().getModid(), getName()), createEntry()); + return (CableTypeEntry) super.register(); + } +} diff --git a/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cable_type/CableTypeEntry.java b/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cable_type/CableTypeEntry.java new file mode 100644 index 00000000..04c0c688 --- /dev/null +++ b/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cable_type/CableTypeEntry.java @@ -0,0 +1,15 @@ +package com.drmangotea.tfmg.content.electricity.connection.cable_type; + +import com.tterrag.registrate.AbstractRegistrate; +import com.tterrag.registrate.util.entry.RegistryEntry; +import net.minecraftforge.registries.RegistryObject; + +public class CableTypeEntry extends RegistryEntry { + public CableTypeEntry(AbstractRegistrate owner, RegistryObject delegate) { + super(owner, delegate); + } + + public static CableTypeEntry cast(RegistryEntry entry) { + return RegistryEntry.cast(CableTypeEntry.class, entry); + } +} diff --git a/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cable_type/CableTypeStats.java b/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cable_type/CableTypeStats.java new file mode 100644 index 00000000..b5f5a571 --- /dev/null +++ b/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cable_type/CableTypeStats.java @@ -0,0 +1,94 @@ +package com.drmangotea.tfmg.content.electricity.connection.cable_type; + +import com.drmangotea.tfmg.TFMG; +import com.drmangotea.tfmg.base.TFMGUtils; +import com.drmangotea.tfmg.config.TFMGConfigs; +import com.drmangotea.tfmg.config.TFMGServerConfig; +import com.drmangotea.tfmg.content.machinery.misc.winding_machine.SpoolItem; +import com.simibubi.create.content.equipment.goggles.GogglesItem; +import com.simibubi.create.foundation.item.TooltipModifier; +import com.simibubi.create.foundation.utility.CreateLang; +import net.createmod.catnip.lang.LangBuilder; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.CommonComponents; +import net.minecraft.network.chat.Component; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import static net.minecraft.ChatFormatting.GRAY; + +public class CableTypeStats implements TooltipModifier { + protected final SpoolItem cableItem; + + public CableTypeStats(SpoolItem cableItem) { + this.cableItem = cableItem; + } + + @Nullable + public static CableTypeStats create(Item item) { + if (item instanceof SpoolItem cableItem) { + if (Objects.equals(cableItem.cableTypeKey, TFMG.asResource("empty"))) return null; + return new CableTypeStats(cableItem); + } + return null; + } + + @Override + public void modify(ItemTooltipEvent context) { + List conductorStats = getCableTypeStats(cableItem, context.getEntity()); + if (!conductorStats.isEmpty()) { + List tooltip = context.getToolTip(); + tooltip.add(CommonComponents.EMPTY); + tooltip.addAll(conductorStats); + } + } + + public static List getCableTypeStats(SpoolItem spoolItem, Player player) { + List list = new ArrayList<>(); + + TFMGServerConfig config = TFMGConfigs.server(); + + boolean hasGoggles = GogglesItem.isWearingGoggles(player); + + CreateLang.translate("tooltip.resistivity") + .style(GRAY) + .addTo(list); + double resistivity = ResistivityValues.getResistivity(TFMGUtils.getCableType(spoolItem.cableTypeKey)); + + LangBuilder builder = CreateLang.builder(); + + builder.space().add(CreateLang.text(resistivity + "Ω")).style(ChatFormatting.GOLD).addTo(list); + + return list; + } + + enum Resistivity { + VERY_LOW(ChatFormatting.RED, ChatFormatting.GOLD), + LOW(ChatFormatting.GOLD, ChatFormatting.YELLOW), + MEDIUM(ChatFormatting.YELLOW, ChatFormatting.GREEN), + HIGH(ChatFormatting.GREEN, ChatFormatting.DARK_GREEN) + ; + + private final ChatFormatting absoluteColor; + private final ChatFormatting relativeColor; + + Resistivity(ChatFormatting absoluteColor, ChatFormatting relativeColor) { + this.absoluteColor = absoluteColor; + this.relativeColor = relativeColor; + } + + public ChatFormatting getAbsoluteColor() { + return absoluteColor; + } + + public ChatFormatting getRelativeColor() { + return relativeColor; + } + } +} diff --git a/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cable_type/ResistivityValues.java b/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cable_type/ResistivityValues.java new file mode 100644 index 00000000..053c1ace --- /dev/null +++ b/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cable_type/ResistivityValues.java @@ -0,0 +1,14 @@ +package com.drmangotea.tfmg.content.electricity.connection.cable_type; + +import com.simibubi.create.api.registry.SimpleRegistry; + +import java.util.function.DoubleSupplier; + +public class ResistivityValues { + public static final SimpleRegistry RESISTIVITIES = SimpleRegistry.create(); + + public static double getResistivity(CableType conductor) { + DoubleSupplier supplier = RESISTIVITIES.get(conductor); + return supplier == null ? 0 : supplier.getAsDouble(); + } +} diff --git a/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cables/CableConnection.java b/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cables/CableConnection.java index 931b2854..73b111d1 100644 --- a/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cables/CableConnection.java +++ b/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cables/CableConnection.java @@ -1,13 +1,10 @@ package com.drmangotea.tfmg.content.electricity.connection.cables; import com.drmangotea.tfmg.base.TFMGUtils; -import com.drmangotea.tfmg.registry.TFMGItems; -import com.tterrag.registrate.util.entry.ItemEntry; +import com.drmangotea.tfmg.content.electricity.connection.cable_type.CableType; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.Items; -import org.checkerframework.checker.units.qual.C; +import net.minecraft.resources.ResourceLocation; public class CableConnection { @@ -46,7 +43,7 @@ public class CableConnection { compoundTag.putBoolean("Visible", visible); - compoundTag.putString("CableType", type.toString()); + compoundTag.putString("CableType", type.getKey().toString()); return compoundTag; } @@ -63,7 +60,7 @@ public class CableConnection { BlockPos blockPos1 = BlockPos.of(compoundTag.getLong("Pos")); boolean visible = compoundTag.getBoolean("Visible"); - CableType type = CableType.valueOf(compoundTag.getString("CableType")); + CableType type = TFMGUtils.getCableType(new ResourceLocation(compoundTag.getString("CableType"))); return new CableConnection(pos1,pos2,blockPos1,type,visible); } public float getLength(){ @@ -72,20 +69,20 @@ public class CableConnection { - public enum CableType{ - NONE(TFMGItems.COPPER_WIRE, 0,0xffffff), - COPPER(TFMGItems.COPPER_WIRE, 0.00188f,0xD8735A), - ALUMINUM(TFMGItems.ALUMINUM_WIRE, 0.0027f,0xEDEFEF), - CONSTANTAN(TFMGItems.CONSTANTAN_WIRE, 1f,0xEDEFEF), - STEEL_REINFORCED_ALUMINUM(TFMGItems.COPPER_WIRE, 0.0027f,0xB8A08D) - ; - public final ItemEntry wire; - public final float resistivity; - public final int color; - CableType(ItemEntry wire, float resistivity, int color){ - this.wire = wire; - this.resistivity = resistivity; - this.color = color; - } - } + //public enum CableType{ + // NONE(TFMGItems.COPPER_WIRE, 0,0xffffff), + // COPPER(TFMGItems.COPPER_WIRE, 0.00188f,0xD8735A), + // ALUMINUM(TFMGItems.ALUMINUM_WIRE, 0.0027f,0xEDEFEF), + // CONSTANTAN(TFMGItems.CONSTANTAN_WIRE, 1f,0xEDEFEF), + // STEEL_REINFORCED_ALUMINUM(TFMGItems.COPPER_WIRE, 0.0027f,0xB8A08D) + // ; + // public final ItemEntry wire; + // public final float resistivity; + // public final int color; + // CableType(ItemEntry wire, float resistivity, int color){ + // this.wire = wire; + // this.resistivity = resistivity; + // this.color = color; + // } + //} } diff --git a/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cables/CableConnectorBlockEntity.java b/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cables/CableConnectorBlockEntity.java index fd4b6043..2359cd6a 100644 --- a/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cables/CableConnectorBlockEntity.java +++ b/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cables/CableConnectorBlockEntity.java @@ -71,7 +71,7 @@ public class CableConnectorBlockEntity extends ElectricBlockEntity implements IH return; for (CableConnection connection : connections) { - ItemEntity itemToDrop = new ItemEntity(level, getBlockPos().getX() + 0.5f, getBlockPos().getY() + 0.5f, getBlockPos().getZ() + 0.5f, new ItemStack(connection.type.wire.get(), (int) (connection.getLength()/8))); + ItemEntity itemToDrop = new ItemEntity(level, getBlockPos().getX() + 0.5f, getBlockPos().getY() + 0.5f, getBlockPos().getZ() + 0.5f, new ItemStack(connection.type.getSpool().get(), (int) (connection.getLength()/8))); if (itemToDrop.getItem().getCount() > 0) { level.addFreshEntity(itemToDrop); } diff --git a/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cables/CableConnectorRenderer.java b/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cables/CableConnectorRenderer.java index e1c640c1..2f90eddd 100644 --- a/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cables/CableConnectorRenderer.java +++ b/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cables/CableConnectorRenderer.java @@ -35,7 +35,7 @@ public class CableConnectorRenderer extends SafeBlockEntityRendererposToConnect.asLong() ? otherBE : be; //CableConnectorBlockEntity connectedBe2= pos.asLong()>posToConnect.asLong() ? be : otherBE; + CableType cableType = TFMGUtils.getCableType(cableTypeKey); // - CableConnection connection1 = new CableConnection(be.getCablePosition(), otherBE.getCablePosition(), otherBE.getBlockPos(),type,true); - CableConnection connection2 = new CableConnection(otherBE.getCablePosition(), be.getCablePosition(), be.getBlockPos(),type,false); + CableConnection connection1 = new CableConnection(be.getCablePosition(), otherBE.getCablePosition(), otherBE.getBlockPos(),cableType,true); + CableConnection connection2 = new CableConnection(otherBE.getCablePosition(), be.getCablePosition(), be.getBlockPos(),cableType,false); float wireCost = (connection1.getLength()/8); @@ -211,7 +207,7 @@ public class SpoolItem extends Item { @Override public boolean isBarVisible(ItemStack stack) { - return model != null; + return !Objects.equals(cableTypeKey, TFMG.asResource("empty")) && TFMGRegistries.registeredCableTypes.containsKey(cableTypeKey); } @Override diff --git a/src/main/java/com/drmangotea/tfmg/content/machinery/misc/winding_machine/WindingMachineBlockEntity.java b/src/main/java/com/drmangotea/tfmg/content/machinery/misc/winding_machine/WindingMachineBlockEntity.java index 78cae645..8d1e7160 100644 --- a/src/main/java/com/drmangotea/tfmg/content/machinery/misc/winding_machine/WindingMachineBlockEntity.java +++ b/src/main/java/com/drmangotea/tfmg/content/machinery/misc/winding_machine/WindingMachineBlockEntity.java @@ -13,6 +13,7 @@ import com.simibubi.create.content.processing.sequenced.SequencedAssemblyRecipe; import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour; import com.simibubi.create.foundation.blockEntity.behaviour.ValueBoxTransform; import com.simibubi.create.foundation.blockEntity.behaviour.scrollValue.ScrollValueBehaviour; +import com.simibubi.create.foundation.item.ItemHelper; import com.simibubi.create.foundation.item.SmartInventory; import com.simibubi.create.foundation.utility.CreateLang; @@ -23,6 +24,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; +import net.minecraft.world.Containers; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; @@ -264,5 +266,9 @@ public class WindingMachineBlockEntity extends KineticBlockEntity implements IHa } } - + public void destroy() { + super.destroy(); + ItemHelper.dropContents(level, worldPosition, inventory); + Containers.dropItemStack(getLevel(), getBlockPos().getX(), getBlockPos().getY(), getBlockPos().getZ(), spool); + } } diff --git a/src/main/java/com/drmangotea/tfmg/content/machinery/misc/winding_machine/WindingMachineRenderer.java b/src/main/java/com/drmangotea/tfmg/content/machinery/misc/winding_machine/WindingMachineRenderer.java index 6c94c1f2..ad8987c9 100644 --- a/src/main/java/com/drmangotea/tfmg/content/machinery/misc/winding_machine/WindingMachineRenderer.java +++ b/src/main/java/com/drmangotea/tfmg/content/machinery/misc/winding_machine/WindingMachineRenderer.java @@ -51,30 +51,30 @@ public class WindingMachineRenderer extends KineticBlockEntityRenderer type, BlockPos pos, BlockState state) { @@ -39,10 +41,12 @@ public class ElectrodeHolderBlockEntity extends ElectricBlockEntity implements I public boolean setElectrode(ItemStack modeItem, boolean simulate) { - for (ElectrodeType type : ElectrodeType.values()) { - if (type.item.is(modeItem.getItem())) { + if (level == null) return false; + for (Electrode electrode : level.registryAccess().registryOrThrow(TFMGRegistries.ELECTRODE)) { + if (electrode.getStack().isEmpty()) continue; + if (modeItem.is(electrode.getStack().getItem())) { if (!simulate) { - electrodeType = type; + this.electrode = electrode; } else return true; } } @@ -67,14 +71,7 @@ public class ElectrodeHolderBlockEntity extends ElectricBlockEntity implements I @Override public float resistance() { - - if (electrodeType != ElectrodeType.NONE) { - if (electrodeType == ElectrodeType.GRAPHITE) { - return 300; - } else return 100; - } - - return 0; + return this.electrode.getResistance(); } @Override @@ -82,13 +79,11 @@ public class ElectrodeHolderBlockEntity extends ElectricBlockEntity implements I return true; } - public boolean setElectrode(String name, boolean simulate) { - for (ElectrodeType type : ElectrodeType.values()) { - if (Objects.equals(type.name, name)) { - if (!simulate) { - electrodeType = type; - } else return true; - } + public boolean setElectrode(Electrode electrode, boolean simulate) { + if (electrode != null) { + if (!simulate) { + this.electrode = electrode; + } else return true; } if (!simulate && hasLevel()) VatBlock.updateVatState(getBlockState(), getLevel(), getBlockPos().relative(Direction.DOWN)); @@ -114,32 +109,31 @@ public class ElectrodeHolderBlockEntity extends ElectricBlockEntity implements I @Override public void write(CompoundTag compound, boolean clientPacket) { - for (ElectrodeType electrode : ElectrodeType.values()) { - if (electrode == electrodeType) { - compound.putString("Electrode", electrode.name); - } - } + compound.putString("Electrode", electrode.getKey().toString()); super.write(compound, clientPacket); } @Override protected void read(CompoundTag compound, boolean clientPacket) { super.read(compound, clientPacket); + setElectrode(TFMGUtils.getElectrode(new ResourceLocation(compound.getString("Electrode"))), false); + } - setElectrode(compound.getString("Electrode"), false); - + public void destroy() { + ItemStack electrodeItem = electrode.getStack(); + Containers.dropItemStack(getLevel(), getBlockPos().getX(), getBlockPos().getY(), getBlockPos().getZ(), electrodeItem); } @Override public String getOperationId() { + return isOperational() ? electrode.getOperationId() : ""; - - return switch (electrodeType) { - - case NONE -> ""; - case COPPER, ZINC -> isOperational() ? "tfmg:electrode" : ""; - case GRAPHITE -> isOperational() ? "tfmg:graphite_electrode" : ""; - }; + //return switch (electrodeType) { +// + // case NONE -> ""; + // case COPPER, ZINC -> isOperational() ? "tfmg:electrode" : ""; + // case GRAPHITE -> isOperational() ? "tfmg:graphite_electrode" : ""; + //}; } @Override @@ -153,22 +147,22 @@ public class ElectrodeHolderBlockEntity extends ElectricBlockEntity implements I } - enum ElectrodeType { - - NONE("none", ItemStack.EMPTY, null), - COPPER("copper", TFMGItems.COPPER_ELECTRODE.asStack(), TFMGPartialModels.COPPER_ELECTRODE), - ZINC("zinc", TFMGItems.ZINC_ELECTRODE.asStack(), TFMGPartialModels.ZINC_ELECTRODE), - GRAPHITE("graphite", TFMGItems.GRAPHITE_ELECTRODE.asStack(), TFMGPartialModels.GRAPHITE_ELECTRODE); - - public final String name; - public final ItemStack item; - public final PartialModel model; - - ElectrodeType(String name, ItemStack stack, PartialModel model) { - this.name = name; - this.item = stack; - this.model = model; - } - - } + //enum ElectrodeType { +// + // NONE("none", ItemStack.EMPTY, null), + // COPPER("copper", TFMGItems.COPPER_ELECTRODE.asStack(), TFMGPartialModels.COPPER_ELECTRODE), + // ZINC("zinc", TFMGItems.ZINC_ELECTRODE.asStack(), TFMGPartialModels.ZINC_ELECTRODE), + // GRAPHITE("graphite", TFMGItems.GRAPHITE_ELECTRODE.asStack(), TFMGPartialModels.GRAPHITE_ELECTRODE); +// + // public final String name; + // public final ItemStack item; + // public final PartialModel model; +// + // ElectrodeType(String name, ItemStack stack, PartialModel model) { + // this.name = name; + // this.item = stack; + // this.model = model; + // } +// + //} } diff --git a/src/main/java/com/drmangotea/tfmg/content/machinery/vat/electrode_holder/ElectrodeHolderRenderer.java b/src/main/java/com/drmangotea/tfmg/content/machinery/vat/electrode_holder/ElectrodeHolderRenderer.java index d4da65ba..9b5dad3d 100644 --- a/src/main/java/com/drmangotea/tfmg/content/machinery/vat/electrode_holder/ElectrodeHolderRenderer.java +++ b/src/main/java/com/drmangotea/tfmg/content/machinery/vat/electrode_holder/ElectrodeHolderRenderer.java @@ -1,19 +1,23 @@ package com.drmangotea.tfmg.content.machinery.vat.electrode_holder; -import com.drmangotea.tfmg.registry.TFMGPartialModels; +import com.drmangotea.tfmg.TFMG; +import com.drmangotea.tfmg.base.TFMGUtils; import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.math.Axis; import com.simibubi.create.foundation.blockEntity.renderer.SafeBlockEntityRenderer; -import net.createmod.catnip.render.CachedBuffers; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; +import net.minecraft.client.renderer.entity.ItemRenderer; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.world.item.ItemDisplayContext; import net.minecraft.world.level.block.state.BlockState; public class ElectrodeHolderRenderer extends SafeBlockEntityRenderer { - + private final ItemRenderer itemRenderer; public ElectrodeHolderRenderer(BlockEntityRendererProvider.Context context) { + itemRenderer = context.getItemRenderer(); } @Override @@ -24,16 +28,17 @@ public class ElectrodeHolderRenderer extends SafeBlockEntityRenderer item; + private final int resistance; + private final String operationId; + + public Electrode(Properties properties) { + this.id = properties.id; + this.item = properties.item; + this.resistance = properties.resistance; + this.operationId = properties.operationId; + } + + public ItemEntry getItem() { + return this.item; + } + + public ItemStack getStack() { + return getItem() != null ? getItem().asStack() : ItemStack.EMPTY; + } + + public int getResistance() { + return this.resistance; + } + + public String getOperationId() { + return this.operationId; + } + + public String getOrCreateDescriptionId() { + if (this.descriptionId == null) { + this.descriptionId = Util.makeDescriptionId("electrode", getKey()); + } + + return this.descriptionId; + } + + public String getDescriptionId() { + return this.getOrCreateDescriptionId(); + } + + public Component getDisplayName() { + return Component.translatable(this.getOrCreateDescriptionId()); + } + + public ResourceLocation getKey() { + return this.id; + } + + public static class Properties { + private ResourceLocation id; + + ItemEntry item; + int resistance = 0; + String operationId = ""; + + public Properties item(ItemEntry item) { + this.item = item; + return this; + } + + public Properties resistance(int resistance) { + this.resistance = resistance; + return this; + } + + public Properties operationId(String operationId) { + this.operationId = operationId; + return this; + } + + public Properties(ResourceLocation id) { + this.id = id; + } + } +} diff --git a/src/main/java/com/drmangotea/tfmg/content/machinery/vat/electrode_holder/electrode/ElectrodeBuilder.java b/src/main/java/com/drmangotea/tfmg/content/machinery/vat/electrode_holder/electrode/ElectrodeBuilder.java new file mode 100644 index 00000000..27be45b5 --- /dev/null +++ b/src/main/java/com/drmangotea/tfmg/content/machinery/vat/electrode_holder/electrode/ElectrodeBuilder.java @@ -0,0 +1,66 @@ +package com.drmangotea.tfmg.content.machinery.vat.electrode_holder.electrode; + +import com.drmangotea.tfmg.base.TFMGRegistries; +import com.tterrag.registrate.AbstractRegistrate; +import com.tterrag.registrate.builders.AbstractBuilder; +import com.tterrag.registrate.builders.BuilderCallback; +import com.tterrag.registrate.util.entry.RegistryEntry; +import com.tterrag.registrate.util.nullness.NonNullFunction; +import com.tterrag.registrate.util.nullness.NonNullSupplier; +import com.tterrag.registrate.util.nullness.NonNullUnaryOperator; +import com.tterrag.registrate.util.nullness.NonnullType; +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.registries.RegistryObject; + +public class ElectrodeBuilder extends AbstractBuilder> { + + public static ElectrodeBuilder create(AbstractRegistrate owner, P parent, String name, BuilderCallback callback, NonNullFunction factory) { + return new ElectrodeBuilder<>(owner, parent, name, callback, factory); + } + + private final NonNullFunction factory; + + private NonNullSupplier initialProperties = () -> new Electrode.Properties(new ResourceLocation(getOwner().getModid(), getName())); + private NonNullFunction propertiesCallback = NonNullUnaryOperator.identity(); + + public ElectrodeBuilder(AbstractRegistrate owner, P parent, String name, BuilderCallback callback, NonNullFunction factory) { + super(owner, parent, name, callback, TFMGRegistries.ELECTRODE); + this.factory = factory; + } + + public ElectrodeBuilder properties(NonNullUnaryOperator func) { + propertiesCallback = propertiesCallback.andThen(func); + return this; + } + + public ElectrodeBuilder initialProperties(NonNullSupplier properties) { + initialProperties = properties; + return this; + } + + public ElectrodeBuilder defaultLang() { + return lang(Electrode::getDescriptionId); + } + + public ElectrodeBuilder lang(String name) { + return lang(Electrode::getDescriptionId, name); + } + + @Override + protected @NonnullType T createEntry() { + Electrode.Properties properties = this.initialProperties.get(); + properties = propertiesCallback.apply(properties); + return factory.apply(properties); + } + + @Override + protected RegistryEntry createEntryWrapper(RegistryObject delegate) { + return new ElectrodeEntry<>(getOwner(), delegate); + } + + @Override + public ElectrodeEntry register() { + TFMGRegistries.registeredElectrodes.put(new ResourceLocation(getOwner().getModid(), getName()), createEntry()); + return (ElectrodeEntry) super.register(); + } +} diff --git a/src/main/java/com/drmangotea/tfmg/content/machinery/vat/electrode_holder/electrode/ElectrodeEntry.java b/src/main/java/com/drmangotea/tfmg/content/machinery/vat/electrode_holder/electrode/ElectrodeEntry.java new file mode 100644 index 00000000..ec35a876 --- /dev/null +++ b/src/main/java/com/drmangotea/tfmg/content/machinery/vat/electrode_holder/electrode/ElectrodeEntry.java @@ -0,0 +1,17 @@ +package com.drmangotea.tfmg.content.machinery.vat.electrode_holder.electrode; + +import com.drmangotea.tfmg.content.electricity.connection.cable_type.CableType; +import com.drmangotea.tfmg.content.electricity.connection.cable_type.CableTypeEntry; +import com.tterrag.registrate.AbstractRegistrate; +import com.tterrag.registrate.util.entry.RegistryEntry; +import net.minecraftforge.registries.RegistryObject; + +public class ElectrodeEntry extends RegistryEntry { + public ElectrodeEntry(AbstractRegistrate owner, RegistryObject delegate) { + super(owner, delegate); + } + + public static ElectrodeEntry cast(RegistryEntry entry) { + return RegistryEntry.cast(ElectrodeEntry.class, entry); + } +} diff --git a/src/main/java/com/drmangotea/tfmg/recipes/jei/ChemicalVatCategory.java b/src/main/java/com/drmangotea/tfmg/recipes/jei/ChemicalVatCategory.java index f71eedbd..e8bd0ef7 100644 --- a/src/main/java/com/drmangotea/tfmg/recipes/jei/ChemicalVatCategory.java +++ b/src/main/java/com/drmangotea/tfmg/recipes/jei/ChemicalVatCategory.java @@ -88,31 +88,10 @@ public class ChemicalVatCategory extends CreateRecipeCategory TFMGGuiTextures.VAT.render(graphics, 0, 24); - if (allowedVatTypes.contains("firebrick_lined_vat") && allowedVatTypes.size() == 1) { - TFMGGuiTextures.FIREPROOF_BRICK_OVERLAY.render(graphics, 55 - 48, 32); - } + drawVatTypes(allowedVatTypes, graphics); - if (machines.contains("tfmg:mixing")) { - TFMGGuiTextures.VAT_MACHINE.render(graphics, 55 - 12, 0); - TFMGGuiTextures.MIXER.render(graphics, 55 - 19, 32); - } - if (machines.contains("tfmg:electrode")) { - TFMGGuiTextures.VAT_MACHINE.render(graphics, 55 - 12 - 32, 0); - TFMGGuiTextures.VAT_MACHINE.render(graphics, 55 - 12 + 32, 0); - TFMGGuiTextures.ELECTRODE.render(graphics, 55 - 3 - 32, 32); - TFMGGuiTextures.ELECTRODE.render(graphics, 55 - 3 + 32, 32); - } - if (machines.contains("tfmg:graphite_electrode")) { - TFMGGuiTextures.VAT_MACHINE.render(graphics, 55 - 12 - 32, 0); - TFMGGuiTextures.VAT_MACHINE.render(graphics, 55 - 12 + 32, 0); - TFMGGuiTextures.VAT_MACHINE.render(graphics, 55 - 12, 0); - TFMGGuiTextures.GRAPHITE_ELECTRODE.render(graphics, 55 - 4 - 32, 32); - TFMGGuiTextures.GRAPHITE_ELECTRODE.render(graphics, 55 - 4 + 32, 32); - TFMGGuiTextures.GRAPHITE_ELECTRODE.render(graphics, 55 - 4, 32); - } - if (recipe.getRequiredHeat() == HeatCondition.HEATED){ - TFMGGuiTextures.VAT_HEATER.render(graphics, 55 - 10, 109); - } + drawSprites(machines, graphics); + renderHeated(recipe.getRequiredHeat(), graphics); int pos = 55; int width = ((recipe.getFluidIngredients().size()) * 21) / 2; for (int i = 0; i < recipe.getFluidIngredients().size(); i++) { @@ -137,5 +116,41 @@ public class ChemicalVatCategory extends CreateRecipeCategory } + private void renderHeated(HeatCondition heatCondition, GuiGraphics graphics) { + if (heatCondition == HeatCondition.HEATED) + TFMGGuiTextures.VAT_HEATER.render(graphics, 55 - 10, 109); + if (heatCondition == HeatCondition.SUPERHEATED) + TFMGGuiTextures.VAT_SUPERHEATER.render(graphics, 55 - 10, 109); + } + //Can be overridden with mixins for easily adding different stuff - Krystal + //Might consider a better way of doing this but idk. + private void drawVatTypes(List allowedVatTypes, GuiGraphics graphics) { + if (allowedVatTypes.contains("firebrick_lined_vat") && allowedVatTypes.size() == 1) { + TFMGGuiTextures.FIREPROOF_BRICK_OVERLAY.render(graphics, 55 - 48, 32); + } + } + + //Can be overridden with mixins for easily adding different stuff - Krystal + //Might consider a better way of doing this but idk. + private void drawSprites(List machines, GuiGraphics graphics) { + if (machines.contains("tfmg:mixing")) { + TFMGGuiTextures.VAT_MACHINE.render(graphics, 55 - 12, 0); + TFMGGuiTextures.MIXER.render(graphics, 55 - 19, 32); + } + if (machines.contains("tfmg:electrode")) { + TFMGGuiTextures.VAT_MACHINE.render(graphics, 55 - 12 - 32, 0); + TFMGGuiTextures.VAT_MACHINE.render(graphics, 55 - 12 + 32, 0); + TFMGGuiTextures.ELECTRODE.render(graphics, 55 - 3 - 32, 32); + TFMGGuiTextures.ELECTRODE.render(graphics, 55 - 3 + 32, 32); + } + if (machines.contains("tfmg:graphite_electrode")) { + TFMGGuiTextures.VAT_MACHINE.render(graphics, 55 - 12 - 32, 0); + TFMGGuiTextures.VAT_MACHINE.render(graphics, 55 - 12 + 32, 0); + TFMGGuiTextures.VAT_MACHINE.render(graphics, 55 - 12, 0); + TFMGGuiTextures.GRAPHITE_ELECTRODE.render(graphics, 55 - 4 - 32, 32); + TFMGGuiTextures.GRAPHITE_ELECTRODE.render(graphics, 55 - 4 + 32, 32); + TFMGGuiTextures.GRAPHITE_ELECTRODE.render(graphics, 55 - 4, 32); + } + } } \ No newline at end of file diff --git a/src/main/java/com/drmangotea/tfmg/recipes/jei/WindingCategory.java b/src/main/java/com/drmangotea/tfmg/recipes/jei/WindingCategory.java index 32ae5e74..1b7c3cc0 100644 --- a/src/main/java/com/drmangotea/tfmg/recipes/jei/WindingCategory.java +++ b/src/main/java/com/drmangotea/tfmg/recipes/jei/WindingCategory.java @@ -48,14 +48,12 @@ public class WindingCategory extends CreateRecipeCategory { AllGuiTextures.JEI_ARROW.render(graphics, 85, 32); AllGuiTextures.JEI_DOWN_ARROW.render(graphics, 43, 4); - PartialModel coil = null; + int coilColor = 0; if (recipe.getIngredients().get(1).getItems()[0].getItem() instanceof SpoolItem) { - - coil = ((SpoolItem)recipe.getIngredients().get(1).getItems()[0].getItem()).model; - + coilColor = recipe.getIngredients().get(1).getItems()[0].getBarColor(); } - this.windingMachine.draw(graphics, 48, 27,coil,true); + this.windingMachine.draw(graphics, 48, 27,coilColor,true); graphics.drawString(Minecraft.getInstance().font, recipe.getProcessingDuration() + " Turns", 86.0F, 9.0F, 4210752, false); } @@ -76,18 +74,16 @@ public class WindingCategory extends CreateRecipeCategory { PoseStack ms = graphics.pose(); - PartialModel coil = null; + int coilColor = 0; if (recipe.getRecipe().getIngredients().get(1).getItems()[0].getItem() instanceof SpoolItem) { - - coil = ((SpoolItem)recipe.getRecipe().getIngredients().get(1).getItems()[0].getItem()).model; - + coilColor = recipe.getRecipe().getIngredients().get(1).getItems()[0].getBarColor(); } windingMachine.offset = index; ms.pushPose(); ms.translate(0.0, 67, 0.0); ms.scale(0.7F, 0.7F, 0.7F); - this.windingMachine.draw(graphics, this.getWidth() / 2, 0,coil,false); + this.windingMachine.draw(graphics, this.getWidth() / 2, 0,coilColor,false); ms.popPose(); diff --git a/src/main/java/com/drmangotea/tfmg/recipes/jei/machines/WindingMachine.java b/src/main/java/com/drmangotea/tfmg/recipes/jei/machines/WindingMachine.java index 149a172e..488c0b70 100644 --- a/src/main/java/com/drmangotea/tfmg/recipes/jei/machines/WindingMachine.java +++ b/src/main/java/com/drmangotea/tfmg/recipes/jei/machines/WindingMachine.java @@ -17,7 +17,7 @@ public class WindingMachine extends AnimatedKinetics { public WindingMachine() { } - public void draw(GuiGraphics graphics, int xOffset, int yOffset, PartialModel coil, boolean shadow) { + public void draw(GuiGraphics graphics, int xOffset, int yOffset, int coilColor, boolean shadow) { PoseStack matrixStack = graphics.pose(); @@ -42,12 +42,13 @@ public class WindingMachine extends AnimatedKinetics { .atLocal(-0.15, -0.4, -0.23) .scale(scale) .render(graphics); - if (coil != null) - blockElement(coil) - .rotateBlock(22.5, 22.5, 0) - .atLocal(-0.15, -0.4, -0.23) - .scale(scale) - .render(graphics); + + blockElement(TFMGPartialModels.SPOOL_WIRE) + .rotateBlock(22.5, 22.5, 0) + .atLocal(-0.15, -0.4, -0.23) + .color(coilColor) + .scale(scale) + .render(graphics); matrixStack.popPose(); } diff --git a/src/main/java/com/drmangotea/tfmg/registry/TFMGCableTypes.java b/src/main/java/com/drmangotea/tfmg/registry/TFMGCableTypes.java new file mode 100644 index 00000000..4e6eeca4 --- /dev/null +++ b/src/main/java/com/drmangotea/tfmg/registry/TFMGCableTypes.java @@ -0,0 +1,59 @@ +package com.drmangotea.tfmg.registry; + +import com.drmangotea.tfmg.config.TFMGResistivity; +import com.drmangotea.tfmg.content.electricity.connection.cable_type.CableType; +import com.drmangotea.tfmg.content.electricity.connection.cable_type.CableTypeEntry; + +import static com.drmangotea.tfmg.TFMG.REGISTRATE; + +public class TFMGCableTypes { + + public static final CableTypeEntry empty = REGISTRATE.cableType("empty", CableType::new) + .properties((p) -> p.spool(TFMGItems.COPPER_SPOOL)) + .register(); + + public static final CableTypeEntry copper = REGISTRATE.cableType("copper", CableType::new) + .properties((p) -> p.color(0xD8735A).spool(TFMGItems.COPPER_SPOOL)) + .transform(TFMGResistivity.setResistivity(0.00188f)) + .register(); + + public static final CableTypeEntry aluminum = REGISTRATE.cableType("aluminum", CableType::new) + .properties((p) -> p.color(0xEDEFEF).spool(TFMGItems.ALUMINUM_SPOOL)) + .transform(TFMGResistivity.setResistivity(0.0027f)) + .register(); + + public static final CableTypeEntry constantan = REGISTRATE.cableType("constantan", CableType::new) + .properties((p) -> p.color(0xCFC2A8).spool(TFMGItems.CONSTANTAN_SPOOL)) + .transform(TFMGResistivity.setResistivity(1f)) + .register(); + + // Why is this a thing? I'll leave it her in case you do need it. - Krystal + //public static final CableTypeEntry steelReinforcedAluminum = REGISTRATE.cableType("steel_reinforced_aluminum", CableType::new) + // .properties((p) -> p.color(0xB8A08D).spool(TFMGItems.COPPER_SPOOL)) + // .transform(TFMGResistivity.setResistivity(0.0027f)) + // .register(); + + public static void register() { + + } + + //static { + // register("empty", new CableType(new CableType.Properties(TFMG.asResource("empty")))); + // register("copper", 0.00188f, 0xD8735A, TFMGItems.COPPER_SPOOL); + // register("aluminum", 0.0027f, 0xEDEFEF, TFMGItems.ALUMINUM_SPOOL); + // register("constantan", 1f, 0xCFC2A8, TFMGItems.CONSTANTAN_SPOOL); + //} +// + //private static void register(String name, float resistivity, int color, ItemEntry spool) { + // ResourceLocation key = TFMG.asResource(name); + // CableType cableType = new CableType(new CableType.Properties(key).color(color).spool(spool).resistivity(resistivity)); + // register(name, cableType); + //} +// + //private static void register(String name, T type) { + // Registry.register(TFMGBuiltinRegistries.CABLE_TYPE, TFMG.asResource(name), type); + //} +// + //public static void init() { + //} +} diff --git a/src/main/java/com/drmangotea/tfmg/registry/TFMGElectrodes.java b/src/main/java/com/drmangotea/tfmg/registry/TFMGElectrodes.java new file mode 100644 index 00000000..631e9b53 --- /dev/null +++ b/src/main/java/com/drmangotea/tfmg/registry/TFMGElectrodes.java @@ -0,0 +1,58 @@ +package com.drmangotea.tfmg.registry; + +import com.drmangotea.tfmg.content.machinery.vat.electrode_holder.electrode.Electrode; +import com.drmangotea.tfmg.content.machinery.vat.electrode_holder.electrode.ElectrodeEntry; + +import static com.drmangotea.tfmg.TFMG.REGISTRATE; + +public class TFMGElectrodes { + + public static final ElectrodeEntry none = REGISTRATE.electrode("none", Electrode::new) + .properties((p) -> p) + .register(); + + public static final ElectrodeEntry copper = REGISTRATE.electrode("copper", Electrode::new) + .properties((p) -> p + .resistance(100) + .item(TFMGItems.COPPER_ELECTRODE) + .operationId("tfmg:electrode") + ) + .register(); + + public static final ElectrodeEntry zinc = REGISTRATE.electrode("zinc", Electrode::new) + .properties((p) -> p + .resistance(100) + .item(TFMGItems.ZINC_ELECTRODE) + .operationId("tfmg:electrode") + ) + .register(); + + public static final ElectrodeEntry graphite = REGISTRATE.electrode("graphite", Electrode::new) + .properties((p) -> p + .resistance(300) + .item(TFMGItems.GRAPHITE_ELECTRODE) + .operationId("tfmg:graphite_electrode") + ) + .register(); + + //static { + // register("none", new Electrode(new Electrode.Properties(TFMG.asResource("none")))); + // register("copper", 100, TFMGItems.COPPER_ELECTRODE, "tfmg:electrode"); + // register("zinc", 100, TFMGItems.ZINC_ELECTRODE, "tfmg:electrode"); + // register("graphite", 300, TFMGItems.GRAPHITE_ELECTRODE, "tfmg:graphite_electrode"); + //} +// + //private static void register(String name, int resistance, ItemEntry item, String operationId) { + // ResourceLocation key = TFMG.asResource(name); + // Electrode electrode = new Electrode(new Electrode.Properties(key).resistance(resistance).item(item).operationId(operationId)); + // register(name, electrode); + //} +// + //private static void register(String name, T type) { + // Registry.register(TFMGBuiltinRegistries.ELECTRODE, TFMG.asResource(name), type); + //} + + public static void register() { + + } +} diff --git a/src/main/java/com/drmangotea/tfmg/registry/TFMGGuiTextures.java b/src/main/java/com/drmangotea/tfmg/registry/TFMGGuiTextures.java index 52f7d08d..ad1fb4cd 100644 --- a/src/main/java/com/drmangotea/tfmg/registry/TFMGGuiTextures.java +++ b/src/main/java/com/drmangotea/tfmg/registry/TFMGGuiTextures.java @@ -31,6 +31,7 @@ public enum TFMGGuiTextures implements ScreenElement { GRAPHITE_ELECTRODE("chemical_vat", 176, 0, 8, 29), FIREPROOF_BRICK_OVERLAY("chemical_vat", 0, 84, 96, 72), VAT_HEATER("chemical_vat", 112, 44, 20, 14), + VAT_SUPERHEATER("chemical_vat", 112, 58, 20, 14) ; diff --git a/src/main/java/com/drmangotea/tfmg/registry/TFMGItems.java b/src/main/java/com/drmangotea/tfmg/registry/TFMGItems.java index e7d82a03..bbb1178b 100644 --- a/src/main/java/com/drmangotea/tfmg/registry/TFMGItems.java +++ b/src/main/java/com/drmangotea/tfmg/registry/TFMGItems.java @@ -5,7 +5,7 @@ import com.drmangotea.tfmg.base.TFMGArmorMaterials; import com.drmangotea.tfmg.base.TFMGTiers; import com.drmangotea.tfmg.content.decoration.gearbox.SteelVerticalGearboxItem; import com.drmangotea.tfmg.content.electricity.configuration_wrench.ElectriciansWrenchItem; -import com.drmangotea.tfmg.content.electricity.connection.cables.CableConnection; +import com.drmangotea.tfmg.content.electricity.connection.cable_type.CableTypeEntry; import com.drmangotea.tfmg.content.electricity.debug.DebugCinderBlockItem; import com.drmangotea.tfmg.content.electricity.measurement.MultimeterItem; import com.drmangotea.tfmg.content.electricity.utilities.polarizer.MagnetItem; @@ -37,8 +37,8 @@ import com.tterrag.registrate.builders.ItemBuilder; import com.tterrag.registrate.util.DataIngredient; import com.tterrag.registrate.util.entry.ItemEntry; import com.tterrag.registrate.util.entry.RegistryEntry; -import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; import net.minecraft.world.item.*; import net.minecraft.world.level.block.Blocks; @@ -188,14 +188,14 @@ public class TFMGItems { ENGINE_CYLINDER = REGISTRATE.item("engine_cylinder", CylinderItem::new).register(), TURBINE_BLADE = REGISTRATE.item("turbine_blade", CylinderItem::new).register(); public static final ItemEntry - EMPTY_SPOOL = spoolItem("empty", null, 0x000000, CableConnection.CableType.NONE) - .recipe((c, p) -> p.stonecutting(DataIngredient.items(TFMGBlocks.HARDENED_PLANKS.asItem()), RecipeCategory.BUILDING_BLOCKS, c::get, 1)) + EMPTY_SPOOL = spoolItem("empty", 0x000000, TFMG.asResource("empty")) + .recipe((c, p) -> p.stonecutting(DataIngredient.items(TFMGBlocks.HARDENED_PLANKS.asItem()), RecipeCategory.BUILDING_BLOCKS, c, 1)) .register(), - COPPER_SPOOL = spoolItem("copper", TFMGPartialModels.COPPER_SPOOL, 0xD8735A, CableConnection.CableType.COPPER) + COPPER_SPOOL = spoolItem("copper", 0xD8735A, TFMG.asResource("copper")) .register(), - ALUMINUM_SPOOL = spoolItem("aluminum", TFMGPartialModels.ALUMINUM_SPOOL, 0xEDEFEF, CableConnection.CableType.ALUMINUM) + ALUMINUM_SPOOL = spoolItem("aluminum", 0xEDEFEF, TFMG.asResource("aluminum")) .register(), - CONSTANTAN_SPOOL = spoolItem("constantan", TFMGPartialModels.CONSTANTAN_SPOOL, 0xCFC2A8, CableConnection.CableType.CONSTANTAN) + CONSTANTAN_SPOOL = spoolItem("constantan", 0xCFC2A8, TFMG.asResource("constantan")) .register(); public static final ItemEntry ELECTROMAGNETIC_COIL = @@ -432,8 +432,8 @@ public class TFMGItems { return map; } - public static ItemBuilder spoolItem(String name, PartialModel model, int barColor, CableConnection.CableType type) { - return REGISTRATE.item(name + "_spool", p -> new SpoolItem(p, model, barColor, type)) + public static ItemBuilder spoolItem(String name, int barColor, ResourceLocation type) { + return REGISTRATE.item(name + "_spool", p -> new SpoolItem(p, barColor, type)) .tag(TFMGTags.TFMGItemTags.SPOOLS.tag) .properties(p -> p.stacksTo(1)); diff --git a/src/main/java/com/drmangotea/tfmg/registry/TFMGPartialModels.java b/src/main/java/com/drmangotea/tfmg/registry/TFMGPartialModels.java index 21f50f36..ac9eb3be 100644 --- a/src/main/java/com/drmangotea/tfmg/registry/TFMGPartialModels.java +++ b/src/main/java/com/drmangotea/tfmg/registry/TFMGPartialModels.java @@ -75,6 +75,7 @@ public class TFMGPartialModels { SHAFTLESS_LARGE_ALUMINUM_COGHWEEL = block("large_aluminum_cogwheel_shaftless"), SHAFTLESS_LARGE_STEEL_COGHWEEL = block("large_steel_cogwheel_shaftless"), SPOOL = block("winding_machine/spool"), + SPOOL_WIRE = block("winding_machine/spool_wire"), COPPER_SPOOL = block("winding_machine/copper_spool"), ALUMINUM_SPOOL = block("winding_machine/aluminum_spool"), CONSTANTAN_SPOOL = block("winding_machine/constantan_spool"), diff --git a/src/main/java/com/drmangotea/tfmg/registry/TFMGTags.java b/src/main/java/com/drmangotea/tfmg/registry/TFMGTags.java index fc75483c..91ed34ba 100644 --- a/src/main/java/com/drmangotea/tfmg/registry/TFMGTags.java +++ b/src/main/java/com/drmangotea/tfmg/registry/TFMGTags.java @@ -256,9 +256,9 @@ public class TFMGTags { public static void init() { TFMGBlockTags.init(); - // TFMGItemTags.init(); + // TFMGItemTags.register(); TFMGFluidTags.init(); - //TFMGEntityTags.init(); - //TFMGRecipeSerializerTags.init(); + //TFMGEntityTags.register(); + //TFMGRecipeSerializerTags.register(); } } diff --git a/src/main/resources/assets/tfmg/models/block/winding_machine/spool_wire.json b/src/main/resources/assets/tfmg/models/block/winding_machine/spool_wire.json new file mode 100644 index 00000000..2e1aa062 --- /dev/null +++ b/src/main/resources/assets/tfmg/models/block/winding_machine/spool_wire.json @@ -0,0 +1,20 @@ +{ + "credit": "Made with Blockbench", + "textures": { + "0": "tfmg:block/spool_wire", + "particle": "tfmg:block/spool_wire" + }, + "elements": [ + { + "from": [4, 6, 6], + "to": [11, 10, 10], + "rotation": {"angle": 0, "axis": "y", "origin": [4, 7, 7]}, + "faces": { + "north": {"uv": [0, 0, 4, 7], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 0, 4, 7], "rotation": 90, "texture": "#0"}, + "up": {"uv": [0, 0, 4, 7], "rotation": 90, "texture": "#0"}, + "down": {"uv": [0, 0, 4, 7], "rotation": 90, "texture": "#0"} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/tfmg/textures/block/spool_wire.png b/src/main/resources/assets/tfmg/textures/block/spool_wire.png new file mode 100644 index 00000000..922ae8e3 Binary files /dev/null and b/src/main/resources/assets/tfmg/textures/block/spool_wire.png differ diff --git a/src/main/resources/assets/tfmg/textures/block/winding_machine_wire.png b/src/main/resources/assets/tfmg/textures/block/winding_machine_wire.png index 6b689078..e52e05f3 100644 Binary files a/src/main/resources/assets/tfmg/textures/block/winding_machine_wire.png and b/src/main/resources/assets/tfmg/textures/block/winding_machine_wire.png differ diff --git a/src/main/resources/assets/tfmg/textures/block/winding_machine_wire_animated.png b/src/main/resources/assets/tfmg/textures/block/winding_machine_wire_animated.png index 66c87d4d..0c5eaad7 100644 Binary files a/src/main/resources/assets/tfmg/textures/block/winding_machine_wire_animated.png and b/src/main/resources/assets/tfmg/textures/block/winding_machine_wire_animated.png differ diff --git a/src/main/resources/assets/tfmg/textures/gui/chemical_vat.png b/src/main/resources/assets/tfmg/textures/gui/chemical_vat.png index da5dbffb..b54d3747 100644 Binary files a/src/main/resources/assets/tfmg/textures/gui/chemical_vat.png and b/src/main/resources/assets/tfmg/textures/gui/chemical_vat.png differ diff --git a/src/main/resources/tfmg.mixins.json b/src/main/resources/tfmg.mixins.json index 161a8e9d..85cff6c9 100644 --- a/src/main/resources/tfmg.mixins.json +++ b/src/main/resources/tfmg.mixins.json @@ -7,10 +7,9 @@ "mixins": [ "FluidPipeBlockMixin", "FluidPropagatorMixin", + "FluidTankBlockEntityMixin", "GoggleOverlayRendererMixin", "PipeAttachmentModelMixin", - - "FluidTankBlockEntityMixin", "accessor.FluidTankBlockEntityAccessor", "accessor.TankSegmentAccessor" ],