Skip to content

Commit

Permalink
add heat conduits (and temp texture)
Browse files Browse the repository at this point in the history
  • Loading branch information
ferriarnus committed Mar 3, 2024
1 parent 5e5dfa4 commit b518cfe
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.enderio.conduits.common.integrations.mekanism;

Check failure on line 1 in src/conduits/java/com/enderio/conduits/common/integrations/mekanism/HeatConduitType.java

View workflow job for this annotation

GitHub Actions / runner / checkstyle

[checkstyle] reported by reviewdog 🐶 Missing package-info.java file. Raw Output: /github/workspace/./src/conduits/java/com/enderio/conduits/common/integrations/mekanism/HeatConduitType.java:1:0: error: Missing package-info.java file. (com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck)

import com.enderio.api.conduit.ConduitTypes;
import com.enderio.api.conduit.IConduitMenuData;
import com.enderio.api.conduit.ticker.IConduitTicker;
import com.enderio.api.misc.Vector2i;
import com.enderio.conduits.EIOConduits;
import com.enderio.conduits.common.init.EnderConduitTypes;
import com.enderio.conduits.common.types.SimpleConduitType;
import net.minecraft.resources.ResourceLocation;

import java.util.function.Supplier;

public class HeatConduitType extends SimpleConduitType<HeatExtendedData> {

public static final IConduitMenuData MENU_DATA = new IConduitMenuData.Simple(false, false, false, false, false, true);

public HeatConduitType(ResourceLocation texture, Vector2i iconTexturePos) {
super(texture, new HeatTicker(), HeatExtendedData::new, EnderConduitTypes.ICON_TEXTURE, iconTexturePos, MENU_DATA);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.enderio.conduits.common.integrations.mekanism;

import com.enderio.api.conduit.IExtendedConduitData;
import net.minecraft.nbt.CompoundTag;

public class HeatExtendedData implements IExtendedConduitData<HeatExtendedData> {
@Override
public CompoundTag serializeNBT() {
return new CompoundTag();
}

@Override
public void deserializeNBT(CompoundTag nbt) {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.enderio.conduits.common.integrations.mekanism;

import com.enderio.api.conduit.IConduitType;
import com.enderio.api.conduit.ticker.CapabilityAwareConduitTicker;
import com.enderio.api.misc.ColorControl;
import dev.gigaherz.graph3.Graph;
import dev.gigaherz.graph3.Mergeable;
import mekanism.api.heat.HeatAPI;
import mekanism.api.heat.IHeatHandler;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
import net.neoforged.neoforge.capabilities.BlockCapability;
import org.apache.commons.lang3.function.TriFunction;

import java.util.List;

public class HeatTicker extends CapabilityAwareConduitTicker<IHeatHandler> {

public HeatTicker() {
}

@Override
protected void tickCapabilityGraph(IConduitType<?> type, List<CapabilityAwareConduitTicker<IHeatHandler>.CapabilityConnection> inserts,
List<CapabilityAwareConduitTicker<IHeatHandler>.CapabilityConnection> extracts, ServerLevel level, Graph<Mergeable.Dummy> graph,
TriFunction<ServerLevel, BlockPos, ColorControl, Boolean> isRedstoneActive) {
for (CapabilityConnection extract : extracts) {
IHeatHandler extractHandler = extract.cap;

for (CapabilityConnection insert : inserts) {
IHeatHandler insertHandler = insert.cap;

double heatCapacity = extractHandler.getTotalHeatCapacity();
double invConduction = insertHandler.getTotalInverseConduction() + extractHandler.getTotalInverseConduction();
double tempToTransfer = (extractHandler.getTotalTemperature() - insertHandler.getTotalTemperature()) / invConduction; //TODO subtract ambient? - HeatAPI.getAmbientTemp(level, )

double heatToTransfer = tempToTransfer * heatCapacity;
if (heatToTransfer > 0) {
extractHandler.handleHeat(-heatToTransfer);
insertHandler.handleHeat(heatToTransfer);
}

}
}
}

@Override
protected BlockCapability<IHeatHandler, Direction> getCapability() {
return MekanismIntegration.HEAT;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import mekanism.api.chemical.infuse.IInfusionHandler;
import mekanism.api.chemical.pigment.IPigmentHandler;
import mekanism.api.chemical.slurry.ISlurryHandler;
import mekanism.api.heat.IHeatHandler;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
Expand All @@ -33,14 +34,19 @@ public class MekanismIntegration implements Integration {
private static final DeferredHolder<IConduitType<?>, ChemicalConduitType> CHEMICAL2 = chemicalConduit("pressurized_chemical", 2000, true, new Vector2i(0,216));
private static final DeferredHolder<IConduitType<?>, ChemicalConduitType> CHEMICAL3 = chemicalConduit("ender_chemical", 64000, true, new Vector2i(24,0));

private static final DeferredHolder<IConduitType<?>, HeatConduitType> HEAT_TYPE = heatConduit("heat", new Vector2i(24,24));

public static final RegiliteItem<Item> CHEMICAL_ITEM = createConduitItem(CHEMICAL, "chemical", "Chemical Conduit");
public static final RegiliteItem<Item> PRESSURIZED_CHEMICAL_ITEM = createConduitItem(CHEMICAL2, "pressurized_chemical", "Pressurized Chemical Conduit");
public static final RegiliteItem<Item> ENDER_CHEMICAL_ITEM = createConduitItem(CHEMICAL3, "ender_chemical", "Ender Chemical Conduit");

public static final RegiliteItem<Item> HEAT_ITEM = createConduitItem(HEAT_TYPE, "heat", "Heat Conduit");

public static final BlockCapability<IGasHandler, Direction> GAS = BlockCapability.createSided(new ResourceLocation(MekanismAPI.MEKANISM_MODID, "gas_handler"), IGasHandler.class);
public static final BlockCapability<ISlurryHandler, Direction> SLURRY = BlockCapability.createSided(new ResourceLocation(MekanismAPI.MEKANISM_MODID, "slurry_handler"), ISlurryHandler.class);
public static final BlockCapability<IInfusionHandler, Direction> INFUSION = BlockCapability.createSided(new ResourceLocation(MekanismAPI.MEKANISM_MODID, "infusion_handler"), IInfusionHandler.class);
public static final BlockCapability<IPigmentHandler, Direction> PIGMENT = BlockCapability.createSided(new ResourceLocation(MekanismAPI.MEKANISM_MODID, "pigment_handler"), IPigmentHandler.class);
public static final BlockCapability<IHeatHandler, Direction> HEAT = BlockCapability.createSided(new ResourceLocation(MekanismAPI.MEKANISM_MODID, "heat_handler"), IHeatHandler.class);

@Override
public void addEventListener(IEventBus modEventBus, IEventBus forgeEventBus) {
Expand All @@ -53,6 +59,11 @@ private static DeferredHolder<IConduitType<?>, ChemicalConduitType> chemicalCond
() -> new ChemicalConduitType(EnderIO.loc("block/conduit/" + name), tier, isMultiFluid, iconPos));
}

private static DeferredHolder<IConduitType<?>, HeatConduitType> heatConduit(String name, Vector2i iconPos) {
return ConduitTypes.CONDUIT_TYPES.register(name,
() -> new HeatConduitType(EnderIO.loc("block/conduit/" + name), iconPos));
}

private static RegiliteItem<Item> createConduitItem(Supplier<? extends IConduitType<?>> type, String itemName, String english) {
return ITEM_REGISTRY
.registerItem(itemName + "_conduit",
Expand All @@ -67,5 +78,7 @@ public void addCapability(RegisterCapabilitiesEvent event) {
event.registerBlockEntity(MekanismIntegration.SLURRY, ConduitBlockEntities.CONDUIT.get(), ConduitBlockEntity.createConduitCap(MekanismIntegration.SLURRY));
event.registerBlockEntity(MekanismIntegration.INFUSION, ConduitBlockEntities.CONDUIT.get(), ConduitBlockEntity.createConduitCap(MekanismIntegration.INFUSION));
event.registerBlockEntity(MekanismIntegration.PIGMENT, ConduitBlockEntities.CONDUIT.get(), ConduitBlockEntity.createConduitCap(MekanismIntegration.PIGMENT));
event.registerBlockEntity(MekanismIntegration.HEAT, ConduitBlockEntities.CONDUIT.get(), ConduitBlockEntity.createConduitCap(MekanismIntegration.HEAT));

}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/conduits/resources/assets/enderio/textures/gui/conduit_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/generated/resources/assets/enderio/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@
"item.enderio.glider_wing": "Glider Wing",
"item.enderio.grains_of_infinity": "Grains of Infinity",
"item.enderio.guardian_diode": "Guardian Diode",
"item.enderio.heat_conduit": "Heat Conduit",
"item.enderio.hootch_bucket": "Hootch Bucket",
"item.enderio.infinity_rod": "Infinity Rod",
"item.enderio.iron_gear": "Infinity Bimetal Gear",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "enderio:item/conduit",
"textures": {
"0": "enderio:block/conduit/heat"
}
}

0 comments on commit b518cfe

Please sign in to comment.