Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename MTE pipes to be more descriptive & cleanup bounding box #3983

Merged
merged 6 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from 4 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
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

import static gregtech.api.enums.Mods.GalacticraftCore;
import static net.minecraftforge.common.util.ForgeDirection.DOWN;
import static net.minecraftforge.common.util.ForgeDirection.EAST;
import static net.minecraftforge.common.util.ForgeDirection.NORTH;
import static net.minecraftforge.common.util.ForgeDirection.SOUTH;
import static net.minecraftforge.common.util.ForgeDirection.UP;
import static net.minecraftforge.common.util.ForgeDirection.WEST;

import java.util.ArrayList;
import java.util.HashSet;
Expand All @@ -18,7 +13,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
Expand Down Expand Up @@ -642,74 +636,6 @@ public String[] getInfoData() {
+ " EU/t" };
}

@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
if (GTMod.instance.isClientSide() && (GTClient.hideValue & 0x2) != 0)
return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 1, aZ + 1);
else return getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
}

private AxisAlignedBB getActualCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
float tSpace = (1f - mThickNess) / 2;
float spaceDown = tSpace;
float spaceUp = 1f - tSpace;
float spaceNorth = tSpace;
float spaceSouth = 1f - tSpace;
float spaceWest = tSpace;
float spaceEast = 1f - tSpace;

if (getBaseMetaTileEntity().getCoverIDAtSide(DOWN) != 0) {
spaceDown = spaceNorth = spaceWest = 0;
spaceSouth = spaceEast = 1;
}
if (getBaseMetaTileEntity().getCoverIDAtSide(UP) != 0) {
spaceNorth = spaceWest = 0;
spaceUp = spaceSouth = spaceEast = 1;
}
if (getBaseMetaTileEntity().getCoverIDAtSide(NORTH) != 0) {
spaceDown = spaceNorth = spaceWest = 0;
spaceUp = spaceEast = 1;
}
if (getBaseMetaTileEntity().getCoverIDAtSide(SOUTH) != 0) {
spaceDown = spaceWest = 0;
spaceUp = spaceSouth = spaceEast = 1;
}
if (getBaseMetaTileEntity().getCoverIDAtSide(WEST) != 0) {
spaceDown = spaceNorth = spaceWest = 0;
spaceUp = spaceSouth = 1;
}
if (getBaseMetaTileEntity().getCoverIDAtSide(EAST) != 0) {
spaceDown = spaceNorth = 0;
spaceUp = spaceSouth = spaceEast = 1;
}

byte tConn = ((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections;
if ((tConn & DOWN.flag) != 0) spaceDown = 0f;
if ((tConn & UP.flag) != 0) spaceUp = 1f;
if ((tConn & NORTH.flag) != 0) spaceNorth = 0f;
if ((tConn & SOUTH.flag) != 0) spaceSouth = 1f;
if ((tConn & WEST.flag) != 0) spaceWest = 0f;
if ((tConn & EAST.flag) != 0) spaceEast = 1f;

return AxisAlignedBB.getBoundingBox(
aX + spaceWest,
aY + spaceDown,
aZ + spaceNorth,
aX + spaceEast,
aY + spaceUp,
aZ + spaceSouth);
}

@Override
public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB,
List<AxisAlignedBB> outputAABB, Entity collider) {
super.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider);
if (GTMod.instance.isClientSide() && (GTClient.hideValue & 0x2) != 0) {
final AxisAlignedBB aabb = getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
if (inputAABB.intersectsWith(aabb)) outputAABB.add(aabb);
}
}

@Override
public boolean shouldJoinIc2Enet() {
if (!GTMod.gregtechproxy.ic2EnergySourceCompat) return false;
Expand Down
Loading