Probably more thread safe (#1501)

This commit is contained in:
Jason Mitchell authored and GitHub committed 2026-08-13 06:19:04 +00:00
1 parent cf63a70645
commit be3721f175
18 files changed
+147 -105

No files matched your search

@@ -13,6 +13,7 @@
package appeng.api.parts;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
public interface IPartCollisionHelper {
@@ -50,4 +51,8 @@ public interface IPartCollisionHelper {
* @return true if this test is to get the BB Collision information.
*/
boolean isBBCollision();
default IBlockAccess getBlockAccess() {
return null;
}
}
@@ -18,6 +18,7 @@ import java.util.EnumSet;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
@@ -189,4 +190,8 @@ public interface IPartRenderHelper {
* @param complementOf sides to render
*/
void setFacesToRender(EnumSet<ForgeDirection> complementOf);
default IBlockAccess getBlockAccess() {
return null;
}
}
@@ -18,6 +18,7 @@ import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import com.google.common.base.Function;
@@ -190,6 +191,11 @@ public final class BusRenderHelper implements IPartRenderHelper {
public boolean isBBCollision() {
return false;
}
@Override
public IBlockAccess getBlockAccess() {
return BusRenderHelper.this.getBlockAccess();
}
}
private static final class BaseBlockTransformFunction implements Function<Block, AEBaseBlock> {
@@ -606,4 +612,9 @@ public final class BusRenderHelper implements IPartRenderHelper {
public ForgeDirection getWorldZ() {
return this.az;
}
@Override
public IBlockAccess getBlockAccess() {
return BusRenderer.INSTANCE.getRenderer().blockAccess;
}
}
@@ -17,6 +17,7 @@ import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.parts.IFacadeContainer;
@@ -35,6 +36,11 @@ public class CableRenderHelper {
}
public void renderStatic(final CableBusContainer cableBusContainer, final IFacadeContainer iFacadeContainer) {
this.renderStatic(cableBusContainer, iFacadeContainer, Minecraft.getMinecraft().theWorld);
}
public void renderStatic(final CableBusContainer cableBusContainer, final IFacadeContainer iFacadeContainer,
final IBlockAccess world) {
final TileEntity te = cableBusContainer.getTile();
final RenderBlocksWorkaround renderer = BusRenderer.INSTANCE.getRenderer();
final BusRenderHelper busRenderHelper = BusRenderHelper.instances.get();
@@ -42,7 +48,7 @@ public class CableRenderHelper {
busRenderHelper.setPass(0);
}
renderer.blockAccess = Minecraft.getMinecraft().theWorld;
renderer.blockAccess = world;
for (final ForgeDirection s : FORGE_DIRECTIONS) {
final IPart part = cableBusContainer.getPart(s);
@@ -77,7 +83,8 @@ public class CableRenderHelper {
busRenderHelper.getWorldY(),
busRenderHelper.getWorldZ(),
null,
true);
true,
world);
part.getBoxes(bch);
}
}
@@ -198,6 +205,7 @@ public class CableRenderHelper {
final double z) {
final RenderBlocksWorkaround renderer = BusRenderer.INSTANCE.getRenderer();
final BusRenderHelper busRenderHelper = BusRenderHelper.instances.get();
renderer.blockAccess = cableBusContainer.getTile().getWorldObj();
for (final ForgeDirection s : FORGE_DIRECTIONS) {
final IPart part = cableBusContainer.getPart(s);
@@ -248,5 +256,6 @@ public class CableRenderHelper {
part.renderDynamic(x, y, z, busRenderHelper, renderer);
}
}
renderer.blockAccess = null;
}
}
@@ -497,7 +497,7 @@ public class RenderBlocksWorkaround extends RenderBlocks {
for (int j = -1; j <= 1; j++) {
for (int k = -1; k <= 1; k++) {
this.lightHashTmp[o] = blk.getMixedBrightnessForBlock(this.blockAccess, x + i, y + j, z + k);
this.lightHashTmp[o] = blk.getMixedBrightnessForBlock(w, x + i, y + j, z + k);
o++;
}
}
@@ -32,13 +32,6 @@ import appeng.util.Platform;
public class RenderBlockWireless extends BaseBlockRender<BlockWireless, TileWireless> {
private int centerX = 0;
private int centerY = 0;
private int centerZ = 0;
private BlockWireless blk;
private boolean hasChan = false;
private boolean hasPower = false;
public RenderBlockWireless() {
super(false, 20);
}
@@ -46,13 +39,6 @@ public class RenderBlockWireless extends BaseBlockRender<BlockWireless, TileWire
@Override
public void renderInventory(final BlockWireless blk, final ItemStack is, final RenderBlocks renderer,
final ItemRenderType type, final Object[] obj) {
this.blk = blk;
this.centerX = 0;
this.centerY = 0;
this.centerZ = 0;
this.hasChan = false;
this.hasPower = false;
final BlockRenderInfo ri = blk.getRendererInstance();
final Tessellator tess = Tessellator.instance;
@@ -102,7 +88,16 @@ public class RenderBlockWireless extends BaseBlockRender<BlockWireless, TileWire
tess.startDrawingQuads();
ri.setTemporaryRenderIcon(null);
this.renderTorchAtAngle(renderer, ForgeDirection.EAST, ForgeDirection.UP, ForgeDirection.SOUTH);
this.renderTorchAtAngle(
renderer,
blk,
false,
0,
0,
0,
ForgeDirection.EAST,
ForgeDirection.UP,
ForgeDirection.SOUTH);
super.postRenderInWorld(renderer);
tess.draw();
@@ -156,12 +151,11 @@ public class RenderBlockWireless extends BaseBlockRender<BlockWireless, TileWire
public boolean renderInWorld(final BlockWireless blk, final IBlockAccess world, final int x, final int y,
final int z, final RenderBlocks renderer) {
final TileWireless tw = blk.getTileEntity(world, x, y, z);
this.blk = blk;
if (tw != null) {
this.hasChan = (tw.getClientFlags() & (TileWireless.POWERED_FLAG | TileWireless.CHANNEL_FLAG))
final boolean hasChan = (tw.getClientFlags() & (TileWireless.POWERED_FLAG | TileWireless.CHANNEL_FLAG))
== (TileWireless.POWERED_FLAG | TileWireless.CHANNEL_FLAG);
this.hasPower = (tw.getClientFlags() & TileWireless.POWERED_FLAG) == TileWireless.POWERED_FLAG;
final boolean hasPower = (tw.getClientFlags() & TileWireless.POWERED_FLAG) == TileWireless.POWERED_FLAG;
final BlockRenderInfo ri = blk.getRendererInstance();
@@ -193,12 +187,9 @@ public class RenderBlockWireless extends BaseBlockRender<BlockWireless, TileWire
this.renderBlockBounds(renderer, 5, 5, 1, 11, 11, 2, fdx, fdy, fdz);
super.renderInWorld(blk, world, x, y, z, renderer);
this.centerX = x;
this.centerY = y;
this.centerZ = z;
ri.setTemporaryRenderIcon(null);
this.renderTorchAtAngle(renderer, fdx, fdy, fdz);
this.renderTorchAtAngle(renderer, blk, hasChan, x, y, z, fdx, fdy, fdz);
super.postRenderInWorld(renderer);
ri.setTemporaryRenderIcons(
@@ -251,11 +242,11 @@ public class RenderBlockWireless extends BaseBlockRender<BlockWireless, TileWire
this.renderBlockBounds(renderer, 5, 5, 0, 11, 11, 1, fdx, fdy, fdz);
final Tessellator tess = Tessellator.instance;
if (this.hasChan) {
if (hasChan) {
final int l = 14;
tess.setBrightness(l << 20 | l << 4);
tess.setColorOpaque_I(AEColor.Transparent.blackVariant);
} else if (this.hasPower) {
} else if (hasPower) {
final int l = 9;
tess.setBrightness(l << 20 | l << 4);
tess.setColorOpaque_I(AEColor.Transparent.whiteVariant);
@@ -290,9 +281,10 @@ public class RenderBlockWireless extends BaseBlockRender<BlockWireless, TileWire
return true;
}
private void renderTorchAtAngle(final RenderBlocks renderer, final ForgeDirection x, final ForgeDirection y,
private void renderTorchAtAngle(final RenderBlocks renderer, final BlockWireless blk, final boolean hasChan,
final int centerX, final int centerY, final int centerZ, final ForgeDirection x, final ForgeDirection y,
final ForgeDirection z) {
final IIcon r = (this.hasChan ? CableBusTextures.BlockWirelessOn.getIcon() : this.blk.getIcon(0, 0));
final IIcon r = (hasChan ? CableBusTextures.BlockWirelessOn.getIcon() : blk.getIcon(0, 0));
final IIcon sides = new OffsetIcon(r, 0.0f, -2.0f);
switch (z) {
@@ -331,14 +323,14 @@ public class RenderBlockWireless extends BaseBlockRender<BlockWireless, TileWire
Tessellator.instance.setColorOpaque_I(0xffffff);
this.renderBlockBounds(renderer, 0, 7, 1, 16, 9, 16, x, y, z);
this.renderFace(this.centerX, this.centerY, this.centerZ, this.blk, sides, renderer, y);
this.renderFace(this.centerX, this.centerY, this.centerZ, this.blk, sides, renderer, y.getOpposite());
this.renderFace(centerX, centerY, centerZ, blk, sides, renderer, y);
this.renderFace(centerX, centerY, centerZ, blk, sides, renderer, y.getOpposite());
this.renderBlockBounds(renderer, 7, 0, 1, 9, 16, 16, x, y, z);
this.renderFace(this.centerX, this.centerY, this.centerZ, this.blk, sides, renderer, x);
this.renderFace(this.centerX, this.centerY, this.centerZ, this.blk, sides, renderer, x.getOpposite());
this.renderFace(centerX, centerY, centerZ, blk, sides, renderer, x);
this.renderFace(centerX, centerY, centerZ, blk, sides, renderer, x.getOpposite());
this.renderBlockBounds(renderer, 7, 7, 1, 9, 9, 10.6, x, y, z);
this.renderFace(this.centerX, this.centerY, this.centerZ, this.blk, r, renderer, z);
this.renderFace(centerX, centerY, centerZ, blk, r, renderer, z);
}
}
@@ -45,7 +45,7 @@ public class RendererCableBus extends BaseBlockRender<BlockCableBus, TileCableBu
final RenderBlocksWorkaround rbw = BusRenderer.INSTANCE.getRenderer();
rbw.renderAllFaces = true;
rbw.overrideBlockTexture = renderer.overrideBlockTexture;
((TileCableBus) tile).getCableBus().renderStatic(x, y, z);
((TileCableBus) tile).getCableBus().renderStatic(world, x, y, z);
rbw.renderAllFaces = false;
}
+1 -1
View File
@@ -170,7 +170,7 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IMask
helper.setPass(pass);
rb.renderAllFaces = true;
rb.overrideBlockTexture = null;
this.getCableBus().renderStatic(pos.x, pos.y, pos.z);
this.getCableBus().renderStatic(this.tile().getWorldObj(), pos.x, pos.y, pos.z);
return helper.getItemsRendered() > 0;
}
return false;
@@ -28,6 +28,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants.NBT;
import net.minecraftforge.common.util.ForgeDirection;
@@ -553,6 +554,21 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
this.renderCache.set(renderCache);
}
protected IBlockAccess getRenderWorld(final IPartRenderHelper rh) {
final IBlockAccess w = rh.getBlockAccess();
return w != null ? w : this.getHostWorld();
}
protected IBlockAccess getRenderWorld(final IPartCollisionHelper bch) {
final IBlockAccess w = bch.getBlockAccess();
return w != null ? w : this.getHostWorld();
}
private IBlockAccess getHostWorld() {
final TileEntity te = this.getTile();
return te == null ? null : te.getWorldObj();
}
private static int getSideIndexFromDirection(ForgeDirection direction) {
if (direction == ForgeDirection.UNKNOWN || direction == null) {
return -1;
@@ -14,6 +14,7 @@ import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.parts.IPartCollisionHelper;
@@ -28,15 +29,22 @@ public class BusCollisionHelper implements IPartCollisionHelper {
private final Entity entity;
private final boolean isVisual;
private final IBlockAccess blockAccess;
public BusCollisionHelper(final List<AxisAlignedBB> boxes, final ForgeDirection x, final ForgeDirection y,
final ForgeDirection z, final Entity e, final boolean visual) {
this(boxes, x, y, z, e, visual, null);
}
public BusCollisionHelper(final List<AxisAlignedBB> boxes, final ForgeDirection x, final ForgeDirection y,
final ForgeDirection z, final Entity e, final boolean visual, final IBlockAccess blockAccess) {
this.boxes = boxes;
this.x = x;
this.y = y;
this.z = z;
this.entity = e;
this.isVisual = visual;
this.blockAccess = blockAccess;
}
public BusCollisionHelper(final List<AxisAlignedBB> boxes, final ForgeDirection s, final Entity e,
@@ -44,6 +52,7 @@ public class BusCollisionHelper implements IPartCollisionHelper {
this.boxes = boxes;
this.entity = e;
this.isVisual = visual;
this.blockAccess = null;
switch (s) {
case DOWN -> {
@@ -152,4 +161,9 @@ public class BusCollisionHelper implements IPartCollisionHelper {
public boolean isBBCollision() {
return !this.isVisual;
}
@Override
public IBlockAccess getBlockAccess() {
return this.blockAccess;
}
}
@@ -17,6 +17,7 @@ import java.util.List;
import java.util.Random;
import java.util.Set;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -26,6 +27,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@@ -719,7 +721,12 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
@SideOnly(Side.CLIENT)
public void renderStatic(final double x, final double y, final double z) {
CableRenderHelper.getInstance().renderStatic(this, this.getFacadeContainer());
this.renderStatic(Minecraft.getMinecraft().theWorld, x, y, z);
}
@SideOnly(Side.CLIENT)
public void renderStatic(final IBlockAccess world, final double x, final double y, final double z) {
CableRenderHelper.getInstance().renderStatic(this, this.getFacadeContainer(), world);
}
@SideOnly(Side.CLIENT)
@@ -501,7 +501,7 @@ public class PartAdvancedLevelEmitter extends PartUpgradeable implements IAdvanc
renderer.renderAllFaces = true;
final Tessellator tess = Tessellator.instance;
tess.setBrightness(rh.getBlock().getMixedBrightnessForBlock(this.getHost().getTile().getWorldObj(), x, y, z));
tess.setBrightness(rh.getBlock().getMixedBrightnessForBlock(this.getRenderWorld(rh), x, y, z));
tess.setColorOpaque_F(1.0F, 1.0F, 1.0F);
this.renderTorchAtAngle(x, y, z);
@@ -4,6 +4,7 @@ import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.networking.events.MENetworkChannelsChanged;
@@ -45,27 +46,28 @@ public abstract class PartBaseAnnihilationPlane extends PartBasicState {
final ForgeDirection e = bch.getWorldX();
final ForgeDirection u = bch.getWorldY();
final IBlockAccess w = this.getRenderWorld(bch);
if (this.isAnnihilationPlane(
te.getWorldObj().getTileEntity(x - e.offsetX, y - e.offsetY, z - e.offsetZ),
w.getTileEntity(x - e.offsetX, y - e.offsetY, z - e.offsetZ),
this.getSide())) {
minX = 0;
}
if (this.isAnnihilationPlane(
te.getWorldObj().getTileEntity(x + e.offsetX, y + e.offsetY, z + e.offsetZ),
w.getTileEntity(x + e.offsetX, y + e.offsetY, z + e.offsetZ),
this.getSide())) {
maxX = 16;
}
if (this.isAnnihilationPlane(
te.getWorldObj().getTileEntity(x - u.offsetX, y - u.offsetY, z - u.offsetZ),
w.getTileEntity(x - u.offsetX, y - u.offsetY, z - u.offsetZ),
this.getSide())) {
minY = 0;
}
if (this.isAnnihilationPlane(
te.getWorldObj().getTileEntity(x + u.offsetX, y + u.offsetY, z + u.offsetZ),
w.getTileEntity(x + u.offsetX, y + u.offsetY, z + u.offsetZ),
this.getSide())) {
maxY = 16;
}
@@ -101,32 +103,24 @@ public abstract class PartBaseAnnihilationPlane extends PartBasicState {
final ForgeDirection e = rh.getWorldX();
final ForgeDirection u = rh.getWorldY();
final TileEntity te = this.getHost().getTile();
final IBlockAccess w = this.getRenderWorld(rh);
if (this.isAnnihilationPlane(
te.getWorldObj().getTileEntity(x - e.offsetX, y - e.offsetY, z - e.offsetZ),
this.getSide())) {
if (this.isAnnihilationPlane(w.getTileEntity(x - e.offsetX, y - e.offsetY, z - e.offsetZ), this.getSide())) {
minX = 0;
}
int maxX = 15;
if (this.isAnnihilationPlane(
te.getWorldObj().getTileEntity(x + e.offsetX, y + e.offsetY, z + e.offsetZ),
this.getSide())) {
if (this.isAnnihilationPlane(w.getTileEntity(x + e.offsetX, y + e.offsetY, z + e.offsetZ), this.getSide())) {
maxX = 16;
}
int minY = 1;
if (this.isAnnihilationPlane(
te.getWorldObj().getTileEntity(x - u.offsetX, y - u.offsetY, z - u.offsetZ),
this.getSide())) {
if (this.isAnnihilationPlane(w.getTileEntity(x - u.offsetX, y - u.offsetY, z - u.offsetZ), this.getSide())) {
minY = 0;
}
int maxY = 15;
if (this.isAnnihilationPlane(
te.getWorldObj().getTileEntity(x + u.offsetX, y + u.offsetY, z + u.offsetZ),
this.getSide())) {
if (this.isAnnihilationPlane(w.getTileEntity(x + u.offsetX, y + u.offsetY, z + u.offsetZ), this.getSide())) {
maxY = 16;
}
@@ -8,6 +8,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@@ -135,28 +136,21 @@ public abstract class PartBaseFormationPlane extends PartUpgradeable
final ForgeDirection e = bch.getWorldX();
final ForgeDirection u = bch.getWorldY();
final IBlockAccess w = this.getRenderWorld(bch);
if (this.isTransitionPlane(
te.getWorldObj().getTileEntity(x - e.offsetX, y - e.offsetY, z - e.offsetZ),
this.getSide())) {
if (this.isTransitionPlane(w.getTileEntity(x - e.offsetX, y - e.offsetY, z - e.offsetZ), this.getSide())) {
minX = 0;
}
if (this.isTransitionPlane(
te.getWorldObj().getTileEntity(x + e.offsetX, y + e.offsetY, z + e.offsetZ),
this.getSide())) {
if (this.isTransitionPlane(w.getTileEntity(x + e.offsetX, y + e.offsetY, z + e.offsetZ), this.getSide())) {
maxX = 16;
}
if (this.isTransitionPlane(
te.getWorldObj().getTileEntity(x - u.offsetX, y - u.offsetY, z - u.offsetZ),
this.getSide())) {
if (this.isTransitionPlane(w.getTileEntity(x - u.offsetX, y - u.offsetY, z - u.offsetZ), this.getSide())) {
minY = 0;
}
if (this.isTransitionPlane(
te.getWorldObj().getTileEntity(x + u.offsetX, y + u.offsetY, z + u.offsetZ),
this.getSide())) {
if (this.isTransitionPlane(w.getTileEntity(x + u.offsetX, y + u.offsetY, z + u.offsetZ), this.getSide())) {
maxY = 16;
}
}
@@ -192,32 +186,24 @@ public abstract class PartBaseFormationPlane extends PartUpgradeable
final ForgeDirection e = rh.getWorldX();
final ForgeDirection u = rh.getWorldY();
final TileEntity te = this.getHost().getTile();
final IBlockAccess w = this.getRenderWorld(rh);
if (this.isTransitionPlane(
te.getWorldObj().getTileEntity(x - e.offsetX, y - e.offsetY, z - e.offsetZ),
this.getSide())) {
if (this.isTransitionPlane(w.getTileEntity(x - e.offsetX, y - e.offsetY, z - e.offsetZ), this.getSide())) {
minX = 0;
}
int maxX = 15;
if (this.isTransitionPlane(
te.getWorldObj().getTileEntity(x + e.offsetX, y + e.offsetY, z + e.offsetZ),
this.getSide())) {
if (this.isTransitionPlane(w.getTileEntity(x + e.offsetX, y + e.offsetY, z + e.offsetZ), this.getSide())) {
maxX = 16;
}
int minY = 1;
if (this.isTransitionPlane(
te.getWorldObj().getTileEntity(x - u.offsetX, y - u.offsetY, z - u.offsetZ),
this.getSide())) {
if (this.isTransitionPlane(w.getTileEntity(x - u.offsetX, y - u.offsetY, z - u.offsetZ), this.getSide())) {
minY = 0;
}
int maxY = 15;
if (this.isTransitionPlane(
te.getWorldObj().getTileEntity(x + u.offsetX, y + u.offsetY, z + u.offsetZ),
this.getSide())) {
if (this.isTransitionPlane(w.getTileEntity(x + u.offsetX, y + u.offsetY, z + u.offsetZ), this.getSide())) {
maxY = 16;
}
@@ -696,7 +696,7 @@ public class PartLevelEmitter extends PartUpgradeable implements ILevelEmitter {
renderer.renderAllFaces = true;
final Tessellator tess = Tessellator.instance;
tess.setBrightness(rh.getBlock().getMixedBrightnessForBlock(this.getHost().getTile().getWorldObj(), x, y, z));
tess.setBrightness(rh.getBlock().getMixedBrightnessForBlock(this.getRenderWorld(rh), x, y, z));
tess.setColorOpaque_F(1.0F, 1.0F, 1.0F);
this.renderTorchAtAngle(x, y, z);
@@ -249,7 +249,7 @@ public class PartCable extends AEBasePart implements IPartCable {
break;
}
} else if (this.getConnections().contains(dir)) {
final TileEntity te = this.getTile().getWorldObj()
final TileEntity te = this.getRenderWorld(rh)
.getTileEntity(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
final IPartHost partHost = te instanceof IPartHost ? (IPartHost) te : null;
final IGridHost gh = te instanceof IGridHost ? (IGridHost) te : null;
@@ -460,8 +460,7 @@ public class PartCable extends AEBasePart implements IPartCable {
@SideOnly(Side.CLIENT)
private void renderGlassConnection(final int x, final int y, final int z, final IPartRenderHelper rh,
final RenderBlocks renderer, final ForgeDirection of) {
final TileEntity te = this.getTile().getWorldObj()
.getTileEntity(x + of.offsetX, y + of.offsetY, z + of.offsetZ);
final TileEntity te = this.getRenderWorld(rh).getTileEntity(x + of.offsetX, y + of.offsetY, z + of.offsetZ);
final IPartHost partHost = te instanceof IPartHost ? (IPartHost) te : null;
final IGridHost gh = te instanceof IGridHost ? (IGridHost) te : null;
@@ -511,8 +510,7 @@ public class PartCable extends AEBasePart implements IPartCable {
@SideOnly(Side.CLIENT)
void renderCoveredConnection(final int x, final int y, final int z, final IPartRenderHelper rh,
final RenderBlocks renderer, final int channels, final ForgeDirection of) {
final TileEntity te = this.getTile().getWorldObj()
.getTileEntity(x + of.offsetX, y + of.offsetY, z + of.offsetZ);
final TileEntity te = this.getRenderWorld(rh).getTileEntity(x + of.offsetX, y + of.offsetY, z + of.offsetZ);
final IPartHost partHost = te instanceof IPartHost ? (IPartHost) te : null;
final IGridHost ghh = te instanceof IGridHost ? (IGridHost) te : null;
@@ -569,8 +567,7 @@ public class PartCable extends AEBasePart implements IPartCable {
@SideOnly(Side.CLIENT)
void renderSmartConnection(final int x, final int y, final int z, final IPartRenderHelper rh,
final RenderBlocks renderer, final int channels, final ForgeDirection of) {
final TileEntity te = this.getTile().getWorldObj()
.getTileEntity(x + of.offsetX, y + of.offsetY, z + of.offsetZ);
final TileEntity te = this.getRenderWorld(rh).getTileEntity(x + of.offsetX, y + of.offsetY, z + of.offsetZ);
final IPartHost partHost = te instanceof IPartHost ? (IPartHost) te : null;
final IGridHost ghh = te instanceof IGridHost ? (IGridHost) te : null;
AEColor myColor = this.getCableColor();
@@ -17,6 +17,7 @@ import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
@@ -81,8 +82,9 @@ public class PartDenseCable extends PartCable implements IUsedChannelProvider {
}
}
final IBlockAccess w = this.getRenderWorld(bch);
for (final ForgeDirection of : this.getConnections()) {
if (this.isDense(of)) {
if (this.isDense(w, of)) {
switch (of) {
case DOWN -> bch.addBox(min, 0.0, min, max, min, max);
case EAST -> bch.addBox(max, min, min, 16.0, max, max);
@@ -170,18 +172,20 @@ public class PartDenseCable extends PartCable implements IUsedChannelProvider {
final EnumSet<ForgeDirection> sides = this.getConnections().clone();
final IBlockAccess w = this.getRenderWorld(rh);
boolean hasBuses = false;
for (final ForgeDirection of : this.getConnections()) {
if (!this.isDense(of)) {
if (!this.isDense(w, of)) {
hasBuses = true;
}
}
if (sides.size() != 2 || !this.nonLinear(sides) || hasBuses) {
for (final ForgeDirection of : this.getConnections()) {
if (this.isDense(of)) {
if (this.isDense(w, of)) {
this.renderDenseConnection(x, y, z, rh, renderer, this.getChannelsOnSide()[of.ordinal()], of);
} else if (this.isSmart(of)) {
} else if (this.isSmart(w, of)) {
this.renderSmartConnection(x, y, z, rh, renderer, this.getChannelsOnSide()[of.ordinal()], of);
} else {
this.renderCoveredConnection(x, y, z, rh, renderer, this.getChannelsOnSide()[of.ordinal()], of);
@@ -281,8 +285,7 @@ public class PartDenseCable extends PartCable implements IUsedChannelProvider {
final RenderBlocks renderer, final int channels, final ForgeDirection of) {
final Tessellator tessellator = Tessellator.instance;
final TileEntity te = this.getTile().getWorldObj()
.getTileEntity(x + of.offsetX, y + of.offsetY, z + of.offsetZ);
final TileEntity te = this.getRenderWorld(rh).getTileEntity(x + of.offsetX, y + of.offsetY, z + of.offsetZ);
final IPartHost partHost = te instanceof IPartHost ? (IPartHost) te : null;
final IGridHost ghh = te instanceof IGridHost ? (IGridHost) te : null;
AEColor myColor = this.getCableColor();
@@ -332,8 +335,8 @@ public class PartDenseCable extends PartCable implements IUsedChannelProvider {
}
}
private boolean isSmart(final ForgeDirection of) {
final TileEntity te = this.getTile().getWorldObj().getTileEntity(
private boolean isSmart(final IBlockAccess w, final ForgeDirection of) {
final TileEntity te = w.getTileEntity(
this.getTile().xCoord + of.offsetX,
this.getTile().yCoord + of.offsetY,
this.getTile().zCoord + of.offsetZ);
@@ -366,8 +369,8 @@ public class PartDenseCable extends PartCable implements IUsedChannelProvider {
});
}
private boolean isDense(final ForgeDirection of) {
final TileEntity te = this.getTile().getWorldObj().getTileEntity(
private boolean isDense(final IBlockAccess w, final ForgeDirection of) {
final TileEntity te = w.getTileEntity(
this.getTile().xCoord + of.offsetX,
this.getTile().yCoord + of.offsetY,
this.getTile().zCoord + of.offsetZ);
@@ -16,6 +16,7 @@ import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
@@ -79,8 +80,9 @@ public class PartDenseCableCovered extends PartCable {
}
}
final IBlockAccess w = this.getRenderWorld(bch);
for (final ForgeDirection of : this.getConnections()) {
if (this.isDense(of)) {
if (this.isDense(w, of)) {
switch (of) {
case DOWN -> bch.addBox(min, 0.0, min, max, min, max);
case EAST -> bch.addBox(max, min, min, 16.0, max, max);
@@ -155,16 +157,18 @@ public class PartDenseCableCovered extends PartCable {
final EnumSet<ForgeDirection> sides = this.getConnections().clone();
final IBlockAccess w = this.getRenderWorld(rh);
boolean hasBuses = false;
for (final ForgeDirection of : this.getConnections()) {
if (!this.isDense(of)) {
if (!this.isDense(w, of)) {
hasBuses = true;
}
}
if (sides.size() != 2 || !this.nonLinear(sides) || hasBuses) {
for (final ForgeDirection of : this.getConnections()) {
if (this.isDense(of)) {
if (this.isDense(w, of)) {
this.renderDenseCoveredConnection(x, y, z, rh, renderer, of);
} else {
this.renderCoveredConnection(x, y, z, rh, renderer, this.getChannelsOnSide()[of.ordinal()], of);
@@ -226,8 +230,7 @@ public class PartDenseCableCovered extends PartCable {
@SideOnly(Side.CLIENT)
private void renderDenseCoveredConnection(final int x, final int y, final int z, final IPartRenderHelper rh,
final RenderBlocks renderer, final ForgeDirection of) {
final TileEntity te = this.getTile().getWorldObj()
.getTileEntity(x + of.offsetX, y + of.offsetY, z + of.offsetZ);
final TileEntity te = this.getRenderWorld(rh).getTileEntity(x + of.offsetX, y + of.offsetY, z + of.offsetZ);
final IPartHost partHost = te instanceof IPartHost ? (IPartHost) te : null;
final IGridHost ghh = te instanceof IGridHost ? (IGridHost) te : null;
@@ -279,8 +282,8 @@ public class PartDenseCableCovered extends PartCable {
});
}
private boolean isDense(final ForgeDirection of) {
final TileEntity te = this.getTile().getWorldObj().getTileEntity(
private boolean isDense(final IBlockAccess w, final ForgeDirection of) {
final TileEntity te = w.getTileEntity(
this.getTile().xCoord + of.offsetX,
this.getTile().yCoord + of.offsetY,
this.getTile().zCoord + of.offsetZ);