mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
the last commit before the great energy massacre
This commit is contained in:
parent
419a331f6d
commit
cb1661f5d3
@ -4,6 +4,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* For anything that connects to power and can be transferred power to, the bottom-level interface.
|
||||
* This is mean for TILE ENTITIES
|
||||
* @author hbm
|
||||
*/
|
||||
public interface IEnergyConnector {
|
||||
|
||||
25
src/main/java/api/hbm/energy/IEnergyConnectorBlock.java
Normal file
25
src/main/java/api/hbm/energy/IEnergyConnectorBlock.java
Normal file
@ -0,0 +1,25 @@
|
||||
package api.hbm.energy;
|
||||
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Interface for all blocks that should visually connect to cables without having an IEnergyConnector tile entity.
|
||||
* This is meant for BLOCKS
|
||||
* @author hbm
|
||||
*
|
||||
*/
|
||||
public interface IEnergyConnectorBlock {
|
||||
|
||||
/**
|
||||
* Same as IEnergyConnector's method but for regular blocks that might not even have TEs. Used for rendering only!
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param dir
|
||||
* @return
|
||||
*/
|
||||
public boolean canConnect(IBlockAccess world, int x, int y, int z, ForgeDirection dir);
|
||||
}
|
||||
5
src/main/java/com/hbm/interfaces/package-info.java
Normal file
5
src/main/java/com/hbm/interfaces/package-info.java
Normal file
@ -0,0 +1,5 @@
|
||||
package com.hbm.interfaces;
|
||||
|
||||
/*
|
||||
* Please kill me
|
||||
*/
|
||||
@ -7,13 +7,16 @@ import com.hbm.main.ResourceManager;
|
||||
import com.hbm.render.util.ObjUtil;
|
||||
|
||||
import api.hbm.energy.IEnergyConnector;
|
||||
import api.hbm.energy.IEnergyConnectorBlock;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.model.obj.WavefrontObject;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class RenderTestCable implements ISimpleBlockRenderingHandler {
|
||||
|
||||
@ -56,12 +59,12 @@ public class RenderTestCable implements ISimpleBlockRenderingHandler {
|
||||
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||
tessellator.setColorOpaque_F(1, 1, 1);
|
||||
|
||||
boolean pX = world.getTileEntity(x + 1, y, z) instanceof IEnergyConnector;
|
||||
boolean nX = world.getTileEntity(x - 1, y, z) instanceof IEnergyConnector;
|
||||
boolean pY = y > 255 ? false : world.getTileEntity(x, y + 1, z) instanceof IEnergyConnector;
|
||||
boolean nY = y < 0 ? false : world.getTileEntity(x, y - 1, z) instanceof IEnergyConnector;
|
||||
boolean pZ = world.getTileEntity(x, y, z + 1) instanceof IEnergyConnector;
|
||||
boolean nZ = world.getTileEntity(x, y, z - 1) instanceof IEnergyConnector;
|
||||
boolean pX = canConnect(world, x + 1, y, z, ForgeDirection.EAST);
|
||||
boolean nX = canConnect(world, x - 1, y, z, ForgeDirection.WEST);
|
||||
boolean pY = canConnect(world, x, y + 1, z, ForgeDirection.UP);
|
||||
boolean nY = canConnect(world, x, y - 1, z, ForgeDirection.DOWN);
|
||||
boolean pZ = canConnect(world, x, y, z + 1, ForgeDirection.SOUTH);
|
||||
boolean nZ = canConnect(world, x, y, z - 1, ForgeDirection.NORTH);
|
||||
|
||||
tessellator.addTranslation(x + 0.5F, y + 0.5F, z + 0.5F);
|
||||
|
||||
@ -86,6 +89,31 @@ public class RenderTestCable implements ISimpleBlockRenderingHandler {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean canConnect(IBlockAccess world, int x, int y, int z, ForgeDirection dir) {
|
||||
|
||||
if(y > 255 || y < 0)
|
||||
return false;
|
||||
|
||||
Block b = world.getBlock(x, y, z);
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(b instanceof IEnergyConnectorBlock) {
|
||||
IEnergyConnectorBlock con = (IEnergyConnectorBlock) b;
|
||||
|
||||
if(con.canConnect(world, x, y, z, dir))
|
||||
return true;
|
||||
}
|
||||
|
||||
if(te instanceof IEnergyConnectorBlock) {
|
||||
IEnergyConnector con = (IEnergyConnector) te;
|
||||
|
||||
if(con.canConnect(dir))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user