Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/generated/resources/assets/gtceu/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -1942,6 +1942,7 @@
"config.jade.plugin_gtceu.energy_converter_provider": "[GTCEu] Energy Converter Mode",
"config.jade.plugin_gtceu.exhaust_vent_info": "[GTCEu] Exhaust Vent Info",
"config.jade.plugin_gtceu.hazard_cleaner_provider": "[GTCEu] Hazard Cleaner",
"config.jade.plugin_gtceu.fluid_pipe_info": "[GTCEu] Fluid Pipe Info",
"config.jade.plugin_gtceu.ldp_endpoint": "[GTCEu] Long Distance Pipeline Endpoint Info",
"config.jade.plugin_gtceu.machine_mode": "[GTCEu] Machine Mode",
"config.jade.plugin_gtceu.maintenance_info": "[GTCEu] Maintenance Info",
Expand Down Expand Up @@ -2354,6 +2355,8 @@
"gtceu.fluid_pipe.channels": "§eChannels: §f%d",
"gtceu.fluid_pipe.cryo_proof": "§6Can handle Cryogenics",
"gtceu.fluid_pipe.gas_proof": "§6Can handle Gases",
"gtceu.fluid_pipe.insulated": "§bInsulated",
"gtceu.fluid_pipe.insulated_by_default": "§6Pre-Insulated",
"gtceu.fluid_pipe.max_temperature": "§cTemperature Limit: §f%s",
"gtceu.fluid_pipe.not_gas_proof": "§4Gases may leak!",
"gtceu.fluid_pipe.plasma_proof": "§6Can handle all Plasmas",
Expand Down Expand Up @@ -4315,6 +4318,13 @@
"item.gtceu.ilc_chip.tooltip": "§7Integrated Logic Circuit",
"item.gtceu.ilc_wafer": "ILC Wafer",
"item.gtceu.ilc_wafer.tooltip": "§7Raw Integrated Circuit",
"item.gtceu.insulation_wrapper": "Insulation Wrapper",
"item.gtceu.insulation_wrapper.desc": "§bNullify damage from thermogenics/cryogenics",
"item.gtceu.insulation_wrapper.message.already_insulated": "§eAll pipes in this network are already insulated",
"item.gtceu.insulation_wrapper.message.invalid_pipe": "§eNot a fluid pipe",
"item.gtceu.insulation_wrapper.message.removed": "§cRemoved Insulation",
"item.gtceu.insulation_wrapper.message.success": "§aInsulated §f%s pipe(s)",
"item.gtceu.insulation_wrapper.usage": "Shift-Right-Click on fluid pipe network",
"item.gtceu.image_module": "Image Module",
"item.gtceu.impure_bentonite_dust": "Impure Pile of Bentonite",
"item.gtceu.impure_cassiterite_sand_dust": "Impure Pile of Cassiterite Sand",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "gtceu:item/insulation_wrapper"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import com.gregtechceu.gtceu.api.sync_system.annotations.RerenderOnChanged;
import com.gregtechceu.gtceu.api.sync_system.annotations.SaveField;
import com.gregtechceu.gtceu.api.sync_system.annotations.SyncToClient;
import com.gregtechceu.gtceu.common.blockentity.FluidPipeBlockEntity;
import com.gregtechceu.gtceu.common.data.GTItems;
import com.gregtechceu.gtceu.common.data.GTMaterialBlocks;
import com.gregtechceu.gtceu.common.data.GTMaterials;
import com.gregtechceu.gtceu.utils.ExtendedUseOnContext;
Expand All @@ -26,6 +28,7 @@
import net.minecraft.core.Direction;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionResult;
Expand Down Expand Up @@ -374,6 +377,15 @@ public ResourceTexture getPipeTexture(boolean isBlock) {
}
return Pair.of(getPipeTuneTool(), InteractionResult.sidedSuccess(isRemote()));
} else if (toolType.contains(GTToolType.CROWBAR)) {
if (this instanceof FluidPipeBlockEntity pipe && pipe.isInsulated() && !pipe.getNodeData().isInsulatedByDefault()) {
if (!isRemote()) {
pipe.setInsulated(false);
player.displayClientMessage(Component.translatable("item.gtceu.insulation_wrapper.message.removed"), true);
Block.popResource(context.getLevel(), this.getBlockPos(),
new ItemStack(GTItems.INSULATION_WRAPPER.get()));
}
return Pair.of(GTToolType.CROWBAR, InteractionResult.sidedSuccess(isRemote()));
}
if (!frameMaterial.isNull()) {
Block.popResource(context.getLevel(), this.getBlockPos(),
GTMaterialBlocks.MATERIAL_BLOCKS.get(TagPrefix.frameGt, frameMaterial).asStack());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1808,6 +1808,27 @@ public Builder fluidPipeProperties(int maxTemp, int throughput, boolean gasProof
return this;
}

/**
* Add Fluid Pipes to this Material.
*
* @param maxTemp The maximum temperature of Fluid that this Pipe can handle before causing damage to the
* Pipe.
* @param throughput The rate at which Fluid can flow through this Pipe.
* @param gasProof Whether this Pipe can hold Gases. If not, some Gas will be lost as it travels through the
* Pipe.
* @param acidProof Whether this Pipe can hold Acids. If not, the Pipe may lose fluid or cause damage.
* @param cryoProof Whether this Pipe can hold Cryogenic Fluids (below 120K). If not, the Pipe may lose fluid
* or cause damage.
* @param plasmaProof Whether this Pipe can hold Plasmas. If not, the Pipe may lose fluid or cause damage.
* @param insulatedByDefault Whether this Pipe is insulated by default. If not, the Pipe may cause damage when storing thermogenics/cryogenics.
*/
public Builder fluidPipeProperties(int maxTemp, int throughput, boolean gasProof, boolean acidProof,
boolean cryoProof, boolean plasmaProof, boolean insulatedByDefault) {
properties.setProperty(PropertyKey.FLUID_PIPE,
new FluidPipeProperties(maxTemp, throughput, gasProof, acidProof, cryoProof, plasmaProof, insulatedByDefault, 1));
return this;
}

/**
* Add Item Pipes to this Material.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,21 @@ public class FluidPipeProperties implements IMaterialProperty, IPropertyFluidFil
@Getter
@Setter
private boolean plasmaProof;
@Getter
@Setter
private boolean insulatedByDefault;

private final Object2BooleanMap<FluidAttribute> containmentPredicate = new Object2BooleanOpenHashMap<>();

public FluidPipeProperties(int maxFluidTemperature, int throughput, boolean gasProof, boolean acidProof,
boolean cryoProof, boolean plasmaProof, int channels) {
boolean cryoProof, boolean plasmaProof, boolean insulatedByDefault, int channels) {
this.maxFluidTemperature = maxFluidTemperature;
this.throughput = throughput;
this.gasProof = gasProof;
if (acidProof) setCanContain(FluidAttributes.ACID, true);
this.cryoProof = cryoProof;
this.plasmaProof = plasmaProof;
this.insulatedByDefault = insulatedByDefault;
this.channels = channels;
}

Expand All @@ -59,7 +63,7 @@ public FluidPipeProperties(int maxFluidTemperature, int throughput, boolean gasP
*/
public FluidPipeProperties(int maxFluidTemperature, int throughput, boolean gasProof, boolean acidProof,
boolean cryoProof, boolean plasmaProof) {
this(maxFluidTemperature, throughput, gasProof, acidProof, cryoProof, plasmaProof, 1);
this(maxFluidTemperature, throughput, gasProof, acidProof, cryoProof, plasmaProof, false, 1);
}

@Override
Expand Down Expand Up @@ -98,6 +102,7 @@ public String toString() {
", cryoProof=" + cryoProof +
", plasmaProof=" + plasmaProof +
", channels=" + channels +
", insulatedByDefault=" + insulatedByDefault +
'}';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ public class GTModelProperties {
public static final ModelProperty<Integer> PIPE_BLOCKED_MASK = new ModelProperty<>();

public static final ModelProperty<ModelData> CHILD_MODEL_DATA = new ModelProperty<>(Objects::nonNull);

public static final ModelProperty<Boolean> PIPE_INSULATED = new ModelProperty<>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.gregtechceu.gtceu.client.model.IBlockEntityRendererBakedModel;
import com.gregtechceu.gtceu.client.renderer.cover.ICoverableRenderer;
import com.gregtechceu.gtceu.client.util.GTQuadTransformers;
import com.gregtechceu.gtceu.common.blockentity.FluidPipeBlockEntity;
import com.gregtechceu.gtceu.common.data.GTMaterialBlocks;
import com.gregtechceu.gtceu.utils.GTUtil;

Expand Down Expand Up @@ -41,10 +42,13 @@ public class BakedPipeModel extends BaseBakedModel implements ICoverableRenderer

private final Map<Direction, BakedModel> parts;
private final Map<Direction, BakedModel> restrictors;
private final Map<Direction, BakedModel> insulation;

public BakedPipeModel(Map<Direction, BakedModel> parts, Map<Direction, BakedModel> restrictors) {
public BakedPipeModel(Map<Direction, BakedModel> parts, Map<Direction, BakedModel> restrictors,
Map<Direction, BakedModel> insulation) {
this.parts = parts;
this.restrictors = restrictors;
this.insulation = insulation;
}

@Override
Expand Down Expand Up @@ -94,6 +98,12 @@ public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction
ICoverableRenderer.super.renderCovers(quads, pipeNode.getCoverContainer(), pos, level, side, rand,
modelData, renderType);

// render insulation overlay if the pipe is insulated and insulation map is not empty
Boolean insulated = modelData.get(GTModelProperties.PIPE_INSULATED);
if (insulated != null && insulated && !insulation.isEmpty()) {
renderInsulationOverlay(quads, connectionMask, state, side, rand, modelData, renderType);
}

if (pipeNode.getFrameMaterial().isNull()) {
return quads;
}
Expand Down Expand Up @@ -143,6 +153,10 @@ public ModelData getModelData(BlockAndTintGetter level, BlockPos pos, BlockState

var builder = modelData.derive();

if (level.getBlockEntity(pos) instanceof FluidPipeBlockEntity pipe) {
builder.with(GTModelProperties.PIPE_INSULATED, pipe.isInsulated());
}

if (level.getBlockEntity(pos) instanceof IPipeNode<?, ?> pipeNode) {
Map<Direction, ModelData> coverModelData = new EnumMap<>(Direction.class);
for (Direction side : GTUtil.DIRECTIONS) {
Expand Down Expand Up @@ -178,6 +192,25 @@ public ChunkRenderTypeSet getRenderTypes(BlockState state, RandomSource rand, Mo
return ChunkRenderTypeSet.union(renderTypes, coverRenderTypes);
}

private void renderInsulationOverlay(List<BakedQuad> quads, @Nullable Integer connectionMask, @Nullable BlockState state,
@Nullable Direction side, RandomSource rand, ModelData modelData, @Nullable RenderType renderType) {
BakedModel overlayCenter = insulation.get(null);
if (overlayCenter != null && (renderType == null ||
(state != null && overlayCenter.getRenderTypes(state, rand, modelData).contains(renderType)))) {
quads.addAll(overlayCenter.getQuads(state, side, rand, modelData, renderType));
}
if (connectionMask == null) return;
for (Direction dir : GTUtil.DIRECTIONS) {
if (PipeBlockEntity.isConnected(connectionMask, dir)) {
BakedModel overlayArm = insulation.get(dir);
if (overlayArm != null && (renderType == null ||
(state != null && overlayArm.getRenderTypes(state, rand, modelData).contains(renderType)))) {
quads.addAll(overlayArm.getQuads(state, side, rand, modelData, renderType));
}
}
}
}

@SuppressWarnings("deprecation")
@Override
public TextureAtlasSprite getParticleIcon() {
Expand All @@ -192,4 +225,4 @@ public TextureAtlasSprite getParticleIcon() {
@Override
public void render(PipeBlockEntity<?, ?> blockEntity, float partialTick, PoseStack poseStack,
MultiBufferSource buffer, int packedLight, int packedOverlay) {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ public static void initDynamicModels() {
public @Nullable ResourceLocation sideSecondary, endSecondary;
@Setter
public @Nullable ResourceLocation sideOverlay, endOverlay;
@Setter
public @Nullable ResourceLocation sideInsulation;

/// Use {@link #getOrCreateBlockModel()} instead of referencing this field directly.
private BlockModelBuilder blockModel;
Expand Down Expand Up @@ -184,13 +186,16 @@ protected BlockModelBuilder getOrCreateBlockModel() {
return this.blockModel;
}
// spotless:off
return this.blockModel = this.provider.models().getBuilder(this.blockId.toString())
// make the "default" model be based on the center part's model
var loader = this.provider.models().getBuilder(this.blockId.toString())
.parent(this.getOrCreateCenterElement())
.customLoader(PipeModelBuilder.begin(this.thickness, this.provider))
.centerModels(this.getOrCreateCenterElement().getLocation())
.connectionModels(this.getOrCreateConnectionElement().getLocation())
.end();
.connectionModels(this.getOrCreateConnectionElement().getLocation());
if (this.sideInsulation != null) {
loader.insulationTextures(this.sideInsulation);
}
return this.blockModel = loader.end();
// make the "default" model be based on the center part's model
// spotless:on
}

Expand Down Expand Up @@ -408,12 +413,13 @@ public boolean equals(Object o) {
Objects.equals(sideSecondary, pipeModel.sideSecondary) &&
Objects.equals(endSecondary, pipeModel.endSecondary) &&
Objects.equals(sideOverlay, pipeModel.sideOverlay) &&
Objects.equals(endOverlay, pipeModel.endOverlay);
Objects.equals(endOverlay, pipeModel.endOverlay) &&
Objects.equals(sideInsulation, pipeModel.sideInsulation);
}

@Override
public int hashCode() {
return Objects.hash(block, side, end, sideSecondary, endSecondary, sideOverlay, endOverlay);
return Objects.hash(block, side, end, sideSecondary, endSecondary, sideOverlay, endOverlay, sideInsulation);
}

@FunctionalInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,19 @@ public class PipeModelLoader implements IGeometryLoader<UnbakedPipeModel> {
restrictors.put(direction, MachineModelLoader.GSON.fromJson(entry.getValue(), MultiVariantModel.class));
}
}
// and the insulation
final Map<Direction, UnbakedModel> insulation = new HashMap<>();
if (json.has("insulation")) {
JsonObject variantsJson = GsonHelper.getAsJsonObject(json, "insulation");
for (Map.Entry<String, JsonElement> entry : variantsJson.entrySet()) {
Direction direction = Direction.byName(entry.getKey());
if (direction == null && !CENTER_KEYS.contains(entry.getKey().toLowerCase(Locale.ROOT))) {
throw new JsonParseException("Invalid pipe model insulation specifier " + entry.getKey());
}
insulation.put(direction, MachineModelLoader.GSON.fromJson(entry.getValue(), MultiVariantModel.class));
}
}

return new UnbakedPipeModel(parts, restrictors);
return new UnbakedPipeModel(parts, restrictors, insulation);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ public class UnbakedPipeModel implements IUnbakedGeometry<UnbakedPipeModel> {

private final Map<@Nullable Direction, UnbakedModel> parts;
private final Map<@NotNull Direction, UnbakedModel> restrictors;
private final Map<@Nullable Direction, UnbakedModel> insulation;

public UnbakedPipeModel(Map<@Nullable Direction, UnbakedModel> parts,
Map<@NotNull Direction, UnbakedModel> restrictors) {
Map<@NotNull Direction, UnbakedModel> restrictors,
Map<@Nullable Direction, UnbakedModel> insulation) {
this.parts = parts;
this.restrictors = restrictors;
this.insulation = insulation;
}

@Override
Expand All @@ -40,7 +43,11 @@ public BakedModel bake(IGeometryBakingContext context, ModelBaker baker,
this.restrictors.forEach((direction, unbaked) -> {
bakedRestrictors.put(direction, unbaked.bake(baker, spriteGetter, modelState, modelLocation));
});
return new BakedPipeModel(bakedParts, bakedRestrictors);
Map<Direction, BakedModel> bakedInsulation = new IdentityHashMap<>();
this.insulation.forEach((direction, unbaked) -> {
bakedInsulation.put(direction, unbaked.bake(baker, spriteGetter, modelState, modelLocation));
});
return new BakedPipeModel(bakedParts, bakedRestrictors, bakedInsulation);
}

@Override
Expand All @@ -67,5 +74,15 @@ public void resolveParents(Function<ResourceLocation, UnbakedModel> resolver, IG
this.restrictors.put(side, variant);
}
});
copy = new IdentityHashMap<>(this.insulation);
copy.forEach((side, variant) -> {
if (variant == null || variant == MISSING_MARKER) {
// replace null & markers with the actual missing model
this.insulation.put(side, missingModel);
} else {
variant.resolveParents(resolver);
this.insulation.put(side, variant);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public void appendHoverText(ItemStack stack, @Nullable BlockGetter level, List<C
if (properties.isAcidProof()) tooltip.add(Component.translatable("gtceu.fluid_pipe.acid_proof"));
if (properties.isCryoProof()) tooltip.add(Component.translatable("gtceu.fluid_pipe.cryo_proof"));
if (properties.isPlasmaProof()) tooltip.add(Component.translatable("gtceu.fluid_pipe.plasma_proof"));
if (properties.isInsulatedByDefault()) tooltip.add(Component.translatable("gtceu.fluid_pipe.insulated_by_default"));
}

@Override
Expand All @@ -133,6 +134,10 @@ public void entityInside(BlockState state, Level level, BlockPos pos, Entity ent
if (level.isClientSide) return;
if (level.getBlockEntity(pos) == null) return;
FluidPipeBlockEntity pipe = (FluidPipeBlockEntity) level.getBlockEntity(pos);
if (pipe.isInsulated()) {
super.entityInside(state, level, pos, entity);
return;
}
Comment thread
syticchan marked this conversation as resolved.

if (pipe.getOffsetTimer() % 10 == 0) {
if (entity instanceof LivingEntity livingEntity) {
Expand Down
Loading
Loading