mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-12 16:27:45 +00:00
Merge branch 'remove_carvablevariation' into dev
Conflicts: src/main/java/com/cricketcraft/chisel/api/IMC.java
This commit is contained in:
commit
aac68bd58e
69 files changed
+1542
-1521
No files matched your search
@@ -2,9 +2,6 @@ package com.cricketcraft.chisel;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.cricketcraft.chisel.entity.EntityChiselSnowman;
|
||||
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
@@ -13,13 +10,17 @@ import net.minecraftforge.common.config.Configuration;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.cricketcraft.chisel.api.ChiselAPIProps;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.block.BlockCarvable;
|
||||
import com.cricketcraft.chisel.compat.Compatibility;
|
||||
import com.cricketcraft.chisel.compat.IMCHandler;
|
||||
import com.cricketcraft.chisel.compat.fmp.FMPCompat;
|
||||
import com.cricketcraft.chisel.config.Configurations;
|
||||
import com.cricketcraft.chisel.entity.EntityChiselSnowman;
|
||||
import com.cricketcraft.chisel.init.ChiselBlocks;
|
||||
import com.cricketcraft.chisel.init.ChiselTabs;
|
||||
import com.cricketcraft.chisel.item.ItemCarvable;
|
||||
import com.cricketcraft.chisel.item.chisel.ChiselController;
|
||||
import com.cricketcraft.chisel.network.ChiselGuiHandler;
|
||||
import com.cricketcraft.chisel.network.PacketHandler;
|
||||
@@ -45,6 +46,7 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry.Type;
|
||||
|
||||
@@ -59,9 +61,6 @@ public class Chisel {
|
||||
public static final BlockCarvable.SoundType soundMetalFootstep = new BlockCarvable.SoundType("metal", 1.0f, 1.0f);
|
||||
public static boolean multipartLoaded = false;
|
||||
public static int renderEldritchId;
|
||||
public static int renderCTMId;
|
||||
public static int renderCTMNoLightId;
|
||||
public static int renderCarpetId;
|
||||
public static int renderAutoChiselId;
|
||||
public static int renderGlowId;
|
||||
public static int renderLayeredId;
|
||||
@@ -71,6 +70,11 @@ public class Chisel {
|
||||
|
||||
@Instance(MOD_ID)
|
||||
public static Chisel instance;
|
||||
|
||||
public Chisel() {
|
||||
ChiselAPIProps.MOD_ID = MOD_ID;
|
||||
CarvableHelper.itemCarvableClass = ItemCarvable.class;
|
||||
}
|
||||
|
||||
@SidedProxy(clientSide = "com.cricketcraft.chisel.proxy.ClientProxy", serverSide = "com.cricketcraft.chisel.proxy.CommonProxy")
|
||||
public static CommonProxy proxy;
|
||||
|
||||
@@ -1,29 +1,7 @@
|
||||
package com.cricketcraft.chisel;
|
||||
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
|
||||
import com.cricketcraft.chisel.block.*;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.carving.Carving;
|
||||
import com.cricketcraft.chisel.carving.CarvingGroup;
|
||||
import com.cricketcraft.chisel.client.render.SubmapManagerFakeController;
|
||||
import com.cricketcraft.chisel.compat.fmp.ItemBlockChiselTorchPart;
|
||||
import com.cricketcraft.chisel.config.Configurations;
|
||||
import com.cricketcraft.chisel.entity.EntityBallOMoss;
|
||||
import com.cricketcraft.chisel.entity.EntityCloudInABottle;
|
||||
import com.cricketcraft.chisel.entity.EntitySmashingRock;
|
||||
import com.cricketcraft.chisel.init.ChiselBlocks;
|
||||
import com.cricketcraft.chisel.init.ChiselItems;
|
||||
import com.cricketcraft.chisel.init.ChiselTabs;
|
||||
import com.cricketcraft.chisel.item.*;
|
||||
import com.cricketcraft.chisel.item.chisel.ItemChisel;
|
||||
import com.cricketcraft.chisel.item.chisel.ItemChisel.ChiselType;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -36,7 +14,39 @@ import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
|
||||
import java.util.List;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.CarvingUtils.SimpleCarvingGroup;
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
import com.cricketcraft.chisel.block.*;
|
||||
import com.cricketcraft.chisel.carving.Carving;
|
||||
import com.cricketcraft.chisel.client.render.SubmapManagerAntiblock;
|
||||
import com.cricketcraft.chisel.client.render.SubmapManagerCarpetFloor;
|
||||
import com.cricketcraft.chisel.client.render.SubmapManagerFakeController;
|
||||
import com.cricketcraft.chisel.client.render.SubmapManagerSlab;
|
||||
import com.cricketcraft.chisel.compat.fmp.ItemBlockChiselTorchPart;
|
||||
import com.cricketcraft.chisel.config.Configurations;
|
||||
import com.cricketcraft.chisel.entity.EntityBallOMoss;
|
||||
import com.cricketcraft.chisel.entity.EntityCloudInABottle;
|
||||
import com.cricketcraft.chisel.entity.EntitySmashingRock;
|
||||
import com.cricketcraft.chisel.init.ChiselBlocks;
|
||||
import com.cricketcraft.chisel.init.ChiselItems;
|
||||
import com.cricketcraft.chisel.init.ChiselTabs;
|
||||
import com.cricketcraft.chisel.item.ItemBallOMoss;
|
||||
import com.cricketcraft.chisel.item.ItemBlockPresent;
|
||||
import com.cricketcraft.chisel.item.ItemCarvable;
|
||||
import com.cricketcraft.chisel.item.ItemCarvablePumpkin;
|
||||
import com.cricketcraft.chisel.item.ItemCarvableSlab;
|
||||
import com.cricketcraft.chisel.item.ItemCloudInABottle;
|
||||
import com.cricketcraft.chisel.item.ItemSmashingRock;
|
||||
import com.cricketcraft.chisel.item.ItemUpgrade;
|
||||
import com.cricketcraft.chisel.item.chisel.ItemChisel;
|
||||
import com.cricketcraft.chisel.item.chisel.ItemChisel.ChiselType;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
import static com.cricketcraft.chisel.init.ChiselBlocks.*;
|
||||
import static com.cricketcraft.chisel.utils.General.sGNames;
|
||||
@@ -99,7 +109,7 @@ public enum Features {
|
||||
@Override
|
||||
void addBlocks() {
|
||||
BlockCarvable andesite = (BlockCarvable) new BlockCarvable(Material.rock).setHardness(2.0F).setResistance(10.0F).setCreativeTab(ChiselTabs.tabStoneChiselBlocks);
|
||||
andesite.carverHelper.setChiselBlockName("andesite");
|
||||
|
||||
andesite.carverHelper.addVariation("tile.andesite.0.desc", 0, "andesite/andesite");
|
||||
andesite.carverHelper.addVariation("tile.andesite.1.desc", 1, "andesite/andesitePolished");
|
||||
andesite.carverHelper.addVariation("tile.andesite.2.desc", 2, "andesite/andesitePillar");
|
||||
@@ -122,13 +132,13 @@ public enum Features {
|
||||
@Override
|
||||
void addBlocks() {
|
||||
BlockCarvable antiBlock = (BlockCarvable) new BlockCarvableAntiBlock().setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
|
||||
antiBlock.carverHelper.setChiselBlockName("Anti Block");
|
||||
|
||||
if (!Configurations.allowChiselCrossColors) {
|
||||
antiBlock.carverHelper.forbidChiseling = true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
antiBlock.carverHelper.addVariation("tile.antiBlock." + ItemDye.field_150921_b[i] + ".desc", i, "antiblock/" + ItemDye.field_150921_b[i] + "-antiBlock");
|
||||
antiBlock.carverHelper.addVariation("tile.antiBlock." + ItemDye.field_150921_b[i] + ".desc", i, new SubmapManagerAntiblock(ItemDye.field_150921_b[i]));
|
||||
}
|
||||
|
||||
antiBlock.carverHelper.registerAll(antiBlock, "antiBlock");
|
||||
@@ -313,7 +323,7 @@ public enum Features {
|
||||
void addBlocks() {
|
||||
BlockCarvable carpet_block = (BlockCarvable) new BlockCarvable(Material.cloth).setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setHardness(2.0F).setResistance(10F)
|
||||
.setStepSound(Block.soundTypeCloth);
|
||||
carpet_block.carverHelper.setChiselBlockName("Carpet Block");
|
||||
|
||||
carpet_block.carverHelper.addVariation("tile.carpet_block.0.desc", 0, "carpet/white");
|
||||
carpet_block.carverHelper.addVariation("tile.carpet_block.1.desc", 1, "carpet/orange");
|
||||
carpet_block.carverHelper.addVariation("tile.carpet_block.2.desc", 2, "carpet/lily");
|
||||
@@ -352,25 +362,25 @@ public enum Features {
|
||||
|
||||
@Override
|
||||
void addBlocks() {
|
||||
BlockMarbleCarpet carpet = (BlockMarbleCarpet) new BlockMarbleCarpet(Material.cloth).setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setHardness(0.1F).setStepSound(Block.soundTypeCloth)
|
||||
BlockCarvableCarpet carpet = (BlockCarvableCarpet) new BlockCarvableCarpet(Material.cloth).setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setHardness(0.1F).setStepSound(Block.soundTypeCloth)
|
||||
.setLightOpacity(0).setStepSound(Block.soundTypeCloth);
|
||||
carpet.carverHelper.setChiselBlockName("Carpet");
|
||||
carpet.carverHelper.addVariation("tile.carpet.0.desc", 0, "carpet/white");
|
||||
carpet.carverHelper.addVariation("tile.carpet.1.desc", 1, "carpet/orange");
|
||||
carpet.carverHelper.addVariation("tile.carpet.2.desc", 2, "carpet/lily");
|
||||
carpet.carverHelper.addVariation("tile.carpet.3.desc", 3, "carpet/lightblue");
|
||||
carpet.carverHelper.addVariation("tile.carpet.4.desc", 4, "carpet/yellow");
|
||||
carpet.carverHelper.addVariation("tile.carpet.5.desc", 5, "carpet/lightgreen");
|
||||
carpet.carverHelper.addVariation("tile.carpet.6.desc", 6, "carpet/pink");
|
||||
carpet.carverHelper.addVariation("tile.carpet.7.desc", 7, "carpet/darkgrey");
|
||||
carpet.carverHelper.addVariation("tile.carpet.8.desc", 8, "carpet/grey");
|
||||
carpet.carverHelper.addVariation("tile.carpet.9.desc", 9, "carpet/teal");
|
||||
carpet.carverHelper.addVariation("tile.carpet.10.desc", 10, "carpet/purple");
|
||||
carpet.carverHelper.addVariation("tile.carpet.11.desc", 11, "carpet/darkblue");
|
||||
carpet.carverHelper.addVariation("tile.carpet.12.desc", 12, "carpet/brown");
|
||||
carpet.carverHelper.addVariation("tile.carpet.13.desc", 13, "carpet/green");
|
||||
carpet.carverHelper.addVariation("tile.carpet.14.desc", 14, "carpet/red");
|
||||
carpet.carverHelper.addVariation("tile.carpet.15.desc", 15, "carpet/black");
|
||||
|
||||
carpet.carverHelper.addVariation("tile.carpet.0.desc", 0, new SubmapManagerCarpetFloor("white"));
|
||||
carpet.carverHelper.addVariation("tile.carpet.1.desc", 1, new SubmapManagerCarpetFloor("orange"));
|
||||
carpet.carverHelper.addVariation("tile.carpet.2.desc", 2, new SubmapManagerCarpetFloor("lily"));
|
||||
carpet.carverHelper.addVariation("tile.carpet.3.desc", 3, new SubmapManagerCarpetFloor("lightblue"));
|
||||
carpet.carverHelper.addVariation("tile.carpet.4.desc", 4, new SubmapManagerCarpetFloor("yellow"));
|
||||
carpet.carverHelper.addVariation("tile.carpet.5.desc", 5, new SubmapManagerCarpetFloor("lightgreen"));
|
||||
carpet.carverHelper.addVariation("tile.carpet.6.desc", 6, new SubmapManagerCarpetFloor("pink"));
|
||||
carpet.carverHelper.addVariation("tile.carpet.7.desc", 7, new SubmapManagerCarpetFloor("darkgrey"));
|
||||
carpet.carverHelper.addVariation("tile.carpet.8.desc", 8, new SubmapManagerCarpetFloor("grey"));
|
||||
carpet.carverHelper.addVariation("tile.carpet.9.desc", 9, new SubmapManagerCarpetFloor("teal"));
|
||||
carpet.carverHelper.addVariation("tile.carpet.10.desc", 10, new SubmapManagerCarpetFloor("purple"));
|
||||
carpet.carverHelper.addVariation("tile.carpet.11.desc", 11, new SubmapManagerCarpetFloor("darkblue"));
|
||||
carpet.carverHelper.addVariation("tile.carpet.12.desc", 12, new SubmapManagerCarpetFloor("brown"));
|
||||
carpet.carverHelper.addVariation("tile.carpet.13.desc", 13, new SubmapManagerCarpetFloor("green"));
|
||||
carpet.carverHelper.addVariation("tile.carpet.14.desc", 14, new SubmapManagerCarpetFloor("red"));
|
||||
carpet.carverHelper.addVariation("tile.carpet.15.desc", 15, new SubmapManagerCarpetFloor("black"));
|
||||
if (!Configurations.allowChiselCrossColors) {
|
||||
carpet.carverHelper.forbidChiseling = true;
|
||||
}
|
||||
@@ -587,7 +597,7 @@ public enum Features {
|
||||
@Override
|
||||
void addBlocks() {
|
||||
BlockCarvable diorite = (BlockCarvable) new BlockCarvable(Material.rock).setHardness(2.0F).setResistance(10.0F).setCreativeTab(ChiselTabs.tabStoneChiselBlocks);
|
||||
diorite.carverHelper.setChiselBlockName("diorite");
|
||||
|
||||
diorite.carverHelper.addVariation("tile.diorite.0.desc", 0, "diorite/diorite");
|
||||
diorite.carverHelper.addVariation("tile.diorite.1.desc", 1, "diorite/dioritePolished");
|
||||
diorite.carverHelper.addVariation("tile.diorite.2.desc", 2, "diorite/dioritePillar");
|
||||
@@ -612,7 +622,7 @@ public enum Features {
|
||||
BlockCarvable dirt = (BlockCarvable) new BlockCarvable(Material.ground).setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setHardness(0.5F).setStepSound(Block.soundTypeGravel)
|
||||
.setBlockName("dirt.default");
|
||||
Carving.chisel.addVariation("dirt", Blocks.dirt, 0, 0);
|
||||
dirt.carverHelper.setChiselBlockName("Dirt");
|
||||
|
||||
// dirt.carverHelper.addVariation("Dirt", 0, Blocks.dirt);
|
||||
dirt.carverHelper.addVariation("tile.dirt.0.desc", 0, "dirt/bricks");
|
||||
dirt.carverHelper.addVariation("tile.dirt.1.desc", 1, "dirt/netherbricks");
|
||||
@@ -674,7 +684,7 @@ public enum Features {
|
||||
void addBlocks() {
|
||||
BlockCarvable factoryblock = (BlockCarvable) new BlockCarvable(Material.iron).setCreativeTab(ChiselTabs.tabMetalChiselBlocks).setHardness(2.0F).setResistance(10F)
|
||||
.setStepSound(Chisel.soundMetalFootstep);
|
||||
factoryblock.carverHelper.setChiselBlockName("factoryblock");
|
||||
|
||||
factoryblock.carverHelper.addVariation("tile.factory.0.desc", 0, "factory/dots");
|
||||
factoryblock.carverHelper.addVariation("tile.factory.1.desc", 1, "factory/rust2");
|
||||
factoryblock.carverHelper.addVariation("tile.factory.2.desc", 2, "factory/rust");
|
||||
@@ -716,7 +726,7 @@ public enum Features {
|
||||
@Override
|
||||
void addBlocks() {
|
||||
BlockCarvable fantasyblock = (BlockCarvable) new BlockCarvable(Material.rock).setCreativeTab(ChiselTabs.tabStoneChiselBlocks).setHardness(2.0F).setResistance(10F);
|
||||
fantasyblock.carverHelper.setChiselBlockName("Fantasy Block");
|
||||
|
||||
fantasyblock.carverHelper.addVariation("tile.fantasyblock.0.desc", 0, "fantasy/brick");
|
||||
fantasyblock.carverHelper.addVariation("tile.fantasyblock.1.desc", 1, "fantasy/brick-faded");
|
||||
fantasyblock.carverHelper.addVariation("tile.fantasyblock.2.desc", 2, "fantasy/brick-wear");
|
||||
@@ -872,10 +882,10 @@ public enum Features {
|
||||
stainedGlass[glassId].carverHelper.addVariation(sGNames[i] + " borderless glass", glassPrefix + 3, texName + "transparent");
|
||||
OreDictionary.registerOre(oreName, new ItemStack(Blocks.stained_glass, 1, i));
|
||||
Carving.chisel.registerOre(blockName, oreName);
|
||||
for (CarvableVariation cv : stainedGlass[glassId].carverHelper.variations) {
|
||||
if (cv.metadata < glassPrefix || cv.metadata >= glassPrefix + 4)
|
||||
for (IVariationInfo info : stainedGlass[glassId].carverHelper.infoList) {
|
||||
if (info.getVariation().getBlockMeta() < glassPrefix || info.getVariation().getBlockMeta() >= glassPrefix + 4)
|
||||
continue;
|
||||
stainedGlass[glassId].carverHelper.registerVariation(blockName, cv, stainedGlass[glassId], cv.metadata);
|
||||
stainedGlass[glassId].carverHelper.registerVariation(blockName, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -896,7 +906,6 @@ public enum Features {
|
||||
stainedGlassPane[glassId] = (BlockCarvablePane) new BlockCarvablePane(Material.glass, true).setStained(true).setHardness(0.3F).setStepSound(Block.soundTypeGlass)
|
||||
.setBlockName("Stained Glass Pane").setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
|
||||
stainedGlassPane[glassId].carverHelper.registerBlock(stainedGlassPane[glassId], blockName);
|
||||
stainedGlassPane[glassId].carverHelper.blockName = "Stained Glass Pane";
|
||||
}
|
||||
stainedGlassPane[glassId].carverHelper.addVariation(sGNames[i] + " bubble glass", glassPrefix, texName + "bubble");
|
||||
stainedGlassPane[glassId].carverHelper.addVariation(sGNames[i] + " glass panel", glassPrefix + 1, texName + "panel");
|
||||
@@ -906,10 +915,10 @@ public enum Features {
|
||||
stainedGlassPane[glassId].carverHelper.addVariation(sGNames[i] + " fancy quadrant glass", glassPrefix + 5, texName + "quad-fancy");
|
||||
OreDictionary.registerOre(oreName, new ItemStack(Blocks.stained_glass_pane, 1, i));
|
||||
Carving.chisel.registerOre(blockName, oreName);
|
||||
for (CarvableVariation cv : stainedGlassPane[glassId].carverHelper.variations) {
|
||||
if (cv.metadata < glassPrefix || cv.metadata >= glassPrefix + 8)
|
||||
for (IVariationInfo info : stainedGlassPane[glassId].carverHelper.infoList) {
|
||||
if (info.getVariation().getBlockMeta() < glassPrefix || info.getVariation().getBlockMeta() >= glassPrefix + 8)
|
||||
continue;
|
||||
stainedGlassPane[glassId].carverHelper.registerVariation(blockName, cv, stainedGlassPane[glassId], cv.metadata);
|
||||
stainedGlassPane[glassId].carverHelper.registerVariation(blockName, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -984,7 +993,7 @@ public enum Features {
|
||||
@Override
|
||||
void addBlocks() {
|
||||
BlockCarvable granite = (BlockCarvable) new BlockCarvable(Material.rock).setHardness(2.0F).setResistance(10.0F).setCreativeTab(ChiselTabs.tabStoneChiselBlocks);
|
||||
granite.carverHelper.setChiselBlockName("granite");
|
||||
|
||||
granite.carverHelper.addVariation("tile.granite.0.desc", 0, "granite/granite");
|
||||
granite.carverHelper.addVariation("tile.granite.1.desc", 1, "granite/granitePolished");
|
||||
granite.carverHelper.addVariation("tile.granite.2.desc", 2, "granite/granitePillar");
|
||||
@@ -1127,7 +1136,7 @@ public enum Features {
|
||||
void addBlocks() {
|
||||
BlockCarvableIcePillar ice_pillar = (BlockCarvableIcePillar) new BlockCarvableIcePillar(Material.ice).setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setHardness(0.5F).setLightOpacity(3)
|
||||
.setStepSound(Block.soundTypeGlass);
|
||||
ice_pillar.carverHelper.setChiselBlockName("Ice Pillar");
|
||||
|
||||
ice_pillar.carverHelper.addVariation("tile.icePillar.0.desc", 0, "icepillar/plainplain");
|
||||
ice_pillar.carverHelper.addVariation("tile.icePillar.1.desc", 1, "icepillar/plaingreek");
|
||||
ice_pillar.carverHelper.addVariation("tile.icePillar.2.desc", 2, "icepillar/greekplain");
|
||||
@@ -1149,7 +1158,7 @@ public enum Features {
|
||||
@Override
|
||||
void addBlocks() {
|
||||
CarvableStairsMaker makerIceStairs = new CarvableStairsMaker(Blocks.ice);
|
||||
makerIceStairs.carverHelper.setChiselBlockName("Ice Stairs");
|
||||
|
||||
makerIceStairs.carverHelper.addVariation("tile.ice_stairs.0.desc", 0, Blocks.ice);
|
||||
makerIceStairs.carverHelper.addVariation("tile.ice_stairs.1.desc", 1, "ice/a1-ice-light");
|
||||
makerIceStairs.carverHelper.addVariation("tile.ice_stairs.2.desc", 2, "ice/a1-stonecobble-icecobble");
|
||||
@@ -1259,7 +1268,7 @@ public enum Features {
|
||||
void addBlocks() {
|
||||
BlockCarvable laboratoryblock = (BlockCarvable) new BlockCarvable(Material.iron).setCreativeTab(ChiselTabs.tabMetalChiselBlocks).setHardness(2.0F).setResistance(10F)
|
||||
.setStepSound(Chisel.soundMetalFootstep);
|
||||
laboratoryblock.carverHelper.setChiselBlockName("laboratoryblock");
|
||||
|
||||
laboratoryblock.carverHelper.addVariation("tile.laboratory.0.desc", 0, "laboratory/wallpanel");
|
||||
laboratoryblock.carverHelper.addVariation("tile.laboratory.1.desc", 1, "laboratory/dottedpanel");
|
||||
laboratoryblock.carverHelper.addVariation("tile.laboratory.2.desc", 2, "laboratory/largewall");
|
||||
@@ -1353,7 +1362,7 @@ public enum Features {
|
||||
@Override
|
||||
void addBlocks() {
|
||||
BlockLeaf leaves = (BlockLeaf) new BlockLeaf(Material.leaves).setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setHardness(0.2F).setStepSound(Block.soundTypeGrass);
|
||||
Carving.chisel.addGroup(new CarvingGroup("leaves") {
|
||||
Carving.chisel.addGroup(new SimpleCarvingGroup("leaves") {
|
||||
|
||||
public List<ICarvingVariation> getVariations() {
|
||||
if (Configurations.chiselBackToVanillaLeaves) {
|
||||
@@ -1404,7 +1413,7 @@ public enum Features {
|
||||
void addBlocks() {
|
||||
BlockCarvable limestone = (BlockCarvable) new BlockCarvable(Material.rock).setCreativeTab(ChiselTabs.tabStoneChiselBlocks).setHardness(2.0F).setResistance(10F)
|
||||
.setStepSound(Block.soundTypeStone);
|
||||
limestone.carverHelper.setChiselBlockName("Limestone");
|
||||
|
||||
limestone.carverHelper.addVariation("tile.limestone.0.desc", 0, "limestone");
|
||||
limestone.carverHelper.addVariation("tile.limestone.1.desc", 1, "limestone/terrain-cobbsmalltilelight");
|
||||
limestone.carverHelper.addVariation("tile.limestone.2.desc", 2, "limestone/terrain-cob-frenchlight");
|
||||
@@ -1426,7 +1435,7 @@ public enum Features {
|
||||
Carving.chisel.registerOre("limestone", "limestone");
|
||||
|
||||
BlockCarvableSlab limestone_slab = (BlockCarvableSlab) new BlockCarvableSlab(limestone).setCreativeTab(ChiselTabs.tabStoneChiselBlocks).setHardness(2.0F).setResistance(10F);
|
||||
limestone_slab.carverHelper.setChiselBlockName("Limestone Slab");
|
||||
|
||||
limestone_slab.carverHelper.addVariation("tile.limestoneSlab.0.desc", 0, "limestone");
|
||||
limestone_slab.carverHelper.addVariation("tile.limestoneSlab.1.desc", 1, "limestone/terrain-cobbsmalltilelight");
|
||||
limestone_slab.carverHelper.addVariation("tile.limestoneSlab.2.desc", 2, "limestone/terrain-cob-frenchlight");
|
||||
@@ -1448,7 +1457,7 @@ public enum Features {
|
||||
Carving.chisel.registerOre("limestone_slab", "limestone_slab");
|
||||
|
||||
CarvableStairsMaker makerLimestoneStairs = new CarvableStairsMaker(limestone);
|
||||
makerLimestoneStairs.carverHelper.setChiselBlockName("Limestone Stairs");
|
||||
|
||||
makerLimestoneStairs.carverHelper.addVariation("tile.limestoneStairs.0.desc", 0, "limestone");
|
||||
makerLimestoneStairs.carverHelper.addVariation("tile.limestoneStairs.1.desc", 1, "limestone/terrain-cobbsmalltilelight");
|
||||
makerLimestoneStairs.carverHelper.addVariation("tile.limestoneStairs.2.desc", 2, "limestone/terrain-cob-frenchlight");
|
||||
@@ -1481,7 +1490,7 @@ public enum Features {
|
||||
void addBlocks() {
|
||||
BlockCarvable marble = (BlockCarvable) new BlockCarvable(Material.rock).setCreativeTab(ChiselTabs.tabStoneChiselBlocks).setHardness(2.0F).setResistance(10F)
|
||||
.setStepSound(Block.soundTypeStone);
|
||||
marble.carverHelper.setChiselBlockName("Marble");
|
||||
|
||||
marble.carverHelper.addVariation("tile.marble.0.desc", 0, "marble");
|
||||
marble.carverHelper.addVariation("tile.marble.1.desc", 1, "marble/a1-stoneornamental-marblebrick");
|
||||
marble.carverHelper.addVariation("tile.marble.2.desc", 2, "marble/a1-stoneornamental-marbleclassicpanel");
|
||||
@@ -1504,7 +1513,7 @@ public enum Features {
|
||||
Carving.chisel.registerOre("marble", "marble");
|
||||
|
||||
BlockCarvableSlab marble_slab = (BlockCarvableSlab) new BlockCarvableSlab(marble).setHardness(2.0F).setResistance(10F);
|
||||
marble_slab.carverHelper.setChiselBlockName("Marble Slab");
|
||||
|
||||
marble_slab.carverHelper.addVariation("tile.marbleSlab.0.desc", 0, "marble");
|
||||
marble_slab.carverHelper.addVariation("tile.marbleSlab.1.desc", 1, "marbleslab/a1-stoneornamental-marblebrick");
|
||||
marble_slab.carverHelper.addVariation("tile.marbleSlab.2.desc", 2, "marbleslab/a1-stoneornamental-marbleclassicpanel");
|
||||
@@ -1518,7 +1527,7 @@ public enum Features {
|
||||
marble_slab.carverHelper.addVariation("tile.marbleSlab.10.desc", 10, "marbleslab/terrain-pistonback-marbledent");
|
||||
marble_slab.carverHelper.addVariation("tile.marbleSlab.11.desc", 11, "marbleslab/terrain-pistonback-marbledent-small");
|
||||
marble_slab.carverHelper.addVariation("tile.marbleSlab.12.desc", 12, "marbleslab/marble-bricks");
|
||||
marble_slab.carverHelper.addVariation("tile.marbleSlab.13.desc", 13, "marbleslab/marble-arranged-bricks");
|
||||
marble_slab.carverHelper.addVariation("tile.marbleSlab.13.desc", 13, new SubmapManagerSlab("marbleslab/marble-arranged-bricks"));
|
||||
marble_slab.carverHelper.addVariation("tile.marbleSlab.14.desc", 14, "marbleslab/marble-fancy-bricks");
|
||||
marble_slab.carverHelper.addVariation("tile.marbleSlab.15.desc", 15, "marbleslab/marble-blocks");
|
||||
marble_slab.carverHelper.registerAll(marble_slab, "marble_slab", ItemCarvableSlab.class);
|
||||
@@ -1526,7 +1535,7 @@ public enum Features {
|
||||
Carving.chisel.registerOre("marble_slab", "marble_slab");
|
||||
|
||||
CarvableStairsMaker makerMarbleStairs = new CarvableStairsMaker(marble);
|
||||
makerMarbleStairs.carverHelper.setChiselBlockName("Marble Stairs");
|
||||
|
||||
makerMarbleStairs.carverHelper.addVariation("tile.marbleStairs.0.desc", 0, "marble");
|
||||
makerMarbleStairs.carverHelper.addVariation("tile.marbleStairs.6.desc", 1, "marbleslab/a1-stoneornamental-marblebrick");
|
||||
makerMarbleStairs.carverHelper.addVariation("tile.marbleStairs.2.desc", 2, "marbleslab/a1-stoneornamental-marbleclassicpanel");
|
||||
@@ -1562,7 +1571,7 @@ public enum Features {
|
||||
if (Configurations.oldPillars) {
|
||||
marble_pillar = (BlockCarvable) new BlockCarvable(Material.rock).setCreativeTab(ChiselTabs.tabStoneChiselBlocks).setHardness(2.0F).setResistance(10F)
|
||||
.setStepSound(Block.soundTypeStone);
|
||||
marble_pillar.carverHelper.setChiselBlockName("Marble Pillar");
|
||||
|
||||
marble_pillar.carverHelper.addVariation("tile.marblePillarOld.0.desc", 0, "marblepillarold/column");
|
||||
marble_pillar.carverHelper.addVariation("tile.marblePillarOld.1.desc", 1, "marblepillarold/capstone");
|
||||
marble_pillar.carverHelper.addVariation("tile.marblePillarOld.2.desc", 2, "marblepillarold/base");
|
||||
@@ -1582,7 +1591,7 @@ public enum Features {
|
||||
} else {
|
||||
marble_pillar = (BlockCarvable) new BlockCarvablePillar(Material.rock).setCreativeTab(ChiselTabs.tabStoneChiselBlocks).setHardness(2.0F).setResistance(10F)
|
||||
.setStepSound(Block.soundTypeStone);
|
||||
marble_pillar.carverHelper.setChiselBlockName("Marble Pillar");
|
||||
|
||||
marble_pillar.carverHelper.addVariation("tile.marblePillar.0.desc", 0, "marblepillar/pillar");
|
||||
marble_pillar.carverHelper.addVariation("tile.marblePillar.1.desc", 1, "marblepillar/default");
|
||||
marble_pillar.carverHelper.addVariation("tile.marblePillar.2.desc", 2, "marblepillar/simple");
|
||||
@@ -1604,7 +1613,7 @@ public enum Features {
|
||||
|
||||
BlockCarvableSlab marble_pillar_slab = (BlockCarvableSlab) new BlockCarvableSlab(marble_pillar).setCreativeTab(ChiselTabs.tabStoneChiselBlocks).setHardness(2.0F).setResistance(10F)
|
||||
.setStepSound(Block.soundTypeStone);
|
||||
marble_pillar_slab.carverHelper.setChiselBlockName("Marble Pillar Slab");
|
||||
|
||||
if (Configurations.oldPillars) {
|
||||
marble_pillar_slab.carverHelper.addVariation("tile.marblePillarSlabOld.0.desc", 0, "marblepillarslabold/column");
|
||||
marble_pillar_slab.carverHelper.addVariation("tile.marblePillarSlabOld.1.desc", 1, "marblepillarslabold/capstone");
|
||||
@@ -1804,7 +1813,7 @@ public enum Features {
|
||||
void addBlocks() {
|
||||
BlockCarvablePackedIcePillar packedice_pillar = (BlockCarvablePackedIcePillar) new BlockCarvablePackedIcePillar(Material.ice).setCreativeTab(ChiselTabs.tabOtherChiselBlocks)
|
||||
.setHardness(0.5F).setLightOpacity(3).setStepSound(Block.soundTypeGlass);
|
||||
packedice_pillar.carverHelper.setChiselBlockName("Packed Ice Pillar");
|
||||
|
||||
packedice_pillar.carverHelper.addVariation("tile.packedice_pillar.0.desc", 0, "icepillar/plainplain");
|
||||
packedice_pillar.carverHelper.addVariation("tile.packedice_pillar.1.desc", 1, "icepillar/plaingreek");
|
||||
packedice_pillar.carverHelper.addVariation("tile.packedice_pillar.2.desc", 2, "icepillar/greekplain");
|
||||
@@ -1821,7 +1830,7 @@ public enum Features {
|
||||
@Override
|
||||
void addBlocks() {
|
||||
CarvableStairsMaker makerPackedIceStairs = new CarvableStairsMaker(Blocks.packed_ice);
|
||||
makerPackedIceStairs.carverHelper.setChiselBlockName("Packed Ice Stairs");
|
||||
|
||||
makerPackedIceStairs.carverHelper.addVariation("tile.packedice_stairs.0.desc", 0, Blocks.packed_ice);
|
||||
makerPackedIceStairs.carverHelper.addVariation("tile.packedice_stairs.1.desc", 1, "ice/a1-ice-light");
|
||||
makerPackedIceStairs.carverHelper.addVariation("tile.packedice_stairs.2.desc", 2, "ice/a1-stonecobble-icecobble");
|
||||
@@ -1854,7 +1863,7 @@ public enum Features {
|
||||
@Override
|
||||
void addBlocks() {
|
||||
BlockCarvablePane paperwall = (BlockCarvablePane) new BlockCarvablePane(Material.ground, true).setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setHardness(0.5F).setResistance(0.5F);
|
||||
paperwall.carverHelper.setChiselBlockName("Paper Wall");
|
||||
|
||||
paperwall.carverHelper.addVariation("tile.paperwall.0.desc", 0, "paper/box");
|
||||
paperwall.carverHelper.addVariation("tile.paperwall.1.desc", 1, "paper/throughMiddle");
|
||||
paperwall.carverHelper.addVariation("tile.paperwall.2.desc", 2, "paper/cross");
|
||||
@@ -1869,7 +1878,7 @@ public enum Features {
|
||||
Carving.chisel.registerOre("paperwall", "paperwall");
|
||||
|
||||
BlockCarvable paperwall_block = (BlockCarvable) new BlockCarvable(Material.ground).setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setHardness(0.5F).setResistance(0.5F);
|
||||
paperwall_block.carverHelper.setChiselBlockName("Paper Wall Block");
|
||||
|
||||
paperwall_block.carverHelper.addVariation("tile.paperwall.0.desc", 0, "paper/box");
|
||||
paperwall_block.carverHelper.addVariation("tile.paperwall.1.desc", 1, "paper/throughMiddle");
|
||||
paperwall_block.carverHelper.addVariation("tile.paperwall.2.desc", 2, "paper/cross");
|
||||
@@ -1897,7 +1906,7 @@ public enum Features {
|
||||
void addBlocks() {
|
||||
BlockPresent present = (BlockPresent) new BlockPresent().setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setHardness(2.0F).setResistance(10.0F).setBlockName("chisel.present");
|
||||
for (int i = 0; i < 16; i++) {
|
||||
present.carverHelper.addVariation("tile.chisel.present.desc", i, Blocks.chest);
|
||||
present.carverHelper.addVariation("tile.chisel.present.desc", i, "planks_oak", "minecraft");
|
||||
}
|
||||
present.carverHelper.registerAll(present, "present", ItemBlockPresent.class);
|
||||
Carving.chisel.registerOre("present", "chest");
|
||||
@@ -2413,7 +2422,7 @@ public enum Features {
|
||||
void addBlocks() {
|
||||
BlockCarvable templeblock = (BlockCarvable) new BlockEldritch().setHardness(2.0F).setCreativeTab(ChiselTabs.tabStoneChiselBlocks).setResistance(10F)
|
||||
.setStepSound(Chisel.soundTempleFootstep);
|
||||
templeblock.carverHelper.setChiselBlockName("Temple Block");
|
||||
|
||||
templeblock.carverHelper.addVariation("tile.templeblock.0.desc", 0, "temple/cobble");
|
||||
templeblock.carverHelper.addVariation("tile.templeblock.1.desc", 1, "temple/ornate");
|
||||
templeblock.carverHelper.addVariation("tile.templeblock.2.desc", 2, "temple/plate");
|
||||
@@ -2446,7 +2455,7 @@ public enum Features {
|
||||
void addBlocks() {
|
||||
BlockCarvable mossy_templeblock = (BlockCarvable) new BlockEldritch().setHardness(2.0F).setCreativeTab(ChiselTabs.tabStoneChiselBlocks).setResistance(10F)
|
||||
.setStepSound(Chisel.soundTempleFootstep);
|
||||
mossy_templeblock.carverHelper.setChiselBlockName("Mossy Temple Block");
|
||||
|
||||
mossy_templeblock.carverHelper.addVariation("tile.mossy_templeblock.0.desc", 0, "templemossy/cobble");
|
||||
mossy_templeblock.carverHelper.addVariation("tile.mossy_templeblock.1.desc", 1, "templemossy/ornate");
|
||||
mossy_templeblock.carverHelper.addVariation("tile.mossy_templeblock.2.desc", 2, "templemossy/plate");
|
||||
@@ -2577,7 +2586,7 @@ public enum Features {
|
||||
void addBlocks() {
|
||||
BlockCarvable tyrian = (BlockCarvable) new BlockCarvable(Material.iron).setCreativeTab(ChiselTabs.tabMetalChiselBlocks).setHardness(5.0F).setResistance(10.0F)
|
||||
.setStepSound(Block.soundTypeMetal);
|
||||
tyrian.carverHelper.setChiselBlockName("Futuristic Armor Plating Block");
|
||||
|
||||
tyrian.carverHelper.addVariation("tile.tyrian.0.desc", 0, "tyrian/shining");
|
||||
tyrian.carverHelper.addVariation("tile.tyrian.1.desc", 1, "tyrian/tyrian");
|
||||
tyrian.carverHelper.addVariation("tile.tyrian.2.desc", 2, "tyrian/chaotic");
|
||||
@@ -2681,7 +2690,7 @@ public enum Features {
|
||||
Carving.chisel.registerOre("voidstone2", "voidstone2");
|
||||
|
||||
BlockCarvable voidstoneRunic = (BlockCarvable) new BlockCarvable(Material.rock).setCreativeTab(ChiselTabs.tabStoneChiselBlocks).setHardness(5.0F).setResistance(10.0F);
|
||||
voidstoneRunic.carverHelper.setChiselBlockName("Voidstone Runic");
|
||||
|
||||
|
||||
for (int i = 1; i < 16; i++)
|
||||
voidstoneRunic.carverHelper.addVariation("tile.voidstoneRunic." + sGNames[i].replaceAll(" ", "").toLowerCase() + ".desc", i, "voidstone/runes/rune" + sGNames[i].replaceAll(" ", ""));
|
||||
@@ -2788,7 +2797,7 @@ public enum Features {
|
||||
final String name = n.replace('-', '_') + "_planks";
|
||||
|
||||
planks[i] = (BlockCarvable) (new BlockCarvable(Material.wood)).setCreativeTab(ChiselTabs.tabWoodChiselBlocks).setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundTypeWood);
|
||||
planks[i].carverHelper.setChiselBlockName(u + " Wood Planks");
|
||||
|
||||
planks[i].carverHelper.addVariation("Smooth " + n + " wood planks", 1, "planks-" + n + "/clean");
|
||||
planks[i].carverHelper.addVariation("Short " + n + " wood planks", 2, "planks-" + n + "/short");
|
||||
planks[i].carverHelper.addVariation("Fancy " + n + " wood plank arrangement", 6, "planks-" + n + "/fancy");
|
||||
@@ -2818,7 +2827,7 @@ public enum Features {
|
||||
@Override
|
||||
void addBlocks() {
|
||||
BlockCarvable woolen_clay = (BlockCarvable) new BlockCarvable(Material.clay).setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setHardness(2F).setResistance(10F);
|
||||
woolen_clay.carverHelper.setChiselBlockName("Woolen Clay");
|
||||
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
woolen_clay.carverHelper.addVariation("tile.woolenClay." + i + ".desc", i, "woolenClay/" + sGNames[i].replaceAll(" ", "").toLowerCase());
|
||||
@@ -2839,8 +2848,7 @@ public enum Features {
|
||||
boolean needsMetaRecipes() {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
;
|
||||
};
|
||||
|
||||
private static final String[] dyeOres = { "dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray", "dyePink", "dyeLime", "dyeYellow",
|
||||
"dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite" };
|
||||
|
||||
@@ -3,5 +3,5 @@ package com.cricketcraft.chisel.api;
|
||||
public class ChiselAPIProps {
|
||||
|
||||
public static final String VERSION = "0.0.2";
|
||||
|
||||
public static String MOD_ID = null; // Set by Chisel
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cricketcraft.chisel.compat.fmp;
|
||||
package com.cricketcraft.chisel.api;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -1,18 +1,19 @@
|
||||
package com.cricketcraft.chisel.api;
|
||||
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
import com.cricketcraft.chisel.api.rendering.ISubmapManager;
|
||||
|
||||
/**
|
||||
* To be implemented on blocks that can be chiseled and need advanced metadata to variation mapping. Currently not very usable without internal classes.
|
||||
*/
|
||||
public interface ICarvable {
|
||||
|
||||
/**
|
||||
* Gets a {@link CarvableVariation} from this block, based on metadata.
|
||||
* Gets a {@link ISubmapManager} from this block, based on metadata.
|
||||
* <p>
|
||||
* Typically you can refer this method to {@link CarvableHelper#getVariation(int)} but this method is provided for more complex metadata handling.
|
||||
*
|
||||
@@ -28,16 +29,17 @@ public interface ICarvable {
|
||||
* Z coord of the block
|
||||
* @param metadata
|
||||
* The metadata of the block
|
||||
* @return The {@link CarvableVariation} that represents this block in the world.
|
||||
* @return The {@link ISubmapManager} that represents this block in the world.
|
||||
*/
|
||||
public CarvableVariation getVariation(IBlockAccess world, int x, int y, int z, int metadata);
|
||||
public IVariationInfo getVariation(IBlockAccess world, int x, int y, int z, int metadata);
|
||||
|
||||
/**
|
||||
* Gets the {@link CarvableVariation} for this block when it is in item form.
|
||||
* Gets the {@link ISubmapManager} for this block when it is in item form.
|
||||
*
|
||||
* @param stack
|
||||
* The {@link ItemStack} representing this block;
|
||||
* @return A {@link CarvableVariation}
|
||||
* @return A {@link ISubmapManager}
|
||||
*/
|
||||
public CarvableVariation getVariation(ItemStack stack);
|
||||
public IVariationInfo getVariation(ItemStack stack);
|
||||
}
|
||||
|
||||
@@ -54,5 +54,10 @@ public enum IMC {
|
||||
/**
|
||||
* The modid of Chisel so you can easily send IMC to this mod.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String CHISEL_MODID = "chisel";
|
||||
|
||||
public static final String getModid() {
|
||||
return ChiselAPIProps.MOD_ID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
package com.cricketcraft.chisel.api.carving;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import com.cricketcraft.chisel.api.ChiselAPIProps;
|
||||
import com.cricketcraft.chisel.api.FMPIMC;
|
||||
import com.cricketcraft.chisel.api.rendering.ISubmapManager;
|
||||
import com.cricketcraft.chisel.api.rendering.TextureType;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class CarvableHelper {
|
||||
|
||||
public static Class<? extends ItemBlock> itemCarvableClass = null;
|
||||
|
||||
private Block theBlock;
|
||||
|
||||
public ArrayList<IVariationInfo> infoList = new ArrayList<IVariationInfo>();
|
||||
IVariationInfo[] infoMap = new IVariationInfo[16];
|
||||
public boolean forbidChiseling = false;
|
||||
|
||||
public CarvableHelper(Block block) {
|
||||
this.theBlock = block;
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, ISubmapManager<? extends RenderBlocks> manager) {
|
||||
addVariation(description, metadata, null, manager);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, Block bb) {
|
||||
addVariation(description, metadata, null, bb, 0, ChiselAPIProps.MOD_ID);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, Block bb, int blockMeta) {
|
||||
addVariation(description, metadata, null, bb, blockMeta, ChiselAPIProps.MOD_ID);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, Block bb, int blockMeta, Material material) {
|
||||
addVariation(description, metadata, null, bb, blockMeta, ChiselAPIProps.MOD_ID);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, String texture) {
|
||||
addVariation(description, metadata, texture, (ISubmapManager<? extends RenderBlocks>) null);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, String texture, ISubmapManager<? extends RenderBlocks> manager) {
|
||||
addVariation(description, metadata, texture, null, 0, ChiselAPIProps.MOD_ID, manager);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, Block bb, String modid) {
|
||||
addVariation(description, metadata, null, bb, 0, modid);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, Block bb, int blockMeta, String modid) {
|
||||
addVariation(description, metadata, null, bb, blockMeta, modid);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, Block bb, int blockMeta, Material material, String modid) {
|
||||
addVariation(description, metadata, null, bb, blockMeta, modid);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, String texture, String modid) {
|
||||
addVariation(description, metadata, texture, null, 0, modid);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, String texture, Block block, int blockMeta, String modid) {
|
||||
addVariation(description, metadata, texture, block, blockMeta, modid, null);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, String texture, Block block, int blockMeta, String modid, ISubmapManager<? extends RenderBlocks> customManager) {
|
||||
|
||||
if (infoList.size() >= 16)
|
||||
return;
|
||||
|
||||
ICarvingVariation var = CarvingUtils.getDefaultVariationFor(theBlock, metadata, metadata);
|
||||
TextureType type = TextureType.getTypeFor(this, modid, texture);
|
||||
if (type == TextureType.CUSTOM && customManager == null && block == null) {
|
||||
throw new IllegalArgumentException(String.format("Could not find texture %s, and no custom texture manager was provided.", texture));
|
||||
}
|
||||
|
||||
IVariationInfo info;
|
||||
ISubmapManager<?> manager;
|
||||
if (customManager != null) {
|
||||
manager = customManager;
|
||||
} else if (block != null) {
|
||||
manager = type.createManagerFor(var, block, blockMeta);
|
||||
} else {
|
||||
manager = type.createManagerFor(var, texture);
|
||||
}
|
||||
info = new VariationInfoBase(var, description, manager);
|
||||
|
||||
infoList.add(info);
|
||||
infoMap[metadata] = info;
|
||||
}
|
||||
|
||||
|
||||
public IVariationInfo getVariation(int metadata) {
|
||||
if (metadata < 0 || metadata > 15)
|
||||
metadata = 0;
|
||||
|
||||
IVariationInfo info = infoMap[metadata];
|
||||
if (info == null)
|
||||
return null;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
if (metadata < 0 || metadata > 15)
|
||||
metadata = 0;
|
||||
|
||||
IVariationInfo info = infoMap[metadata];
|
||||
if (info == null)
|
||||
return getMissingIcon();
|
||||
|
||||
return info.getSubmapManager().getIcon(side, metadata);
|
||||
}
|
||||
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if (metadata < 0 || metadata > 15)
|
||||
metadata = 0;
|
||||
|
||||
IVariationInfo info = infoMap[metadata];
|
||||
if (info == null)
|
||||
return getMissingIcon();
|
||||
|
||||
return info.getSubmapManager().getIcon(world, x, y, z, side);
|
||||
}
|
||||
|
||||
public void registerAll(Block block, String name) {
|
||||
registerAll(block, name, itemCarvableClass);
|
||||
}
|
||||
|
||||
public void registerBlock(Block block, String name) {
|
||||
registerBlock(block, name, itemCarvableClass);
|
||||
}
|
||||
|
||||
void registerBlock(Block block, String name, Class<? extends ItemBlock> cl) {
|
||||
block.setBlockName("chisel." + name);
|
||||
GameRegistry.registerBlock(block, cl, name);
|
||||
}
|
||||
|
||||
public void registerAll(Block block, String name, Class<? extends ItemBlock> cl) {
|
||||
registerBlock(block, name, cl);
|
||||
registerVariations(name, block);
|
||||
}
|
||||
|
||||
public void registerVariations(String name, Block block) {
|
||||
for (IVariationInfo info : infoList) {
|
||||
registerVariation(name, info);
|
||||
}
|
||||
}
|
||||
|
||||
public void registerVariation(String name, IVariationInfo info) {
|
||||
|
||||
Block block = info.getVariation().getBlock();
|
||||
|
||||
if (block.renderAsNormalBlock() || block.isOpaqueCube() || block.isNormalCube()) {
|
||||
FMPIMC.registerFMP(block, info.getVariation().getBlockMeta());
|
||||
}
|
||||
|
||||
if (forbidChiseling)
|
||||
return;
|
||||
|
||||
CarvingUtils.getChiselRegistry().addVariation(name, info.getVariation());
|
||||
}
|
||||
|
||||
public void registerBlockIcons(String modName, Block block, IIconRegister register) {
|
||||
for (IVariationInfo info : infoList) {
|
||||
info.getSubmapManager().registerIcons(modName, block, register);
|
||||
}
|
||||
}
|
||||
|
||||
public void registerSubBlocks(Block block, CreativeTabs tabs, List<ItemStack> list) {
|
||||
for (IVariationInfo info : infoList) {
|
||||
list.add(new ItemStack(block, 1, info.getVariation().getItemMeta()));
|
||||
}
|
||||
}
|
||||
|
||||
public void registerOre(String ore) {
|
||||
OreDictionary.registerOre(ore, infoList.get(0).getVariation().getBlock());
|
||||
}
|
||||
|
||||
public IIcon getMissingIcon() {
|
||||
return ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,14 @@
|
||||
package com.cricketcraft.chisel.api.carving;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class CarvingUtils {
|
||||
|
||||
/**
|
||||
@@ -30,56 +35,141 @@ public class CarvingUtils {
|
||||
return new ItemStack(variation.getBlock(), 1, variation.getItemMeta());
|
||||
}
|
||||
|
||||
private static Field _chisel;
|
||||
private static boolean registryErrored = false;
|
||||
private static final String CARVING_CLASS = "com.cricketcraft.chisel.carving.Carving";
|
||||
|
||||
private static Class<ICarvableHelper> _carvableHelper;
|
||||
private static boolean helperErrored = false;
|
||||
private static final String CARVABLE_HELPER_CLASS = "com.cricketcraft.carving.CarvableHelper";
|
||||
public static ICarvingRegistry chisel;
|
||||
|
||||
/**
|
||||
* @return The instance of the chisel carving registry from the chisel mod.
|
||||
* <p>
|
||||
* If chisel is not installed or some other error occurs this will return null.
|
||||
* If chisel is not installed this will return null.
|
||||
*/
|
||||
public static ICarvingRegistry getChiselRegistry() {
|
||||
if (registryErrored) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
if (_chisel == null) {
|
||||
_chisel = Class.forName(CARVING_CLASS).getDeclaredField("chisel");
|
||||
}
|
||||
return (ICarvingRegistry) _chisel.get(null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
registryErrored = true;
|
||||
return getChiselRegistry();
|
||||
}
|
||||
return chisel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return An instance of an {@link ICarvableHelper}.
|
||||
* <p>
|
||||
* If chisel is not installed or some other error occurs this will return null.
|
||||
* Creates a standard {@link ICarvingVariation} for the given data. Use this if you do not need any custom behavior in your own variation.
|
||||
*
|
||||
* @param block
|
||||
* The block of the variation
|
||||
* @param metadata
|
||||
* The metadata of both the block and item
|
||||
* @param order
|
||||
* The sorting order.
|
||||
* @return A standard {@link ICarvingVariation} instance.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static ICarvableHelper getCarvableHelperInstance() {
|
||||
if (helperErrored) {
|
||||
return null;
|
||||
public static ICarvingVariation getDefaultVariationFor(Block block, int metadata, int order) {
|
||||
return new SimpleCarvingVariation(block, metadata, order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a standard {@link ICarvingGroup} for the given name. Use this if you do not need any custom behavior in your own group.
|
||||
*
|
||||
* @param name
|
||||
* The name of the group.
|
||||
* @return A standard {@link ICarvingGroup} instance.
|
||||
*/
|
||||
public static ICarvingGroup getDefaultGroupFor(String name) {
|
||||
return new SimpleCarvingGroup(name);
|
||||
}
|
||||
|
||||
public static class SimpleCarvingVariation implements ICarvingVariation {
|
||||
|
||||
private int order;
|
||||
private Block block;
|
||||
private int meta;
|
||||
private int damage;
|
||||
|
||||
public SimpleCarvingVariation(Block block, int metadata, int order) {
|
||||
this.order = order;
|
||||
this.block = block;
|
||||
this.meta = metadata;
|
||||
this.damage = metadata;
|
||||
}
|
||||
|
||||
try {
|
||||
if (_carvableHelper == null) {
|
||||
_carvableHelper = (Class<ICarvableHelper>) Class.forName(CARVABLE_HELPER_CLASS);
|
||||
}
|
||||
return _carvableHelper.newInstance();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
helperErrored = true;
|
||||
return getCarvableHelperInstance();
|
||||
@Override
|
||||
public Block getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemMeta() {
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return order;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SimpleCarvingGroup implements ICarvingGroup {
|
||||
|
||||
private String name;
|
||||
private String sound;
|
||||
private String oreName;
|
||||
|
||||
private List<ICarvingVariation> variations = Lists.newArrayList();
|
||||
|
||||
public SimpleCarvingGroup(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<ICarvingVariation> getVariations() {
|
||||
return Lists.newArrayList(variations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addVariation(ICarvingVariation variation) {
|
||||
variations.add(variation);
|
||||
Collections.sort(variations, new Comparator<ICarvingVariation>() {
|
||||
|
||||
@Override
|
||||
public int compare(ICarvingVariation o1, ICarvingVariation o2) {
|
||||
return CarvingUtils.compare(o1, o2);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeVariation(ICarvingVariation variation) {
|
||||
ICarvingVariation toRemove = null;
|
||||
for (ICarvingVariation v : variations) {
|
||||
if (v.getBlock() == variation.getBlock() && v.getBlockMeta() == variation.getBlockMeta()) {
|
||||
toRemove = v;
|
||||
}
|
||||
}
|
||||
return toRemove == null ? false : variations.remove(toRemove);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSound() {
|
||||
return sound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSound(String sound) {
|
||||
this.sound = sound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOreName() {
|
||||
return oreName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOreName(String oreName) {
|
||||
this.oreName = oreName;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package com.cricketcraft.chisel.api.carving;
|
||||
|
||||
|
||||
public interface ICarvableHelper {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.cricketcraft.chisel.api.carving;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
|
||||
import com.cricketcraft.chisel.api.rendering.ISubmapManager;
|
||||
import com.cricketcraft.chisel.api.rendering.TextureType;
|
||||
|
||||
public interface IVariationInfo {
|
||||
|
||||
ISubmapManager<? extends RenderBlocks> getSubmapManager();
|
||||
|
||||
ICarvingVariation getVariation();
|
||||
|
||||
String getDescription();
|
||||
|
||||
TextureType getType();
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.cricketcraft.chisel.api.carving;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import com.cricketcraft.chisel.api.rendering.ISubmapManager;
|
||||
import com.cricketcraft.chisel.api.rendering.TextureType;
|
||||
|
||||
public class VariationInfoBase implements IVariationInfo {
|
||||
|
||||
private ICarvingVariation variation;
|
||||
private String unlocDesc;
|
||||
private ISubmapManager<? extends RenderBlocks> manager;
|
||||
private TextureType type;
|
||||
|
||||
public VariationInfoBase(ICarvingVariation variation, String unlocDesc, ISubmapManager<? extends RenderBlocks> manager) {
|
||||
this(variation, unlocDesc, manager, TextureType.CUSTOM);
|
||||
}
|
||||
|
||||
public VariationInfoBase(ICarvingVariation variation, String unlocDesc, ISubmapManager<? extends RenderBlocks> manager, TextureType type) {
|
||||
this.variation = variation;
|
||||
this.unlocDesc = unlocDesc;
|
||||
this.manager = manager;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICarvingVariation getVariation() {
|
||||
return variation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return StatCollector.translateToLocal(unlocDesc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISubmapManager<? extends RenderBlocks> getSubmapManager() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureType getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
+8
-5
@@ -1,4 +1,4 @@
|
||||
package com.cricketcraft.chisel.api.client;
|
||||
package com.cricketcraft.chisel.api.rendering;
|
||||
|
||||
import gnu.trove.map.TIntObjectMap;
|
||||
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||
@@ -12,7 +12,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import com.cricketcraft.chisel.api.IFacade;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import static com.cricketcraft.chisel.api.client.Dir.*;
|
||||
import static com.cricketcraft.chisel.api.rendering.Dir.*;
|
||||
|
||||
// @formatter:off
|
||||
/**
|
||||
@@ -68,15 +68,15 @@ import static com.cricketcraft.chisel.api.client.Dir.*;
|
||||
public class CTM {
|
||||
|
||||
/** Some hardcoded offset values for the different corner indeces */
|
||||
private int[] submapOffsets = { 4, 5, 1, 0 };
|
||||
private TIntObjectMap<Dir[]> submapMap = new TIntObjectHashMap<Dir[]>();
|
||||
private static int[] submapOffsets = { 4, 5, 1, 0 };
|
||||
private static TIntObjectMap<Dir[]> submapMap = new TIntObjectHashMap<Dir[]>();
|
||||
private static EnumMap<Dir, Boolean> connectionMap = Maps.newEnumMap(Dir.class);
|
||||
/** For use via the Chisel 2 config only, altering this could cause unintended behavior */
|
||||
public static boolean disableObscuredFaceCheckConfig = false;
|
||||
|
||||
public Boolean disableObscuredFaceCheck = null;
|
||||
|
||||
private CTM() {
|
||||
static {
|
||||
for (Dir dir : Dir.VALUES) {
|
||||
connectionMap.put(dir, false);
|
||||
}
|
||||
@@ -86,6 +86,9 @@ public class CTM {
|
||||
submapMap.put(2, new Dir[] { TOP, RIGHT, TOP_RIGHT });
|
||||
submapMap.put(3, new Dir[] { TOP, LEFT, TOP_LEFT });
|
||||
}
|
||||
|
||||
private CTM() {
|
||||
}
|
||||
|
||||
public static CTM getInstance() {
|
||||
return new CTM();
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.cricketcraft.chisel.api.rendering;
|
||||
|
||||
|
||||
public class ClientUtils {
|
||||
|
||||
public static int renderCTMId;
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cricketcraft.chisel.api.client;
|
||||
package com.cricketcraft.chisel.api.rendering;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
+10
-2
@@ -1,11 +1,13 @@
|
||||
package com.cricketcraft.chisel.api.client;
|
||||
package com.cricketcraft.chisel.api.rendering;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface ISubmapManager {
|
||||
public interface ISubmapManager<T extends RenderBlocks> {
|
||||
|
||||
/**
|
||||
* Gets the icon for item rendering, based on side and item metadata.
|
||||
@@ -34,4 +36,10 @@ public interface ISubmapManager {
|
||||
* The IIconRegister instance.
|
||||
*/
|
||||
void registerIcons(String modName, Block block, IIconRegister register);
|
||||
|
||||
T createRenderContext(RenderBlocks rendererOld, IBlockAccess world);
|
||||
|
||||
void preRenderSide(T renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side);
|
||||
|
||||
void postRenderSide(T renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side);
|
||||
}
|
||||
+170
-84
@@ -1,15 +1,13 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import com.cricketcraft.chisel.api.client.CTM;
|
||||
import com.cricketcraft.chisel.api.client.TextureSubmap;
|
||||
package com.cricketcraft.chisel.api.rendering;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import static com.cricketcraft.chisel.client.render.RenderBlocksCTM.Vert.*;
|
||||
import static com.cricketcraft.chisel.client.render.RenderBlocksCTM.SubSide.*;
|
||||
import static com.cricketcraft.chisel.client.render.RenderBlocksCTM.Vert.Y_HALF_X;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import static com.cricketcraft.chisel.api.rendering.RenderBlocksCTM.SubSide.*;
|
||||
import static com.cricketcraft.chisel.api.rendering.RenderBlocksCTM.Vert.*;
|
||||
|
||||
public class RenderBlocksCTM extends RenderBlocks {
|
||||
|
||||
@@ -18,13 +16,10 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
*
|
||||
* The naming scheme is as follows:
|
||||
*
|
||||
* ZERO and ONE are special cases, they are the absolute min and absolute
|
||||
* max of the block. X, Y, Z, or any combination means that the axes listed
|
||||
* in the name are at 1. X, Y, Z, or any combination followed by HALF means
|
||||
* that those axes are at 0.5. X, Y, Z, or any combination after a HALF
|
||||
* means those axes are at 1.
|
||||
* ZERO is a special case, it is the absolute min point of the block. X, Y, Z, or any combination means that the axes listed in the name are at 1. X, Y, Z, or any combination followed by HALF
|
||||
* means that those axes are at 0.5. X, Y, Z, or any combination after a HALF means those axes are at 1.
|
||||
*/
|
||||
enum Vert {
|
||||
protected enum Vert {
|
||||
// @formatter:off
|
||||
ZERO(0, 0, 0),
|
||||
XYZ(1, 1, 1),
|
||||
@@ -61,25 +56,55 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
private static double u, v, xDiff, yDiff, zDiff, uDiff, vDiff;
|
||||
|
||||
void render(RenderBlocksCTM inst, int cacheID) {
|
||||
void render(RenderBlocksCTM inst, ForgeDirection normal, int cacheID) {
|
||||
if (inst.enableAO) {
|
||||
inst.tessellator.setColorOpaque_F(inst.redCache[cacheID], inst.grnCache[cacheID], inst.bluCache[cacheID]);
|
||||
inst.tessellator.setBrightness(inst.lightingCache[cacheID]);
|
||||
}
|
||||
u = cacheID == 1 || cacheID == 2 ? inst.maxU : inst.minU;
|
||||
v = cacheID < 2 ? inst.maxV : inst.minV;
|
||||
|
||||
uDiff = inst.maxU - inst.minU;
|
||||
vDiff = inst.maxV - inst.minV;
|
||||
|
||||
inst.tessellator.addVertexWithUV(x, y, z, inst.uCache[cacheID], inst.vCache[cacheID]);
|
||||
if (inst.renderMinX + inst.renderMinY + inst.renderMinZ != 0 || inst.renderMaxX + inst.renderMaxY + inst.renderMaxZ != 3) {
|
||||
boolean uMin = u == inst.minU;
|
||||
boolean vMin = v == inst.minV;
|
||||
|
||||
xDiff = inst.renderMaxX - inst.renderMinX;
|
||||
yDiff = inst.renderMaxY - inst.renderMinY;
|
||||
zDiff = inst.renderMaxZ - inst.renderMinZ;
|
||||
|
||||
if (normal.offsetY != 0) {
|
||||
uDiff *= uMin ? inst.renderMinX : 1 - inst.renderMaxX;
|
||||
vDiff *= vMin ? inst.renderMinZ : 1 - inst.renderMaxZ;
|
||||
} else if (normal.offsetX != 0) {
|
||||
uDiff *= uMin ? inst.renderMinZ : 1 - inst.renderMaxZ;
|
||||
vDiff *= vMin ? inst.renderMinY : 1 - inst.renderMaxY;
|
||||
} else if (normal.offsetZ != 0) {
|
||||
uDiff *= uMin ? inst.renderMinX : 1 - inst.renderMaxX;
|
||||
vDiff *= vMin ? inst.renderMinY : 1 - inst.renderMaxY;
|
||||
}
|
||||
u = u == inst.minU ? inst.minU + uDiff : inst.maxU - uDiff;
|
||||
|
||||
v = v == inst.minV ? inst.minV + vDiff : inst.maxV - vDiff;
|
||||
} else {
|
||||
xDiff = yDiff = zDiff = 1;
|
||||
}
|
||||
|
||||
inst.tessellator.addVertexWithUV(inst.renderMinX + (x * xDiff), inst.renderMinY + (y * yDiff), inst.renderMinZ + (z * zDiff), u, v);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Each side is divided into 4 sub-sides. LB(left bottom), RB(right bottom),
|
||||
* LT(right top), and RT(right top).
|
||||
* Each side is divided into 4 sub-sides. LB(left bottom), RB(right bottom), LT(right top), and RT(right top).
|
||||
*
|
||||
* Each sub-side contains 4 {@link Vert} objects representing its position
|
||||
* on the block.
|
||||
* Each sub-side contains 4 {@link Vert} objects representing its position on the block.
|
||||
*/
|
||||
enum SubSide {
|
||||
protected enum SubSide {
|
||||
// @formatter:off
|
||||
XNEG_LB(ZERO, Z_HALF, YZ_HALF, Y_HALF), XNEG_RB(Z_HALF, Z, Y_HALF_Z, YZ_HALF), XNEG_RT(YZ_HALF, Y_HALF_Z, YZ, Z_HALF_Y), XNEG_LT(Y_HALF, YZ_HALF, Z_HALF_Y, Y),
|
||||
XPOS_LB(XZ, Z_HALF_X, YZ_HALF_X, Y_HALF_XZ), XPOS_RB(Z_HALF_X, X, Y_HALF_X, YZ_HALF_X), XPOS_RT(YZ_HALF_X, Y_HALF_X, XY, Z_HALF_XY), XPOS_LT(Y_HALF_XZ, YZ_HALF_X, Z_HALF_XY, XYZ),
|
||||
@@ -91,53 +116,71 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
YPOS_LB(YZ, X_HALF_YZ, XZ_HALF_Y, Z_HALF_Y), YPOS_RB(X_HALF_YZ, XYZ, Z_HALF_XY, XZ_HALF_Y), YPOS_RT(XZ_HALF_Y, Z_HALF_XY, XY, X_HALF_Y), YPOS_LT(Z_HALF_Y, XZ_HALF_Y, X_HALF_Y, Y);
|
||||
// @formatter:on
|
||||
private Vert xmin, xmax, ymin, ymax;
|
||||
private ForgeDirection normal;
|
||||
|
||||
SubSide(Vert xmin, Vert ymin, Vert ymax, Vert xmax) {
|
||||
this.xmin = xmin;
|
||||
this.ymin = ymin;
|
||||
this.ymax = ymax;
|
||||
this.xmax = xmax;
|
||||
this.normal = calcNormal();
|
||||
}
|
||||
|
||||
private ForgeDirection calcNormal() {
|
||||
double xTot = xmin.x + xmax.x + ymin.x + ymax.x;
|
||||
double yTot = xmin.y + xmax.y + ymin.y + ymax.y;
|
||||
double zTot = xmin.z + xmax.z + ymin.z + ymax.z;
|
||||
if (xTot % 4 == 0) {
|
||||
return xTot > 0 ? ForgeDirection.EAST : ForgeDirection.WEST;
|
||||
} else if (yTot % 4 == 0) {
|
||||
return yTot > 0 ? ForgeDirection.UP : ForgeDirection.DOWN;
|
||||
} else if (zTot % 4 == 0) {
|
||||
return zTot > 0 ? ForgeDirection.SOUTH : ForgeDirection.NORTH;
|
||||
}
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
void render(RenderBlocksCTM inst) {
|
||||
xmin.render(inst, 0);
|
||||
ymin.render(inst, 1);
|
||||
ymax.render(inst, 2);
|
||||
xmax.render(inst, 3);
|
||||
xmin.render(inst, normal, 0);
|
||||
ymin.render(inst, normal, 1);
|
||||
ymax.render(inst, normal, 2);
|
||||
xmax.render(inst, normal, 3);
|
||||
}
|
||||
}
|
||||
|
||||
private static CTM ctm = CTM.getInstance();
|
||||
|
||||
protected static CTM ctm = CTM.getInstance();
|
||||
|
||||
// globals added to save the JVM some trouble. No need to constantly create
|
||||
// and destroy ints if we don't have to
|
||||
int blockLightBitChannel = 0;
|
||||
int redBitChannel = 0;
|
||||
int greenBitChannel = 0;
|
||||
int blueBitChannel = 0;
|
||||
int sunlightBitChannel = 0;
|
||||
protected int blockLightBitChannel = 0;
|
||||
protected int redBitChannel = 0;
|
||||
protected int greenBitChannel = 0;
|
||||
protected int blueBitChannel = 0;
|
||||
protected int sunlightBitChannel = 0;
|
||||
|
||||
RenderBlocksCTM() {
|
||||
public RenderBlocksCTM() {
|
||||
super();
|
||||
renderMaxX = renderMaxY = renderMaxZ = 1;
|
||||
}
|
||||
|
||||
Tessellator tessellator;
|
||||
double[] uCache = new double[4];
|
||||
double[] vCache = new double[4];
|
||||
int[] lightingCache = new int[4];
|
||||
float[] redCache = new float[4];
|
||||
float[] grnCache = new float[4];
|
||||
float[] bluCache = new float[4];
|
||||
TextureSubmap submap;
|
||||
TextureSubmap submapSmall;
|
||||
RenderBlocks rendererOld;
|
||||
protected Tessellator tessellator;
|
||||
protected double minU, maxU;
|
||||
protected double minV, maxV;
|
||||
protected int[] lightingCache = new int[4];
|
||||
protected float[] redCache = new float[4];
|
||||
protected float[] grnCache = new float[4];
|
||||
protected float[] bluCache = new float[4];
|
||||
public TextureSubmap submap;
|
||||
public TextureSubmap submapSmall;
|
||||
public RenderBlocks rendererOld;
|
||||
public ISubmapManager<RenderBlocksCTM> manager;
|
||||
|
||||
int[][] lightmap = new int[3][3];
|
||||
float[][] redmap = new float[3][3];
|
||||
float[][] grnmap = new float[3][3];
|
||||
float[][] blumap = new float[3][3];
|
||||
protected int[][] lightmap = new int[3][3];
|
||||
protected float[][] redmap = new float[3][3];
|
||||
protected float[][] grnmap = new float[3][3];
|
||||
protected float[][] blumap = new float[3][3];
|
||||
|
||||
int bx, by, bz;
|
||||
protected int bx, by, bz;
|
||||
|
||||
@Override
|
||||
public boolean renderStandardBlock(Block block, int x, int y, int z) {
|
||||
@@ -174,7 +217,7 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
* shakes fist in anger
|
||||
*/
|
||||
// @formatter:on
|
||||
void fillLightmap(int bottomLeft, int bottomRight, int topRight, int topLeft) {
|
||||
protected void fillLightmap(int bottomLeft, int bottomRight, int topRight, int topLeft) {
|
||||
lightmap[0][0] = bottomLeft;
|
||||
lightmap[2][0] = bottomRight;
|
||||
lightmap[2][2] = topRight;
|
||||
@@ -188,7 +231,7 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
lightmap[1][1] = avg(bottomLeft, bottomRight, topRight, topLeft);
|
||||
}
|
||||
|
||||
void fillColormap(float bottomLeft, float bottomRight, float topRight, float topLeft, float[][] map) {
|
||||
protected void fillColormap(float bottomLeft, float bottomRight, float topRight, float topLeft, float[][] map) {
|
||||
map[0][0] = bottomLeft;
|
||||
map[2][0] = bottomRight;
|
||||
map[2][2] = topRight;
|
||||
@@ -202,7 +245,7 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
map[1][1] = (bottomLeft + bottomRight + topRight + topLeft) / 4.0F;
|
||||
}
|
||||
|
||||
void getLight(int x, int y) {
|
||||
protected void getLight(int x, int y) {
|
||||
lightingCache[0] = lightmap[0 + x][0 + y];
|
||||
lightingCache[1] = lightmap[1 + x][0 + y];
|
||||
lightingCache[2] = lightmap[1 + x][1 + y];
|
||||
@@ -227,7 +270,7 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
/**
|
||||
* This works around a bug in CLC atm
|
||||
*/
|
||||
int avg(int... lightVals) {
|
||||
private int avg(int... lightVals) {
|
||||
blockLightBitChannel = 0;
|
||||
redBitChannel = 0;
|
||||
greenBitChannel = 0;
|
||||
@@ -246,7 +289,8 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
| ((blueBitChannel / lightVals.length) & 0xF0000) | ((sunlightBitChannel / lightVals.length) & 0xF00000);
|
||||
}
|
||||
|
||||
void side(SubSide side, int iconIndex) {
|
||||
protected void side(SubSide side, int iconIndex) {
|
||||
|
||||
IIcon icon;
|
||||
TextureSubmap map;
|
||||
if (iconIndex >= 16) {
|
||||
@@ -264,15 +308,20 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
double vmax = icon.getMaxV();
|
||||
double vmin = icon.getMinV();
|
||||
|
||||
uCache[0] = umin;
|
||||
uCache[1] = umax;
|
||||
uCache[2] = umax;
|
||||
uCache[3] = umin;
|
||||
minU = umin;
|
||||
maxU = umax;
|
||||
minV = vmin;
|
||||
maxV = vmax;
|
||||
|
||||
vCache[0] = vmax;
|
||||
vCache[1] = vmax;
|
||||
vCache[2] = vmin;
|
||||
vCache[3] = vmin;
|
||||
// uCache[0] = umin;
|
||||
// uCache[1] = umax;
|
||||
// uCache[2] = umax;
|
||||
// uCache[3] = umin;
|
||||
//
|
||||
// vCache[0] = vmax;
|
||||
// vCache[1] = vmax;
|
||||
// vCache[2] = vmin;
|
||||
// vCache[3] = vmin;
|
||||
|
||||
side.render(this);
|
||||
}
|
||||
@@ -282,13 +331,15 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) {
|
||||
IIcon i = rendererOld.overrideBlockTexture;
|
||||
|
||||
tessellator.addVertexWithUV(0.0, 1.0, 0.0, i.getMinU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(0.0, 0.0, 0.0, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(0.0, 0.0, 1.0, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(0.0, 1.0, 1.0, i.getMaxU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(renderMinX, renderMaxY, renderMinZ, i.getMinU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(renderMinX, renderMinY, renderMinZ, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(renderMinX, renderMinY, renderMaxZ, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(renderMinX, renderMaxY, renderMaxZ, i.getMaxU(), i.getMinV());
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 4);
|
||||
|
||||
pre(ForgeDirection.WEST);
|
||||
|
||||
fillLightmap(brightnessBottomRight, brightnessTopRight, brightnessTopLeft, brightnessBottomLeft);
|
||||
fillColormap(colorRedBottomRight, colorRedTopRight, colorRedTopLeft, colorRedBottomLeft, redmap);
|
||||
fillColormap(colorGreenBottomRight, colorGreenTopRight, colorGreenTopLeft, colorGreenBottomLeft, grnmap);
|
||||
@@ -302,6 +353,8 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
side(XNEG_RT, tex[2]);
|
||||
getLight(0, 1);
|
||||
side(XNEG_LT, tex[3]);
|
||||
|
||||
post(ForgeDirection.WEST);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,17 +363,20 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) {
|
||||
IIcon i = rendererOld.overrideBlockTexture;
|
||||
|
||||
tessellator.addVertexWithUV(1.0, 1.0, 1.0, i.getMaxU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(1.0, 0.0, 1.0, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(1.0, 0.0, 0.0, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(1.0, 1.0, 0.0, i.getMinU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(renderMaxX, renderMaxY, renderMaxZ, i.getMaxU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(renderMaxX, renderMinY, renderMaxZ, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(renderMaxX, renderMinY, renderMinZ, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(renderMaxX, renderMaxY, renderMinZ, i.getMinU(), i.getMinV());
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 5);
|
||||
|
||||
pre(ForgeDirection.EAST);
|
||||
|
||||
fillLightmap(brightnessTopLeft, brightnessBottomLeft, brightnessBottomRight, brightnessTopRight);
|
||||
fillColormap(colorRedTopLeft, colorRedBottomLeft, colorRedBottomRight, colorRedTopRight, redmap);
|
||||
fillColormap(colorGreenTopLeft, colorGreenBottomLeft, colorGreenBottomRight, colorGreenTopRight, grnmap);
|
||||
fillColormap(colorBlueTopLeft, colorBlueBottomLeft, colorBlueBottomRight, colorBlueTopRight, blumap);
|
||||
|
||||
getLight(0, 0);
|
||||
side(XPOS_LB, tex[0]);
|
||||
getLight(1, 0);
|
||||
@@ -329,6 +385,8 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
side(XPOS_RT, tex[2]);
|
||||
getLight(0, 1);
|
||||
side(XPOS_LT, tex[3]);
|
||||
|
||||
post(ForgeDirection.EAST);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,17 +395,20 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) {
|
||||
IIcon i = rendererOld.overrideBlockTexture;
|
||||
|
||||
tessellator.addVertexWithUV(1.0, 1.0, 0.0, i.getMaxU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(1.0, 0.0, 0.0, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(0.0, 0.0, 0.0, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(0.0, 1.0, 0.0, i.getMinU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(renderMaxX, renderMaxY, renderMinZ, i.getMaxU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(renderMaxX, renderMinY, renderMinZ, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(renderMinX, renderMinY, renderMinZ, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(renderMinX, renderMaxY, renderMinZ, i.getMinU(), i.getMinV());
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 2);
|
||||
|
||||
pre(ForgeDirection.NORTH);
|
||||
|
||||
fillLightmap(brightnessBottomRight, brightnessTopRight, brightnessTopLeft, brightnessBottomLeft);
|
||||
fillColormap(colorRedBottomRight, colorRedTopRight, colorRedTopLeft, colorRedBottomLeft, redmap);
|
||||
fillColormap(colorGreenBottomRight, colorGreenTopRight, colorGreenTopLeft, colorGreenBottomLeft, grnmap);
|
||||
fillColormap(colorBlueBottomRight, colorBlueTopRight, colorBlueTopLeft, colorBlueBottomLeft, blumap);
|
||||
|
||||
getLight(0, 0);
|
||||
side(ZNEG_LB, tex[0]);
|
||||
getLight(1, 0);
|
||||
@@ -356,6 +417,8 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
side(ZNEG_RT, tex[2]);
|
||||
getLight(0, 1);
|
||||
side(ZNEG_LT, tex[3]);
|
||||
|
||||
post(ForgeDirection.NORTH);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -364,17 +427,20 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) {
|
||||
IIcon i = rendererOld.overrideBlockTexture;
|
||||
|
||||
tessellator.addVertexWithUV(0.0, 1.0, 1.0, i.getMinU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(0.0, 0.0, 1.0, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(1.0, 0.0, 1.0, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(1.0, 1.0, 1.0, i.getMaxU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(renderMinX, renderMaxY, renderMaxZ, i.getMinU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(renderMinX, renderMinY, renderMaxZ, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(renderMaxX, renderMinY, renderMaxZ, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(renderMaxX, renderMaxY, renderMaxZ, i.getMaxU(), i.getMinV());
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 3);
|
||||
|
||||
pre(ForgeDirection.SOUTH);
|
||||
|
||||
fillLightmap(brightnessBottomLeft, brightnessBottomRight, brightnessTopRight, brightnessTopLeft);
|
||||
fillColormap(colorRedBottomLeft, colorRedBottomRight, colorRedTopRight, colorRedTopLeft, redmap);
|
||||
fillColormap(colorGreenBottomLeft, colorGreenBottomRight, colorGreenTopRight, colorGreenTopLeft, grnmap);
|
||||
fillColormap(colorBlueBottomLeft, colorBlueBottomRight, colorBlueTopRight, colorBlueTopLeft, blumap);
|
||||
|
||||
getLight(0, 0);
|
||||
side(ZPOS_LB, tex[0]);
|
||||
getLight(1, 0);
|
||||
@@ -383,6 +449,8 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
side(ZPOS_RT, tex[2]);
|
||||
getLight(0, 1);
|
||||
side(ZPOS_LT, tex[3]);
|
||||
|
||||
post(ForgeDirection.SOUTH);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,17 +459,20 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) {
|
||||
IIcon i = rendererOld.overrideBlockTexture;
|
||||
|
||||
tessellator.addVertexWithUV(0.0, 0.0, 1.0, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(0.0, 0.0, 0.0, i.getMinU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(1.0, 0.0, 0.0, i.getMaxU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(1.0, 0.0, 1.0, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(renderMinX, renderMinY, renderMaxZ, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(renderMinX, renderMinY, renderMinZ, i.getMinU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(renderMaxX, renderMinY, renderMinZ, i.getMaxU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(renderMaxX, renderMinY, renderMaxZ, i.getMaxU(), i.getMaxV());
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 0);
|
||||
|
||||
pre(ForgeDirection.DOWN);
|
||||
|
||||
fillLightmap(brightnessBottomLeft, brightnessBottomRight, brightnessTopRight, brightnessTopLeft);
|
||||
fillColormap(colorRedBottomLeft, colorRedBottomRight, colorRedTopRight, colorRedTopLeft, redmap);
|
||||
fillColormap(colorGreenBottomLeft, colorGreenBottomRight, colorGreenTopRight, colorGreenTopLeft, grnmap);
|
||||
fillColormap(colorBlueBottomLeft, colorBlueBottomRight, colorBlueTopRight, colorBlueTopLeft, blumap);
|
||||
|
||||
getLight(0, 0);
|
||||
side(YNEG_LB, tex[0]);
|
||||
getLight(1, 0);
|
||||
@@ -410,6 +481,8 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
side(YNEG_RT, tex[2]);
|
||||
getLight(0, 1);
|
||||
side(YNEG_LT, tex[3]);
|
||||
|
||||
post(ForgeDirection.DOWN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,17 +491,20 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) {
|
||||
IIcon i = rendererOld.overrideBlockTexture;
|
||||
|
||||
tessellator.addVertexWithUV(0.0, 1.0, 0.0, i.getMinU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(0.0, 1.0, 1.0, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(1.0, 1.0, 1.0, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(1.0, 1.0, 0.0, i.getMaxU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(renderMinX, renderMaxY, renderMinZ, i.getMinU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(renderMinX, renderMaxY, renderMaxZ, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(renderMaxX, renderMaxY, renderMaxZ, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(renderMaxX, renderMaxY, renderMinZ, i.getMaxU(), i.getMinV());
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 1);
|
||||
|
||||
pre(ForgeDirection.UP);
|
||||
|
||||
fillLightmap(brightnessTopRight, brightnessTopLeft, brightnessBottomLeft, brightnessBottomRight);
|
||||
fillColormap(colorRedTopRight, colorRedTopLeft, colorRedBottomLeft, colorRedBottomRight, redmap);
|
||||
fillColormap(colorGreenTopRight, colorGreenTopLeft, colorGreenBottomLeft, colorGreenBottomRight, grnmap);
|
||||
fillColormap(colorBlueTopRight, colorBlueTopLeft, colorBlueBottomLeft, colorBlueBottomRight, blumap);
|
||||
|
||||
getLight(0, 0);
|
||||
side(YPOS_LB, tex[0]);
|
||||
getLight(1, 0);
|
||||
@@ -437,6 +513,16 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
side(YPOS_RT, tex[2]);
|
||||
getLight(0, 1);
|
||||
side(YPOS_LT, tex[3]);
|
||||
|
||||
post(ForgeDirection.UP);
|
||||
}
|
||||
}
|
||||
|
||||
protected void pre(ForgeDirection face) {
|
||||
manager.preRenderSide(this, blockAccess, bx, by, bz, face);
|
||||
}
|
||||
|
||||
protected void post(ForgeDirection face) {
|
||||
manager.postRenderSide(this, blockAccess, bx, by, bz, face);
|
||||
}
|
||||
}
|
||||
+6
-4
@@ -1,4 +1,4 @@
|
||||
package com.cricketcraft.chisel.api.client;
|
||||
package com.cricketcraft.chisel.api.rendering;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -79,9 +79,11 @@ public class TextureSubmap {
|
||||
*/
|
||||
@SubscribeEvent
|
||||
public final void TexturesStitched(TextureStitchEvent.Post event) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
icons[x][y] = new TextureVirtual(getBaseIcon(), width, height, x, y);
|
||||
for (TextureSubmap ts : submaps) {
|
||||
for (int x = 0; x < ts.width; x++) {
|
||||
for (int y = 0; y < ts.height; y++) {
|
||||
ts.icons[x][y] = new TextureVirtual(ts.getBaseIcon(), ts.width, ts.height, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,436 @@
|
||||
package com.cricketcraft.chisel.api.rendering;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
|
||||
import com.cricketcraft.chisel.client.render.RenderBlocksColumn;
|
||||
|
||||
/**
|
||||
* Handles all default {@link ISubmapManager} behavior
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public enum TextureType {
|
||||
|
||||
// @formatter:off
|
||||
TOPSIDE("top", "side") {
|
||||
@Override
|
||||
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
|
||||
return new IIcon[]{
|
||||
register.registerIcon(modName + ":" + texturePath + "-side"),
|
||||
register.registerIcon(modName + ":" + texturePath + "-top")
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
|
||||
IIcon[] icons = (IIcon[]) cachedObject;
|
||||
return side > 1 ? icons[0] : icons[1];
|
||||
}
|
||||
},
|
||||
TOPBOTSIDE("top", "bottom", "side"){
|
||||
@Override
|
||||
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
|
||||
return new IIcon[]{
|
||||
register.registerIcon(modName + ":" + texturePath + "-side"),
|
||||
register.registerIcon(modName + ":" + texturePath + "-bottom"),
|
||||
register.registerIcon(modName + ":" + texturePath + "-top")
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
|
||||
IIcon[] icons = (IIcon[]) cachedObject;
|
||||
return side > 1 ? icons[0] : icons[side + 1];
|
||||
}
|
||||
},
|
||||
CTMV("ctmv", "top"){
|
||||
@Override
|
||||
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
|
||||
return Pair.of(new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-ctmv"), 2, 2), register.registerIcon(modName + ":" + texturePath + "-top"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
|
||||
Pair<TextureSubmap, IIcon> data = (Pair<TextureSubmap, IIcon>) cachedObject;
|
||||
return side < 2 ? data.getRight() : data.getLeft().getSubIcon(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) {
|
||||
Pair<IIcon, TextureSubmap> data = (Pair<IIcon, TextureSubmap>) cachedObject;
|
||||
if (side < 2)
|
||||
return data.getLeft();
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
boolean topConnected = ctm.isConnected(world, x, y + 1, z, side, block, meta);
|
||||
boolean botConnected = ctm.isConnected(world, x, y - 1, z, side, block, meta);
|
||||
|
||||
TextureSubmap map = data.getRight();
|
||||
if (topConnected && botConnected)
|
||||
return map.getSubIcon(0, 1);
|
||||
if (topConnected && !botConnected)
|
||||
return map.getSubIcon(1, 1);
|
||||
if (!topConnected && botConnected)
|
||||
return map.getSubIcon(1, 0);
|
||||
return map.getSubIcon(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RenderBlocks createRenderContext(RenderBlocks rendererOld, IBlockAccess world, Object cachedObject) {
|
||||
RenderBlocksColumn ret = theRenderBlocksColumn;
|
||||
Pair<IIcon, TextureSubmap> data = (Pair<IIcon, TextureSubmap>) cachedObject;
|
||||
|
||||
ret.blockAccess = world;
|
||||
ret.renderMaxX = 1.0;
|
||||
ret.renderMaxY = 1.0;
|
||||
ret.renderMaxZ = 1.0;
|
||||
|
||||
ret.submap = data.getRight();
|
||||
ret.iconTop = data.getLeft();
|
||||
return ret;
|
||||
}
|
||||
},
|
||||
CTMH("ctmh", "top"){
|
||||
@Override
|
||||
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
|
||||
return Pair.of(new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-ctmh"), 2, 2), register.registerIcon(modName + ":" + texturePath + "-top"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
|
||||
return CTMV.getIcon(variation, cachedObject, side, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) {
|
||||
Pair<IIcon, TextureSubmap> data = (Pair<IIcon, TextureSubmap>) cachedObject;
|
||||
if (side < 2)
|
||||
return data.getLeft();
|
||||
|
||||
Block block = ctm.getBlockOrFacade(world, x, y, z, side);
|
||||
|
||||
boolean p;
|
||||
boolean n;
|
||||
boolean reverse = side == 2 || side == 5;
|
||||
|
||||
if (side < 4) {
|
||||
p = ctm.isConnected(world, x - 1, y, z, side, block, meta);
|
||||
n = ctm.isConnected(world, x + 1, y, z, side, block, meta);
|
||||
} else {
|
||||
p = ctm.isConnected(world, x, y, z - 1, side, block, meta);
|
||||
n = ctm.isConnected(world, x, y, z + 1, side, block, meta);
|
||||
}
|
||||
|
||||
TextureSubmap map = data.getRight();
|
||||
if (p && n)
|
||||
return map.getSubIcon(1, 0);
|
||||
else if (p)
|
||||
return map.getSubIcon(reverse ? 0 : 1, 1);
|
||||
else if (n)
|
||||
return map.getSubIcon(reverse ? 0 : 1, 1);
|
||||
return map.getSubIcon(0, 0);
|
||||
}
|
||||
},
|
||||
V9("v9"){
|
||||
@Override
|
||||
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
|
||||
return new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-v9"), 3, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
|
||||
return ((TextureSubmap)cachedObject).getSubIcon(1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) {
|
||||
int variationSize = (this == TextureType.V9) ? 3 : 2;
|
||||
TextureSubmap map = (TextureSubmap) cachedObject;
|
||||
|
||||
int xModulus = x % variationSize;
|
||||
int zModulus = z % variationSize;
|
||||
//This ensures that blocks placed near 0,0 or it's axis' do not misbehave
|
||||
int textureX = (xModulus < 0) ? (xModulus + variationSize) : xModulus;
|
||||
int textureZ = (zModulus < 0) ? (zModulus + variationSize) : zModulus;
|
||||
//Always invert the y index
|
||||
int textureY = (variationSize - (y % variationSize) - 1);
|
||||
|
||||
if (side == 2 || side == 5) {
|
||||
//For WEST, SOUTH reverse the indexes for both X and Z
|
||||
textureX = (variationSize - textureX - 1);
|
||||
textureZ = (variationSize - textureZ - 1);
|
||||
} /*else if (side == 0) {
|
||||
//For DOWN, reverse the indexes for only Z
|
||||
textureZ = (variationSize - textureZ - 1);
|
||||
}*/
|
||||
|
||||
int index;
|
||||
if (side == 0 || side == 1) {
|
||||
// DOWN || UP
|
||||
index = textureX + textureZ * variationSize;
|
||||
} else if (side == 2 || side == 3) {
|
||||
// NORTH || SOUTH
|
||||
index = textureX + textureY * variationSize;
|
||||
} else {
|
||||
// WEST || EAST
|
||||
index = textureZ + textureY * variationSize;
|
||||
}
|
||||
|
||||
return map.getSubIcon(index % variationSize, index / variationSize);
|
||||
}
|
||||
},
|
||||
V4("v4"){
|
||||
@Override
|
||||
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
|
||||
return new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-v4"), 3, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
|
||||
return ((TextureSubmap)cachedObject).getSubIcon(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) {
|
||||
return V9.getIcon(variation, cachedObject, world, x, y, z, side, meta);
|
||||
}
|
||||
},
|
||||
CTMX("", "ctm"){
|
||||
@Override
|
||||
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
|
||||
IIcon baseIcon = register.registerIcon(modName + ":" + texturePath);
|
||||
return Triple.of(
|
||||
baseIcon,
|
||||
new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-ctm"), 4, 4),
|
||||
new TextureSubmap(baseIcon, 2, 2)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
|
||||
return ((Triple<IIcon, ?, ?>)cachedObject).getLeft();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RenderBlocks createRenderContext(RenderBlocks rendererOld, IBlockAccess world, Object cachedObject) {
|
||||
RenderBlocksCTM ret = theRenderBlocksCTM;
|
||||
Triple<?, TextureSubmap, TextureSubmap> data = (Triple<?, TextureSubmap, TextureSubmap>) cachedObject;
|
||||
ret.blockAccess = world;
|
||||
ret.renderMaxX = 1.0;
|
||||
ret.renderMaxY = 1.0;
|
||||
ret.renderMaxZ = 1.0;
|
||||
|
||||
ret.submap = data.getMiddle();
|
||||
ret.submapSmall = data.getRight();
|
||||
|
||||
ret.rendererOld = rendererOld;
|
||||
return ret;
|
||||
}
|
||||
},
|
||||
R16("r16"){
|
||||
@Override
|
||||
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
|
||||
return new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-r16"), 4, 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
|
||||
return V9.getIcon(variation, cachedObject, side, meta);
|
||||
}
|
||||
},
|
||||
R9("r9"){
|
||||
@Override
|
||||
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
|
||||
return new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-r9"), 3, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
|
||||
return V9.getIcon(variation, cachedObject, side, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) {
|
||||
return R4.getIcon(variation, cachedObject, side, meta);
|
||||
}
|
||||
},
|
||||
R4("r4"){
|
||||
|
||||
@Override
|
||||
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
|
||||
return new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-r4"), 2, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
|
||||
return V4.getIcon(variation, cachedObject, side, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) {
|
||||
rand.setSeed(x + y + z + side);
|
||||
rand.nextBoolean();
|
||||
int size = this == TextureType.R4 ? 2 : 3;
|
||||
return ((TextureSubmap)cachedObject).getSubIcon(rand.nextInt(size), rand.nextInt(size));
|
||||
}
|
||||
},
|
||||
NORMAL,
|
||||
CUSTOM;
|
||||
|
||||
private static final TextureType[] VALUES;
|
||||
private static final CTM ctm = CTM.getInstance();
|
||||
private static final Random rand = new Random();
|
||||
private static final RenderBlocksCTM theRenderBlocksCTM = new RenderBlocksCTM();
|
||||
private static final RenderBlocksColumn theRenderBlocksColumn = new RenderBlocksColumn();
|
||||
|
||||
private String[] suffixes;
|
||||
static {
|
||||
VALUES = ArrayUtils.subarray(values(), 0, values().length - 1);
|
||||
}
|
||||
|
||||
private TextureType(String... suffixes) {
|
||||
this.suffixes = suffixes.length == 0 ? new String[] { "" } : suffixes;
|
||||
}
|
||||
|
||||
public ISubmapManager<RenderBlocks> createManagerFor(ICarvingVariation variation, String texturePath) {
|
||||
return new SubmapManagerDefault(this, variation, texturePath);
|
||||
}
|
||||
|
||||
public ISubmapManager<RenderBlocks> createManagerFor(ICarvingVariation variation, Block block, int meta) {
|
||||
return new SubmapManagerExistingIcon(this, variation, block, meta);
|
||||
}
|
||||
|
||||
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
|
||||
return register.registerIcon(modName + ":" + texturePath);
|
||||
}
|
||||
|
||||
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
|
||||
return (IIcon) cachedObject;
|
||||
}
|
||||
|
||||
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) {
|
||||
return getIcon(variation, cachedObject, side, meta);
|
||||
}
|
||||
|
||||
protected RenderBlocks createRenderContext(RenderBlocks rendererOld, IBlockAccess world, Object cachedObject) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static TextureType getTypeFor(CarvableHelper inst, String modid, String path) {
|
||||
if (path == null) {
|
||||
return CUSTOM;
|
||||
}
|
||||
for (TextureType t : VALUES) {
|
||||
boolean matches = true;
|
||||
for (String s : t.suffixes) {
|
||||
if (!exists(modid, path, s.isEmpty() ? s : "-" + s)) {
|
||||
matches = false;
|
||||
}
|
||||
}
|
||||
if (matches) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
return CUSTOM;
|
||||
}
|
||||
|
||||
// This is ugly, but faster than class.getResource
|
||||
private static boolean exists(String modid, String path, String postfix) {
|
||||
ResourceLocation rl = new ResourceLocation(modid, "textures/blocks/" + path + postfix + ".png");
|
||||
try {
|
||||
Minecraft.getMinecraft().getResourceManager().getAllResources(rl);
|
||||
return true;
|
||||
} catch (Throwable t) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private abstract static class SubmapManagerBase<T extends RenderBlocks> implements ISubmapManager<T> {
|
||||
protected final TextureType type;
|
||||
protected ICarvingVariation variation;
|
||||
protected Object cachedObject;
|
||||
|
||||
private SubmapManagerBase(TextureType type, ICarvingVariation variation) {
|
||||
this.type = type;
|
||||
this.variation = variation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return type.getIcon(variation, cachedObject, side, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return type.getIcon(variation, cachedObject, world, x, y, z, side, world.getBlockMetadata(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public T createRenderContext(RenderBlocks rendererOld, IBlockAccess world) {
|
||||
return (T) type.createRenderContext(rendererOld, world, cachedObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
}
|
||||
}
|
||||
|
||||
private static class SubmapManagerDefault extends SubmapManagerBase<RenderBlocks> {
|
||||
|
||||
private String texturePath;
|
||||
|
||||
private SubmapManagerDefault(TextureType type, ICarvingVariation variation, String texturePath) {
|
||||
super(type, variation);
|
||||
this.texturePath = texturePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(String modName, Block block, IIconRegister register) {
|
||||
cachedObject = type.registerIcons(variation, modName, texturePath, register);
|
||||
}
|
||||
}
|
||||
|
||||
private static class SubmapManagerExistingIcon extends SubmapManagerBase<RenderBlocks> {
|
||||
|
||||
private Block block;
|
||||
private int meta;
|
||||
|
||||
private SubmapManagerExistingIcon(TextureType type, ICarvingVariation variation, Block block, int meta) {
|
||||
super(type, variation);
|
||||
this.block = block;
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return block.getIcon(side, this.meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return getIcon(side, world.getBlockMetadata(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(String modName, Block block, IIconRegister register) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
@API(apiVersion = ChiselAPIProps.VERSION, owner = "Chisel", provides = "ChiselAPI|Rendering")
|
||||
package com.cricketcraft.chisel.api.rendering;
|
||||
|
||||
import com.cricketcraft.chisel.api.ChiselAPIProps;
|
||||
|
||||
import cpw.mods.fml.common.API;
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.init.ChiselTabs;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
@@ -16,7 +11,15 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import java.util.List;
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
import com.cricketcraft.chisel.api.rendering.ClientUtils;
|
||||
import com.cricketcraft.chisel.init.ChiselTabs;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockCarvable extends Block implements ICarvable {
|
||||
|
||||
@@ -32,7 +35,7 @@ public class BlockCarvable extends Block implements ICarvable {
|
||||
if (m == Material.rock || m == Material.iron) {
|
||||
setHarvestLevel("pickaxe", 0);
|
||||
}
|
||||
carverHelper = new CarvableHelper();
|
||||
carverHelper = new CarvableHelper(this);
|
||||
setResistance(10.0F);
|
||||
setHardness(2.0F);
|
||||
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
|
||||
@@ -76,16 +79,16 @@ public class BlockCarvable extends Block implements ICarvable {
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return Chisel.renderCTMId;
|
||||
return ClientUtils.renderCTMId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
public IVariationInfo getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(ItemStack stack) {
|
||||
public IVariationInfo getVariation(ItemStack stack) {
|
||||
return carverHelper.getVariation(stack.getItemDamage());
|
||||
}
|
||||
|
||||
|
||||
@@ -4,30 +4,14 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
|
||||
public class BlockCarvableAntiBlock extends BlockCarvableColor implements ICarvable {
|
||||
|
||||
public CarvableHelper carverHelper;
|
||||
|
||||
public BlockCarvableAntiBlock() {
|
||||
super(Material.rock);
|
||||
carverHelper = new CarvableHelper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return Chisel.renderCTMNoLightId;
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
@Override
|
||||
public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) {
|
||||
return false;
|
||||
|
||||
+10
-10
@@ -11,17 +11,17 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
import com.cricketcraft.chisel.api.rendering.ClientUtils;
|
||||
|
||||
public class BlockMarbleCarpet extends BlockCarpet implements ICarvable {
|
||||
public class BlockCarvableCarpet extends BlockCarpet implements ICarvable {
|
||||
|
||||
public CarvableHelper carverHelper;
|
||||
|
||||
public BlockMarbleCarpet(Material m) {
|
||||
carverHelper = new CarvableHelper();
|
||||
public BlockCarvableCarpet(Material m) {
|
||||
carverHelper = new CarvableHelper(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,19 +48,19 @@ public class BlockMarbleCarpet extends BlockCarpet implements ICarvable {
|
||||
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
|
||||
carverHelper.registerSubBlocks(this, tabs, list);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return Chisel.renderCarpetId;
|
||||
return ClientUtils.renderCTMId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
public IVariationInfo getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(ItemStack stack) {
|
||||
public IVariationInfo getVariation(ItemStack stack) {
|
||||
return carverHelper.getVariation(stack.getItemDamage());
|
||||
}
|
||||
}
|
||||
@@ -11,10 +11,10 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
import com.cricketcraft.chisel.api.rendering.ClientUtils;
|
||||
import com.cricketcraft.chisel.init.ChiselTabs;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -28,7 +28,7 @@ public class BlockCarvableGlass extends BlockGlass implements ICarvable {
|
||||
public BlockCarvableGlass() {
|
||||
super(Material.glass, false);
|
||||
|
||||
carverHelper = new CarvableHelper();
|
||||
carverHelper = new CarvableHelper(this);
|
||||
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class BlockCarvableGlass extends BlockGlass implements ICarvable {
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return Chisel.renderCTMId;
|
||||
return ClientUtils.renderCTMId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,12 +73,12 @@ public class BlockCarvableGlass extends BlockGlass implements ICarvable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
public IVariationInfo getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(ItemStack stack) {
|
||||
public IVariationInfo getVariation(ItemStack stack) {
|
||||
return carverHelper.getVariation(stack.getItemDamage());
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
|
||||
public class BlockCarvableIce extends BlockIce implements ICarvable {
|
||||
|
||||
@@ -24,7 +24,7 @@ public class BlockCarvableIce extends BlockIce implements ICarvable {
|
||||
|
||||
public BlockCarvableIce() {
|
||||
super();
|
||||
carverHelper = new CarvableHelper();
|
||||
carverHelper = new CarvableHelper(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,12 +58,12 @@ public class BlockCarvableIce extends BlockIce implements ICarvable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
public IVariationInfo getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(ItemStack stack) {
|
||||
public IVariationInfo getVariation(ItemStack stack) {
|
||||
return carverHelper.getVariation(stack.getItemDamage());
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.util.Facing;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -6,7 +6,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.init.ChiselBlocks;
|
||||
|
||||
public class BlockCarvableIceStairs extends BlockCarvableStairs {
|
||||
|
||||
+6
-6
@@ -9,23 +9,23 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockMarbleLamp extends BlockCarvable {
|
||||
public class BlockCarvableLamp extends BlockCarvable {
|
||||
|
||||
BlockMarbleLamp blockUnpowered;
|
||||
BlockMarbleLamp blockPowered;
|
||||
BlockCarvableLamp blockUnpowered;
|
||||
BlockCarvableLamp blockPowered;
|
||||
boolean powered;
|
||||
|
||||
public BlockMarbleLamp() {
|
||||
public BlockCarvableLamp() {
|
||||
super(Material.redstoneLight);
|
||||
|
||||
powered = false;
|
||||
blockUnpowered = this;
|
||||
blockPowered = new BlockMarbleLamp(this);
|
||||
blockPowered = new BlockCarvableLamp(this);
|
||||
|
||||
setHardness(0.3F);
|
||||
}
|
||||
|
||||
public BlockMarbleLamp(BlockMarbleLamp unpoweredVersion) {
|
||||
public BlockCarvableLamp(BlockCarvableLamp unpoweredVersion) {
|
||||
super(Material.redstoneLight);
|
||||
|
||||
carverHelper = unpoweredVersion.carverHelper;
|
||||
@@ -16,8 +16,8 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
|
||||
public class BlockCarvablePackedIce extends Block implements ICarvable {
|
||||
|
||||
@@ -25,7 +25,7 @@ public class BlockCarvablePackedIce extends Block implements ICarvable {
|
||||
|
||||
public BlockCarvablePackedIce() {
|
||||
super(Material.ice);
|
||||
carverHelper = new CarvableHelper();
|
||||
carverHelper = new CarvableHelper(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,12 +64,12 @@ public class BlockCarvablePackedIce extends Block implements ICarvable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
public IVariationInfo getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(ItemStack stack) {
|
||||
public IVariationInfo getVariation(ItemStack stack) {
|
||||
return carverHelper.getVariation(stack.getItemDamage());
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.init.ChiselBlocks;
|
||||
|
||||
public class BlockCarvablePackedIceStairs extends BlockCarvableStairs {
|
||||
|
||||
@@ -12,8 +12,8 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
import com.cricketcraft.chisel.client.render.RendererCTMPane;
|
||||
import com.cricketcraft.chisel.init.ChiselTabs;
|
||||
|
||||
@@ -28,7 +28,7 @@ public class BlockCarvablePane extends BlockPane implements ICarvable {
|
||||
public BlockCarvablePane(Material material, boolean drops) {
|
||||
super("", "", material, drops);
|
||||
|
||||
carverHelper = new CarvableHelper();
|
||||
carverHelper = new CarvableHelper(this);
|
||||
|
||||
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
|
||||
}
|
||||
@@ -70,12 +70,12 @@ public class BlockCarvablePane extends BlockPane implements ICarvable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
public IVariationInfo getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(ItemStack stack) {
|
||||
public IVariationInfo getVariation(ItemStack stack) {
|
||||
return carverHelper.getVariation(stack.getItemDamage());
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
import com.cricketcraft.chisel.client.render.RendererPillar;
|
||||
|
||||
public class BlockCarvablePillar extends BlockCarvable {
|
||||
@@ -32,17 +32,19 @@ public class BlockCarvablePillar extends BlockCarvable {
|
||||
|
||||
public IIcon getCtmIcon(int index, int metadata) {
|
||||
// Workaround to prevent crash with invalid meta
|
||||
CarvableVariation var = null;
|
||||
if (metadata <= carverHelper.variations.size())
|
||||
var = carverHelper.variations.get(metadata);
|
||||
IVariationInfo var = null;
|
||||
if (metadata <= carverHelper.infoList.size())
|
||||
var = carverHelper.infoList.get(metadata);
|
||||
else
|
||||
var = carverHelper.variations.get(0);
|
||||
var = carverHelper.infoList.get(0);
|
||||
return var.getSubmapManager().getIcon(0, metadata);
|
||||
|
||||
if (index >= 4)
|
||||
return var.iconTop;
|
||||
if (var.seamsCtmVert == null)
|
||||
return var.icon;
|
||||
return var.seamsCtmVert.getSubIcon(index % 2, index / 2);
|
||||
// TODO fix pillars
|
||||
// if (index >= 4)
|
||||
// return var.iconTop;
|
||||
// if (var.seamsCtmVert == null)
|
||||
// return var.icon;
|
||||
// return var.seamsCtmVert.getSubIcon(index % 2, index / 2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import com.cricketcraft.chisel.entity.EntityChiselSnowman;
|
||||
import com.cricketcraft.chisel.init.ChiselBlocks;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockPumpkin;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
@@ -10,15 +8,16 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
import com.cricketcraft.chisel.entity.EntityChiselSnowman;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockCarvablePumpkin extends BlockPumpkin implements ICarvable {
|
||||
|
||||
@@ -34,7 +33,7 @@ public class BlockCarvablePumpkin extends BlockPumpkin implements ICarvable {
|
||||
this.setStepSound(Block.soundTypeWood);
|
||||
if (isOn)
|
||||
setLightLevel(10.0F);
|
||||
carverHelper = new CarvableHelper();
|
||||
carverHelper = new CarvableHelper(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,12 +111,12 @@ public class BlockCarvablePumpkin extends BlockPumpkin implements ICarvable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
public IVariationInfo getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(ItemStack stack) {
|
||||
public IVariationInfo getVariation(ItemStack stack) {
|
||||
return carverHelper.getVariation(stack.getItemDamage());
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,9 @@ import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
import com.cricketcraft.chisel.api.rendering.ClientUtils;
|
||||
import com.cricketcraft.chisel.init.ChiselTabs;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -27,7 +28,7 @@ public class BlockCarvableSand extends BlockSand implements ICarvable {
|
||||
|
||||
public BlockCarvableSand() {
|
||||
super();
|
||||
carverHelper = new CarvableHelper();
|
||||
carverHelper = new CarvableHelper(this);
|
||||
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
|
||||
}
|
||||
|
||||
@@ -69,16 +70,16 @@ public class BlockCarvableSand extends BlockSand implements ICarvable {
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return Chisel.renderCTMId;
|
||||
return ClientUtils.renderCTMId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
public IVariationInfo getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(ItemStack stack) {
|
||||
public IVariationInfo getVariation(ItemStack stack) {
|
||||
return carverHelper.getVariation(stack.getItemDamage());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,9 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import static net.minecraftforge.common.util.ForgeDirection.DOWN;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.UP;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockCompressedPowered;
|
||||
import net.minecraft.block.BlockFarmland;
|
||||
import net.minecraft.block.BlockHopper;
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.block.BlockSnow;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -26,6 +17,8 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import static net.minecraftforge.common.util.ForgeDirection.UP;
|
||||
|
||||
public class BlockCarvableSlab extends BlockCarvable {
|
||||
|
||||
public Block master;
|
||||
|
||||
@@ -15,8 +15,8 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
import com.cricketcraft.chisel.client.render.RendererStairs;
|
||||
|
||||
public class BlockCarvableStairs extends BlockStairs implements ICarvable {
|
||||
@@ -82,12 +82,12 @@ public class BlockCarvableStairs extends BlockStairs implements ICarvable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
public IVariationInfo getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(blockMeta + (metadata / 8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(ItemStack stack) {
|
||||
public IVariationInfo getVariation(ItemStack stack) {
|
||||
return carverHelper.getVariation(blockMeta + (stack.getItemDamage() / 8));
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,8 @@ import net.minecraft.world.World;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
import com.cricketcraft.chisel.init.ChiselTabs;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -26,7 +26,7 @@ public class BlockCarvableTorch extends BlockTorch implements ICarvable {
|
||||
|
||||
public BlockCarvableTorch(int idx, String tex) {
|
||||
super();
|
||||
carverHelper = new CarvableHelper();
|
||||
carverHelper = new CarvableHelper(this);
|
||||
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
|
||||
setLightLevel(0.9375F);
|
||||
setBlockName("torch");
|
||||
@@ -35,12 +35,12 @@ public class BlockCarvableTorch extends BlockTorch implements ICarvable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
public IVariationInfo getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(ItemStack stack) {
|
||||
public IVariationInfo getVariation(ItemStack stack) {
|
||||
return carverHelper.getVariation(stack.getItemDamage());
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -9,16 +9,16 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
|
||||
public class BlockMarbleWall extends BlockWall {
|
||||
public class BlockCarvableWall extends BlockWall {
|
||||
|
||||
CarvableHelper carverHelper;
|
||||
|
||||
public BlockMarbleWall(Block block) {
|
||||
public BlockCarvableWall(Block block) {
|
||||
super(block);
|
||||
|
||||
carverHelper = new CarvableHelper();
|
||||
carverHelper = new CarvableHelper(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -12,8 +12,8 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
|
||||
public class BlockMultiLayer extends BlockMultiLayerBase implements ICarvable {
|
||||
|
||||
@@ -22,13 +22,13 @@ public class BlockMultiLayer extends BlockMultiLayerBase implements ICarvable {
|
||||
public BlockMultiLayer(Material mat, String baseIcon) {
|
||||
super(mat, baseIcon);
|
||||
|
||||
carverHelper = new CarvableHelper();
|
||||
carverHelper = new CarvableHelper(this);
|
||||
}
|
||||
|
||||
public BlockMultiLayer(Material mat, Block block) {
|
||||
super(mat, block);
|
||||
|
||||
carverHelper = new CarvableHelper();
|
||||
carverHelper = new CarvableHelper(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,12 +54,12 @@ public class BlockMultiLayer extends BlockMultiLayerBase implements ICarvable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
public IVariationInfo getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(ItemStack stack) {
|
||||
public IVariationInfo getVariation(ItemStack stack) {
|
||||
return carverHelper.getVariation(stack.getItemDamage());
|
||||
}
|
||||
}
|
||||
@@ -21,9 +21,9 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
import com.cricketcraft.chisel.block.tileentity.TileEntityPresent;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -36,7 +36,7 @@ public class BlockPresent extends Block implements ICarvable {
|
||||
|
||||
public BlockPresent() {
|
||||
super(Material.wood);
|
||||
carverHelper = new CarvableHelper();
|
||||
carverHelper = new CarvableHelper(this);
|
||||
minX = 0.0625F;
|
||||
minZ = 0.0625F;
|
||||
maxX = 0.9375F;
|
||||
@@ -215,12 +215,12 @@ public class BlockPresent extends Block implements ICarvable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
public IVariationInfo getVariation(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(ItemStack stack) {
|
||||
public IVariationInfo getVariation(ItemStack stack) {
|
||||
return carverHelper.getVariation(stack.getItemDamage());
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import com.cricketcraft.chisel.client.GeneralChiselClient;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Random;
|
||||
import com.cricketcraft.chisel.client.GeneralChiselClient;
|
||||
|
||||
public class BlockSnakestoneObsidian extends BlockSnakestone {
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.cricketcraft.chisel.block;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
import com.cricketcraft.chisel.item.ItemCarvable;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
@@ -17,7 +17,7 @@ public class CarvableStairsMaker {
|
||||
String blockName;
|
||||
|
||||
public CarvableStairsMaker(Block base) {
|
||||
carverHelper = new CarvableHelper();
|
||||
carverHelper = new CarvableHelper(base);
|
||||
blockBase = base;
|
||||
}
|
||||
|
||||
@@ -33,10 +33,10 @@ public class CarvableStairsMaker {
|
||||
blocks[i].setBlockName("chisel." + n);
|
||||
GameRegistry.registerBlock(blocks[i], ItemCarvable.class, n);
|
||||
|
||||
for (int meta = 0; meta < 2 && i * 2 + meta < carverHelper.variations.size(); meta++) {
|
||||
CarvableVariation variation = carverHelper.variations.get(i * 2 + meta);
|
||||
for (int meta = 0; meta < 2 && i * 2 + meta < carverHelper.infoList.size(); meta++) {
|
||||
IVariationInfo info = carverHelper.infoList.get(i * 2 + meta);
|
||||
|
||||
carverHelper.registerVariation(name, variation, blocks[i], meta * 8);
|
||||
carverHelper.registerVariation(name, info);
|
||||
|
||||
GameRegistry.addRecipe(new ItemStack(blocks[i], 4, meta * 8), "* ", "** ", "***", '*', new ItemStack(blockBase, 1, i * 2 + meta));
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.cricketcraft.chisel.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
|
||||
public interface IStairsCreator {
|
||||
|
||||
|
||||
@@ -1,468 +0,0 @@
|
||||
package com.cricketcraft.chisel.carving;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockPane;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.client.CTM;
|
||||
import com.cricketcraft.chisel.api.client.ISubmapManager;
|
||||
import com.cricketcraft.chisel.api.client.TextureSubmap;
|
||||
import com.cricketcraft.chisel.compat.fmp.FMPIMC;
|
||||
import com.cricketcraft.chisel.item.ItemCarvable;
|
||||
import com.cricketcraft.chisel.utils.GeneralClient;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class CarvableHelper {
|
||||
|
||||
public enum TextureType {
|
||||
|
||||
TOPSIDE("top", "side"),
|
||||
TOPBOTSIDE("top", "bottom", "side"),
|
||||
CTMV("ctmv", "top"),
|
||||
CTMH("ctmh", "top"),
|
||||
V9("v9"),
|
||||
V4("v4"),
|
||||
CTMX("", "ctm"),
|
||||
R16("r16"),
|
||||
R9("r9"),
|
||||
R4("r4"),
|
||||
NORMAL,
|
||||
CUSTOM;
|
||||
|
||||
private static final TextureType[] VALUES;
|
||||
private String[] suffixes;
|
||||
static {
|
||||
VALUES = ArrayUtils.subarray(values(), 0, values().length - 1);
|
||||
}
|
||||
|
||||
private TextureType(String... suffixes) {
|
||||
this.suffixes = suffixes.length == 0 ? new String[] { "" } : suffixes;
|
||||
}
|
||||
|
||||
public static TextureType getTypeFor(CarvableHelper inst, String modid, String path) {
|
||||
for (TextureType t : VALUES) {
|
||||
boolean matches = true;
|
||||
for (String s : t.suffixes) {
|
||||
if (!inst.exists(modid, path, s.isEmpty() ? s : "-" + s)) {
|
||||
matches = false;
|
||||
}
|
||||
}
|
||||
if (matches) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
return CUSTOM;
|
||||
}
|
||||
}
|
||||
|
||||
private static CTM ctm = CTM.getInstance();
|
||||
|
||||
public ArrayList<CarvableVariation> variations = new ArrayList<CarvableVariation>();
|
||||
CarvableVariation[] map = new CarvableVariation[16];
|
||||
public boolean forbidChiseling = false;
|
||||
public String blockName;
|
||||
|
||||
public void addVariation(String description, int metadata, Block bb) {
|
||||
addVariation(description, metadata, null, bb, 0, Chisel.MOD_ID);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, Block bb, int blockMeta) {
|
||||
addVariation(description, metadata, null, bb, blockMeta, Chisel.MOD_ID);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, Block bb, int blockMeta, Material material) {
|
||||
addVariation(description, metadata, null, bb, blockMeta, Chisel.MOD_ID);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, String texture) {
|
||||
addVariation(description, metadata, texture, (ISubmapManager) null);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, String texture, ISubmapManager manager) {
|
||||
addVariation(description, metadata, texture, null, 0, Chisel.MOD_ID, manager);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, Block bb, String modid) {
|
||||
addVariation(description, metadata, null, bb, 0, modid);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, Block bb, int blockMeta, String modid) {
|
||||
addVariation(description, metadata, null, bb, blockMeta, modid);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, Block bb, int blockMeta, Material material, String modid) {
|
||||
addVariation(description, metadata, null, bb, blockMeta, modid);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, String texture, String modid) {
|
||||
addVariation(description, metadata, texture, null, 0, modid);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, String texture, Block block, int blockMeta, String modid) {
|
||||
addVariation(description, metadata, texture, block, blockMeta, modid, null);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, String texture, Block block, int blockMeta, String modid, ISubmapManager customManager) {
|
||||
|
||||
if (variations.size() >= 16)
|
||||
return;
|
||||
|
||||
if (blockName == null && block != null)
|
||||
blockName = block.getLocalizedName();
|
||||
else if (blockName == null && description != null)
|
||||
blockName = description;
|
||||
|
||||
CarvableVariation variation = new CarvableVariation();
|
||||
variation.setDescriptionUnloc(description);
|
||||
variation.metadata = metadata;
|
||||
variation.blockName = blockName;
|
||||
|
||||
if (texture != null && FMLCommonHandler.instance().getSide().isClient()) {
|
||||
variation.texture = texture;
|
||||
variation.type = (TextureType) TextureType.getTypeFor(this, modid, variation.texture);
|
||||
if (variation.type == TextureType.CUSTOM && customManager == null) {
|
||||
throw new IllegalArgumentException(String.format("Could not find texture %s, and no custom texture manager was provided.", texture));
|
||||
}
|
||||
variation.manager = customManager;
|
||||
} else {
|
||||
variation.block = block;
|
||||
variation.type = TextureType.TOPBOTSIDE;
|
||||
variation.blockMeta = blockMeta;
|
||||
}
|
||||
|
||||
variations.add(variation);
|
||||
map[metadata] = variation;
|
||||
}
|
||||
|
||||
// This is ugly, but faster than class.getResource
|
||||
private boolean exists(String modid, String path, String postfix) {
|
||||
ResourceLocation rl = new ResourceLocation(modid, "textures/blocks/" + path + postfix + ".png");
|
||||
try {
|
||||
Minecraft.getMinecraft().getResourceManager().getAllResources(rl);
|
||||
return true;
|
||||
} catch (Throwable t) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public CarvableVariation getVariation(int metadata) {
|
||||
if (metadata < 0 || metadata > 15)
|
||||
metadata = 0;
|
||||
|
||||
CarvableVariation variation = map[metadata];
|
||||
if (variation == null)
|
||||
return null;
|
||||
|
||||
return variation;
|
||||
}
|
||||
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
if (metadata < 0 || metadata > 15)
|
||||
metadata = 0;
|
||||
|
||||
CarvableVariation variation = map[metadata];
|
||||
if (variation == null)
|
||||
return GeneralClient.getMissingIcon();
|
||||
|
||||
switch (variation.type) {
|
||||
case NORMAL:
|
||||
return variation.icon;
|
||||
case TOPSIDE:
|
||||
if (side == 0 || side == 1)
|
||||
return variation.iconTop;
|
||||
else
|
||||
return variation.icon;
|
||||
case TOPBOTSIDE:
|
||||
if (side == 1)
|
||||
return variation.iconTop;
|
||||
else if (side == 0)
|
||||
return variation.iconBot;
|
||||
else
|
||||
return variation.icon;
|
||||
case CTMV:
|
||||
if (side < 2)
|
||||
return variation.iconTop;
|
||||
else
|
||||
return variation.seamsCtmVert.getSubIcon(0, 0);
|
||||
case CTMH:
|
||||
if (side < 2)
|
||||
return variation.iconTop;
|
||||
else
|
||||
return variation.seamsCtmVert.getSubIcon(0, 0);
|
||||
case V9:
|
||||
return variation.variations9.getSubIcon(1, 1);
|
||||
case V4:
|
||||
return variation.variations9.getSubIcon(0, 0);
|
||||
case CTMX:
|
||||
return variation.icon;
|
||||
case R16:
|
||||
return variation.variations9.getSubIcon(1, 1);
|
||||
case R9:
|
||||
return variation.variations9.getSubIcon(1, 1);
|
||||
case R4:
|
||||
return variation.variations9.getSubIcon(0, 0);
|
||||
case CUSTOM:
|
||||
return variation.manager.getIcon(side, metadata);
|
||||
}
|
||||
|
||||
return GeneralClient.getMissingIcon();
|
||||
}
|
||||
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if (metadata < 0 || metadata > 15)
|
||||
metadata = 0;
|
||||
|
||||
CarvableVariation variation = map[metadata];
|
||||
if (variation == null)
|
||||
return GeneralClient.getMissingIcon();
|
||||
|
||||
switch (variation.type) {
|
||||
case NORMAL:
|
||||
case TOPSIDE:
|
||||
case TOPBOTSIDE:
|
||||
return getIcon(side, metadata);
|
||||
case CTMV: {
|
||||
if (side < 2)
|
||||
return variation.iconTop;
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
boolean topConnected = ctm.isConnected(world, x, y + 1, z, side, block, metadata);
|
||||
boolean botConnected = ctm.isConnected(world, x, y - 1, z, side, block, metadata);
|
||||
|
||||
if (topConnected && botConnected)
|
||||
return variation.seamsCtmVert.getSubIcon(0, 1);
|
||||
if (topConnected && !botConnected)
|
||||
return variation.seamsCtmVert.getSubIcon(1, 1);
|
||||
if (!topConnected && botConnected)
|
||||
return variation.seamsCtmVert.getSubIcon(1, 0);
|
||||
return variation.seamsCtmVert.getSubIcon(0, 0);
|
||||
}
|
||||
case CTMH:
|
||||
if (side < 2)
|
||||
return variation.iconTop;
|
||||
|
||||
Block block = ctm.getBlockOrFacade(world, x, y, z, side);
|
||||
|
||||
boolean p;
|
||||
boolean n;
|
||||
boolean reverse = side == 2 || side == 5;
|
||||
|
||||
if (side < 4) {
|
||||
p = ctm.isConnected(world, x - 1, y, z, side, block, metadata);
|
||||
n = ctm.isConnected(world, x + 1, y, z, side, block, metadata);
|
||||
} else {
|
||||
p = ctm.isConnected(world, x, y, z - 1, side, block, metadata);
|
||||
n = ctm.isConnected(world, x, y, z + 1, side, block, metadata);
|
||||
}
|
||||
|
||||
if (p && n)
|
||||
return variation.seamsCtmVert.getSubIcon(1, 0);
|
||||
else if (p)
|
||||
return variation.seamsCtmVert.getSubIcon(reverse ? 0 : 1, 1);
|
||||
else if (n)
|
||||
return variation.seamsCtmVert.getSubIcon(reverse ? 0 : 1, 1);
|
||||
return variation.seamsCtmVert.getSubIcon(0, 0);
|
||||
case V9:
|
||||
case V4:
|
||||
int variationSize = (variation.type == TextureType.V9) ? 3 : 2;
|
||||
|
||||
int xModulus = x % variationSize;
|
||||
int zModulus = z % variationSize;
|
||||
//This ensures that blocks placed near 0,0 or it's axis' do not misbehave
|
||||
int textureX = (xModulus < 0) ? (xModulus + variationSize) : xModulus;
|
||||
int textureZ = (zModulus < 0) ? (zModulus + variationSize) : zModulus;
|
||||
//Always invert the y index
|
||||
int textureY = (variationSize - (y % variationSize) - 1);
|
||||
|
||||
if (side == 2 || side == 5) {
|
||||
//For WEST, SOUTH reverse the indexes for both X and Z
|
||||
textureX = (variationSize - textureX - 1);
|
||||
textureZ = (variationSize - textureZ - 1);
|
||||
} /*else if (side == 0) {
|
||||
//For DOWN, reverse the indexes for only Z
|
||||
textureZ = (variationSize - textureZ - 1);
|
||||
}//*/
|
||||
|
||||
int index;
|
||||
if (side == 0 || side == 1) {
|
||||
// DOWN || UP
|
||||
index = textureX + textureZ * variationSize;
|
||||
} else if (side == 2 || side == 3) {
|
||||
// NORTH || SOUTH
|
||||
index = textureX + textureY * variationSize;
|
||||
} else {
|
||||
// WEST || EAST
|
||||
index = textureZ + textureY * variationSize;
|
||||
}
|
||||
|
||||
return variation.variations9.getSubIcon(index % variationSize, index / variationSize);
|
||||
case CTMX:
|
||||
return variation.icon;
|
||||
case R16:
|
||||
case R9:
|
||||
case R4:
|
||||
|
||||
int indexRan = x + y + z;
|
||||
if ((side == 2) || (side == 5)) {
|
||||
indexRan = -indexRan;
|
||||
}
|
||||
while (indexRan < 0) {
|
||||
indexRan = indexRan + 10000;
|
||||
}
|
||||
int size = variation.type == TextureType.V4 ? 2 : 3;
|
||||
|
||||
// rand.setSeed(indexRan); // Broken
|
||||
|
||||
return variation.variations9.getSubIcon(indexRan % size, indexRan / size);
|
||||
case CUSTOM:
|
||||
return variation.manager.getIcon(world, x, y, z, side);
|
||||
}
|
||||
|
||||
return GeneralClient.getMissingIcon();
|
||||
}
|
||||
|
||||
public void registerAll(Block block, String name) {
|
||||
registerAll(block, name, ItemCarvable.class);
|
||||
}
|
||||
|
||||
public void registerBlock(Block block, String name) {
|
||||
registerBlock(block, name, ItemCarvable.class);
|
||||
}
|
||||
|
||||
void registerBlock(Block block, String name, Class<? extends ItemCarvable> cl) {
|
||||
block.setBlockName("chisel." + name);
|
||||
GameRegistry.registerBlock(block, cl, name);
|
||||
}
|
||||
|
||||
public void registerAll(Block block, String name, Class<? extends ItemCarvable> cl) {
|
||||
registerBlock(block, name, cl);
|
||||
registerVariations(name, block);
|
||||
}
|
||||
|
||||
public void registerVariations(String name, Block block) {
|
||||
for (CarvableVariation variation : variations) {
|
||||
registerVariation(name, variation, block, variation.metadata);
|
||||
}
|
||||
}
|
||||
|
||||
public void registerVariation(String name, CarvableVariation variation, Block block, int blockMeta) {
|
||||
|
||||
if (block.renderAsNormalBlock() || block.isOpaqueCube() || block.isNormalCube()) {
|
||||
FMPIMC.registerFMP(block, blockMeta);
|
||||
}
|
||||
|
||||
if (forbidChiseling)
|
||||
return;
|
||||
|
||||
Carving.chisel.addVariation(name, block, blockMeta, variation.metadata);
|
||||
}
|
||||
|
||||
public void registerBlockIcons(String modName, Block block, IIconRegister register) {
|
||||
for (CarvableVariation variation : variations) {
|
||||
if (variation.block != null) {
|
||||
variation.block.registerBlockIcons(register);
|
||||
|
||||
if (variation.block instanceof BlockPane) {
|
||||
variation.icon = variation.block.getBlockTextureFromSide(2);
|
||||
variation.iconTop = ((BlockPane) variation.block).getBlockTextureFromSide(0);
|
||||
variation.iconBot = ((BlockPane) variation.block).getBlockTextureFromSide(0);
|
||||
|
||||
} else {
|
||||
switch (variation.type) {
|
||||
case NORMAL:
|
||||
variation.icon = variation.block.getIcon(2, variation.blockMeta);
|
||||
break;
|
||||
case TOPSIDE:
|
||||
variation.icon = variation.block.getIcon(2, variation.blockMeta);
|
||||
variation.iconTop = variation.block.getIcon(0, variation.blockMeta);
|
||||
break;
|
||||
case TOPBOTSIDE:
|
||||
variation.icon = variation.block.getIcon(2, variation.blockMeta);
|
||||
variation.iconTop = variation.block.getIcon(1, variation.blockMeta);
|
||||
variation.iconBot = variation.block.getIcon(0, variation.blockMeta);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch (variation.type) {
|
||||
case NORMAL:
|
||||
variation.icon = register.registerIcon(modName + ":" + variation.texture);
|
||||
break;
|
||||
case TOPSIDE:
|
||||
variation.icon = register.registerIcon(modName + ":" + variation.texture + "-side");
|
||||
variation.iconTop = register.registerIcon(modName + ":" + variation.texture + "-top");
|
||||
break;
|
||||
case TOPBOTSIDE:
|
||||
variation.icon = register.registerIcon(modName + ":" + variation.texture + "-side");
|
||||
variation.iconTop = register.registerIcon(modName + ":" + variation.texture + "-top");
|
||||
variation.iconBot = register.registerIcon(modName + ":" + variation.texture + "-bottom");
|
||||
break;
|
||||
case CTMV:
|
||||
variation.seamsCtmVert = new TextureSubmap(register.registerIcon(modName + ":" + variation.texture + "-ctmv"), 2, 2);
|
||||
variation.iconTop = register.registerIcon(modName + ":" + variation.texture + "-top");
|
||||
break;
|
||||
case CTMH:
|
||||
variation.seamsCtmVert = new TextureSubmap(register.registerIcon(modName + ":" + variation.texture + "-ctmh"), 2, 2);
|
||||
variation.iconTop = register.registerIcon(modName + ":" + variation.texture + "-top");
|
||||
break;
|
||||
case V9:
|
||||
variation.variations9 = new TextureSubmap(register.registerIcon(modName + ":" + variation.texture + "-v9"), 3, 3);
|
||||
break;
|
||||
case V4:
|
||||
variation.variations9 = new TextureSubmap(register.registerIcon(modName + ":" + variation.texture + "-v4"), 2, 2);
|
||||
break;
|
||||
case CTMX:
|
||||
variation.icon = register.registerIcon(modName + ":" + variation.texture);
|
||||
variation.submap = new TextureSubmap(register.registerIcon(modName + ":" + variation.texture + "-ctm"), 4, 4);
|
||||
variation.submapSmall = new TextureSubmap(variation.icon, 2, 2);
|
||||
break;
|
||||
case R16:
|
||||
variation.variations9 = new TextureSubmap(register.registerIcon(modName + ":" + variation.texture + "-r16"), 4, 4);
|
||||
break;
|
||||
case R9:
|
||||
variation.variations9 = new TextureSubmap(register.registerIcon(modName + ":" + variation.texture + "-r9"), 3, 3);
|
||||
break;
|
||||
case R4:
|
||||
variation.variations9 = new TextureSubmap(register.registerIcon(modName + ":" + variation.texture + "-r4"), 2, 2);
|
||||
break;
|
||||
case CUSTOM:
|
||||
variation.manager.registerIcons(modName, block, register);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void registerSubBlocks(Block block, CreativeTabs tabs, List<ItemStack> list) {
|
||||
for (CarvableVariation variation : variations) {
|
||||
list.add(new ItemStack(block, 1, variation.metadata));
|
||||
}
|
||||
}
|
||||
|
||||
public void setChiselBlockName(String name) {
|
||||
blockName = name;
|
||||
}
|
||||
|
||||
public void registerOre(String ore) {
|
||||
OreDictionary.registerOre(ore, variations.get(0).block);
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.cricketcraft.chisel.carving;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import com.cricketcraft.chisel.api.client.ISubmapManager;
|
||||
import com.cricketcraft.chisel.api.client.TextureSubmap;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper.TextureType;
|
||||
|
||||
public class CarvableVariation {
|
||||
|
||||
public String blockName;
|
||||
public String descriptionUnloc;
|
||||
public int metadata;
|
||||
public TextureType type = TextureType.NORMAL;
|
||||
|
||||
public Block block;
|
||||
public int blockMeta;
|
||||
|
||||
public String texture;
|
||||
|
||||
public IIcon icon;
|
||||
public IIcon iconBot;
|
||||
public IIcon iconTop;
|
||||
|
||||
public CarvableVariationCTM ctm;
|
||||
public TextureSubmap seamsCtmVert;
|
||||
public TextureSubmap variations9;
|
||||
|
||||
public TextureSubmap submap;
|
||||
public TextureSubmap submapSmall;
|
||||
|
||||
public ISubmapManager manager;
|
||||
|
||||
public String getDescription() {
|
||||
return I18n.format(descriptionUnloc);
|
||||
}
|
||||
|
||||
public void setDescriptionUnloc(String desc) {
|
||||
this.descriptionUnloc = desc;
|
||||
}
|
||||
|
||||
static class CarvableVariationCTM {
|
||||
|
||||
TextureSubmap seams[] = new TextureSubmap[3];
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.carving.CarvingUtils;
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingGroup;
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingRegistry;
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
|
||||
@@ -21,6 +22,10 @@ public class Carving implements ICarvingRegistry {
|
||||
|
||||
public static final ICarvingRegistry chisel = new Carving();
|
||||
public static final Carving needle = new Carving();
|
||||
|
||||
static {
|
||||
CarvingUtils.chisel = chisel;
|
||||
}
|
||||
|
||||
private Carving() {
|
||||
}
|
||||
@@ -152,7 +157,7 @@ public class Carving implements ICarvingRegistry {
|
||||
throw new NullPointerException("Cannot add variation in group " + groupName + " for null block.");
|
||||
}
|
||||
|
||||
ICarvingVariation variation = new CarvingVariation(block, metadata, order);
|
||||
ICarvingVariation variation = CarvingUtils.getDefaultVariationFor(block, metadata, order);
|
||||
addVariation(groupName, variation);
|
||||
}
|
||||
|
||||
@@ -167,7 +172,7 @@ public class Carving implements ICarvingRegistry {
|
||||
ICarvingGroup group = groups.getGroupByName(groupName);
|
||||
|
||||
if (group == null) {
|
||||
group = new CarvingGroup(groupName);
|
||||
group = CarvingUtils.getDefaultGroupFor(groupName);
|
||||
addGroup(group);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
package com.cricketcraft.chisel.carving;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import com.cricketcraft.chisel.api.carving.CarvingUtils;
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingGroup;
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class CarvingGroup implements ICarvingGroup {
|
||||
|
||||
private String name;
|
||||
private String sound;
|
||||
private String oreName;
|
||||
|
||||
private List<ICarvingVariation> variations = Lists.newArrayList();
|
||||
|
||||
public CarvingGroup(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<ICarvingVariation> getVariations() {
|
||||
return Lists.newArrayList(variations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addVariation(ICarvingVariation variation) {
|
||||
variations.add(variation);
|
||||
Collections.sort(variations, new Comparator<ICarvingVariation>() {
|
||||
|
||||
@Override
|
||||
public int compare(ICarvingVariation o1, ICarvingVariation o2) {
|
||||
return CarvingUtils.compare(o1, o2);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeVariation(ICarvingVariation variation) {
|
||||
ICarvingVariation toRemove = null;
|
||||
for (ICarvingVariation v : variations) {
|
||||
if (v.getBlock() == variation.getBlock() && v.getBlockMeta() == variation.getBlockMeta()) {
|
||||
toRemove = v;
|
||||
}
|
||||
}
|
||||
return toRemove == null ? false : variations.remove(toRemove);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSound() {
|
||||
return sound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSound(String sound) {
|
||||
this.sound = sound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOreName() {
|
||||
return oreName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOreName(String oreName) {
|
||||
this.oreName = oreName;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.cricketcraft.chisel.carving;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
|
||||
|
||||
public class CarvingVariation implements ICarvingVariation {
|
||||
|
||||
private int order;
|
||||
private Block block;
|
||||
private int meta;
|
||||
private int damage;
|
||||
|
||||
public CarvingVariation(Block block, int metadata, int ord) {
|
||||
this.order = ord;
|
||||
this.block = block;
|
||||
this.meta = metadata;
|
||||
this.damage = metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemMeta() {
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return order;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BlockCarpetRenderer extends RendererCTM {
|
||||
|
||||
public BlockCarpetRenderer() {
|
||||
super();
|
||||
|
||||
Chisel.renderCarpetId = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
rendererCTM = new RenderBlocksCTMCarpet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return Chisel.renderCarpetId;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class RenderBlocksCTMCarpet extends RenderBlocksCTM {
|
||||
|
||||
RenderBlocksCTMCarpet() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon) {
|
||||
rendererOld.renderFaceXNeg(block, 0, 0, 0, submapSmall.getBaseIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon) {
|
||||
rendererOld.renderFaceXPos(block, 0, 0, 0, submapSmall.getBaseIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon) {
|
||||
rendererOld.renderFaceZNeg(block, 0, 0, 0, submapSmall.getBaseIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon) {
|
||||
rendererOld.renderFaceZPos(block, 0, 0, 0, submapSmall.getBaseIcon());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,310 +0,0 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import com.cricketcraft.chisel.api.client.CTM;
|
||||
import com.cricketcraft.chisel.api.client.TextureSubmap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
// TODO rewrite this to use the updated RenderBlocksCTM code
|
||||
public class RenderBlocksCTMFullbright extends RenderBlocks {
|
||||
|
||||
private static CTM ctm = CTM.getInstance();
|
||||
|
||||
RenderBlocksCTMFullbright() {
|
||||
super();
|
||||
resetVertices();
|
||||
}
|
||||
|
||||
Tessellator tessellator;
|
||||
double[] X = new double[26];
|
||||
double[] Y = new double[26];
|
||||
double[] Z = new double[26];
|
||||
double[] U = new double[26];
|
||||
double[] V = new double[26];
|
||||
TextureSubmap submap;
|
||||
TextureSubmap submapSmall;
|
||||
RenderBlocks rendererOld;
|
||||
|
||||
int bx, by, bz;
|
||||
|
||||
@Override
|
||||
public boolean renderStandardBlock(Block block, int x, int y, int z) {
|
||||
bx = x;
|
||||
by = y;
|
||||
bz = z;
|
||||
|
||||
tessellator = Tessellator.instance;
|
||||
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
|
||||
|
||||
tessellator.addTranslation(x, y, z);
|
||||
|
||||
boolean res = super.renderStandardBlock(block, x, y, z);
|
||||
|
||||
tessellator.addTranslation(-x, -y, -z);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void side(int a, int b, int c, int d, int iconIndex, boolean flip) {
|
||||
IIcon icon;
|
||||
TextureSubmap map;
|
||||
if (iconIndex >= 16) {
|
||||
iconIndex -= 16;
|
||||
map = submapSmall;
|
||||
} else {
|
||||
map = submap;
|
||||
}
|
||||
int x = iconIndex % map.getWidth();
|
||||
int y = iconIndex / map.getHeight();
|
||||
icon = map.getSubIcon(x, y);
|
||||
|
||||
double u0 = icon.getMaxU();
|
||||
double u1 = icon.getMinU();
|
||||
double v0 = icon.getMaxV();
|
||||
double v1 = icon.getMinV();
|
||||
|
||||
U[a] = flip ? u1 : u1;
|
||||
U[b] = flip ? u0 : u1;
|
||||
U[c] = flip ? u0 : u0;
|
||||
U[d] = flip ? u1 : u0;
|
||||
|
||||
V[a] = flip ? v1 : v1;
|
||||
V[b] = flip ? v1 : v0;
|
||||
V[c] = flip ? v0 : v0;
|
||||
V[d] = flip ? v0 : v1;
|
||||
|
||||
vert(a);
|
||||
vert(b);
|
||||
vert(c);
|
||||
vert(d);
|
||||
}
|
||||
|
||||
void vert(int index) {
|
||||
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
|
||||
tessellator.setBrightness(0xF000F0);
|
||||
tessellator.addVertexWithUV(X[index], Y[index], Z[index], U[index], V[index]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon) {
|
||||
if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) {
|
||||
IIcon i = rendererOld.overrideBlockTexture;
|
||||
|
||||
tessellator.addVertexWithUV(0.0, 1.0, 0.0, i.getMinU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(0.0, 0.0, 0.0, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(0.0, 0.0, 1.0, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(0.0, 1.0, 1.0, i.getMaxU(), i.getMinV());
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 4);
|
||||
|
||||
side(1, 14, 9, 23, tex[0], false);
|
||||
side(23, 9, 17, 5, tex[1], false);
|
||||
side(9, 19, 4, 17, tex[3], false);
|
||||
side(14, 0, 19, 9, tex[2], false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon) {
|
||||
if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) {
|
||||
IIcon i = rendererOld.overrideBlockTexture;
|
||||
|
||||
tessellator.addVertexWithUV(1.0, 1.0, 1.0, i.getMaxU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(1.0, 0.0, 1.0, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(1.0, 0.0, 0.0, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(1.0, 1.0, 0.0, i.getMinU(), i.getMinV());
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 5);
|
||||
|
||||
side(11, 21, 3, 15, tex[3], false);
|
||||
side(16, 7, 21, 11, tex[2], false);
|
||||
side(25, 11, 15, 2, tex[1], false);
|
||||
side(6, 16, 11, 25, tex[0], false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon) {
|
||||
if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) {
|
||||
IIcon i = rendererOld.overrideBlockTexture;
|
||||
|
||||
tessellator.addVertexWithUV(1.0, 1.0, 0.0, i.getMaxU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(1.0, 0.0, 0.0, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(0.0, 0.0, 0.0, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(0.0, 1.0, 0.0, i.getMinU(), i.getMinV());
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 2);
|
||||
|
||||
side(2, 15, 8, 22, tex[0], false);
|
||||
side(15, 3, 18, 8, tex[2], false);
|
||||
side(8, 18, 0, 14, tex[3], false);
|
||||
side(22, 8, 14, 1, tex[1], false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon) {
|
||||
if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) {
|
||||
IIcon i = rendererOld.overrideBlockTexture;
|
||||
|
||||
tessellator.addVertexWithUV(0.0, 1.0, 1.0, i.getMinU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(0.0, 0.0, 1.0, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(1.0, 0.0, 1.0, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(1.0, 1.0, 1.0, i.getMaxU(), i.getMinV());
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 3);
|
||||
|
||||
side(17, 4, 20, 10, tex[2], false);
|
||||
side(5, 17, 10, 24, tex[0], false);
|
||||
side(24, 10, 16, 6, tex[1], false);
|
||||
side(10, 20, 7, 16, tex[3], false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon) {
|
||||
if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) {
|
||||
IIcon i = rendererOld.overrideBlockTexture;
|
||||
|
||||
tessellator.addVertexWithUV(0.0, 0.0, 1.0, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(0.0, 0.0, 0.0, i.getMinU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(1.0, 0.0, 0.0, i.getMaxU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(1.0, 0.0, 1.0, i.getMaxU(), i.getMaxV());
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 0);
|
||||
|
||||
side(13, 21, 7, 20, tex[3], true);
|
||||
side(19, 13, 20, 4, tex[2], true);
|
||||
side(0, 18, 13, 19, tex[0], true);
|
||||
side(18, 3, 21, 13, tex[1], true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceYPos(Block block, double x, double y, double z, IIcon icon) {
|
||||
if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) {
|
||||
IIcon i = rendererOld.overrideBlockTexture;
|
||||
|
||||
tessellator.addVertexWithUV(0.0, 1.0, 0.0, i.getMinU(), i.getMinV());
|
||||
tessellator.addVertexWithUV(0.0, 1.0, 1.0, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(1.0, 1.0, 1.0, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(1.0, 1.0, 0.0, i.getMaxU(), i.getMinV());
|
||||
} else {
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 1);
|
||||
|
||||
side(12, 24, 6, 25, tex[3], false);
|
||||
side(22, 12, 25, 2, tex[1], false);
|
||||
side(1, 23, 12, 22, tex[0], false);
|
||||
side(23, 5, 24, 12, tex[2], false);
|
||||
}
|
||||
}
|
||||
|
||||
void resetVertices() {
|
||||
X[0] = 0;
|
||||
Z[0] = 0;
|
||||
Y[0] = 0;
|
||||
|
||||
X[1] = 0;
|
||||
Z[1] = 0;
|
||||
Y[1] = 1;
|
||||
|
||||
X[2] = 1;
|
||||
Z[2] = 0;
|
||||
Y[2] = 1;
|
||||
|
||||
X[3] = 1;
|
||||
Z[3] = 0;
|
||||
Y[3] = 0;
|
||||
|
||||
X[4] = 0;
|
||||
Z[4] = 1;
|
||||
Y[4] = 0;
|
||||
|
||||
X[5] = 0;
|
||||
Z[5] = 1;
|
||||
Y[5] = 1;
|
||||
|
||||
X[6] = 1;
|
||||
Z[6] = 1;
|
||||
Y[6] = 1;
|
||||
|
||||
X[7] = 1;
|
||||
Z[7] = 1;
|
||||
Y[7] = 0;
|
||||
|
||||
X[8] = 0.5;
|
||||
Z[8] = 0;
|
||||
Y[8] = 0.5;
|
||||
|
||||
X[9] = 0;
|
||||
Z[9] = 0.5;
|
||||
Y[9] = 0.5;
|
||||
|
||||
X[10] = 0.5;
|
||||
Z[10] = 1;
|
||||
Y[10] = 0.5;
|
||||
|
||||
X[11] = 1;
|
||||
Z[11] = 0.5;
|
||||
Y[11] = 0.5;
|
||||
|
||||
X[12] = 0.5;
|
||||
Z[12] = 0.5;
|
||||
Y[12] = 1;
|
||||
|
||||
X[13] = 0.5;
|
||||
Z[13] = 0.5;
|
||||
Y[13] = 0;
|
||||
|
||||
X[14] = 0;
|
||||
Z[14] = 0;
|
||||
Y[14] = 0.5;
|
||||
|
||||
X[15] = 1;
|
||||
Z[15] = 0;
|
||||
Y[15] = 0.5;
|
||||
|
||||
X[16] = 1;
|
||||
Z[16] = 1;
|
||||
Y[16] = 0.5;
|
||||
|
||||
X[17] = 0;
|
||||
Z[17] = 1;
|
||||
Y[17] = 0.5;
|
||||
|
||||
X[18] = 0.5;
|
||||
Z[18] = 0;
|
||||
Y[18] = 0;
|
||||
|
||||
X[19] = 0;
|
||||
Z[19] = 0.5;
|
||||
Y[19] = 0;
|
||||
|
||||
X[20] = 0.5;
|
||||
Z[20] = 1;
|
||||
Y[20] = 0;
|
||||
|
||||
X[21] = 1;
|
||||
Z[21] = 0.5;
|
||||
Y[21] = 0;
|
||||
|
||||
X[22] = 0.5;
|
||||
Z[22] = 0;
|
||||
Y[22] = 1;
|
||||
|
||||
X[23] = 0;
|
||||
Z[23] = 0.5;
|
||||
Y[23] = 1;
|
||||
|
||||
X[24] = 0.5;
|
||||
Z[24] = 1;
|
||||
Y[24] = 1;
|
||||
|
||||
X[25] = 1;
|
||||
Z[25] = 0.5;
|
||||
Y[25] = 1;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import com.cricketcraft.chisel.api.client.CTM;
|
||||
import com.cricketcraft.chisel.api.client.TextureSubmap;
|
||||
import com.cricketcraft.chisel.api.rendering.CTM;
|
||||
import com.cricketcraft.chisel.api.rendering.TextureSubmap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
@@ -10,12 +10,13 @@ import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class RenderBlocksColumn extends RenderBlocks {
|
||||
|
||||
TextureSubmap submap;
|
||||
IIcon iconTop;
|
||||
IIcon sides[] = new IIcon[6];
|
||||
CTM ctm = CTM.getInstance();
|
||||
public TextureSubmap submap;
|
||||
public IIcon iconTop;
|
||||
|
||||
private IIcon sides[] = new IIcon[6];
|
||||
private CTM ctm = CTM.getInstance();
|
||||
|
||||
RenderBlocksColumn() {
|
||||
public RenderBlocksColumn() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,11 @@ import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper.TextureType;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
import com.cricketcraft.chisel.api.rendering.ClientUtils;
|
||||
import com.cricketcraft.chisel.api.rendering.ISubmapManager;
|
||||
import com.cricketcraft.chisel.api.rendering.RenderBlocksCTM;
|
||||
import com.cricketcraft.chisel.utils.Drawing;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
@@ -21,8 +22,8 @@ public class RendererCTM implements ISimpleBlockRenderingHandler {
|
||||
RenderBlocksColumn rendererColumn = new RenderBlocksColumn();
|
||||
|
||||
public RendererCTM() {
|
||||
if (Chisel.renderCTMId == 0) {
|
||||
Chisel.renderCTMId = RenderingRegistry.getNextAvailableRenderId();
|
||||
if (ClientUtils.renderCTMId == 0) {
|
||||
ClientUtils.renderCTMId = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,44 +34,26 @@ public class RendererCTM implements ISimpleBlockRenderingHandler {
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks rendererOld) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
CarvableVariation var = ((ICarvable) block).getVariation(world, x, y, z, meta);
|
||||
|
||||
if (rendererOld.hasOverrideBlockTexture()) {
|
||||
// breaking anim
|
||||
rendererOld.renderStandardBlock(block, x, y, z);
|
||||
return true;
|
||||
IVariationInfo var = ((ICarvable) block).getVariation(world, x, y, z, meta);
|
||||
|
||||
if (!rendererOld.hasOverrideBlockTexture() && var != null) {
|
||||
RenderBlocks rb = var.getSubmapManager().createRenderContext(rendererOld, world);
|
||||
if (rb != null && rb != rendererOld) {
|
||||
rb.blockAccess = world;
|
||||
if (rb instanceof RenderBlocksCTM) {
|
||||
((RenderBlocksCTM)rb).manager = (ISubmapManager<RenderBlocksCTM>) var.getSubmapManager();
|
||||
((RenderBlocksCTM)rb).rendererOld = rendererOld;
|
||||
}
|
||||
return rb.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
switch (var == null ? TextureType.NORMAL : var.type) {
|
||||
case CTMX:
|
||||
rendererCTM.blockAccess = world;
|
||||
rendererCTM.renderMaxX = 1.0;
|
||||
rendererCTM.renderMaxY = 1.0;
|
||||
rendererCTM.renderMaxZ = 1.0;
|
||||
|
||||
rendererCTM.submap = var.submap;
|
||||
rendererCTM.submapSmall = var.submapSmall;
|
||||
|
||||
rendererCTM.rendererOld = rendererOld;
|
||||
|
||||
return rendererCTM.renderStandardBlock(block, x, y, z);
|
||||
case CTMV:
|
||||
rendererColumn.blockAccess = world;
|
||||
rendererColumn.renderMaxX = 1.0;
|
||||
rendererColumn.renderMaxY = 1.0;
|
||||
rendererColumn.renderMaxZ = 1.0;
|
||||
|
||||
rendererColumn.submap = var.seamsCtmVert;
|
||||
rendererColumn.iconTop = var.iconTop;
|
||||
|
||||
return rendererColumn.renderStandardBlock(block, x, y, z);
|
||||
default:
|
||||
return rendererOld.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
return rendererOld.renderStandardBlock(block, x, y, z) || rendererOld.hasOverrideBlockTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,7 +63,6 @@ public class RendererCTM implements ISimpleBlockRenderingHandler {
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return Chisel.renderCTMId;
|
||||
return ClientUtils.renderCTMId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper.TextureType;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.utils.Drawing;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class RendererCTMFullbright implements ISimpleBlockRenderingHandler {
|
||||
|
||||
public RenderBlocksCTMFullbright rendererCTMNoLight = new RenderBlocksCTMFullbright();
|
||||
|
||||
public RendererCTMFullbright() {
|
||||
if (Chisel.renderCTMNoLightId == 0) {
|
||||
Chisel.renderCTMNoLightId = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
Drawing.drawBlock(block, metadata, renderer);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks rendererOld) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
CarvableVariation var = ((ICarvable) block).getVariation(world, x, y, z, meta);
|
||||
|
||||
if (var != null && var.type == TextureType.CTMX) {
|
||||
rendererCTMNoLight.blockAccess = world;
|
||||
rendererCTMNoLight.renderMaxX = 1.0;
|
||||
rendererCTMNoLight.renderMaxY = 1.0;
|
||||
rendererCTMNoLight.renderMaxZ = 1.0;
|
||||
|
||||
rendererCTMNoLight.submap = var.submap;
|
||||
rendererCTMNoLight.submapSmall = var.submapSmall;
|
||||
|
||||
rendererCTMNoLight.rendererOld = rendererOld;
|
||||
|
||||
return rendererCTMNoLight.renderStandardBlock(block, x, y, z);
|
||||
} else {
|
||||
return rendererOld.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int renderId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return Chisel.renderCTMNoLightId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,8 +6,8 @@ import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.cricketcraft.chisel.api.rendering.TextureType;
|
||||
import com.cricketcraft.chisel.block.BlockCarvablePillar;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper.TextureType;
|
||||
import com.cricketcraft.chisel.utils.Drawing;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
@@ -39,6 +39,7 @@ public class RendererPillar implements ISimpleBlockRenderingHandler {
|
||||
|
||||
}
|
||||
|
||||
// TODO this is a hardcoded mess...icon decisions should be left to the ISubmapManager, not here
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block blck, int modelId, RenderBlocks renderer) {
|
||||
if (!(blck instanceof BlockCarvablePillar))
|
||||
@@ -49,10 +50,10 @@ public class RendererPillar implements ISimpleBlockRenderingHandler {
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
|
||||
// Probably not the best way to handle this...
|
||||
if (metadata >= block.carverHelper.variations.size()) {
|
||||
if (metadata >= block.carverHelper.infoList.size()) {
|
||||
metadata = 0;
|
||||
} else {
|
||||
if (block.carverHelper.variations.get(metadata).type != TextureType.CTMV) {
|
||||
if (block.carverHelper.infoList.get(metadata).getType() != TextureType.CTMV) {
|
||||
block.sides[0] = block.carverHelper.getIcon(0, metadata);
|
||||
block.sides[1] = block.carverHelper.getIcon(1, metadata);
|
||||
block.sides[2] = block.carverHelper.getIcon(2, metadata);
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.cricketcraft.chisel.api.rendering.RenderBlocksCTM;
|
||||
import com.cricketcraft.chisel.api.rendering.TextureSubmap;
|
||||
|
||||
public class SubmapManagerAntiblock extends SubmapManagerBase<RenderBlocksCTM> {
|
||||
|
||||
private static final RenderBlocksCTM rb = new RenderBlocksCTM() {
|
||||
|
||||
@Override
|
||||
protected void fillLightmap(int bottomLeft, int bottomRight, int topRight, int topLeft) {
|
||||
int maxLight = 0xF000F0;
|
||||
super.fillLightmap(maxLight, maxLight, maxLight, maxLight);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillColormap(float bottomLeft, float bottomRight, float topRight, float topLeft, float[][] map) {
|
||||
int color = 0xFFFFFF;
|
||||
super.fillColormap(color, color, color, color, map);
|
||||
}
|
||||
};
|
||||
|
||||
private String color;
|
||||
private TextureSubmap submap, submapSmall;
|
||||
|
||||
public SubmapManagerAntiblock(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return submapSmall.getBaseIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(String modName, Block block, IIconRegister register) {
|
||||
submap = new TextureSubmap(register.registerIcon(modName + ":antiblock/" + color + "-antiBlock-ctm"), 4, 4);
|
||||
submapSmall = new TextureSubmap(register.registerIcon(modName + ":antiblock/" + color + "-antiBlock"), 2, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderBlocksCTM createRenderContext(RenderBlocks rendererOld, IBlockAccess world) {
|
||||
rb.submap = submap;
|
||||
rb.submapSmall = submapSmall;
|
||||
return rb;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.cricketcraft.chisel.api.rendering.ISubmapManager;
|
||||
|
||||
|
||||
public abstract class SubmapManagerBase<T extends RenderBlocks> implements ISubmapManager<T> {
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return getIcon(side, world.getBlockMetadata(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public T createRenderContext(RenderBlocks rendererOld, IBlockAccess world) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preRenderSide(T renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postRenderSide(T renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.cricketcraft.chisel.api.rendering.RenderBlocksCTM;
|
||||
import com.cricketcraft.chisel.api.rendering.TextureSubmap;
|
||||
|
||||
public class SubmapManagerCarpetFloor extends SubmapManagerBase<RenderBlocksCTM> {
|
||||
|
||||
private static RenderBlocksCTM rb = new RenderBlocksCTM();
|
||||
|
||||
private TextureSubmap submap;
|
||||
private TextureSubmap submapSmall;
|
||||
private String color;
|
||||
|
||||
public SubmapManagerCarpetFloor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return submapSmall.getBaseIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return getIcon(side, world.getBlockMetadata(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(String modName, Block block, IIconRegister register) {
|
||||
String path = modName + ":carpet/" + color;
|
||||
submap = new TextureSubmap(register.registerIcon(path + "-ctm"), 4, 4);
|
||||
submapSmall = new TextureSubmap(register.registerIcon(path), 2, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderBlocksCTM createRenderContext(RenderBlocks rendererOld, IBlockAccess world) {
|
||||
rb.renderMaxY = 1f / 16f;
|
||||
rb.submap = submap;
|
||||
rb.submapSmall = submapSmall;
|
||||
return rb;
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -1,18 +1,18 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.cricketcraft.chisel.api.client.CTM;
|
||||
import com.cricketcraft.chisel.api.client.ISubmapManager;
|
||||
import com.cricketcraft.chisel.api.client.TextureSubmap;
|
||||
import com.cricketcraft.chisel.api.rendering.CTM;
|
||||
import com.cricketcraft.chisel.api.rendering.TextureSubmap;
|
||||
import com.cricketcraft.chisel.init.ChiselBlocks;
|
||||
|
||||
import static com.cricketcraft.chisel.api.client.Dir.*;
|
||||
import static com.cricketcraft.chisel.api.rendering.Dir.*;
|
||||
|
||||
public class SubmapManagerFakeController implements ISubmapManager {
|
||||
public class SubmapManagerFakeController extends SubmapManagerBase<RenderBlocks> {
|
||||
|
||||
private TextureSubmap map;
|
||||
private CTM ctm = CTM.getInstance();
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.cricketcraft.chisel.api.rendering.ISubmapManager;
|
||||
import com.cricketcraft.chisel.api.rendering.RenderBlocksCTM;
|
||||
import com.cricketcraft.chisel.api.rendering.TextureSubmap;
|
||||
|
||||
public class SubmapManagerSlab implements ISubmapManager<RenderBlocksCTM> {
|
||||
|
||||
private static RenderBlocksCTM rb = new RenderBlocksCTM();
|
||||
|
||||
private TextureSubmap submap;
|
||||
private TextureSubmap submapSmall;
|
||||
private IIcon sideTexture;
|
||||
private String texture;
|
||||
|
||||
public SubmapManagerSlab(String texture) {
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return submapSmall.getBaseIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return getIcon(side, world.getBlockMetadata(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(String modName, Block block, IIconRegister register) {
|
||||
String path = modName + ":" + texture;
|
||||
submap = new TextureSubmap(register.registerIcon(path + "-ctm"), 4, 4);
|
||||
submapSmall = new TextureSubmap(register.registerIcon(path), 2, 2);
|
||||
sideTexture = register.registerIcon(path + "-side");
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderBlocksCTM createRenderContext(RenderBlocks rendererOld, IBlockAccess world) {
|
||||
rb.renderMaxY = 1f / 2f;
|
||||
rb.submap = submap;
|
||||
rb.submapSmall = submapSmall;
|
||||
return rb;
|
||||
}
|
||||
|
||||
private boolean hadOverride = false;
|
||||
|
||||
@Override
|
||||
public void preRenderSide(RenderBlocksCTM renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
if (side.ordinal() < 2 && !renderer.rendererOld.hasOverrideBlockTexture()) {
|
||||
renderer.rendererOld.setOverrideBlockTexture(sideTexture);
|
||||
hadOverride = false;
|
||||
} else {
|
||||
hadOverride = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postRenderSide(RenderBlocksCTM renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
if (!hadOverride) {
|
||||
renderer.rendererOld.clearOverrideBlockTexture();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.cricketcraft.chisel.config;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.Features;
|
||||
import com.cricketcraft.chisel.api.client.CTM;
|
||||
import com.cricketcraft.chisel.api.rendering.CTM;
|
||||
|
||||
import net.minecraft.item.ItemDye;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
@@ -91,7 +91,7 @@ public class Configurations {
|
||||
particlesTickrate = config.get(category, "particleTickrate", 1, "Particle tick rate. Greater value = less particles.").getInt(1);
|
||||
oldPillars = config.get(category, "pillarOldGraphics", false, "Use old pillar textures").getBoolean(false);
|
||||
disableCTM = !config.get(category, "connectedTextures", true, "Enable connected textures").getBoolean(true);
|
||||
CTM.disableObscuredFaceCheckConfig = connectInsideCTM = !config.get(category, "connectInsideCTM", false,
|
||||
CTM.disableObscuredFaceCheckConfig = connectInsideCTM = config.get(category, "connectInsideCTM", false,
|
||||
"Choose whether the inside corner is disconnected on a CTM block - http://imgur.com/eUywLZ4").getBoolean(false);
|
||||
fancy = config.get(category, "fancyLeaves", true, "Enable fancy textures").getBoolean(true);
|
||||
blockDescriptions = config.get(category, "tooltipsUseBlockDescriptions", true, "Make variations of blocks have the same name, and use the description in tooltip to distinguish them.")
|
||||
|
||||
@@ -19,7 +19,7 @@ public final class ChiselBlocks {
|
||||
public static final BlockCarvableSlab limestone_slab = null;
|
||||
public static final BlockCarvableSlab marble_pillar_slab = null;
|
||||
public static final BlockCarvable cobblestone = null;
|
||||
public static final BlockMarbleWall cobblestoneWall = null;
|
||||
public static final BlockCarvableWall cobblestoneWall = null;
|
||||
public static final BlockCarvableGlass glass = null;
|
||||
public static final BlockCarvableGlass glass2 = null;
|
||||
public static final BlockCarvablePane glass_pane = null;
|
||||
@@ -54,7 +54,7 @@ public final class ChiselBlocks {
|
||||
public static final BlockCarvable fantasyblock = null;
|
||||
public static final BlockCarvable fantasyblock2 = null;
|
||||
public static final BlockCarvable carpet_block = null;
|
||||
public static final BlockMarbleCarpet carpet = null;
|
||||
public static final BlockCarvableCarpet carpet = null;
|
||||
public static final BlockCarvable bookshelf = null;
|
||||
public static final BlockCarvable tyrian = null;
|
||||
public static final BlockCarvable dirt = null;
|
||||
|
||||
@@ -10,7 +10,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
import com.cricketcraft.chisel.config.Configurations;
|
||||
import com.cricketcraft.chisel.utils.General;
|
||||
|
||||
@@ -47,7 +47,7 @@ public class ItemCarvable extends ItemBlock {
|
||||
return;
|
||||
|
||||
ICarvable carvable = (ICarvable) block;
|
||||
CarvableVariation var = carvable.getVariation(stack);
|
||||
IVariationInfo var = carvable.getVariation(stack);
|
||||
if (var == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.cricketcraft.chisel.item;
|
||||
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.config.Configurations;
|
||||
import com.cricketcraft.chisel.utils.General;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -12,7 +10,10 @@ import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import java.util.List;
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
import com.cricketcraft.chisel.config.Configurations;
|
||||
import com.cricketcraft.chisel.utils.General;
|
||||
|
||||
public class ItemCarvablePumpkin extends ItemBlock {
|
||||
|
||||
@@ -52,7 +53,7 @@ public class ItemCarvablePumpkin extends ItemBlock {
|
||||
return;
|
||||
|
||||
ICarvable carvable = (ICarvable) block;
|
||||
CarvableVariation var = carvable.getVariation(stack);
|
||||
IVariationInfo var = carvable.getVariation(stack);
|
||||
if (var == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -39,9 +39,7 @@ public class ClientProxy extends CommonProxy {
|
||||
RenderingRegistry.registerBlockHandler(new RendererPillar());
|
||||
RenderingRegistry.registerBlockHandler(new RendererEldritch());
|
||||
RenderingRegistry.registerBlockHandler(new RendererCTM());
|
||||
RenderingRegistry.registerBlockHandler(new BlockCarpetRenderer());
|
||||
RenderingRegistry.registerBlockHandler(new RendererLayeredGlow());
|
||||
RenderingRegistry.registerBlockHandler(new RendererCTMFullbright());
|
||||
RenderingRegistry.registerBlockHandler(new RendererSimpleLayered());
|
||||
|
||||
RenderingRegistry.registerBlockHandler(new RendererMultiLayer());
|
||||
|
||||
@@ -16,10 +16,10 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.cricketcraft.chisel.api.IAdvancedChisel;
|
||||
import com.cricketcraft.chisel.api.carving.CarvingUtils;
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
|
||||
import com.cricketcraft.chisel.api.carving.IChiselMode;
|
||||
import com.cricketcraft.chisel.carving.Carving;
|
||||
import com.cricketcraft.chisel.carving.CarvingVariation;
|
||||
import com.cricketcraft.chisel.item.chisel.ChiselMode;
|
||||
|
||||
public class General {
|
||||
@@ -143,9 +143,9 @@ public class General {
|
||||
initTag(chisel);
|
||||
chisel.stackTagCompound.setString(MODE_KEY, mode.name());
|
||||
}
|
||||
|
||||
|
||||
public static ICarvingVariation getVariation(ItemStack stack) {
|
||||
ICarvingVariation v = Carving.chisel.getVariation(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage());
|
||||
return v == null ? new CarvingVariation(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 99) : v;
|
||||
return v == null ? CarvingUtils.getDefaultVariationFor(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 99) : v;
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,6 @@ import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -19,10 +17,6 @@ public class GeneralClient {
|
||||
Minecraft.getMinecraft().theWorld.playSound(x + 0.5, y + 0.5, z + 0.5, sound, 0.3f + 0.7f * rand.nextFloat(), 0.6f + 0.4f * rand.nextFloat(), true);
|
||||
}
|
||||
|
||||
public static IIcon getMissingIcon() {
|
||||
return ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
|
||||
}
|
||||
|
||||
static HashMap<String, ResourceLocation> resources = new HashMap<String, ResourceLocation>();
|
||||
|
||||
public static void bind(String textureName) {
|
||||
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 758 B |
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 449 B |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 629 B |
Reference in new issue
Block a user