use of crazypants.enderio.base.conduit.IClientConduit in project EnderIO by SleepyTrousers.
the class ConduitBundleRenderer method addBreakingQuads.
private void addBreakingQuads(@Nonnull IConduitBundle bundle, @Nonnull List<BakedQuad> quads) {
Class<? extends IConduit> conduitType = null;
RayTraceResult hit = Minecraft.getMinecraft().objectMouseOver;
if (NullHelper.untrust(hit) != null && (hit.hitInfo instanceof CollidableComponent)) {
conduitType = ((CollidableComponent) hit.hitInfo).conduitType;
}
if (breakingAnimOnWholeConduit) {
for (IClientConduit c : bundle.getClientConduits()) {
if (conduitType == c.getClass() || conduitType == c.getBaseConduitType()) {
IConduitRenderer renderer = getRendererForConduit(c);
renderer.addBakedQuads(this, bundle, (IClientConduit.WithDefaultRendering) c, 1, BlockRenderLayer.CUTOUT, quads);
}
}
}
List<CollidableComponent> connectors = bundle.getConnectors();
for (CollidableComponent component : connectors) {
if (component != null) {
if (component.conduitType == conduitType || conduitType == null) {
IClientConduit.WithDefaultRendering conduit = (IClientConduit.WithDefaultRendering) bundle.getConduit(component.conduitType);
if (conduit != null) {
TextureAtlasSprite tex = conduit.getTextureForState(component);
BakedQuadBuilder.addBakedQuads(quads, component.bound, tex);
}
}
}
}
}
use of crazypants.enderio.base.conduit.IClientConduit in project EnderIO by SleepyTrousers.
the class ConduitBundleRenderer method render.
// TESR rendering
@Override
public void render(@Nonnull TileConduitBundle te, double x, double y, double z, float partialTick, int b, float alpha) {
IConduitBundle bundle = te;
EntityPlayerSP player = Minecraft.getMinecraft().player;
if (bundle.hasFacade() && bundle.getPaintSource().isOpaqueCube() && !YetaUtil.isFacadeHidden(bundle, player)) {
return;
}
float brightness = -1;
boolean hasDynamic = false;
for (IClientConduit c : bundle.getClientConduits()) {
// TODO Temporary work around
IClientConduit.WithDefaultRendering con = (IClientConduit.WithDefaultRendering) c;
if (YetaUtil.renderConduit(player, con)) {
IConduitRenderer renderer = getRendererForConduit(con);
if (renderer.isDynamic()) {
if (!hasDynamic) {
hasDynamic = true;
BlockPos loc = bundle.getLocation();
brightness = bundle.getEntity().getWorld().getLightFor(EnumSkyBlock.SKY, loc);
RenderUtil.setupLightmapCoords(te.getPos(), te.getWorld());
RenderUtil.bindBlockTexture();
GlStateManager.enableNormalize();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.shadeModel(GL11.GL_SMOOTH);
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder tes = tessellator.getBuffer();
tes.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
}
renderer.renderDynamicEntity(this, bundle, con, x, y, z, partialTick, brightness);
}
}
}
if (hasDynamic) {
Tessellator.getInstance().draw();
GlStateManager.disableNormalize();
GlStateManager.disableBlend();
GlStateManager.shadeModel(GL11.GL_FLAT);
GlStateManager.popMatrix();
}
}
use of crazypants.enderio.base.conduit.IClientConduit in project EnderIO by SleepyTrousers.
the class ConduitBundleRenderer method addConduitQuads.
private void addConduitQuads(@Nonnull IBlockStateWrapper state, @Nonnull IConduitBundle bundle, float brightness, @Nonnull BlockRenderLayer layer, @Nonnull List<BakedQuad> quads) {
// Conduits
Set<EnumFacing> externals = new HashSet<EnumFacing>();
List<BoundingBox> wireBounds = new ArrayList<BoundingBox>();
if (bundle.hasFacade() && state.getYetaDisplayMode().isHideFacades()) {
wireBounds.add(BoundingBox.UNIT_CUBE);
}
for (IClientConduit c : bundle.getClientConduits()) {
// TODO Temporary Workaround
IClientConduit.WithDefaultRendering con = (IClientConduit.WithDefaultRendering) c;
if (state.getYetaDisplayMode().renderConduit(con)) {
IConduitRenderer renderer = getRendererForConduit(con);
renderer.addBakedQuads(this, bundle, con, brightness, layer, quads);
Set<EnumFacing> extCons = con.getExternalConnections();
for (EnumFacing dir : extCons) {
if (con.getConnectionMode(dir) != ConnectionMode.DISABLED && con.getConnectionMode(dir) != ConnectionMode.NOT_SET) {
externals.add(dir);
}
}
} else if (con != null) {
Collection<CollidableComponent> components = con.getCollidableComponents();
for (CollidableComponent component : components) {
addWireBounds(wireBounds, component);
}
}
}
// Internal connectors between conduits
List<CollidableComponent> connectors = bundle.getConnectors();
for (CollidableComponent component : connectors) {
if (component != null) {
if (component.conduitType != null) {
// TODO Make an actual check before assuming a default render
IClientConduit.WithDefaultRendering conduit = (IClientConduit.WithDefaultRendering) bundle.getConduit(component.conduitType);
if (conduit != null) {
if (state.getYetaDisplayMode().renderConduit(component.conduitType)) {
TextureAtlasSprite tex = conduit.getTextureForState(component);
if (tex == null) {
tex = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
}
BakedQuadBuilder.addBakedQuads(quads, component.bound, tex);
} else {
addWireBounds(wireBounds, component);
}
}
} else if (state.getYetaDisplayMode().getDisplayMode().isAll()) {
TextureAtlasSprite tex = ConduitBundleRenderManager.instance.getConnectorIcon(component.data);
BakedQuadBuilder.addBakedQuads(quads, component.bound, tex);
}
}
}
// render these after the 'normal' conduits so help with proper blending
for (BoundingBox wireBound : wireBounds) {
BakedQuadBuilder.addBakedQuads(quads, wireBound, ConduitBundleRenderManager.instance.getWireFrameIcon());
}
// External connection terminations
for (EnumFacing dir : externals) {
addQuadsForExternalConnection(dir, quads);
}
if (quads.isEmpty() && !bundle.hasFacade()) {
BakedQuadBuilder.addBakedQuads(quads, BoundingBox.UNIT_CUBE.scale(.10), ConduitBundleRenderManager.instance.getWireFrameIcon());
BakedQuadBuilder.addBakedQuads(quads, BoundingBox.UNIT_CUBE.scale(.15), ConduitBundleRenderManager.instance.getWireFrameIcon());
BakedQuadBuilder.addBakedQuads(quads, BoundingBox.UNIT_CUBE.scale(.20), ConduitBundleRenderManager.instance.getWireFrameIcon());
BakedQuadBuilder.addBakedQuads(quads, BoundingBox.UNIT_CUBE.scale(.25), ConduitBundleRenderManager.instance.getWireFrameIcon());
}
}
use of crazypants.enderio.base.conduit.IClientConduit in project EnderIO by SleepyTrousers.
the class TileConduitBundle method onAfterNbtRead.
@Override
protected void onAfterNbtRead() {
super.onAfterNbtRead();
if (world.isRemote) {
// keep conduits sorted so the client side cache key is stable
ConduitRegistry.sort(conduits);
CopyOnWriteArrayList<IClientConduit> temp = new CopyOnWriteArrayList<>();
for (IConduit c : conduits) {
if (c instanceof IClientConduit) {
c.setBundle(this);
temp.add((IClientConduit) c);
}
}
final ConduitCacheKey oldHashCode = new ConduitCacheKey(), newHashCode = new ConduitCacheKey();
makeConduitHashCode(getClientConduits(), oldHashCode);
makeConduitHashCode(temp, newHashCode);
if (hasWorld() && getWorld().isRemote && oldHashCode.hashCode() != newHashCode.hashCode()) {
clientUpdated = true;
}
// switch over atomically to avoid threading issues
clientConduits = temp;
conduits = new CopyOnWriteArrayList<IConduit>();
} else {
// no threads on server-side. but to be safe, conduits only go into the list after they got a bundle set
// (a.k.a. "do better than World.addTileEntities()"
serverConduits.clear();
for (IConduit c : conduits) {
if (c instanceof IServerConduit) {
c.setBundle(this);
serverConduits.add((IServerConduit) c);
}
}
conduits.clear();
}
cachedCollidables.clear();
}
Aggregations