Fix cover placing issue with such small AABB of metapipes
This commit is contained in:
parent
f6a9bbb293
commit
e18f0a186d
4 changed files with 122 additions and 60 deletions
|
@ -33,6 +33,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static gregtech.api.enums.GT_Values.VN;
|
||||
|
||||
|
@ -107,34 +108,6 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile
|
|||
GT_Utility.applyElectricityDamage((EntityLivingBase) aEntity, mTransferredVoltageLast20, mTransferredAmperageLast20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
|
||||
float tSpace = (1f - mThickNess)/2;
|
||||
float tSide0 = tSpace;
|
||||
float tSide1 = 1f - tSpace;
|
||||
float tSide2 = tSpace;
|
||||
float tSide3 = 1f - tSpace;
|
||||
float tSide4 = tSpace;
|
||||
float tSide5 = 1f - tSpace;
|
||||
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 0) != 0){tSide0=tSide2=tSide4=0;tSide3=tSide5=1;}
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 1) != 0){tSide2=tSide4=0;tSide1=tSide3=tSide5=1;}
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 2) != 0){tSide0=tSide2=tSide4=0;tSide1=tSide5=1;}
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 3) != 0){tSide0=tSide4=0;tSide1=tSide3=tSide5=1;}
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 4) != 0){tSide0=tSide2=tSide4=0;tSide1=tSide3=1;}
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 5) != 0){tSide0=tSide2=0;tSide1=tSide3=tSide5=1;}
|
||||
|
||||
byte tConn = ((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections;
|
||||
if((tConn & (1 << ForgeDirection.DOWN.ordinal()) ) != 0) tSide0 = 0f;
|
||||
if((tConn & (1 << ForgeDirection.UP.ordinal()) ) != 0) tSide1 = 1f;
|
||||
if((tConn & (1 << ForgeDirection.NORTH.ordinal())) != 0) tSide2 = 0f;
|
||||
if((tConn & (1 << ForgeDirection.SOUTH.ordinal())) != 0) tSide3 = 1f;
|
||||
if((tConn & (1 << ForgeDirection.WEST.ordinal()) ) != 0) tSide4 = 0f;
|
||||
if((tConn & (1 << ForgeDirection.EAST.ordinal()) ) != 0) tSide5 = 1f;
|
||||
|
||||
return AxisAlignedBB.getBoundingBox(aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSimpleMachine() {
|
||||
return true;
|
||||
|
@ -360,4 +333,48 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile
|
|||
mConnections = aNBT.getByte("mConnections");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
|
||||
if (GT_Mod.instance.isClientSide() && (GT_Client.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 tSide0 = tSpace;
|
||||
float tSide1 = 1f - tSpace;
|
||||
float tSide2 = tSpace;
|
||||
float tSide3 = 1f - tSpace;
|
||||
float tSide4 = tSpace;
|
||||
float tSide5 = 1f - tSpace;
|
||||
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 0) != 0){tSide0=tSide2=tSide4=0;tSide3=tSide5=1;}
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 1) != 0){tSide2=tSide4=0;tSide1=tSide3=tSide5=1;}
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 2) != 0){tSide0=tSide2=tSide4=0;tSide1=tSide5=1;}
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 3) != 0){tSide0=tSide4=0;tSide1=tSide3=tSide5=1;}
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 4) != 0){tSide0=tSide2=tSide4=0;tSide1=tSide3=1;}
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 5) != 0){tSide0=tSide2=0;tSide1=tSide3=tSide5=1;}
|
||||
|
||||
byte tConn = ((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections;
|
||||
if((tConn & (1 << ForgeDirection.DOWN.ordinal()) ) != 0) tSide0 = 0f;
|
||||
if((tConn & (1 << ForgeDirection.UP.ordinal()) ) != 0) tSide1 = 1f;
|
||||
if((tConn & (1 << ForgeDirection.NORTH.ordinal())) != 0) tSide2 = 0f;
|
||||
if((tConn & (1 << ForgeDirection.SOUTH.ordinal())) != 0) tSide3 = 1f;
|
||||
if((tConn & (1 << ForgeDirection.WEST.ordinal()) ) != 0) tSide4 = 0f;
|
||||
if((tConn & (1 << ForgeDirection.EAST.ordinal()) ) != 0) tSide5 = 1f;
|
||||
|
||||
return AxisAlignedBB.getBoundingBox(aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3);
|
||||
}
|
||||
|
||||
@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 (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x2) != 0) {
|
||||
AxisAlignedBB aabb = getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
|
||||
if (inputAABB.intersectsWith(aabb)) outputAABB.add(aabb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import net.minecraftforge.fluids.FluidTankInfo;
|
|||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
@ -217,34 +218,6 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity{
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
|
||||
float tSpace = (1f - mThickNess)/2;
|
||||
float tSide0 = tSpace;
|
||||
float tSide1 = 1f - tSpace;
|
||||
float tSide2 = tSpace;
|
||||
float tSide3 = 1f - tSpace;
|
||||
float tSide4 = tSpace;
|
||||
float tSide5 = 1f - tSpace;
|
||||
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 0) != 0){tSide0=tSide2=tSide4=0;tSide3=tSide5=1;}
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 1) != 0){tSide2=tSide4=0;tSide1=tSide3=tSide5=1;}
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 2) != 0){tSide0=tSide2=tSide4=0;tSide1=tSide5=1;}
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 3) != 0){tSide0=tSide4=0;tSide1=tSide3=tSide5=1;}
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 4) != 0){tSide0=tSide2=tSide4=0;tSide1=tSide3=1;}
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 5) != 0){tSide0=tSide2=0;tSide1=tSide3=tSide5=1;}
|
||||
|
||||
byte tConn = ((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections;
|
||||
if((tConn & (1 << ForgeDirection.DOWN.ordinal()) ) != 0) tSide0 = 0f;
|
||||
if((tConn & (1 << ForgeDirection.UP.ordinal()) ) != 0) tSide1 = 1f;
|
||||
if((tConn & (1 << ForgeDirection.NORTH.ordinal())) != 0) tSide2 = 0f;
|
||||
if((tConn & (1 << ForgeDirection.SOUTH.ordinal())) != 0) tSide3 = 1f;
|
||||
if((tConn & (1 << ForgeDirection.WEST.ordinal()) ) != 0) tSide4 = 0f;
|
||||
if((tConn & (1 << ForgeDirection.EAST.ordinal()) ) != 0) tSide5 = 1f;
|
||||
|
||||
return AxisAlignedBB.getBoundingBox(aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
|
||||
if (aBaseMetaTileEntity.isServerSide() && aTick % 5 == 0) {
|
||||
|
@ -618,4 +591,48 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity{
|
|||
public boolean isLiquidOutput(byte aSide) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
|
||||
if (GT_Mod.instance.isClientSide() && (GT_Client.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 tSide0 = tSpace;
|
||||
float tSide1 = 1f - tSpace;
|
||||
float tSide2 = tSpace;
|
||||
float tSide3 = 1f - tSpace;
|
||||
float tSide4 = tSpace;
|
||||
float tSide5 = 1f - tSpace;
|
||||
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 0) != 0){tSide0=tSide2=tSide4=0;tSide3=tSide5=1;}
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 1) != 0){tSide2=tSide4=0;tSide1=tSide3=tSide5=1;}
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 2) != 0){tSide0=tSide2=tSide4=0;tSide1=tSide5=1;}
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 3) != 0){tSide0=tSide4=0;tSide1=tSide3=tSide5=1;}
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 4) != 0){tSide0=tSide2=tSide4=0;tSide1=tSide3=1;}
|
||||
if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 5) != 0){tSide0=tSide2=0;tSide1=tSide3=tSide5=1;}
|
||||
|
||||
byte tConn = ((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections;
|
||||
if((tConn & (1 << ForgeDirection.DOWN.ordinal()) ) != 0) tSide0 = 0f;
|
||||
if((tConn & (1 << ForgeDirection.UP.ordinal()) ) != 0) tSide1 = 1f;
|
||||
if((tConn & (1 << ForgeDirection.NORTH.ordinal())) != 0) tSide2 = 0f;
|
||||
if((tConn & (1 << ForgeDirection.SOUTH.ordinal())) != 0) tSide3 = 1f;
|
||||
if((tConn & (1 << ForgeDirection.WEST.ordinal()) ) != 0) tSide4 = 0f;
|
||||
if((tConn & (1 << ForgeDirection.EAST.ordinal()) ) != 0) tSide5 = 1f;
|
||||
|
||||
return AxisAlignedBB.getBoundingBox(aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3);
|
||||
}
|
||||
|
||||
@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 (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x2) != 0) {
|
||||
AxisAlignedBB aabb = getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
|
||||
if (inputAABB.intersectsWith(aabb)) outputAABB.add(aabb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import gregtech.api.metatileentity.MetaPipeEntity;
|
|||
import gregtech.api.objects.GT_RenderedTexture;
|
||||
import gregtech.api.util.GT_Utility;
|
||||
import gregtech.common.GT_Client;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
|
@ -25,6 +26,7 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileEntityItemPipe{
|
||||
|
@ -355,6 +357,13 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE
|
|||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
|
||||
if (GT_Mod.instance.isClientSide() && (GT_Client.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 tSide0 = tSpace;
|
||||
float tSide1 = 1f - tSpace;
|
||||
|
@ -379,6 +388,14 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE
|
|||
if((tConn & (1 << ForgeDirection.EAST.ordinal()) ) != 0) tSide5 = 1f;
|
||||
|
||||
return AxisAlignedBB.getBoundingBox(aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3);
|
||||
|
||||
}
|
||||
|
||||
@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 (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x2) != 0) {
|
||||
AxisAlignedBB aabb = getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
|
||||
if (inputAABB.intersectsWith(aabb)) outputAABB.add(aabb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import gregtech.api.enums.Materials;
|
|||
import gregtech.api.interfaces.tileentity.ICoverable;
|
||||
import gregtech.api.interfaces.tileentity.ITurnable;
|
||||
import gregtech.api.metatileentity.BaseMetaPipeEntity;
|
||||
import gregtech.api.objects.GT_ItemStack;
|
||||
import gregtech.api.util.GT_Log;
|
||||
import gregtech.api.util.GT_PlayedSound;
|
||||
import gregtech.api.util.GT_Recipe;
|
||||
|
@ -563,9 +564,9 @@ public class GT_Client extends GT_Proxy
|
|||
try {
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
if (player == null) return 0;
|
||||
ItemStack held = player.getCurrentEquippedItem();
|
||||
if (held == null) return 0;
|
||||
int[] ids = OreDictionary.getOreIDs(held);
|
||||
ItemStack tCurrentItem = player.getCurrentEquippedItem();
|
||||
if (tCurrentItem == null) return 0;
|
||||
int[] ids = OreDictionary.getOreIDs(tCurrentItem);
|
||||
int hide = 0;
|
||||
for (int i : ids) {
|
||||
if (OreDictionary.getOreName(i).equals("craftingToolSolderingIron")) {
|
||||
|
@ -573,6 +574,16 @@ public class GT_Client extends GT_Proxy
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList)
|
||||
|| GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList)
|
||||
|| GT_Utility.isStackInList(tCurrentItem, GregTech_API.sHardHammerList)
|
||||
|| GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSoftHammerList)
|
||||
|| GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWireCutterList)
|
||||
|| GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList)
|
||||
|| GT_Utility.isStackInList(tCurrentItem, GregTech_API.sCrowbarList)
|
||||
|| GregTech_API.sCovers.containsKey(new GT_ItemStack(tCurrentItem))) {
|
||||
hide |= 0x2;
|
||||
}
|
||||
return hide;
|
||||
}catch(Exception e){
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue