Added the utmost LP configs
This commit is contained in:
parent
a5eefd8bec
commit
6b8942730c
|
@ -1,7 +0,0 @@
|
|||
package com.cricketcraft.chisel.api;
|
||||
|
||||
public class ChiselAPIProps {
|
||||
|
||||
public static final String VERSION = "0.1.0";
|
||||
public static String MOD_ID = null; // Set by Chisel
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package com.cricketcraft.chisel.api;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
|
||||
public class FMPIMC {
|
||||
|
||||
public static void registerFMP(Block block) {
|
||||
registerFMP(block, 0, 15);
|
||||
}
|
||||
|
||||
public static void registerFMP(Block block, int minMeta, int maxMeta) {
|
||||
for (int c = minMeta; c <= maxMeta; c++) {
|
||||
registerFMP(block, c);
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerFMP(Block block, int meta) {
|
||||
FMLInterModComms.sendMessage("ForgeMicroblock", "microMaterial", new ItemStack(block, 1, meta));
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package com.cricketcraft.chisel.api;
|
||||
|
||||
import com.cricketcraft.chisel.api.carving.IChiselMode;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Implement this on chisel items which require more control over chisel modes
|
||||
* (including adding new modes).
|
||||
*/
|
||||
public interface IAdvancedChisel {
|
||||
|
||||
/**
|
||||
* Gets the next mode the button in the GUI should switch to given the
|
||||
* current mode.
|
||||
*
|
||||
* @param stack
|
||||
* The {@link ItemStack} representing the chisel
|
||||
* @param current
|
||||
* The {@link IChiselMode} that is currently active
|
||||
* @return The next {@link IChiselMode} in the loop
|
||||
*/
|
||||
public IChiselMode getNextMode(ItemStack stack, IChiselMode current);
|
||||
|
||||
/**
|
||||
* Gets an {@link IChiselMode} instance from a String name
|
||||
*
|
||||
* @param chisel
|
||||
* The {@link ItemStack} representing the chisel
|
||||
* @param name
|
||||
* The name of the {@link IChiselMode mode}
|
||||
* @return An {@link IChiselMode} that has the name {@code name}
|
||||
*/
|
||||
public IChiselMode getMode(ItemStack chisel, String name);
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package com.cricketcraft.chisel.api;
|
||||
|
||||
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.ctmlib.ICTMBlock;
|
||||
import com.cricketcraft.ctmlib.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 extends ICTMBlock<IVariationInfo> {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param metadata
|
||||
* The metadata of the block
|
||||
* @param world
|
||||
* {@link IBlockAccess} object, usually a world. Use of {@link IBlockAccess} Is necessary due to this method's use in rendering.
|
||||
* @param x
|
||||
* X coord of the block
|
||||
* @param y
|
||||
* Y coord of the block
|
||||
* @param z
|
||||
* Z coord of the block
|
||||
* @param metadata
|
||||
* The metadata of the block
|
||||
* @return The {@link ISubmapManager} that represents this block in the world.
|
||||
*/
|
||||
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata);
|
||||
|
||||
/**
|
||||
* Gets the {@link ISubmapManager} for this block when it is in item form.
|
||||
*
|
||||
* @return A {@link ISubmapManager}
|
||||
*/
|
||||
public IVariationInfo getManager(int meta);
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
package com.cricketcraft.chisel.api;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
|
||||
|
||||
/**
|
||||
* Implement this on items which can be used to chisel blocks.
|
||||
*/
|
||||
public interface IChiselItem {
|
||||
|
||||
/**
|
||||
* Checks whether the chisel can have its GUI opened
|
||||
*
|
||||
* @param world
|
||||
* {@link World} object
|
||||
* @param player
|
||||
* The player holding the chisel. It can always be assumed that the player's current item will be this.
|
||||
* @param chisel
|
||||
* The {@link ItemStack} representing your chisel
|
||||
* @return True if the GUI should open. False otherwise.
|
||||
*/
|
||||
boolean canOpenGui(World world, EntityPlayer player, ItemStack chisel);
|
||||
|
||||
/**
|
||||
* Called when an item is chiseled using this chisel
|
||||
*
|
||||
* @param world
|
||||
* {@link World} object
|
||||
* @param chisel
|
||||
* The {@link ItemStack} representing the chisel
|
||||
* @param target
|
||||
* The {@link ICarvingVariation} representing the target item
|
||||
* @return True if the chisel should be damaged. False otherwise.
|
||||
*/
|
||||
boolean onChisel(World world, ItemStack chisel, ICarvingVariation target);
|
||||
|
||||
/**
|
||||
* Called to check if this {@link ItemStack} can be chiseled in this chisel. If not, there will be no possible variants displayed in the GUI.
|
||||
* <p>
|
||||
* It is not necessary to take into account whether this item <i>has</i> any variants, this method will only be called after that check.
|
||||
*
|
||||
* @param world
|
||||
* {@link World} object
|
||||
* @param chisel
|
||||
* The {@link ItemStack} representing the chisel
|
||||
* @param target
|
||||
* The {@link ICarvingVariation} representing the target item
|
||||
* @return True if the current target can be chiseled into anything. False otherwise.
|
||||
*/
|
||||
boolean canChisel(World world, ItemStack chisel, ICarvingVariation target);
|
||||
|
||||
/**
|
||||
* Allows you to control if your item can chisel this block in the world.
|
||||
*
|
||||
* @param world
|
||||
* World object
|
||||
* @param player
|
||||
* {@link EntityPlayer The player} holding the chisel.
|
||||
* @param x
|
||||
* X coord of the block being chiseled
|
||||
* @param y
|
||||
* Y coord of the block being chiseled
|
||||
* @param z
|
||||
* Z coord of the block being chiseled
|
||||
* @param block
|
||||
* The {@link Block} being chiseled
|
||||
* @param metadata
|
||||
* The blocks' metadata
|
||||
* @return True if the chiseling should take place. False otherwise.
|
||||
*/
|
||||
boolean canChiselBlock(World world, EntityPlayer player, int x, int y, int z, Block block, int metadata);
|
||||
|
||||
/**
|
||||
* Allows you to control if your item has chiseling modes.
|
||||
*
|
||||
* @param chisel
|
||||
* The {@link ItemStack} representing the chisel.
|
||||
* @return True if the chisel supports modes. False otherwise.
|
||||
*/
|
||||
boolean hasModes(ItemStack chisel);
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package com.cricketcraft.chisel.api;
|
||||
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
/**
|
||||
* This extension of {@link IFacade} allows the block to say whether or not OTHER CTM blocks can connect to IT.
|
||||
*/
|
||||
public interface IConnectable {
|
||||
|
||||
/**
|
||||
* Determines whether other CTM blocks can connect to this one.
|
||||
*
|
||||
* @param world
|
||||
* @param x
|
||||
* The X position of the block that is connecting to this one. NOT the position of your block.
|
||||
* @param y
|
||||
* The Y position of the block that is connecting to this one. NOT the position of your block.
|
||||
* @param z
|
||||
* The Z position of the block that is connecting to this one. NOT the position of your block.
|
||||
* @param side
|
||||
* The side being drawn.
|
||||
* @return True if a block can connect to this one from the given direction. False otherwise.
|
||||
*/
|
||||
boolean canConnectCTM(IBlockAccess world, int x, int y, int z, int side);
|
||||
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package com.cricketcraft.chisel.api;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* To be implemented on blocks that "hide" another block inside, so connected textuers can still be
|
||||
* accomplished.
|
||||
*/
|
||||
public interface IFacade
|
||||
{
|
||||
/**
|
||||
* Gets the block this facade is acting as.
|
||||
*
|
||||
* @param world {@link World}
|
||||
* @param x X coord of your block
|
||||
* @param y Y coord of your block
|
||||
* @param z Z coord of your block
|
||||
* @param side The side being rendered, NOT the side being connected from.
|
||||
* <p>
|
||||
* This value can be -1 if no side is specified. Please handle this appropriately.
|
||||
* @return The block inside of your facade block.
|
||||
*/
|
||||
Block getFacade(IBlockAccess world, int x, int y, int z, int side);
|
||||
|
||||
/**
|
||||
* Gets the metadata of the block that this facade is acting as.
|
||||
*
|
||||
* @param world {@link World}
|
||||
* @param x X coord of your block
|
||||
* @param y Y coord of your block
|
||||
* @param z Z coord of your block
|
||||
* @param side The side being rendered, NOT the side being connected from.
|
||||
* <p>
|
||||
* This value can be -1 if no side is specified. Please handle this appropriately.
|
||||
* @return The metadata of your facade block.
|
||||
*/
|
||||
int getFacadeMetadata(IBlockAccess world, int x, int y, int z, int side);
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
package com.cricketcraft.chisel.api;
|
||||
|
||||
/**
|
||||
* Use the enum constants (using {@link #key} or calling {@link #toString()}) in this class as keys for IMC messages sent to chisel
|
||||
* <p>
|
||||
* It is also acceptable to copy the Strings in this class to avoid referencing this API.
|
||||
*/
|
||||
public enum IMC {
|
||||
|
||||
/**
|
||||
* Adds a variation to a group.
|
||||
*
|
||||
* Use this to add a variation to a group. String syntax:
|
||||
* <p>
|
||||
* groupname|blockname|meta
|
||||
* <p>
|
||||
* An example would be {@code "mygroup|minecraft:dirt|1"} and this will add the vanilla dirt block with metadata 1 to the "mygroup" group, creating that group if need be.
|
||||
*/
|
||||
ADD_VARIATION("variation:add"),
|
||||
|
||||
/**
|
||||
* Removes a variation from a group.
|
||||
*
|
||||
* Use this to remove a variation from a group. String syntax:
|
||||
* <p>
|
||||
* groupname|blockname|meta
|
||||
* <p>
|
||||
* An example would be {@code "mygroup|minecraft:dirt|1"} and this will add the vanilla dirt block with metadata 1 to the "mygroup" group, creating that group if need be.
|
||||
*/
|
||||
REMOVE_VARIATION("variation:remove"),
|
||||
|
||||
/**
|
||||
* Registers an oredict name to a group. This can be used to automatically add all blocks with this oredict name to a group. String syntax:
|
||||
* <p>
|
||||
* groupname|oredictname
|
||||
* <p>
|
||||
* An example would be {@code "mygroup|plankWood"} which will add all blocks registered in the oredict as "plankWood" to your group called "mygroup".
|
||||
*/
|
||||
REGISTER_GROUP_ORE("group:ore");
|
||||
|
||||
/**
|
||||
* The IMC message key for this message type.
|
||||
*/
|
||||
public final String key;
|
||||
|
||||
IMC(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package com.cricketcraft.chisel.api;
|
||||
|
||||
import net.minecraft.stats.StatBase;
|
||||
import net.minecraft.stats.StatBasic;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
|
||||
public class Statistics {
|
||||
|
||||
public static StatBase blocksChiseled = (new StatBasic("stat.blockChiseled", new ChatComponentTranslation("stat.blockChiseled", new Object[0])));
|
||||
|
||||
public static void init(){
|
||||
blocksChiseled.initIndependentStat();
|
||||
blocksChiseled.registerStat();
|
||||
}
|
||||
}
|
|
@ -1,220 +0,0 @@
|
|||
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.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.TextureType;
|
||||
import com.cricketcraft.ctmlib.ISubmapManager;
|
||||
|
||||
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 {
|
||||
|
||||
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 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) null);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, String texture, ISubmapManager manager) {
|
||||
addVariation(description, metadata, texture, null, 0, ChiselAPIProps.MOD_ID, manager, metadata);
|
||||
}
|
||||
|
||||
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, metadata);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, String texture, int order) {
|
||||
addVariation(description, metadata, texture, null, 0, ChiselAPIProps.MOD_ID, (ISubmapManager) null, order);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, String texture, Block block, int blockMeta, String modid, ISubmapManager customManager, int order) {
|
||||
|
||||
if (infoList.size() >= 16)
|
||||
return;
|
||||
|
||||
IVariationInfo info = FMLCommonHandler.instance().getSide().isClient()
|
||||
? getClientInfo(modid, texture, description, metadata, block, blockMeta, customManager, order)
|
||||
: getServerInfo(modid, texture, description, metadata, block, blockMeta, customManager, order);
|
||||
|
||||
infoList.add(info);
|
||||
infoMap[metadata] = info;
|
||||
}
|
||||
|
||||
private IVariationInfo getClientInfo(String modid, String texture, String description, int metadata, Block block, int blockMeta, ISubmapManager customManager, int order) {
|
||||
ICarvingVariation var = CarvingUtils.getDefaultVariationFor(theBlock, metadata, order);
|
||||
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));
|
||||
}
|
||||
|
||||
ISubmapManager manager;
|
||||
if (customManager != null) {
|
||||
manager = customManager;
|
||||
} else if (block != null) {
|
||||
manager = type.createManagerFor(var, block, blockMeta);
|
||||
} else {
|
||||
manager = type.createManagerFor(var, texture);
|
||||
}
|
||||
return new VariationInfoBase(var, description, manager);
|
||||
}
|
||||
|
||||
private IVariationInfo getServerInfo(String modid, String texture, String description, int metadata, Block block, int blockMeta, ISubmapManager customManager, int order) {
|
||||
ICarvingVariation var = CarvingUtils.getDefaultVariationFor(theBlock, metadata, order);
|
||||
return new VariationInfoBase(var, description, null);
|
||||
}
|
||||
|
||||
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.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.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);
|
||||
}
|
||||
|
||||
public void registerVariations(String name) {
|
||||
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());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(String modName, Block block, IIconRegister register) {
|
||||
for (IVariationInfo info : infoList) {
|
||||
info.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, theBlock);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getMissingIcon() {
|
||||
return ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
|
||||
}
|
||||
}
|
|
@ -1,175 +0,0 @@
|
|||
package com.cricketcraft.chisel.api.carving;
|
||||
|
||||
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 {
|
||||
|
||||
/**
|
||||
* A simple way to compare two {@link ICarvingVariation} objects based on the {@link ICarvingVariation#getOrder() getOrder()} method.
|
||||
*
|
||||
* @param v1
|
||||
* The first {@link ICarvingVariation variation}.
|
||||
* @param v2
|
||||
* The second {@link ICarvingVariation variation}.
|
||||
* @return A positive integer if the first's order is greater, a negative integer if the second's is greater, and 0 if they are equal.
|
||||
*/
|
||||
public static int compare(ICarvingVariation v1, ICarvingVariation v2) {
|
||||
return v1.getOrder() - v2.getOrder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an {@link ItemStack} representing the passed {@link ICarvingVariation}.
|
||||
*
|
||||
* @param variation
|
||||
* An {@link ICarvingVariation}
|
||||
* @return An {@link ItemStack}
|
||||
*/
|
||||
public static ItemStack getStack(ICarvingVariation variation) {
|
||||
return new ItemStack(variation.getBlock(), 1, variation.getItemMeta());
|
||||
}
|
||||
|
||||
public static ICarvingRegistry chisel;
|
||||
|
||||
/**
|
||||
* @return The instance of the chisel carving registry from the chisel mod.
|
||||
* <p>
|
||||
* If chisel is not installed this will return null.
|
||||
*/
|
||||
public static ICarvingRegistry getChiselRegistry() {
|
||||
return chisel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
@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,74 +0,0 @@
|
|||
package com.cricketcraft.chisel.api.carving;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a group of chiselable blocks.
|
||||
* <p>
|
||||
* This is an object that contains a collection of {@link ICarvingVariation} objects, and keeps them sorted. You may sort them in any way (or not at all), and {@link ICarvingVariation#getOrder()} will
|
||||
* likely be of use to do so.
|
||||
* <p>
|
||||
* It also defines what sound and oredict name the group as a whole has.
|
||||
*/
|
||||
public interface ICarvingGroup {
|
||||
|
||||
/**
|
||||
* The name of this group. Used for internal identification.
|
||||
*
|
||||
* @return A string name for the group
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Can return null. If null, fallback sound will be used (the standard chisel sound).
|
||||
*
|
||||
* @return The string resource path of the sound to use for chiseling items in this group
|
||||
*/
|
||||
String getSound();
|
||||
|
||||
/**
|
||||
* Sets the sound of this group
|
||||
*
|
||||
* @param sound
|
||||
* A string resource path for the sound this group makes when chiseled
|
||||
*/
|
||||
void setSound(String sound);
|
||||
|
||||
/**
|
||||
* The oredict name to match to this group. All items with this oredict name will be assumed to be part of this group.
|
||||
*
|
||||
* @return An ore dictionary name
|
||||
*/
|
||||
String getOreName();
|
||||
|
||||
/**
|
||||
* Sets the oredict name for this group.
|
||||
*
|
||||
* @param oreName
|
||||
* The String oredict name to be associated with this group.
|
||||
*/
|
||||
void setOreName(String oreName);
|
||||
|
||||
/**
|
||||
* Gets all carving variations associated with this group.
|
||||
*
|
||||
* @return A {@link List} of {@link ICarvingVariation}s
|
||||
*/
|
||||
List<ICarvingVariation> getVariations();
|
||||
|
||||
/**
|
||||
* Adds a variation to this group. Do not call this from external code, as it will fail to remove the inverse lookup from the registry.
|
||||
*
|
||||
* @param variation
|
||||
* An {@link ICarvingVariation} to add to this group
|
||||
*/
|
||||
void addVariation(ICarvingVariation variation);
|
||||
|
||||
/**
|
||||
* Removes a variation to this group. Do not call this from external code, as it will fail to remove the inverse lookup from the registry.
|
||||
*
|
||||
* @param variation
|
||||
* An {@link ICarvingVariation} to add to this group
|
||||
*/
|
||||
boolean removeVariation(ICarvingVariation variation);
|
||||
}
|
|
@ -1,204 +0,0 @@
|
|||
package com.cricketcraft.chisel.api.carving;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Represents a registry of {@link ICarvingGroup}s
|
||||
* <p>
|
||||
* To obtain chisel's instance of this class, use {@link CarvingUtils#getChiselRegistry()}
|
||||
*/
|
||||
public interface ICarvingRegistry {
|
||||
|
||||
/* Getters */
|
||||
|
||||
/**
|
||||
* Finds the group the block/meta pair belongs to in the registry.
|
||||
*
|
||||
* @param block
|
||||
* The block of the variation
|
||||
* @param meta
|
||||
* The metadata of the variation
|
||||
* @return The {@link ICarvingGroup} that the block/meta pair belongs to
|
||||
*/
|
||||
ICarvingGroup getGroup(Block block, int meta);
|
||||
|
||||
/**
|
||||
* Gets an {@link ICarvingGroup} by its name.
|
||||
*
|
||||
* @param name
|
||||
* The name of the group
|
||||
* @return An {@link ICarvingGroup}
|
||||
*/
|
||||
ICarvingGroup getGroup(String name);
|
||||
|
||||
/**
|
||||
* Gets the {@link ICarvingVariation} instance represented by this block/meta pair.
|
||||
*
|
||||
* @param block
|
||||
* The block of the variatoin
|
||||
* @param meta
|
||||
* The metadata of the variation
|
||||
* @return The {@link ICarvingVariation} containing this block/meta pair
|
||||
*/
|
||||
ICarvingVariation getVariation(Block block, int meta);
|
||||
|
||||
/**
|
||||
* Gets the list of {@link ICarvingVariation}s from the group that contains this block/meta pair.
|
||||
*
|
||||
* @param block
|
||||
* The block of the variation
|
||||
* @param meta
|
||||
* The metadata of the variation
|
||||
* @return All of the {@link ICarvingVariation}s in the group that contains this block/meta pair
|
||||
*/
|
||||
List<ICarvingVariation> getGroupVariations(Block block, int meta);
|
||||
|
||||
/**
|
||||
* Gets the oredict name for the group that contains this block/meta pair.
|
||||
*
|
||||
* @param block
|
||||
* The block of the variation
|
||||
* @param meta
|
||||
* The metadata of the variation
|
||||
* @return A string oredict name for the group
|
||||
*/
|
||||
String getOreName(Block block, int meta);
|
||||
|
||||
/**
|
||||
* Gets the possible output items for this {@link ItemStack}. To be used for machines/GUIs that chisel items.
|
||||
*
|
||||
* @param chiseled
|
||||
* The {@link ItemStack} being chiseled
|
||||
* @return A list of stacks that can be chiseled from the passed {@link ItemStack stack}
|
||||
*/
|
||||
List<ItemStack> getItemsForChiseling(ItemStack chiseled);
|
||||
|
||||
/**
|
||||
* Gets the sound resource string for the group represented by this block/meta pair.
|
||||
*
|
||||
* @param block
|
||||
* The block of the variation
|
||||
* @param metadata
|
||||
* The metadata of the variation
|
||||
* @return The string resource for the sound that can be used in {@link World#playSound(double, double, double, String, float, float, boolean)} and other methods.
|
||||
*/
|
||||
public String getVariationSound(Block block, int metadata);
|
||||
|
||||
/**
|
||||
* Gets the sound resource string for the group represented by this item/meta pair.
|
||||
* <p>
|
||||
* Mostly a convenience for calling {@link #getVariationSound(Block, int)} with {@link Block#getBlockFromItem(Item)}.
|
||||
*
|
||||
* @param item
|
||||
* The item of the variation
|
||||
* @param metadata
|
||||
* The metadata of the variation
|
||||
* @return The string resource for the sound that can be used in {@link World#playSound(double, double, double, String, float, float, boolean)} and other methods.
|
||||
*/
|
||||
public String getVariationSound(Item item, int metadata);
|
||||
|
||||
/**
|
||||
* @return A list of all registered group names, sorted alphabetically.
|
||||
*/
|
||||
List<String> getSortedGroupNames();
|
||||
|
||||
/* Setters */
|
||||
|
||||
/**
|
||||
* Adds a variation to the registry.
|
||||
*
|
||||
* @param groupName
|
||||
* The name of the group to add to.
|
||||
* @param block
|
||||
* The block of the variation
|
||||
* @param metadata
|
||||
* The metadata of the variation
|
||||
* @param order
|
||||
* The order of the variation in the list of all variations in the group. Higher numbers are sorted at the end.
|
||||
*/
|
||||
void addVariation(String groupName, Block block, int metadata, int order);
|
||||
|
||||
/**
|
||||
* Adds a variation to the registry.
|
||||
*
|
||||
* @param groupName
|
||||
* The name of the group to add to
|
||||
* @param variation
|
||||
* The {@link ICarvingVariation} to add
|
||||
*/
|
||||
void addVariation(String groupName, ICarvingVariation variation);
|
||||
|
||||
/**
|
||||
* Adds a group to the registry.
|
||||
*
|
||||
* @param group
|
||||
* The {@link ICarvingGroup} to add.
|
||||
*/
|
||||
void addGroup(ICarvingGroup group);
|
||||
|
||||
/**
|
||||
* Removes a group from the registry.
|
||||
* <p>
|
||||
* This in effect removes all variations associated with the group, though they are not explicitly removed from the object. If you maintain a reference to the {@link ICarvingGroup} that is
|
||||
* removed, it will still contain its variations.
|
||||
*
|
||||
* @param groupName
|
||||
* The name of the group to remove.
|
||||
* @return The {@link ICarvingGroup} that was removed.
|
||||
*/
|
||||
ICarvingGroup removeGroup(String groupName);
|
||||
|
||||
/**
|
||||
* Removes a varaition with the passed {@link Block} and metadata from the registry. If this variation is registered with mutiple groups, it will remove it from all of them.
|
||||
*
|
||||
* @param block
|
||||
* The {@link Block} of the {@link ICarvingVariation variation}
|
||||
* @param metadata
|
||||
* The metadata of the {@link ICarvingVariation variation}
|
||||
* @return The ICarvingVariation that was removed. Null if nothing was removed.
|
||||
*/
|
||||
ICarvingVariation removeVariation(Block block, int metadata);
|
||||
|
||||
/**
|
||||
* Removes a varaition with the passed {@link Block} and metadata from the registry, but only from the specified {@link ICarvingGroup} name.
|
||||
*
|
||||
* @param block
|
||||
* The {@link Block} of the {@link ICarvingVariation variation}
|
||||
* @param metadata
|
||||
* The metadata of the {@link ICarvingVariation variation}
|
||||
* @param group
|
||||
* The name of the group that the variation should be removed from
|
||||
* @return The ICarvingVariation that was removed. Null if nothing was removed.
|
||||
*/
|
||||
ICarvingVariation removeVariation(Block block, int metadata, String group);
|
||||
|
||||
/**
|
||||
* Registers a group to an oredict name.
|
||||
* <p>
|
||||
* Doing this means that all blocks that are registered to this oredict name will act as if they are a part of this group.
|
||||
*
|
||||
* @param groupName
|
||||
* The name of the group
|
||||
* @param oreName
|
||||
* The oredict name
|
||||
*/
|
||||
void registerOre(String groupName, String oreName);
|
||||
|
||||
/**
|
||||
* Sets the sound resource for a group.
|
||||
* <p>
|
||||
* This is the sound that is used when a block from this group is chiseled. <br/>
|
||||
* Does <i>not</i> need to be explicitly set.
|
||||
*
|
||||
* @param name
|
||||
* The name of the group
|
||||
* @param sound
|
||||
* The resource string for the sound
|
||||
*/
|
||||
void setVariationSound(String name, String sound);
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package com.cricketcraft.chisel.api.carving;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
/**
|
||||
* Represents a variation of a chiselable block.
|
||||
*/
|
||||
public interface ICarvingVariation {
|
||||
|
||||
/**
|
||||
* The base block of this variation.
|
||||
*
|
||||
* @return A {@link Block} that is the base of this variation
|
||||
*/
|
||||
Block getBlock();
|
||||
|
||||
/**
|
||||
* The metadata of this variation
|
||||
*
|
||||
* @return An int representing the metadata of this variation's {@link Block} in the world.
|
||||
*/
|
||||
int getBlockMeta();
|
||||
|
||||
/**
|
||||
* The item metadata of this variation
|
||||
*
|
||||
* @return An int representing the metadata of this variations's {@link Item}.
|
||||
*/
|
||||
int getItemMeta();
|
||||
|
||||
/**
|
||||
* The "order" of this variation. Represents its position in the list of variations held by a group.
|
||||
*
|
||||
* @return An integer to represent the position of this variation in the list of all variations in the group
|
||||
*/
|
||||
int getOrder();
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package com.cricketcraft.chisel.api.carving;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IChiselMode {
|
||||
|
||||
/**
|
||||
* NOTE: This method is responsible for increasing the "Blocks Chiseled" statistic found in the Statistics class.
|
||||
*/
|
||||
void chiselAll(EntityPlayer player, World world, int x, int y, int z, ForgeDirection side, ICarvingVariation variation);
|
||||
|
||||
/**
|
||||
* Implemented implicitly by enums. If your IChiselMode is not an enum constant, this needs to be implemented explicitly.
|
||||
*
|
||||
* @return The name of the mode.
|
||||
*/
|
||||
String name();
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package com.cricketcraft.chisel.api.carving;
|
||||
|
||||
import com.cricketcraft.chisel.api.rendering.TextureType;
|
||||
import com.cricketcraft.ctmlib.ISubmapManager;
|
||||
|
||||
public interface IVariationInfo extends ISubmapManager {
|
||||
|
||||
ICarvingVariation getVariation();
|
||||
|
||||
String getDescription();
|
||||
|
||||
TextureType getType();
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
package com.cricketcraft.chisel.api.carving;
|
||||
|
||||
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.util.StatCollector;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.cricketcraft.chisel.api.rendering.TextureType;
|
||||
import com.cricketcraft.ctmlib.ISubmapManager;
|
||||
|
||||
public class VariationInfoBase implements IVariationInfo {
|
||||
|
||||
private ICarvingVariation variation;
|
||||
private String unlocDesc;
|
||||
private ISubmapManager manager;
|
||||
private TextureType type;
|
||||
|
||||
public VariationInfoBase(ICarvingVariation variation, String unlocDesc, ISubmapManager manager) {
|
||||
this(variation, unlocDesc, manager, TextureType.CUSTOM);
|
||||
}
|
||||
|
||||
public VariationInfoBase(ICarvingVariation variation, String unlocDesc, ISubmapManager 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 TextureType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
// ISubmapManager delegation
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return manager.getIcon(side, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return manager.getIcon(world, x, y, z, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(String modName, Block block, IIconRegister register) {
|
||||
manager.registerIcons(modName, block, register);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) {
|
||||
return manager.createRenderContext(rendererOld, block, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
manager.preRenderSide(renderer, world, x, y, z, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
manager.postRenderSide(renderer, world, x, y, z, side);
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
@API(apiVersion = ChiselAPIProps.VERSION, owner = "Chisel", provides = "ChiselAPI|Carving")
|
||||
package com.cricketcraft.chisel.api.carving;
|
||||
|
||||
import com.cricketcraft.chisel.api.ChiselAPIProps;
|
||||
|
||||
import cpw.mods.fml.common.API;
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
@API(apiVersion = ChiselAPIProps.VERSION, owner = "chisel", provides = "ChiselAPI")
|
||||
package com.cricketcraft.chisel.api;
|
||||
|
||||
import cpw.mods.fml.common.API;
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
package com.cricketcraft.chisel.api.rendering;
|
||||
|
||||
|
||||
public class ClientUtils {
|
||||
|
||||
public static int renderCTMId;
|
||||
|
||||
}
|
|
@ -1,487 +0,0 @@
|
|||
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.ctmlib.CTM;
|
||||
import com.cricketcraft.ctmlib.ISubmapManager;
|
||||
import com.cricketcraft.ctmlib.RenderBlocksCTM;
|
||||
import com.cricketcraft.ctmlib.RenderBlocksColumn;
|
||||
import com.cricketcraft.ctmlib.TextureSubmap;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Handles all default {@link ISubmapManager} behavior
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "deprecation" })
|
||||
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<TextureSubmap, IIcon> data = (Pair<TextureSubmap, IIcon>) cachedObject;
|
||||
if (side < 2)
|
||||
return data.getRight();
|
||||
|
||||
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.getLeft();
|
||||
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
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected RenderBlocks createRenderContext(RenderBlocks rendererOld, IBlockAccess world, Object cachedObject) {
|
||||
RenderBlocksColumn ret = theRenderBlocksColumn;
|
||||
Pair<TextureSubmap, IIcon> data = (Pair<TextureSubmap, IIcon>) cachedObject;
|
||||
|
||||
ret.blockAccess = world;
|
||||
ret.renderMaxX = 1.0;
|
||||
ret.renderMaxY = 1.0;
|
||||
ret.renderMaxZ = 1.0;
|
||||
|
||||
ret.submap = data.getLeft();
|
||||
ret.iconTop = data.getRight();
|
||||
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<TextureSubmap, IIcon> data = (Pair<TextureSubmap, IIcon>) cachedObject;
|
||||
if (side < 2)
|
||||
return data.getRight();
|
||||
|
||||
Block block = ctm.getBlockOrFacade(world, x, y, z, side);
|
||||
|
||||
boolean p;
|
||||
boolean n;
|
||||
boolean reverse = side == 3 || side == 4;
|
||||
|
||||
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.getLeft();
|
||||
if (p && n)
|
||||
return map.getSubIcon(1, 0);
|
||||
else if (p)
|
||||
return map.getSubIcon(reverse ? 1 : 0, 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) {
|
||||
return getVIcon(this, (TextureSubmap) cachedObject, x, y, z, side);
|
||||
}
|
||||
},
|
||||
V4("v4"){
|
||||
@Override
|
||||
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
|
||||
return new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-v4"), 2, 2);
|
||||
}
|
||||
|
||||
@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 getVIcon(this, (TextureSubmap) cachedObject, x, y, z, side);
|
||||
}
|
||||
},
|
||||
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
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected RenderBlocks createRenderContext(RenderBlocks rendererOld, IBlockAccess world, Object cachedObject) {
|
||||
RenderBlocksCTM ret = theRenderBlocksCTM;
|
||||
Triple<?, TextureSubmap, TextureSubmap> data = (Triple<?, TextureSubmap, TextureSubmap>) cachedObject;
|
||||
ret.blockAccess = world;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) {
|
||||
return getRIcon(this, (TextureSubmap) cachedObject, x, y, z, side);
|
||||
}
|
||||
},
|
||||
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 getRIcon(this, (TextureSubmap) cachedObject, x, y, z, side);
|
||||
}
|
||||
},
|
||||
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) {
|
||||
return getRIcon(this, (TextureSubmap) cachedObject, x, y, z, side);
|
||||
}
|
||||
},
|
||||
NORMAL,
|
||||
CUSTOM;
|
||||
|
||||
/* Some util stuff for shared code between v* and r* */
|
||||
|
||||
public static IIcon getVIcon(TextureType type, TextureSubmap map, int x, int y, int z, int side) {
|
||||
int variationSize = (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 map.getSubIcon(index % variationSize, index / variationSize);
|
||||
}
|
||||
|
||||
public static IIcon getRIcon(TextureType type, TextureSubmap map, int x, int y, int z, int side) {
|
||||
rand.setSeed(getCoordinateRandom(x, y, z));
|
||||
rand.nextBoolean();
|
||||
int size = type == TextureType.R4 ? 2 : type == TextureType.R9 ? 3 : 4;
|
||||
return map.getSubIcon(rand.nextInt(size), rand.nextInt(size));
|
||||
}
|
||||
|
||||
private static long getCoordinateRandom(int x, int y, int z) {
|
||||
// MC 1.8 code...
|
||||
long l = (x * 3129871) ^ z * 116129781L ^ y;
|
||||
l = l * l * 42317861L + l * 11L;
|
||||
return l;
|
||||
}
|
||||
|
||||
/* End of that mess */
|
||||
|
||||
private static final TextureType[] VALUES;
|
||||
private static final CTM ctm = CTM.getInstance();
|
||||
private static final Random rand = new Random();
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static RenderBlocksCTM theRenderBlocksCTM;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static RenderBlocksColumn theRenderBlocksColumn;
|
||||
|
||||
private String[] suffixes;
|
||||
static {
|
||||
VALUES = ArrayUtils.subarray(values(), 0, values().length - 1);
|
||||
}
|
||||
|
||||
private TextureType(String... suffixes) {
|
||||
this.suffixes = suffixes.length == 0 ? new String[] { "" } : suffixes;
|
||||
}
|
||||
|
||||
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 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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected RenderBlocks createRenderContext(RenderBlocks rendererOld, IBlockAccess world, Object cachedObject) {
|
||||
return rendererOld;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract static class AbstractSubmapManager implements ISubmapManager {
|
||||
protected final TextureType type;
|
||||
protected ICarvingVariation variation;
|
||||
protected Object cachedObject;
|
||||
|
||||
private AbstractSubmapManager(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 RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) {
|
||||
initStatics();
|
||||
RenderBlocks rb = type.createRenderContext(rendererOld, world, cachedObject);
|
||||
rb.setRenderBoundsFromBlock(block);
|
||||
return rb;
|
||||
}
|
||||
|
||||
@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) {
|
||||
}
|
||||
|
||||
public Object getCachedObject() {
|
||||
return cachedObject;
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static class SubmapManagerDefault extends AbstractSubmapManager {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static class SubmapManagerExistingIcon extends AbstractSubmapManager {
|
||||
|
||||
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) {
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
@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;
|
||||
|
Loading…
Reference in a new issue