diff --git a/src/main/java/com/drmangotea/tfmg/TFMG.java b/src/main/java/com/drmangotea/tfmg/TFMG.java index 137a0ff1..6fdd805c 100644 --- a/src/main/java/com/drmangotea/tfmg/TFMG.java +++ b/src/main/java/com/drmangotea/tfmg/TFMG.java @@ -62,6 +62,8 @@ public class TFMG { TFMGSoundEvents.prepare(); + TFMGElectrodes.init(); + TFMGCableTypes.init(); TFMGCreativeTabs.register(modEventBus); TFMGBlocks.init(); TFMGBlockEntities.init(); diff --git a/src/main/java/com/drmangotea/tfmg/TFMGRegistries.java b/src/main/java/com/drmangotea/tfmg/TFMGRegistries.java new file mode 100644 index 00000000..7b56f9d9 --- /dev/null +++ b/src/main/java/com/drmangotea/tfmg/TFMGRegistries.java @@ -0,0 +1,30 @@ +package com.drmangotea.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.neoforged.neoforge.registries.RegistryBuilder; + +import static com.drmangotea.tfmg.TFMG.REGISTRATE; + +public class TFMGRegistries { + public static final ResourceKey> CABLE_TYPE = createRegistryKey("cable_types"); + public static final ResourceKey> ELECTRODE = createRegistryKey("electrodes"); + + public static final Registry CABLE_TYPE_REGISTRY = makeSyncedRegistry(CABLE_TYPE); + public static final Registry ELECTRODE_REGISTRY = makeSyncedRegistry(ELECTRODE); + + + private static ResourceKey> createRegistryKey(String name) { + return ResourceKey.createRegistryKey(TFMG.asResource(name)); + } + + private static Registry makeSyncedRegistry(ResourceKey> registryKey) { + return new RegistryBuilder<>(registryKey).sync(true).create(); + } + + private static Registry makeRegistry(ResourceKey> registryKey) { + return new RegistryBuilder<>(registryKey).create(); + } +} diff --git a/src/main/java/com/drmangotea/tfmg/base/TFMGRegistrate.java b/src/main/java/com/drmangotea/tfmg/base/TFMGRegistrate.java index 7b078792..4988c023 100644 --- a/src/main/java/com/drmangotea/tfmg/base/TFMGRegistrate.java +++ b/src/main/java/com/drmangotea/tfmg/base/TFMGRegistrate.java @@ -2,12 +2,17 @@ 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; import com.simibubi.create.foundation.item.TooltipModifier; import com.tterrag.registrate.Registrate; import com.tterrag.registrate.builders.FluidBuilder; +import com.tterrag.registrate.util.nullness.NonNullFunction; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; @@ -69,4 +74,36 @@ public class TFMGRegistrate extends CreateRegistrate { return TFMG.REGISTRATE.get(name+"_bucket", Registries.ITEM).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/TFMGUtils.java b/src/main/java/com/drmangotea/tfmg/base/TFMGUtils.java index 355a95b2..07241dda 100644 --- a/src/main/java/com/drmangotea/tfmg/base/TFMGUtils.java +++ b/src/main/java/com/drmangotea/tfmg/base/TFMGUtils.java @@ -2,9 +2,12 @@ package com.drmangotea.tfmg.base; import com.drmangotea.tfmg.TFMG; +import com.drmangotea.tfmg.TFMGRegistries; 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 +25,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; @@ -383,4 +387,12 @@ public class TFMGUtils { } + public static Electrode getElectrode(ResourceLocation key) { + return TFMGRegistries.ELECTRODE_REGISTRY.get(key); + } + + public static CableType getCableType(ResourceLocation key) { + return TFMGRegistries.CABLE_TYPE_REGISTRY.get(key); + } + } diff --git a/src/main/java/com/drmangotea/tfmg/base/events/TFMGCommonEvents.java b/src/main/java/com/drmangotea/tfmg/base/events/TFMGCommonEvents.java index 020dd2ea..44c78720 100644 --- a/src/main/java/com/drmangotea/tfmg/base/events/TFMGCommonEvents.java +++ b/src/main/java/com/drmangotea/tfmg/base/events/TFMGCommonEvents.java @@ -2,6 +2,7 @@ package com.drmangotea.tfmg.base.events; import com.drmangotea.tfmg.TFMG; +import com.drmangotea.tfmg.TFMGRegistries; import com.drmangotea.tfmg.content.decoration.tanks.TFMGFluidTankBlockEntity; import com.drmangotea.tfmg.content.decoration.tanks.steel.SteelTankBlockEntity; import com.drmangotea.tfmg.content.electricity.base.IElectric; @@ -37,6 +38,7 @@ import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent; import net.neoforged.neoforge.event.AddReloadListenerEvent; import net.neoforged.neoforge.event.level.BlockEvent; import net.neoforged.neoforge.event.level.LevelEvent; +import net.neoforged.neoforge.registries.NewRegistryEvent; @EventBusSubscriber @@ -105,6 +107,13 @@ public class TFMGCommonEvents { CokeOvenBlockEntity.registerCapabilities(event); AirIntakeBlockEntity.registerCapabilities(event); } + + @SubscribeEvent + public static void newRegistry(NewRegistryEvent event) { + event.register(TFMGRegistries.CABLE_TYPE_REGISTRY); + event.register(TFMGRegistries.ELECTRODE_REGISTRY); + } } + } diff --git a/src/main/java/com/drmangotea/tfmg/config/TFMGConfigs.java b/src/main/java/com/drmangotea/tfmg/config/TFMGConfigs.java index 747977f3..d77db6a6 100644 --- a/src/main/java/com/drmangotea/tfmg/config/TFMGConfigs.java +++ b/src/main/java/com/drmangotea/tfmg/config/TFMGConfigs.java @@ -1,5 +1,6 @@ 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; @@ -60,6 +61,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..9ec6faf8 --- /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.neoforged.neoforge.common.ModConfigSpec; +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(ModConfigSpec.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(); + ModConfigSpec.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..4a48d691 100644 --- a/src/main/java/com/drmangotea/tfmg/config/TFMGServerConfig.java +++ b/src/main/java/com/drmangotea/tfmg/config/TFMGServerConfig.java @@ -8,6 +8,7 @@ public class TFMGServerConfig extends ConfigBase { public final TFMGStress stressValues = nested(0, 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..a246a485 --- /dev/null +++ b/src/main/java/com/drmangotea/tfmg/content/electricity/connection/cable_type/CableTypeBuilder.java @@ -0,0 +1,68 @@ +package com.drmangotea.tfmg.content.electricity.connection.cable_type; + +import com.drmangotea.tfmg.TFMG; +import com.drmangotea.tfmg.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.core.Registry; +import net.minecraft.resources.ResourceLocation; +import net.neoforged.neoforge.registries.DeferredHolder; + +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(ResourceLocation.fromNamespaceAndPath(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(DeferredHolder delegate) { + return new CableTypeEntry<>(getOwner(), delegate); + } + + @Override + public CableTypeEntry register() { + //Registry.register(TFMGRegistries.CABLE_TYPE_REGISTRY, ResourceLocation.fromNamespaceAndPath(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..67f05ec9 --- /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.neoforged.neoforge.registries.DeferredHolder; + +public class CableTypeEntry extends RegistryEntry { + public CableTypeEntry(AbstractRegistrate owner, DeferredHolder 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/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..aa3994f7 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,10 +1,12 @@ package com.drmangotea.tfmg.content.electricity.connection.cables; import com.drmangotea.tfmg.base.TFMGUtils; +import com.drmangotea.tfmg.content.electricity.connection.cable_type.CableType; import com.drmangotea.tfmg.registry.TFMGItems; import com.tterrag.registrate.util.entry.ItemEntry; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; import org.checkerframework.checker.units.qual.C; @@ -46,7 +48,7 @@ public class CableConnection { compoundTag.putBoolean("Visible", visible); - compoundTag.putString("CableType", type.toString()); + compoundTag.putString("CableType", type.getKey().toString()); return compoundTag; } @@ -63,29 +65,11 @@ 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(ResourceLocation.parse(compoundTag.getString("CableType"))); return new CableConnection(pos1,pos2,blockPos1,type,visible); } public float getLength(){ return TFMGUtils.getDistance(new BlockPos((int) pos1.x(), (int) pos1.y(), (int) pos1.z()),new BlockPos((int) pos2.x(), (int) pos2.y(), (int) pos2.z()), false); } - - - 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 09ccbe74..f3a9ab10 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 @@ -72,7 +72,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 03ee63b1..0dbe4910 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 @@ -36,7 +36,7 @@ public class CableConnectorRenderer extends SafeBlockEntityRendererposToConnect.asLong() ? otherBE : be; //CableConnectorBlockEntity connectedBe2= pos.asLong()>posToConnect.asLong() ? be : otherBE; -// - CableConnection connection1 = new CableConnection(be.getCablePosition(), otherBE.getCablePosition(), otherBE.getBlockPos(),type,true); - CableConnection connection2 = new CableConnection(otherBE.getCablePosition(), be.getCablePosition(), be.getBlockPos(),type,false); + CableType cableType = TFMGUtils.getCableType(cableTypeKey); + + 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); @@ -224,7 +227,7 @@ public class SpoolItem extends Item { @Override public boolean isBarVisible(ItemStack stack) { - return model != null; + return !Objects.equals(cableTypeKey, TFMG.asResource("empty")) && TFMGRegistries.CABLE_TYPE_REGISTRY.containsKey(cableTypeKey); } @Override 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 e7341be3..37da64c6 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 @@ -52,18 +52,18 @@ public class WindingMachineRenderer extends KineticBlockEntityRenderer type, BlockPos pos, BlockState state) { @@ -40,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 : TFMGRegistries.ELECTRODE_REGISTRY.stream().toList()) { + if (electrode.getStack().isEmpty()) continue; + if (modeItem.is(electrode.getStack().getItem())) { if (!simulate) { - electrodeType = type; + this.electrode = electrode; } else return true; } } @@ -68,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 @@ -83,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)); @@ -115,11 +109,8 @@ public class ElectrodeHolderBlockEntity extends ElectricBlockEntity implements I @Override public void write(CompoundTag compound, HolderLookup.Provider registries, boolean clientPacket) { - for (ElectrodeType electrode : ElectrodeType.values()) { - if (electrode == electrodeType) { - compound.putString("Electrode", electrode.name); - } - } + compound.putString("Electrode", electrode.getKey().toString()); + super.write(compound,registries , clientPacket); } @@ -127,20 +118,13 @@ public class ElectrodeHolderBlockEntity extends ElectricBlockEntity implements I protected void read(CompoundTag compound, HolderLookup.Provider registries, boolean clientPacket) { super.read(compound,registries , clientPacket); - setElectrode(compound.getString("Electrode"), false); + setElectrode(TFMGUtils.getElectrode(ResourceLocation.parse(compound.getString("Electrode"))), false); } @Override public String getOperationId() { - - - return switch (electrodeType) { - - case NONE -> ""; - case COPPER, ZINC -> isOperational() ? "tfmg:electrode" : ""; - case GRAPHITE -> isOperational() ? "tfmg:graphite_electrode" : ""; - }; + return isOperational() ? electrode.getOperationId() : ""; } @Override @@ -154,22 +138,4 @@ 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; - } - - } } 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..6c21a8eb 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,27 @@ package com.drmangotea.tfmg.content.machinery.vat.electrode_holder; +import com.drmangotea.tfmg.TFMG; +import com.drmangotea.tfmg.base.TFMGUtils; import com.drmangotea.tfmg.registry.TFMGPartialModels; 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) { + this.itemRenderer = context.getItemRenderer(); } @Override @@ -24,16 +32,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..fde1a4ad --- /dev/null +++ b/src/main/java/com/drmangotea/tfmg/content/machinery/vat/electrode_holder/electrode/ElectrodeBuilder.java @@ -0,0 +1,67 @@ +package com.drmangotea.tfmg.content.machinery.vat.electrode_holder.electrode; + +import com.drmangotea.tfmg.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.core.Registry; +import net.minecraft.resources.ResourceLocation; +import net.neoforged.neoforge.registries.DeferredHolder; + +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(ResourceLocation.fromNamespaceAndPath(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(DeferredHolder delegate) { + return new ElectrodeEntry<>(getOwner(), delegate); + } + + @Override + public ElectrodeEntry register() { + //Registry.register(TFMGRegistries.ELECTRODE_REGISTRY, ResourceLocation.fromNamespaceAndPath(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..9c1d9e87 --- /dev/null +++ b/src/main/java/com/drmangotea/tfmg/content/machinery/vat/electrode_holder/electrode/ElectrodeEntry.java @@ -0,0 +1,15 @@ +package com.drmangotea.tfmg.content.machinery.vat.electrode_holder.electrode; + +import com.tterrag.registrate.AbstractRegistrate; +import com.tterrag.registrate.util.entry.RegistryEntry; +import net.neoforged.neoforge.registries.DeferredHolder; + +public class ElectrodeEntry extends RegistryEntry { + public ElectrodeEntry(AbstractRegistrate owner, DeferredHolder 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/mixin/BuiltInRegistriesMixin.java b/src/main/java/com/drmangotea/tfmg/mixin/BuiltInRegistriesMixin.java new file mode 100644 index 00000000..04e3005b --- /dev/null +++ b/src/main/java/com/drmangotea/tfmg/mixin/BuiltInRegistriesMixin.java @@ -0,0 +1,28 @@ +package com.drmangotea.tfmg.mixin; + +import com.drmangotea.tfmg.TFMG; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import java.util.function.Consumer; + +@Mixin(BuiltInRegistries.class) +public class BuiltInRegistriesMixin { + static { + //TFMGBuiltInRegistries.init(); + } + + @WrapOperation(method = "validate", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/Registry;forEach(Ljava/util/function/Consumer;)V")) + private static > void create$ourRegistriesAreNotEmpty(Registry instance, Consumer consumer, Operation original) { + Consumer callback = (t) -> { + if (!t.key().location().getNamespace().equals(TFMG.MOD_ID)) + consumer.accept(t); + }; + + original.call(instance, callback); + } +} 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 97644d12..41190728 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,11 @@ public class ChemicalVatCategory extends CreateRecipeCategory TFMGGuiTextures.VAT.render(graphics, 0, 24); - if (allowedVatTypes.contains("tfmg:firebrick_lined_vat") && allowedVatTypes.size() == 1) { - TFMGGuiTextures.FIREPROOF_BRICK_OVERLAY.render(graphics, 55 - 48, 32); - } + drawVatTypes(allowedVatTypes, graphics); + + drawSprites(machines, graphics); + renderHeated(recipe.getRequiredHeat(), 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); - } int pos = 55; int width = ((recipe.getFluidIngredients().size()) * 21) / 2; for (int i = 0; i < recipe.getFluidIngredients().size(); i++) { @@ -137,5 +117,38 @@ 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); + } + + 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); + } + } + + 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 bd19c4d0..afd12515 100644 --- a/src/main/java/com/drmangotea/tfmg/recipes/jei/WindingCategory.java +++ b/src/main/java/com/drmangotea/tfmg/recipes/jei/WindingCategory.java @@ -49,14 +49,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); } @@ -77,18 +75,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..f70e2734 --- /dev/null +++ b/src/main/java/com/drmangotea/tfmg/registry/TFMGCableTypes.java @@ -0,0 +1,51 @@ +package com.drmangotea.tfmg.registry; + +import com.drmangotea.tfmg.TFMG; +import com.drmangotea.tfmg.TFMGRegistries; +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 com.simibubi.create.api.contraption.ContraptionType; +import com.simibubi.create.api.registry.CreateBuiltInRegistries; +import com.simibubi.create.content.contraptions.Contraption; +import com.tterrag.registrate.util.entry.ItemEntry; +import net.minecraft.core.Holder; +import net.minecraft.core.Registry; +import net.minecraft.resources.ResourceLocation; + +import java.util.function.Supplier; + +import static com.drmangotea.tfmg.TFMG.REGISTRATE; +import static com.simibubi.create.AllContraptionTypes.BY_LEGACY_NAME; + +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 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..d8c77e30 --- /dev/null +++ b/src/main/java/com/drmangotea/tfmg/registry/TFMGElectrodes.java @@ -0,0 +1,41 @@ +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(); + + public static void init() { + + } +} diff --git a/src/main/java/com/drmangotea/tfmg/registry/TFMGGuiTextures.java b/src/main/java/com/drmangotea/tfmg/registry/TFMGGuiTextures.java index d05dfe13..ae60cf58 100644 --- a/src/main/java/com/drmangotea/tfmg/registry/TFMGGuiTextures.java +++ b/src/main/java/com/drmangotea/tfmg/registry/TFMGGuiTextures.java @@ -32,6 +32,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 dd112f2a..59af1fb9 100644 --- a/src/main/java/com/drmangotea/tfmg/registry/TFMGItems.java +++ b/src/main/java/com/drmangotea/tfmg/registry/TFMGItems.java @@ -41,6 +41,7 @@ import com.tterrag.registrate.util.entry.RegistryEntry; import dev.engine_room.flywheel.lib.model.baked.PartialModel; import net.minecraft.core.Holder; 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; @@ -191,14 +192,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) + EMPTY_SPOOL = spoolItem("empty", 0x000000, TFMG.asResource("empty")) .recipe((c, p) -> p.stonecutting(DataIngredient.items(TFMGBlocks.HARDENED_PLANKS.asItem()), RecipeCategory.BUILDING_BLOCKS, c::get, 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 = @@ -447,8 +448,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/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..0b76c601 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..e00fa574 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..86eb5fa5 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 96ea7bed..ce1dd032 100644 --- a/src/main/resources/tfmg.mixins.json +++ b/src/main/resources/tfmg.mixins.json @@ -5,6 +5,7 @@ "compatibilityLevel": "JAVA_8", "refmap": "tfmg.refmap.json", "mixins": [ + "BuiltInRegistriesMixin", "FluidPipeBlockMixin", "FluidPropagatorMixin", "FluidTankBlockEntityMixin",