Skip to content

Commit

Permalink
Rename MTE pipes to be more descriptive & cleanup bounding box (#3983)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Robertz <[email protected]>
  • Loading branch information
miozune and Dream-Master authored Feb 27, 2025
1 parent f3c4372 commit 395fa31
Show file tree
Hide file tree
Showing 23 changed files with 205 additions and 748 deletions.
144 changes: 0 additions & 144 deletions src/main/java/bartworks/system/material/BWMetaGeneratedFrames.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import tectech.mechanics.pipe.IConnectsToEnergyTunnel;
import tectech.thing.metaTileEntity.pipe.MTEPipeEnergy;
import tectech.thing.metaTileEntity.pipe.MTEPipeLaser;

@Deprecated
public interface LowPowerLaser extends IMetaTileEntity, IConnectsToEnergyTunnel {
Expand Down Expand Up @@ -99,11 +99,11 @@ default void moveAroundLowPower(IGregTechTileEntity aBaseMetaTileEntity) {
}

if ((!(aMetaTileEntity instanceof LowPowerLaser lowPowerLaser) || !lowPowerLaser.isTunnel())
&& !(aMetaTileEntity instanceof MTEPipeEnergy)) {
&& !(aMetaTileEntity instanceof MTEPipeLaser)) {
return;
}

if (aMetaTileEntity instanceof MTEPipeEnergy tePipeEnergy) {
if (aMetaTileEntity instanceof MTEPipeLaser tePipeEnergy) {
if (tePipeEnergy.connectionCount < 2) {
return;
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/goodgenerator/util/CrackRecipeAdder.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import gregtech.api.enums.OrePrefixes;
import gregtech.api.enums.TierEU;
import gregtech.api.metatileentity.implementations.MTECable;
import gregtech.api.metatileentity.implementations.MTEFluid;
import gregtech.api.metatileentity.implementations.MTEFluidPipe;
import gregtech.api.util.GTOreDictUnificator;
import gregtech.api.util.GTRecipeBuilder;
import gregtech.api.util.GTUtility;
Expand Down Expand Up @@ -192,7 +192,7 @@ public static void registerPipe(int ID, Werkstoff material, int flow, int temp,
String Name = material.getDefaultName();
GTOreDictUnificator.registerOre(
OrePrefixes.pipeTiny.get(material.getBridgeMaterial()),
new MTEFluid(
new MTEFluidPipe(
ID,
"GT_Pipe_" + unName + "_Tiny",
"Tiny " + Name + " Fluid Pipe",
Expand All @@ -203,7 +203,7 @@ public static void registerPipe(int ID, Werkstoff material, int flow, int temp,
gas).getStackForm(1L));
GTOreDictUnificator.registerOre(
OrePrefixes.pipeSmall.get(material.getBridgeMaterial()),
new MTEFluid(
new MTEFluidPipe(
ID + 1,
"GT_Pipe_" + unName + "_Small",
"Small " + Name + " Fluid Pipe",
Expand All @@ -214,7 +214,7 @@ public static void registerPipe(int ID, Werkstoff material, int flow, int temp,
gas).getStackForm(1L));
GTOreDictUnificator.registerOre(
OrePrefixes.pipeMedium.get(material.getBridgeMaterial()),
new MTEFluid(
new MTEFluidPipe(
ID + 2,
"GT_Pipe_" + unName,
Name + " Fluid Pipe",
Expand All @@ -225,7 +225,7 @@ public static void registerPipe(int ID, Werkstoff material, int flow, int temp,
gas).getStackForm(1L));
GTOreDictUnificator.registerOre(
OrePrefixes.pipeLarge.get(material.getBridgeMaterial()),
new MTEFluid(
new MTEFluidPipe(
ID + 3,
"GT_Pipe_" + unName + "_Large",
"Large " + Name + " Fluid Pipe",
Expand All @@ -236,7 +236,7 @@ public static void registerPipe(int ID, Werkstoff material, int flow, int temp,
gas).getStackForm(1L));
GTOreDictUnificator.registerOre(
OrePrefixes.pipeHuge.get(material.getBridgeMaterial()),
new MTEFluid(
new MTEFluidPipe(
ID + 4,
"GT_Pipe_" + unName + "_Huge",
"Huge " + Name + " Fluid Pipe",
Expand Down
72 changes: 72 additions & 0 deletions src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;

import gregtech.GTMod;
import gregtech.api.GregTechAPI;
import gregtech.api.enums.Dyes;
import gregtech.api.enums.GTValues;
Expand All @@ -29,6 +31,7 @@
import gregtech.api.util.GTUtil;
import gregtech.api.util.ISerializableObject;
import gregtech.api.util.WorldSpawnedEventBuilder;
import gregtech.common.GTClient;
import gregtech.common.covers.CoverInfo;

/**
Expand Down Expand Up @@ -393,6 +396,75 @@ public boolean isConnectedAtSide(ForgeDirection sideDirection) {
return (mConnections & sideDirection.flag) != 0;
}

@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
final float thickness = getThickNess();
// While holding tool, make it full block
final boolean shouldBeFullBlock = GTMod.instance.isClientSide() && (GTClient.hideValue & 0x2) != 0;
if (shouldBeFullBlock || thickness == 1) {
return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1);
}

// Otherwise, account for attached covers and connections

final float space = (1f - thickness) / 2;
float yStart = space;
float yEnd = 1f - space;
float zStart = space;
float zEnd = 1f - space;
float xStart = space;
float xEnd = 1f - space;
final BaseMetaPipeEntity baseTE = (BaseMetaPipeEntity) getBaseMetaTileEntity();

if (baseTE.getCoverIDAtSide(ForgeDirection.DOWN) != 0) {
yStart = zStart = xStart = 0;
zEnd = xEnd = 1;
}
if (baseTE.getCoverIDAtSide(ForgeDirection.UP) != 0) {
zStart = xStart = 0;
yEnd = zEnd = xEnd = 1;
}
if (baseTE.getCoverIDAtSide(ForgeDirection.NORTH) != 0) {
yStart = zStart = xStart = 0;
yEnd = xEnd = 1;
}
if (baseTE.getCoverIDAtSide(ForgeDirection.SOUTH) != 0) {
yStart = xStart = 0;
yEnd = zEnd = xEnd = 1;
}
if (baseTE.getCoverIDAtSide(ForgeDirection.WEST) != 0) {
yStart = zStart = xStart = 0;
yEnd = zEnd = 1;
}
if (baseTE.getCoverIDAtSide(ForgeDirection.EAST) != 0) {
yStart = zStart = 0;
yEnd = zEnd = xEnd = 1;
}

// this.mConnections isn't synced, but BaseMetaPipeEntity.mConnections is for some reason
final byte connections = baseTE.mConnections;
if ((connections & ForgeDirection.DOWN.flag) != 0) {
yStart = 0f;
}
if ((connections & ForgeDirection.UP.flag) != 0) {
yEnd = 1f;
}
if ((connections & ForgeDirection.NORTH.flag) != 0) {
zStart = 0f;
}
if ((connections & ForgeDirection.SOUTH.flag) != 0) {
zEnd = 1f;
}
if ((connections & ForgeDirection.WEST.flag) != 0) {
xStart = 0f;
}
if ((connections & ForgeDirection.EAST.flag) != 0) {
xEnd = 1f;
}

return AxisAlignedBB.getBoundingBox(x + xStart, y + yStart, z + zStart, x + xEnd, y + yEnd, z + zEnd);
}

public boolean letsIn(CoverBehavior coverBehavior, ForgeDirection side, int aCoverID, int aCoverVariable,
ICoverable aTileEntity) {
return false;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/gregtech/api/metatileentity/MetaTileEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import tectech.thing.metaTileEntity.pipe.MTEPipeData;
import tectech.thing.metaTileEntity.pipe.MTEPipeEnergy;
import tectech.thing.metaTileEntity.pipe.MTEPipeLaser;

/**
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
Expand Down Expand Up @@ -606,7 +606,7 @@ public void onBlockDestroyed() {
final IGregTechTileEntity iGregTechTileEntity = meta.getIGregTechTileEntityAtSide(side);

if (iGregTechTileEntity != null) {
if (iGregTechTileEntity.getMetaTileEntity() instanceof MTEPipeEnergy neighbor) {
if (iGregTechTileEntity.getMetaTileEntity() instanceof MTEPipeLaser neighbor) {
neighbor.mConnections &= ~side.getOpposite().flag;
neighbor.connectionCount--;
}
Expand All @@ -631,7 +631,7 @@ public void onColorChangeServer(byte aColor) {

final IGregTechTileEntity iGregTechTileEntity = meta.getIGregTechTileEntityAtSide(side);
if (iGregTechTileEntity != null) {
if (iGregTechTileEntity.getMetaTileEntity() instanceof MTEPipeEnergy pipe) pipe.updateNetwork(true);
if (iGregTechTileEntity.getMetaTileEntity() instanceof MTEPipeLaser pipe) pipe.updateNetwork(true);
if (iGregTechTileEntity.getMetaTileEntity() instanceof MTEPipeData pipe) pipe.updateNetwork(true);
}
}
Expand Down
Loading

0 comments on commit 395fa31

Please sign in to comment.