mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-12 16:27:45 +00:00
1 parent
aac68bd58e
commit
9e0b56afe1
5 files changed
+54
-17
No files matched your search
@@ -13,6 +13,7 @@ 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.carving.Carving;
|
||||
import com.cricketcraft.chisel.compat.Compatibility;
|
||||
import com.cricketcraft.chisel.compat.IMCHandler;
|
||||
import com.cricketcraft.chisel.compat.fmp.FMPCompat;
|
||||
@@ -74,6 +75,7 @@ public class Chisel {
|
||||
public Chisel() {
|
||||
ChiselAPIProps.MOD_ID = MOD_ID;
|
||||
CarvableHelper.itemCarvableClass = ItemCarvable.class;
|
||||
Carving.construct();
|
||||
}
|
||||
|
||||
@SidedProxy(clientSide = "com.cricketcraft.chisel.proxy.ClientProxy", serverSide = "com.cricketcraft.chisel.proxy.CommonProxy")
|
||||
|
||||
@@ -6,7 +6,6 @@ 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;
|
||||
@@ -21,7 +20,10 @@ 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.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class CarvableHelper {
|
||||
|
||||
@@ -37,7 +39,7 @@ public class CarvableHelper {
|
||||
this.theBlock = block;
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, ISubmapManager<? extends RenderBlocks> manager) {
|
||||
public void addVariation(String description, int metadata, ISubmapManager<?> manager) {
|
||||
addVariation(description, metadata, null, manager);
|
||||
}
|
||||
|
||||
@@ -54,10 +56,10 @@ public class CarvableHelper {
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, String texture) {
|
||||
addVariation(description, metadata, texture, (ISubmapManager<? extends RenderBlocks>) null);
|
||||
addVariation(description, metadata, texture, (ISubmapManager<?>) null);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, String texture, ISubmapManager<? extends RenderBlocks> manager) {
|
||||
public void addVariation(String description, int metadata, String texture, ISubmapManager<?> manager) {
|
||||
addVariation(description, metadata, texture, null, 0, ChiselAPIProps.MOD_ID, manager);
|
||||
}
|
||||
|
||||
@@ -81,18 +83,26 @@ public class CarvableHelper {
|
||||
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) {
|
||||
public void addVariation(String description, int metadata, String texture, Block block, int blockMeta, String modid, ISubmapManager<?> customManager) {
|
||||
|
||||
if (infoList.size() >= 16)
|
||||
return;
|
||||
|
||||
IVariationInfo info = FMLCommonHandler.instance().getSide().isClient()
|
||||
? getClientInfo(modid, texture, description, metadata, block, blockMeta, customManager)
|
||||
: getServerInfo(modid, texture, description, metadata, block, blockMeta, customManager);
|
||||
|
||||
infoList.add(info);
|
||||
infoMap[metadata] = info;
|
||||
}
|
||||
|
||||
private IVariationInfo getClientInfo(String modid, String texture, String description, int metadata, Block block, int blockMeta, ISubmapManager<?> customManager) {
|
||||
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;
|
||||
@@ -101,12 +111,13 @@ public class CarvableHelper {
|
||||
} else {
|
||||
manager = type.createManagerFor(var, texture);
|
||||
}
|
||||
info = new VariationInfoBase(var, description, manager);
|
||||
|
||||
infoList.add(info);
|
||||
infoMap[metadata] = info;
|
||||
return new VariationInfoBase(var, description, manager);
|
||||
}
|
||||
|
||||
private IVariationInfo getServerInfo(String modid, String texture, String description, int metadata, Block block, int blockMeta, ISubmapManager<?> customManager) {
|
||||
ICarvingVariation var = CarvingUtils.getDefaultVariationFor(theBlock, metadata, metadata);
|
||||
return new VariationInfoBase(var, description, null);
|
||||
}
|
||||
|
||||
|
||||
public IVariationInfo getVariation(int metadata) {
|
||||
if (metadata < 0 || metadata > 15)
|
||||
@@ -181,6 +192,7 @@ public class CarvableHelper {
|
||||
CarvingUtils.getChiselRegistry().addVariation(name, info.getVariation());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(String modName, Block block, IIconRegister register) {
|
||||
for (IVariationInfo info : infoList) {
|
||||
info.getSubmapManager().registerIcons(modName, block, register);
|
||||
@@ -197,6 +209,7 @@ public class CarvableHelper {
|
||||
OreDictionary.registerOre(ore, infoList.get(0).getVariation().getBlock());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getMissingIcon() {
|
||||
return ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ public class VariationInfoBase implements IVariationInfo {
|
||||
|
||||
private ICarvingVariation variation;
|
||||
private String unlocDesc;
|
||||
private ISubmapManager<? extends RenderBlocks> manager;
|
||||
private ISubmapManager<?> manager;
|
||||
private TextureType type;
|
||||
|
||||
public VariationInfoBase(ICarvingVariation variation, String unlocDesc, ISubmapManager<? extends RenderBlocks> manager) {
|
||||
@@ -35,7 +35,7 @@ public class VariationInfoBase implements IVariationInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISubmapManager<? extends RenderBlocks> getSubmapManager() {
|
||||
public ISubmapManager<?> getSubmapManager() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@ import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
|
||||
import com.cricketcraft.chisel.client.render.RenderBlocksColumn;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Handles all default {@link ISubmapManager} behavior
|
||||
*/
|
||||
@@ -90,6 +93,7 @@ public enum TextureType {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected RenderBlocks createRenderContext(RenderBlocks rendererOld, IBlockAccess world, Object cachedObject) {
|
||||
RenderBlocksColumn ret = theRenderBlocksColumn;
|
||||
Pair<IIcon, TextureSubmap> data = (Pair<IIcon, TextureSubmap>) cachedObject;
|
||||
@@ -226,6 +230,7 @@ public enum TextureType {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected RenderBlocks createRenderContext(RenderBlocks rendererOld, IBlockAccess world, Object cachedObject) {
|
||||
RenderBlocksCTM ret = theRenderBlocksCTM;
|
||||
Triple<?, TextureSubmap, TextureSubmap> data = (Triple<?, TextureSubmap, TextureSubmap>) cachedObject;
|
||||
@@ -294,8 +299,10 @@ public enum TextureType {
|
||||
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();
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static RenderBlocksCTM theRenderBlocksCTM;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static RenderBlocksColumn theRenderBlocksColumn;
|
||||
|
||||
private String[] suffixes;
|
||||
static {
|
||||
@@ -306,14 +313,22 @@ public enum TextureType {
|
||||
this.suffixes = suffixes.length == 0 ? new String[] { "" } : suffixes;
|
||||
}
|
||||
|
||||
public ISubmapManager<RenderBlocks> createManagerFor(ICarvingVariation variation, String texturePath) {
|
||||
private static void initStatics() {
|
||||
if (theRenderBlocksCTM == null) {
|
||||
theRenderBlocksCTM = new RenderBlocksCTM();
|
||||
theRenderBlocksColumn = new RenderBlocksColumn();
|
||||
}
|
||||
}
|
||||
|
||||
public ISubmapManager<?> createManagerFor(ICarvingVariation variation, String texturePath) {
|
||||
return new SubmapManagerDefault(this, variation, texturePath);
|
||||
}
|
||||
|
||||
public ISubmapManager<RenderBlocks> createManagerFor(ICarvingVariation variation, Block block, int meta) {
|
||||
public ISubmapManager<?> createManagerFor(ICarvingVariation variation, Block block, int meta) {
|
||||
return new SubmapManagerExistingIcon(this, variation, block, meta);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
|
||||
return register.registerIcon(modName + ":" + texturePath);
|
||||
}
|
||||
@@ -326,6 +341,7 @@ public enum TextureType {
|
||||
return getIcon(variation, cachedObject, side, meta);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected RenderBlocks createRenderContext(RenderBlocks rendererOld, IBlockAccess world, Object cachedObject) {
|
||||
return null;
|
||||
}
|
||||
@@ -359,6 +375,7 @@ public enum TextureType {
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private abstract static class SubmapManagerBase<T extends RenderBlocks> implements ISubmapManager<T> {
|
||||
protected final TextureType type;
|
||||
protected ICarvingVariation variation;
|
||||
@@ -381,6 +398,7 @@ public enum TextureType {
|
||||
|
||||
@Override
|
||||
public T createRenderContext(RenderBlocks rendererOld, IBlockAccess world) {
|
||||
initStatics();
|
||||
return (T) type.createRenderContext(rendererOld, world, cachedObject);
|
||||
}
|
||||
|
||||
@@ -393,6 +411,7 @@ public enum TextureType {
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static class SubmapManagerDefault extends SubmapManagerBase<RenderBlocks> {
|
||||
|
||||
private String texturePath;
|
||||
@@ -408,6 +427,7 @@ public enum TextureType {
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static class SubmapManagerExistingIcon extends SubmapManagerBase<RenderBlocks> {
|
||||
|
||||
private Block block;
|
||||
|
||||
@@ -26,6 +26,8 @@ public class Carving implements ICarvingRegistry {
|
||||
static {
|
||||
CarvingUtils.chisel = chisel;
|
||||
}
|
||||
|
||||
public static void construct() {}
|
||||
|
||||
private Carving() {
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user