mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-22 05:02:25 +00:00
Improved mechanism used to update facade rendering when a wrench is equipped.
As a side effect, fixed #65
This commit is contained in:
1 parent
f4baf19f2b
commit
b6f61eee7f
8 files changed
+83
-78
No files matched your search
@@ -19,7 +19,7 @@
|
||||
|
||||
<property name="mc.version" value="1.6.2"/>
|
||||
<property name="forge.version" value="9.10.0.828"/>
|
||||
<property name="project.version" value="0.1.23"/>
|
||||
<property name="project.version" value="0.1.24dev"/>
|
||||
|
||||
<property name="forge.name" value="minecraftforge-src-${mc.version}-${forge.version}.zip"/>
|
||||
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
package crazypants.enderio;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
|
||||
public class ClientTickHandler implements ITickHandler {
|
||||
|
||||
private boolean hidingConduits = false;
|
||||
private boolean first = true;
|
||||
|
||||
@Override
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData) {
|
||||
EntityPlayer player = (EntityPlayer) tickData[0];
|
||||
boolean curVal = ConduitUtil.isToolEquipped(player) || ConduitUtil.isConduitEquipped(player);
|
||||
if (first) {
|
||||
hidingConduits = curVal;
|
||||
first = false;
|
||||
}
|
||||
if (curVal != hidingConduits) {
|
||||
hidingConduits = curVal;
|
||||
WorldClient world = FMLClientHandler.instance().getClient().theWorld;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<TileEntity> checkList = world.loadedTileEntityList;
|
||||
for (TileEntity o : checkList) {
|
||||
if (o.blockType != null && o.blockType.blockID == EnderIO.blockConduitBundle.blockID) {
|
||||
if (o.getDistanceFrom(player.posX, player.posY, player.posZ) < o.getMaxRenderDistanceSquared()) {
|
||||
world.markBlockForRenderUpdate(o.xCoord, o.yCoord, o.zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<TickType> ticks() {
|
||||
return EnumSet.of(TickType.PLAYER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "EnderIO Client Tick Handler";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -213,8 +213,7 @@ public class EnderIO {
|
||||
// }
|
||||
|
||||
@EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
TickRegistry.registerTickHandler(new ClientTickHandler(), Side.CLIENT);
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
@@ -74,7 +74,7 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider {
|
||||
|
||||
TileConduitBundle cb = (TileConduitBundle)
|
||||
world.getBlockTileEntity(target.blockX, target.blockY, target.blockZ);
|
||||
if (ConduitUtil.renderFacade(cb, Minecraft.getMinecraft().thePlayer)) {
|
||||
if (ConduitUtil.isSolidFacadeRendered(cb, Minecraft.getMinecraft().thePlayer)) {
|
||||
if (cb.getFacadeId() > 0) {
|
||||
tex = Block.blocksList[cb.getFacadeId()].getIcon(target.sideHit,
|
||||
cb.getFacadeMetadata());
|
||||
@@ -309,7 +309,7 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider {
|
||||
|
||||
boolean breakBlock = true;
|
||||
List<ItemStack> drop = new ArrayList<ItemStack>();
|
||||
if (ConduitUtil.renderFacade(te, player)) {
|
||||
if (ConduitUtil.isSolidFacadeRendered(te, player)) {
|
||||
breakBlock = false;
|
||||
ItemStack fac = new ItemStack(ModObject.itemConduitFacade.actualId, 1, 0);
|
||||
PainterUtil.setSourceBlock(fac, te.getFacadeId(), te.getFacadeMetadata());
|
||||
@@ -527,7 +527,7 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider {
|
||||
IConduitBundle con = (IConduitBundle) te;
|
||||
|
||||
BoundingBox minBB = new BoundingBox(1, 1, 1, 0, 0, 0);
|
||||
if (!ConduitUtil.renderFacade(con, EnderIO.proxy.getClientPlayer())) {
|
||||
if (!ConduitUtil.isSolidFacadeRendered(con, EnderIO.proxy.getClientPlayer())) {
|
||||
|
||||
Collection<CollidableComponent> bounds = con.getCollidableComponents();
|
||||
for (CollidableComponent bnd : bounds) {
|
||||
@@ -597,7 +597,7 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider {
|
||||
IConduitBundle bundle = (IConduitBundle) te;
|
||||
List<RaytraceResult> hits = new ArrayList<RaytraceResult>();
|
||||
|
||||
if (ConduitUtil.renderFacade(bundle, player)) {
|
||||
if (ConduitUtil.isSolidFacadeRendered(bundle, player)) {
|
||||
setBlockBounds(0, 0, 0, 1, 1, 1);
|
||||
MovingObjectPosition hitPos = super.collisionRayTrace(world, x, y, z,
|
||||
origin, direction);
|
||||
|
||||
@@ -17,7 +17,10 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.conduit.IConduitBundle.FacadeRenderState;
|
||||
import crazypants.enderio.conduit.liquid.ILiquidConduit;
|
||||
import crazypants.enderio.conduit.liquid.LiquidConduitNetwork;
|
||||
import crazypants.enderio.conduit.power.IPowerConduit;
|
||||
@@ -76,8 +79,18 @@ public class ConduitUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static FacadeRenderState getRequiredFacadeRenderState(IConduitBundle bundle, EntityPlayer player) {
|
||||
if(!bundle.hasFacade()) {
|
||||
return FacadeRenderState.NONE;
|
||||
}
|
||||
if(isFacadeHidden(bundle, player)) {
|
||||
return FacadeRenderState.WIRE_FRAME;
|
||||
}
|
||||
return FacadeRenderState.FULL;
|
||||
}
|
||||
|
||||
public static boolean renderFacade(IConduitBundle bundle, EntityPlayer player) {
|
||||
public static boolean isSolidFacadeRendered(IConduitBundle bundle, EntityPlayer player) {
|
||||
return bundle.getFacadeId() > 0 && !isFacadeHidden(bundle, player);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,9 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
@@ -38,14 +41,34 @@ public interface IConduitBundle extends IInternalPowerReceptor, IFluidHandler {
|
||||
Set<ForgeDirection> getAllConnections();
|
||||
|
||||
boolean containsConnection(ForgeDirection dir);
|
||||
|
||||
//geometry
|
||||
|
||||
List<CollidableComponent> getCollidableComponents();
|
||||
|
||||
List<CollidableComponent> getConnectors();
|
||||
|
||||
// events
|
||||
|
||||
void onNeighborBlockChange(int blockId);
|
||||
|
||||
void onBlockRemoved();
|
||||
|
||||
void dirty();
|
||||
|
||||
// Facade
|
||||
|
||||
enum FacadeRenderState {
|
||||
NONE,
|
||||
FULL,
|
||||
WIRE_FRAME
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
FacadeRenderState getFacadeRenderedAs();
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void setFacadeRenderAs(FacadeRenderState state);
|
||||
|
||||
boolean hasFacade();
|
||||
|
||||
@@ -59,10 +82,8 @@ public interface IConduitBundle extends IInternalPowerReceptor, IFluidHandler {
|
||||
|
||||
int getFacadeMetadata();
|
||||
|
||||
List<CollidableComponent> getCollidableComponents();
|
||||
|
||||
List<CollidableComponent> getConnectors();
|
||||
|
||||
void dirty();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -6,6 +6,9 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
@@ -19,6 +22,7 @@ import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.PacketHandler;
|
||||
import crazypants.enderio.conduit.IConduitBundle.FacadeRenderState;
|
||||
import crazypants.enderio.conduit.geom.CollidableCache;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.enderio.conduit.geom.ConduitConnectorType;
|
||||
@@ -42,6 +46,9 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
|
||||
private boolean conduitsDirty = true;
|
||||
private boolean collidablesDirty = true;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private FacadeRenderState facadeRenderAs = FacadeRenderState.NONE;
|
||||
|
||||
public TileConduitBundle() {
|
||||
blockType = EnderIO.blockConduitBundle;
|
||||
@@ -119,6 +126,20 @@ public class TileConduitBundle extends TileEntity implements IConduitBundle {
|
||||
public int getFacadeMetadata() {
|
||||
return facadeMeta;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public FacadeRenderState getFacadeRenderedAs() {
|
||||
return facadeRenderAs;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void setFacadeRenderAs(FacadeRenderState state) {
|
||||
this.facadeRenderAs = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
|
||||
@@ -27,6 +27,7 @@ import crazypants.enderio.conduit.BlockConduitBundle;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
import crazypants.enderio.conduit.IConduitBundle.FacadeRenderState;
|
||||
import crazypants.enderio.conduit.facade.BlockConduitFacade;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.render.BoundingBox;
|
||||
@@ -39,12 +40,8 @@ public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements
|
||||
|
||||
public static final float CONNECTOR_DEPTH = 0.05f;
|
||||
|
||||
public ConduitBundleRenderer(float conduitScale) {
|
||||
|
||||
|
||||
//float connectorWidth = 0.3f;
|
||||
float connectorWidth = 0.25f + (conduitScale * 0.5f);
|
||||
|
||||
public ConduitBundleRenderer(float conduitScale) {
|
||||
float connectorWidth = 0.25f + (conduitScale * 0.5f);
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
connectorBounds.put(dir, createConnector(dir, CONNECTOR_DEPTH, connectorWidth));
|
||||
}
|
||||
@@ -54,7 +51,14 @@ public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements
|
||||
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTick) {
|
||||
IConduitBundle bundle = (IConduitBundle) te;
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
if (ConduitUtil.renderFacade(bundle, player)) {
|
||||
|
||||
FacadeRenderState curRS = bundle.getFacadeRenderedAs();
|
||||
FacadeRenderState rs = ConduitUtil.getRequiredFacadeRenderState(bundle, player);
|
||||
if(curRS != rs) {
|
||||
te.worldObj.markBlockForRenderUpdate(te.xCoord, te.yCoord, te.zCoord);
|
||||
}
|
||||
|
||||
if (curRS == FacadeRenderState.FULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -184,6 +188,9 @@ public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements
|
||||
int facadeId = bundle.getFacadeId();
|
||||
if (ConduitUtil.isFacadeHidden(bundle, player)) {
|
||||
bundle.setFacadeId(0, false);
|
||||
bundle.setFacadeRenderAs(FacadeRenderState.WIRE_FRAME);
|
||||
} else {
|
||||
bundle.setFacadeRenderAs(FacadeRenderState.FULL);
|
||||
}
|
||||
|
||||
BlockConduitFacade facb = (BlockConduitFacade) Block.blocksList[ModObject.blockConduitFacade.actualId];
|
||||
@@ -195,6 +202,8 @@ public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements
|
||||
|
||||
bundle.setFacadeId(facadeId, false);
|
||||
|
||||
} else {
|
||||
bundle.setFacadeRenderAs(FacadeRenderState.NONE);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user