mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-02-21 21:42:28 +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.
|
* For anything that connects to power and can be transferred power to, the bottom-level interface.
|
||||||
|
* This is mean for TILE ENTITIES
|
||||||
* @author hbm
|
* @author hbm
|
||||||
*/
|
*/
|
||||||
public interface IEnergyConnector {
|
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 com.hbm.render.util.ObjUtil;
|
||||||
|
|
||||||
import api.hbm.energy.IEnergyConnector;
|
import api.hbm.energy.IEnergyConnector;
|
||||||
|
import api.hbm.energy.IEnergyConnectorBlock;
|
||||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.renderer.RenderBlocks;
|
import net.minecraft.client.renderer.RenderBlocks;
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraftforge.client.model.obj.WavefrontObject;
|
import net.minecraftforge.client.model.obj.WavefrontObject;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class RenderTestCable implements ISimpleBlockRenderingHandler {
|
public class RenderTestCable implements ISimpleBlockRenderingHandler {
|
||||||
|
|
||||||
@ -56,12 +59,12 @@ public class RenderTestCable implements ISimpleBlockRenderingHandler {
|
|||||||
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||||
tessellator.setColorOpaque_F(1, 1, 1);
|
tessellator.setColorOpaque_F(1, 1, 1);
|
||||||
|
|
||||||
boolean pX = world.getTileEntity(x + 1, y, z) instanceof IEnergyConnector;
|
boolean pX = canConnect(world, x + 1, y, z, ForgeDirection.EAST);
|
||||||
boolean nX = world.getTileEntity(x - 1, y, z) instanceof IEnergyConnector;
|
boolean nX = canConnect(world, x - 1, y, z, ForgeDirection.WEST);
|
||||||
boolean pY = y > 255 ? false : world.getTileEntity(x, y + 1, z) instanceof IEnergyConnector;
|
boolean pY = canConnect(world, x, y + 1, z, ForgeDirection.UP);
|
||||||
boolean nY = y < 0 ? false : world.getTileEntity(x, y - 1, z) instanceof IEnergyConnector;
|
boolean nY = canConnect(world, x, y - 1, z, ForgeDirection.DOWN);
|
||||||
boolean pZ = world.getTileEntity(x, y, z + 1) instanceof IEnergyConnector;
|
boolean pZ = canConnect(world, x, y, z + 1, ForgeDirection.SOUTH);
|
||||||
boolean nZ = world.getTileEntity(x, y, z - 1) instanceof IEnergyConnector;
|
boolean nZ = canConnect(world, x, y, z - 1, ForgeDirection.NORTH);
|
||||||
|
|
||||||
tessellator.addTranslation(x + 0.5F, y + 0.5F, z + 0.5F);
|
tessellator.addTranslation(x + 0.5F, y + 0.5F, z + 0.5F);
|
||||||
|
|
||||||
@ -86,6 +89,31 @@ public class RenderTestCable implements ISimpleBlockRenderingHandler {
|
|||||||
|
|
||||||
return true;
|
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
|
@Override
|
||||||
public boolean shouldRender3DInInventory(int modelId) {
|
public boolean shouldRender3DInInventory(int modelId) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user