Controllers are done

This commit is contained in:
Cricket committed 2015-06-21 22:28:46 -04:00
1 parent 9b6e1495d4
commit 09f12d5194
11 files changed
+75 -11

No files matched your search

@@ -786,16 +786,14 @@ public enum Features {
FUTURA {
// TODO Overlay is WIP
@Override
void addBlocks() {
BlockCarvable futura = (BlockCarvable) new BlockCarvable(Material.rock/*
* , "futura/screenOverlay-ctm"
*/).setCreativeTab(ChiselTabs.tabMetalChiselBlocks).setHardness(2.0F).setResistance(10F);
BlockCarvable futura = (BlockCarvable) new BlockCarvable(Material.rock).setCreativeTab(ChiselTabs.tabMetalChiselBlocks).setHardness(2.0F).setResistance(10F);
futura.carverHelper.addVariation("tile.futura.0.desc", 0, "futura/WIP/screenMetallicWIP");
futura.carverHelper.addVariation("tile.futura.1.desc", 1, "futura/WIP/screenCyanWIP");
futura.carverHelper.addVariation("tile.futura.2.desc", 2, "futura/WIP/controllerWIP", new SubmapManagerFakeController());
futura.carverHelper.addVariation("tile.futura.2.desc", 2, "futura/WIP/controllerWIP-Overlay", new SubmapManagerFakeController(2));
futura.carverHelper.addVariation("tile.futura.3.desc", 3, "futura/WIP/wavyWIP");
futura.carverHelper.addVariation("tile.futura.4.desc", 4, "futura/WIP/controllerWIP-Overlay", new SubmapManagerFakeController(4));
futura.carverHelper.registerAll(futura, "futura");
BlockCarvable circuits = (BlockCarvable) new BlockCarvableGlow("animations/strobe").setCreativeTab(ChiselTabs.tabMetalChiselBlocks).setHardness(2.0F).setResistance(10.0F);
@@ -1,5 +1,6 @@
package com.cricketcraft.chisel.block;
import com.cricketcraft.chisel.client.render.SubmapManagerBase;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
@@ -14,6 +15,7 @@ public class BlockCarvableGlow extends BlockCarvableColor {
@SideOnly(Side.CLIENT)
private IIcon glowTexture;
private SubmapManagerBase submapManagerBase;
private String glowTexturePath;
public BlockCarvableGlow(String glowTexture) {
@@ -27,12 +29,26 @@ public class BlockCarvableGlow extends BlockCarvableColor {
this.glowTexturePath = glowTexture;
}
public BlockCarvableGlow(Material material, String glowTexture, SubmapManagerBase submapManagerBase){
super(material);
this.glowTexturePath = glowTexture;
this.submapManagerBase = submapManagerBase;
}
@Override
public void registerBlockIcons(IIconRegister register) {
super.registerBlockIcons(register);
glowTexture = register.registerIcon(Chisel.MOD_ID + ":" + glowTexturePath);
}
public boolean hasSubmapManager(){
return submapManagerBase == null;
}
public SubmapManagerBase getSubmapManager(){
return hasSubmapManager() ? submapManagerBase : null;
}
public IIcon getGlowTexture() {
return glowTexture;
}
@@ -1,5 +1,7 @@
package com.cricketcraft.chisel.client.render;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import com.cricketcraft.chisel.api.rendering.RenderBlocksCTM;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
@@ -37,11 +39,33 @@ public class RendererLayeredGlow implements ISimpleBlockRenderingHandler {
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
Tessellator.instance.setColorOpaque_I(Configurations.configColors[world.getBlockMetadata(x, y, z)]);
Tessellator.instance.setBrightness(0xF000F0);
Drawing.renderAllFaces(renderer, block, x, y, z, ((BlockCarvableGlow) block).getGlowTexture());
Tessellator.instance.setBrightness(0xF000F0);
BlockCarvableGlow glow = (BlockCarvableGlow) block;
if(glow.hasSubmapManager()){
renderer.overrideBlockTexture = glow.getGlowTexture();
getContext(renderer, glow, world).renderBlockAllFaces(glow, x, y, z);
} else {
Drawing.renderAllFaces(renderer, block, x, y, z, ((BlockCarvableGlow) block).getGlowTexture());
}
renderer.renderStandardBlock(block, x, y, z);
return true;
}
private RenderBlocks getContext(RenderBlocks rendererOld, BlockCarvableGlow block, IBlockAccess world) {
if (!rendererOld.hasOverrideBlockTexture() && block != null) {
RenderBlocks rb = block.getSubmapManager().createRenderContext(rendererOld, block, world);
if (rb != null && rb != rendererOld) {
rb.blockAccess = world;
if (rb instanceof RenderBlocksCTM) {
RenderBlocksCTM rbctm = (RenderBlocksCTM) rb;
rbctm.manager = rbctm.manager == null ? block.getSubmapManager() : rbctm.manager;
rbctm.rendererOld = rbctm.rendererOld == null ? rendererOld : rbctm.rendererOld;
}
return rb;
}
}
return rendererOld;
}
@Override
public boolean shouldRender3DInInventory(int modelId) {
@@ -18,9 +18,11 @@ public class SubmapManagerFakeController extends SubmapManagerBase {
private TextureSubmap map;
private CTM ctm = CTM.getInstance();
private int meta;
public SubmapManagerFakeController() {
public SubmapManagerFakeController(int meta) {
ctm.disableObscuredFaceCheck = true;
this.meta = meta;
}
@Override
@@ -30,7 +32,7 @@ public class SubmapManagerFakeController extends SubmapManagerBase {
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
ctm.buildConnectionMap(world, x, y, z, side, ChiselBlocks.futura, 2);
ctm.buildConnectionMap(world, x, y, z, side, ChiselBlocks.futura, meta);
if (ctm.connectedAnd(TOP, BOTTOM, LEFT, RIGHT)) {
return map.getSubIcon(1, 1);
} else if (ctm.connectedAnd(TOP, BOTTOM)) {
@@ -45,6 +47,10 @@ public class SubmapManagerFakeController extends SubmapManagerBase {
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(String modName, Block block, IIconRegister register) {
map = new TextureSubmap(register.registerIcon(modName + ":futura/WIP/controllerWIP-ctm"), 2, 2);
if(meta == 2){
map = new TextureSubmap(register.registerIcon(modName + ":futura/WIP/controller"), 2, 2);
} else {
map = new TextureSubmap(register.registerIcon(modName + ":futura/WIP/controllerPurple"), 2, 2);
}
}
}
@@ -128,7 +128,7 @@ public class InventoryChiselSelection implements IInventory {
activeVariations = 0;
while (activeVariations < normalSlots && activeVariations < list.size()) {
if(Block.blockRegistry.getNameForObject(list.get(activeVariations)) != null) {
if(Block.blockRegistry.getNameForObject(Block.getBlockFromItem(list.get(activeVariations).getItem())) != null) {
inventory[activeVariations] = list.get(activeVariations);
activeVariations++;
}