mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-20 20:32:24 +00:00
Get rid of the ugly RenderBlocksCTMFullbright, some other refactors
This commit is contained in:
1 parent
3ae753ebc3
commit
2f6b455514
20 files changed
+215
-534
No files matched your search
@@ -36,6 +36,7 @@ public class CarvableHelper {
|
||||
public CarvableHelper(Block block) {
|
||||
this.theBlock = block;
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, ISubmapManager<? extends RenderBlocks> manager) {
|
||||
addVariation(description, metadata, null, manager);
|
||||
}
|
||||
@@ -87,18 +88,20 @@ public class CarvableHelper {
|
||||
|
||||
ICarvingVariation var = CarvingUtils.getDefaultVariationFor(theBlock, metadata, metadata);
|
||||
TextureType type = TextureType.getTypeFor(this, modid, texture);
|
||||
if (type == TextureType.CUSTOM && customManager == null) {
|
||||
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) {
|
||||
info = new VariationInfoBase(var, description, customManager);
|
||||
manager = customManager;
|
||||
} else if (block != null) {
|
||||
manager = type.createManagerFor(var, block, blockMeta);
|
||||
} else {
|
||||
info = new VariationInfoBase(var, description, type.createManagerFor(var, texture));
|
||||
manager = type.createManagerFor(var, texture);
|
||||
}
|
||||
|
||||
// TODO handling for block texture override params
|
||||
info = new VariationInfoBase(var, description, manager);
|
||||
|
||||
infoList.add(info);
|
||||
infoMap[metadata] = info;
|
||||
|
||||
@@ -311,6 +311,10 @@ public enum TextureType {
|
||||
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);
|
||||
}
|
||||
@@ -356,17 +360,14 @@ public enum TextureType {
|
||||
}
|
||||
}
|
||||
|
||||
private static class SubmapManagerDefault implements ISubmapManager<RenderBlocks> {
|
||||
|
||||
private TextureType type;
|
||||
private ICarvingVariation variation;
|
||||
private Object cachedObject;
|
||||
private String texturePath;
|
||||
private abstract static class SubmapManagerBase<T extends RenderBlocks> implements ISubmapManager<T> {
|
||||
protected final TextureType type;
|
||||
protected ICarvingVariation variation;
|
||||
protected Object cachedObject;
|
||||
|
||||
private SubmapManagerDefault(TextureType type, ICarvingVariation variation, String texturePath) {
|
||||
private SubmapManagerBase(TextureType type, ICarvingVariation variation) {
|
||||
this.type = type;
|
||||
this.variation = variation;
|
||||
this.texturePath = texturePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -378,15 +379,10 @@ public enum TextureType {
|
||||
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 void registerIcons(String modName, Block block, IIconRegister register) {
|
||||
cachedObject = type.registerIcons(variation, modName, texturePath, register);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderBlocks createRenderContext(RenderBlocks rendererOld, IBlockAccess world) {
|
||||
return type.createRenderContext(rendererOld, world, cachedObject);
|
||||
public T createRenderContext(RenderBlocks rendererOld, IBlockAccess world) {
|
||||
return (T) type.createRenderContext(rendererOld, world, cachedObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -397,4 +393,45 @@ public enum TextureType {
|
||||
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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user