mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-16 18:55:06 +00:00
Repackage to team.chisel (excepting API)
This commit is contained in:
1 parent
7555e21144
commit
9574e05c29
132 files changed
+526
-596
No files matched your search
@@ -0,0 +1,108 @@
|
||||
package team.chisel;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import team.chisel.utils.General;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class BlockNameConversion {
|
||||
|
||||
static final private HashMap<String, String> namingConversion = new HashMap<String, String>();
|
||||
|
||||
public static class NameConversions {
|
||||
|
||||
public final static int MAX = 5;
|
||||
|
||||
protected static String conversion(String oldname, int step) {
|
||||
oldname = General.cleanTags(oldname);
|
||||
String newname = null;
|
||||
switch (step) {
|
||||
case 0: // lookup list
|
||||
return namingConversion.get(oldname);
|
||||
case 1: // remove Chisel:
|
||||
if (oldname.startsWith("Chisel:")) {
|
||||
newname = oldname.replaceAll("(?i)" + "Chisel:", "");
|
||||
}
|
||||
return newname;
|
||||
case 2: // rename "marbleSlab" -> "marble_slab", "redstone" ->
|
||||
// "redstone_block"
|
||||
newname = oldname.replaceAll("([a-z]+)([A-Z])", "$1_$2").toLowerCase();
|
||||
|
||||
if (newname.startsWith("block_")) {
|
||||
newname = newname.replaceFirst("block_([a-z_]+)", "$1_block");
|
||||
} else if (newname.startsWith("snakestone_")) {
|
||||
newname = newname.replaceFirst("snakestone_([a-z_]+)", "$1_snakestone");
|
||||
}
|
||||
return newname;
|
||||
case 3: // rename "wood-dark-oak" -> "dark_oak_planks"
|
||||
newname = oldname.replaceAll("([a-z]+)([A-Z])", "$1_$2").toLowerCase().replace('-', '_');
|
||||
if (newname.contains("wood_")) {
|
||||
newname = newname.replaceFirst("wood_([a-z_]+)", "$1_planks");
|
||||
}
|
||||
return newname;
|
||||
case (MAX - 1): // ALWAYS last: rename "blockYxx" -> "yxx" (e.g.
|
||||
// "dirt" -> "dirt").
|
||||
// This can be dangerous in cases like "carpet" (a block) ->
|
||||
// "carpet" (NO block)
|
||||
return oldname.replaceAll("([a-z]+)([A-Z])", "$1_$2").toLowerCase().replaceFirst("block_", "");
|
||||
default:
|
||||
throw new IndexOutOfBoundsException("conversion got invalid parameter step=" + step);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static public void init() {
|
||||
namingConversion.put("blockCobble", "cobblestone");
|
||||
namingConversion.put("iron", "iron_block");
|
||||
namingConversion.put("gold", "gold_block");
|
||||
namingConversion.put("diamond", "diamond_block");
|
||||
namingConversion.put("lightstone", "glowstone");
|
||||
namingConversion.put("lapis", "lapis_block");
|
||||
namingConversion.put("emerald", "emerald_block");
|
||||
namingConversion.put("hellrock", "netherrack");
|
||||
namingConversion.put("stoneMoss", "mossy_cobblestone");
|
||||
namingConversion.put("stoneBrick", "stonebrick");
|
||||
namingConversion.put("fenceIron", "iron_bars");
|
||||
namingConversion.put("fantasy", "fantasyblock");
|
||||
namingConversion.put("carpetFloor", "carpet");
|
||||
namingConversion.put("temple", "templeblock");
|
||||
namingConversion.put("templeMossy", "mossy_templeblock");
|
||||
namingConversion.put("factory", "factoryblock");
|
||||
namingConversion.put("laboratory", "laboratoryblock");
|
||||
// "LightGray" is unfortunately converted to "light_gray"
|
||||
namingConversion.put("stainedGlassLightGray", "stained_glass_lightgray");
|
||||
namingConversion.put("stainedGlassPaneLightGray", "stained_glass_pane_lightgray");
|
||||
namingConversion.put("blockTemple", "templeblock");
|
||||
namingConversion.put("stoneBrick", "stonebricksmooth");
|
||||
namingConversion.put("blockTempleMossy", "mossy_templeblock");
|
||||
namingConversion.put("blockFactory", "factoryblock");
|
||||
namingConversion.put("blockFft", "fantasyblock");
|
||||
namingConversion.put("blockCarpetFloor", "carpet");
|
||||
namingConversion.put("blockLaboratory", "laboratoryblock");
|
||||
}
|
||||
|
||||
public static Item findItem(String oldname) {
|
||||
FMLLog.getLogger().trace("[Chisel 2] findItem() START " + oldname);
|
||||
Item item = null;
|
||||
for (int i = 0; i < NameConversions.MAX && item == null; i++) {
|
||||
FMLLog.getLogger().trace("[Chisel 2] findItem() Checking for " + NameConversions.conversion(oldname, i));
|
||||
item = GameRegistry.findItem(Chisel.MOD_ID, NameConversions.conversion(oldname, i));
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public static Block findBlock(String oldname) {
|
||||
FMLLog.getLogger().trace("[Chisel 2] findBlock() START: " + oldname);
|
||||
Block block = null;
|
||||
for (int i = 0; i < NameConversions.MAX && block == null; i++) {
|
||||
FMLLog.getLogger().trace("[Chisel 2] findBlock() Checking for " + NameConversions.conversion(oldname, i));
|
||||
block = GameRegistry.findBlock(Chisel.MOD_ID, NameConversions.conversion(oldname, i));
|
||||
}
|
||||
|
||||
return block;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
package team.chisel;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
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.Statistics;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
|
||||
import team.chisel.block.BlockCarvable;
|
||||
import team.chisel.carving.Carving;
|
||||
import team.chisel.compat.Compatibility;
|
||||
import team.chisel.compat.IMCHandler;
|
||||
import team.chisel.compat.fmp.FMPCompat;
|
||||
import team.chisel.config.Configurations;
|
||||
import team.chisel.entity.EntityChiselSnowman;
|
||||
import team.chisel.init.ChiselBlocks;
|
||||
import team.chisel.init.ChiselTabs;
|
||||
import team.chisel.item.ItemCarvable;
|
||||
import team.chisel.item.chisel.ChiselController;
|
||||
import team.chisel.network.ChiselGuiHandler;
|
||||
import team.chisel.network.PacketHandler;
|
||||
import team.chisel.proxy.CommonProxy;
|
||||
import team.chisel.utils.General;
|
||||
import team.chisel.world.GeneratorChisel;
|
||||
import cpw.mods.fml.client.event.ConfigChangedEvent;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
|
||||
import cpw.mods.fml.common.event.FMLMissingMappingsEvent.MissingMapping;
|
||||
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;
|
||||
|
||||
@Mod(modid = Chisel.MOD_ID, name = Chisel.MOD_NAME, version = Chisel.VERSION, guiFactory = "com.cricketcraft.chisel.client.gui.GuiFactory", dependencies = "after:EE3;after:ForgeMultipart;after:Thaumcraft;after:appliedenergistics2;after:Railcraft;after:AWWayofTime;after:TwilightForest")
|
||||
public class Chisel {
|
||||
|
||||
public static final String MOD_ID = "chisel";
|
||||
public static final BlockCarvable.SoundType soundTempleFootstep = new BlockCarvable.SoundType("dig.stone", MOD_ID + ":step.templeblock", 1.0f, 1.0f);
|
||||
public static final String MOD_NAME = "Chisel 2";
|
||||
public static final String VERSION = "@VERSION@";
|
||||
public static final BlockCarvable.SoundType soundHolystoneFootstep = new BlockCarvable.SoundType("holystone", 1.0f, 1.0f);
|
||||
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 renderAutoChiselId;
|
||||
public static int renderGlowId;
|
||||
public static int renderLayeredId;
|
||||
public static int roadLineId;
|
||||
|
||||
public static final Logger logger = LogManager.getLogger(MOD_NAME);
|
||||
|
||||
@Instance(MOD_ID)
|
||||
public static Chisel instance;
|
||||
|
||||
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")
|
||||
public static CommonProxy proxy;
|
||||
|
||||
@EventHandler
|
||||
public void missingMapping(FMLMissingMappingsEvent event) {
|
||||
BlockNameConversion.init();
|
||||
|
||||
for (MissingMapping m : event.get()) {
|
||||
// This bug was introduced along with Chisel 1.5.2, and was fixed in
|
||||
// 1.5.3.
|
||||
// Ice Stairs were called null.0-7 instead of other names, and
|
||||
// Marble/Limestone stairs did not exist.
|
||||
// This fixes the bug.
|
||||
if (m.name.startsWith("null.") && m.name.length() == 6 && m.type == Type.BLOCK) {
|
||||
m.warn();// (Action.WARN);
|
||||
}
|
||||
|
||||
// Fix mapping of snakestoneSand, snakestoneStone, limestoneStairs,
|
||||
// marbleStairs when loading an old (1.5.4) save
|
||||
else if (m.type == Type.BLOCK) {
|
||||
final Block block = BlockNameConversion.findBlock(m.name);
|
||||
|
||||
if (block != null) {
|
||||
m.remap(block);
|
||||
FMLLog.getLogger().info("Remapping block " + m.name + " to " + General.getName(block));
|
||||
} else
|
||||
FMLLog.getLogger().warn("Block " + m.name + " could not get remapped.");
|
||||
} else if (m.type == Type.ITEM) {
|
||||
final Item item = BlockNameConversion.findItem(m.name);
|
||||
|
||||
if (item != null) {
|
||||
m.remap(item);
|
||||
FMLLog.getLogger().info("Remapping item " + m.name + " to " + General.getName(item));
|
||||
|
||||
} else
|
||||
FMLLog.getLogger().warn("Item " + m.name + " could not get remapped.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
|
||||
File configFile = event.getSuggestedConfigurationFile();
|
||||
Configurations.configExists = configFile.exists();
|
||||
Configurations.config = new Configuration(configFile);
|
||||
Configurations.config.load();
|
||||
Configurations.refreshConfig();
|
||||
|
||||
ChiselTabs.preInit();
|
||||
Features.preInit();
|
||||
Statistics.init();
|
||||
PacketHandler.init();
|
||||
ChiselController.INSTANCE.preInit();
|
||||
if (Loader.isModLoaded("ForgeMultipart")) {
|
||||
new FMPCompat().init();
|
||||
}
|
||||
proxy.preInit();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
Features.init();
|
||||
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(this, new ChiselGuiHandler());
|
||||
|
||||
addWorldgen(Features.MARBLE, ChiselBlocks.marble, Configurations.marbleAmount);
|
||||
addWorldgen(Features.LIMESTONE, ChiselBlocks.limestone, Configurations.limestoneAmount);
|
||||
addWorldgen(Features.ANDESITE, ChiselBlocks.andesite, Configurations.andesiteAmount, 40, 100, 0.5);
|
||||
addWorldgen(Features.GRANITE, ChiselBlocks.granite, Configurations.graniteAmount, 40, 100, 0.5);
|
||||
addWorldgen(Features.DIORITE, ChiselBlocks.diorite, Configurations.dioriteAmount, 40, 100, 0.5);
|
||||
GameRegistry.registerWorldGenerator(GeneratorChisel.INSTANCE, 1000);
|
||||
|
||||
EntityRegistry.registerModEntity(EntityChiselSnowman.class, "snowman", 0, this, 80, 1, true);
|
||||
|
||||
proxy.init();
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLCommonHandler.instance().bus().register(instance);
|
||||
|
||||
FMLInterModComms.sendMessage("Waila", "register", "com.cricketcraft.chisel.compat.WailaCompat.register");
|
||||
}
|
||||
|
||||
private void addWorldgen(Features feature, Block block, double... data) {
|
||||
if (feature.enabled()) {
|
||||
if (data.length == 1) {
|
||||
GeneratorChisel.INSTANCE.addFeature(block, 32, (int) data[0]);
|
||||
} else if (data.length > 1 && data.length < 4) {
|
||||
GeneratorChisel.INSTANCE.addFeature(block, 32, (int) data[0], (int) data[1], (int) data[2]);
|
||||
} else if (data.length == 4) {
|
||||
GeneratorChisel.INSTANCE.addFeature(block, 32, (int) data[0], (int) data[1], (int) data[2], data[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
ChiselTabs.postInit();
|
||||
Compatibility.init(event);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onIMC(IMCEvent event) {
|
||||
for (IMCMessage msg : event.getMessages()) {
|
||||
IMCHandler.INSTANCE.handleMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
|
||||
if (event.modID.equals("chisel")) {
|
||||
Configurations.refreshConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,76 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.block.tileentity.TileEntityAutoChisel;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockAutoChisel extends BlockContainer {
|
||||
|
||||
public BlockAutoChisel() {
|
||||
super(Material.rock);
|
||||
setHardness(1F);
|
||||
setBlockBounds(0.125f, 0, 0.125f, 0.875f, 0.8125f, 0.875f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return Chisel.renderAutoChiselId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int metadata, float x1, float y1, float z1) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (world.isRemote)
|
||||
return true;
|
||||
|
||||
if (tile != null && tile instanceof TileEntityAutoChisel && !player.isSneaking()) {
|
||||
player.openGui(Chisel.instance, 1, world, x, y, z);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int par6) {
|
||||
dropItems(world, x, y, z);
|
||||
super.breakBlock(world, x, y, z, block, par6);
|
||||
}
|
||||
|
||||
private void dropItems(World world, int x, int y, int z) {
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
|
||||
if (!(tileEntity instanceof TileEntityAutoChisel)) {
|
||||
return;
|
||||
}
|
||||
|
||||
TileEntityAutoChisel inventory = (TileEntityAutoChisel) world.getTileEntity(x, y, z);
|
||||
|
||||
for (int c = 0; c < inventory.getSizeInventory(); c++) {
|
||||
ItemStack stack = inventory.getStackInSlot(c);
|
||||
if (stack != null) {
|
||||
dropBlockAsItem(world, x, y, z, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1, int var2) {
|
||||
return new TileEntityAutoChisel();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
/**
|
||||
* Created by Pokefenn
|
||||
*/
|
||||
public class BlockBeaconBase extends BlockCarvable {
|
||||
|
||||
public BlockBeaconBase() {
|
||||
super();
|
||||
}
|
||||
|
||||
public BlockBeaconBase(Material mat) {
|
||||
super(mat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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 team.chisel.Chisel;
|
||||
import team.chisel.init.ChiselTabs;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockCarvable extends Block implements ICarvable {
|
||||
|
||||
public CarvableHelper carverHelper;
|
||||
private boolean isAlpha;
|
||||
|
||||
public BlockCarvable() {
|
||||
this(Material.rock);
|
||||
}
|
||||
|
||||
public BlockCarvable(Material m) {
|
||||
super(m);
|
||||
if (m == Material.rock || m == Material.iron) {
|
||||
setHarvestLevel("pickaxe", 0);
|
||||
}
|
||||
carverHelper = new CarvableHelper(this);
|
||||
setResistance(10.0F);
|
||||
setHardness(2.0F);
|
||||
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
|
||||
}
|
||||
|
||||
public BlockCarvable setStained(boolean a) {
|
||||
this.isAlpha = a;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderBlockPass() {
|
||||
return isAlpha ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return carverHelper.getIcon(side, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return carverHelper.getIcon(world, x, y, z, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
carverHelper.registerBlockIcons(Chisel.MOD_ID, this, register);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
|
||||
carverHelper.registerSubBlocks(this, tabs, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return ClientUtils.renderCTMId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(int meta) {
|
||||
return carverHelper.getVariation(meta);
|
||||
}
|
||||
|
||||
public static class SoundType extends Block.SoundType {
|
||||
|
||||
public final String soundNameStep;
|
||||
public final String soundNameBreak;
|
||||
public final String soundNamePlace;
|
||||
|
||||
/**
|
||||
* Creates a SoundType with automatic names for step and break sounds. Sound names dig.soundName and step.soundName must be specified in the sounds.json
|
||||
*
|
||||
* @param soundName
|
||||
* block of the sound. Will automatically be expanded to "mod:dig.soundName" and "mod:step.soundName" respectively)
|
||||
* @param volume
|
||||
* default 1.0f
|
||||
* @param frequency
|
||||
* default 1.0f
|
||||
*/
|
||||
public SoundType(String soundName, float volume, float frequency) {
|
||||
super(soundName, volume, frequency);
|
||||
this.soundNameStep = null;
|
||||
this.soundNameBreak = null;
|
||||
this.soundNamePlace = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a SoundType with manual names for step and break sounds. Sound names must be specified in the sounds.json
|
||||
*
|
||||
* @param soundNameBreak
|
||||
* block break sound
|
||||
* @param soundNameStep
|
||||
* block step sound
|
||||
* @param volume
|
||||
* default 1.0f
|
||||
* @param frequency
|
||||
* default 1.0f
|
||||
*/
|
||||
public SoundType(String soundNameBreak, String soundNameStep, float volume, float frequency) {
|
||||
super(soundNameStep, volume, frequency);
|
||||
this.soundNameStep = soundNameStep;
|
||||
this.soundNameBreak = soundNameBreak;
|
||||
this.soundNamePlace = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a SoundType with manual names for step, break and place sounds. Sound names must be specified in the sounds.json
|
||||
*
|
||||
* @param soundNameBreak
|
||||
* block break sound
|
||||
* @param soundNameStep
|
||||
* block step sound
|
||||
* @param soundNamePlace
|
||||
* block place sound
|
||||
* @param volume
|
||||
* default 1.0f
|
||||
* @param frequency
|
||||
* default 1.0f
|
||||
*/
|
||||
public SoundType(String soundNameBreak, String soundNameStep, String soundNamePlace, float volume, float frequency) {
|
||||
super(soundNameStep, volume, frequency);
|
||||
this.soundNameStep = soundNameStep;
|
||||
this.soundNameBreak = soundNameBreak;
|
||||
this.soundNamePlace = soundNamePlace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBreakSound() {
|
||||
if (soundNameBreak == null)
|
||||
return Chisel.MOD_ID + ":dig." + this.soundName;
|
||||
else
|
||||
return this.soundNameBreak;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStepResourcePath() {
|
||||
if (soundNameStep == null)
|
||||
return Chisel.MOD_ID + ":step." + this.soundName;
|
||||
else
|
||||
return this.soundNameStep;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String func_150496_b() {
|
||||
if (soundNamePlace == null)
|
||||
return getBreakSound();
|
||||
else
|
||||
return this.soundNamePlace;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class BlockCarvableAntiBlock extends BlockCarvableColor implements ICarvable {
|
||||
|
||||
public BlockCarvableAntiBlock() {
|
||||
super(Material.rock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
|
||||
import team.chisel.block.tileentity.TileEntityCarvableBeacon;
|
||||
import team.chisel.init.ChiselTabs;
|
||||
import net.minecraft.block.BlockBeacon;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockCarvableBeacon extends BlockBeacon implements ICarvable {
|
||||
|
||||
public static int renderId;
|
||||
|
||||
public CarvableHelper carverHelper;
|
||||
|
||||
public BlockCarvableBeacon() {
|
||||
super();
|
||||
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
|
||||
setLightLevel(5.0F);
|
||||
setBlockTextureName("beacon");
|
||||
carverHelper = new CarvableHelper(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityCarvableBeacon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par5, float hitX, float hitY, float hitZ) {
|
||||
if (world.isRemote) {
|
||||
return true;
|
||||
} else {
|
||||
TileEntityCarvableBeacon tileentitybeacon = (TileEntityCarvableBeacon) world.getTileEntity(x, y, z);
|
||||
|
||||
if (tileentitybeacon != null) {
|
||||
player.func_146104_a(tileentitybeacon);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return renderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
|
||||
super.onBlockPlacedBy(world, x, y, z, player, stack);
|
||||
|
||||
if (stack.hasDisplayName()) {
|
||||
((TileEntityCarvableBeacon) world.getTileEntity(x, y, z)).func_145999_a(stack.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(int meta) {
|
||||
return carverHelper.getVariation(meta);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockCarvableBookshelf extends BlockCarvable {
|
||||
|
||||
public BlockCarvableBookshelf() {
|
||||
super(Material.wood);
|
||||
setHarvestLevel("axe", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
if (side < 2)
|
||||
return Blocks.planks.getBlockTextureFromSide(side);
|
||||
return super.getIcon(side, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
if (side < 2)
|
||||
return Blocks.planks.getBlockTextureFromSide(side);
|
||||
return super.getIcon(world, x, y, z, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random random) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int ammount, Random random, int meta) {
|
||||
return Items.book;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int damage) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDamageValue(World world, int x, int y, int z) {
|
||||
return world.getBlockMetadata(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEnchantPowerBonus(World world, int x, int y, int z) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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 net.minecraft.block.BlockCarpet;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class BlockCarvableCarpet extends BlockCarpet implements ICarvable {
|
||||
|
||||
public CarvableHelper carverHelper;
|
||||
|
||||
public BlockCarvableCarpet(Material m) {
|
||||
carverHelper = new CarvableHelper(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return carverHelper.getIcon(side, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return carverHelper.getIcon(world, x, y, z, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
carverHelper.registerBlockIcons("Chisel", this, register);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
|
||||
carverHelper.registerSubBlocks(this, tabs, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return ClientUtils.renderCTMId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(int meta) {
|
||||
return carverHelper.getVariation(meta);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockCarvableColor extends BlockCarvable {
|
||||
|
||||
public BlockCarvableColor() {
|
||||
this(Material.rock);
|
||||
}
|
||||
|
||||
public BlockCarvableColor(Material m) {
|
||||
super(m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int color) {
|
||||
int newColor = 15 - color;
|
||||
if (world.getBlockMetadata(x, y, z) != newColor) {
|
||||
world.setBlockMetadataWithNotify(x, y, z, newColor, 3);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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 team.chisel.init.ChiselTabs;
|
||||
import net.minecraft.block.BlockGlass;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockCarvableGlass extends BlockGlass implements ICarvable {
|
||||
|
||||
public CarvableHelper carverHelper;
|
||||
private boolean isAlpha = false;
|
||||
|
||||
public BlockCarvableGlass() {
|
||||
super(Material.glass, false);
|
||||
|
||||
carverHelper = new CarvableHelper(this);
|
||||
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
|
||||
}
|
||||
|
||||
public BlockCarvableGlass setStained(boolean a) {
|
||||
this.isAlpha = a;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return ClientUtils.renderCTMId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return carverHelper.getIcon(side, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
carverHelper.registerBlockIcons("Chisel", this, register);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
|
||||
carverHelper.registerSubBlocks(this, tabs, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(int meta) {
|
||||
return carverHelper.getVariation(meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderBlockPass() {
|
||||
return isAlpha ? 1 : 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.client.render.SubmapManagerBase;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockCarvableGlow extends BlockCarvableColor {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon glowTexture;
|
||||
|
||||
private SubmapManagerBase submapManagerBase;
|
||||
private String glowTexturePath;
|
||||
|
||||
public BlockCarvableGlow(String glowTexture) {
|
||||
super();
|
||||
setLightLevel(0.5f);
|
||||
this.glowTexturePath = glowTexture;
|
||||
}
|
||||
|
||||
public BlockCarvableGlow(Material mat, String glowTexture) {
|
||||
super(mat);
|
||||
this.glowTexturePath = glowTexture;
|
||||
}
|
||||
|
||||
public BlockCarvableGlow(Material material, String glowTexture, SubmapManagerBase submapManagerBase) {
|
||||
super(material);
|
||||
this.glowTexturePath = glowTexture;
|
||||
this.submapManagerBase = submapManagerBase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
super.registerBlockIcons(register);
|
||||
glowTexture = register.registerIcon(Chisel.MOD_ID + ":" + glowTexturePath);
|
||||
}
|
||||
|
||||
public boolean hasSubmapManager() {
|
||||
return submapManagerBase == null;
|
||||
}
|
||||
|
||||
public SubmapManagerBase getSubmapManager() {
|
||||
return hasSubmapManager() ? submapManagerBase : null;
|
||||
}
|
||||
|
||||
public IIcon getGlowTexture() {
|
||||
return glowTexture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return Chisel.renderGlowId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockCarvableGlowstone extends BlockCarvable {
|
||||
|
||||
public BlockCarvableGlowstone() {
|
||||
super(Material.glass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random random) {
|
||||
return Blocks.glowstone.quantityDropped(random);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int i, Random random, int a) {
|
||||
return Items.glowstone_dust;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
|
||||
Block glowstone = world.getBlock(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
return new ItemStack(Item.getItemFromBlock(glowstone), 1, meta);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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 net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockIce;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockCarvableIce extends BlockIce implements ICarvable {
|
||||
|
||||
public CarvableHelper carverHelper;
|
||||
|
||||
public BlockCarvableIce() {
|
||||
super();
|
||||
carverHelper = new CarvableHelper(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return ClientUtils.renderCTMId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return carverHelper.getIcon(side, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
carverHelper.registerBlockIcons("Chisel", this, register);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
|
||||
carverHelper.registerSubBlocks(this, tabs, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) {
|
||||
super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
|
||||
|
||||
par2EntityPlayer.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(this)], 1);
|
||||
par2EntityPlayer.addExhaustion(0.025F);
|
||||
|
||||
/*
|
||||
* if(this.canSilkHarvest(par1World, par2EntityPlayer, par3, par4, par5, par6) && EnchantmentHelper.getSilkTouchModifier(par2EntityPlayer)) { ItemStack itemstack =
|
||||
* this.createStackedBlock(par6);
|
||||
*
|
||||
* if(itemstack != null) { this.dropBlockAsItem(par1World, par3, par4, par5, itemstack); } }
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(int meta) {
|
||||
return carverHelper.getVariation(meta);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
|
||||
import team.chisel.init.ChiselBlocks;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockCarvableIceStairs extends BlockCarvableStairs {
|
||||
|
||||
public BlockCarvableIceStairs(Block block, int meta, CarvableHelper helper) {
|
||||
super(block, meta, helper);
|
||||
|
||||
slipperiness = 0.98F;
|
||||
setTickRandomly(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) {
|
||||
ChiselBlocks.ice.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random par1Random) {
|
||||
return ChiselBlocks.ice.quantityDropped(par1Random);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
|
||||
ChiselBlocks.ice.updateTick(par1World, par2, par3, par4, par5Random);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMobilityFlag() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockCarvableLamp extends BlockCarvable {
|
||||
|
||||
BlockCarvableLamp blockUnpowered;
|
||||
BlockCarvableLamp blockPowered;
|
||||
boolean powered;
|
||||
|
||||
public BlockCarvableLamp() {
|
||||
super(Material.redstoneLight);
|
||||
|
||||
powered = false;
|
||||
blockUnpowered = this;
|
||||
blockPowered = new BlockCarvableLamp(this);
|
||||
|
||||
setHardness(0.3F);
|
||||
}
|
||||
|
||||
public BlockCarvableLamp(BlockCarvableLamp unpoweredVersion) {
|
||||
super(Material.redstoneLight);
|
||||
|
||||
carverHelper = unpoweredVersion.carverHelper;
|
||||
|
||||
powered = true;
|
||||
blockUnpowered = unpoweredVersion;
|
||||
blockPowered = this;
|
||||
|
||||
setLightLevel(1.0F);
|
||||
setHardness(0.3F);
|
||||
}
|
||||
|
||||
public void checkPower(World world, int x, int y, int z) {
|
||||
if (world.isRemote)
|
||||
return;
|
||||
|
||||
boolean isGettingPower = world.isBlockIndirectlyGettingPowered(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if (powered && !isGettingPower) {
|
||||
world.setBlock(x, y, z, blockUnpowered, meta, 2);
|
||||
} else if (!powered && isGettingPower) {
|
||||
world.setBlock(x, y, z, blockPowered, meta, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z) {
|
||||
checkPower(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
|
||||
checkPower(world, x, y, z);
|
||||
}
|
||||
|
||||
/*
|
||||
* @Override public void updateTick(World world, int x, int y, int z, Random rand){ if (world.isRemote) return;
|
||||
*
|
||||
* if(powered && !world.isBlockIndirectlyGettingPowered(x, y, z)){ int meta=world.getBlockMetadata(x, y, z); world.setBlock(x, y, z, Block.redstoneLampIdle.blockID, meta, 2); } }
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int par1, Random par2Random, int par3) {
|
||||
return Item.getItemFromBlock(blockUnpowered);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
|
||||
return new ItemStack(blockUnpowered, 1, world.getBlockMetadata(x, y, z));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockCarvableLayered extends BlockCarvable {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon baseTexture;
|
||||
private String baseTexLocation;
|
||||
|
||||
public BlockCarvableLayered(Material mat, String baseTexLocation) {
|
||||
super(mat);
|
||||
this.baseTexLocation = baseTexLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
super.registerBlockIcons(register);
|
||||
baseTexture = register.registerIcon(Chisel.MOD_ID + ":" + baseTexLocation);
|
||||
}
|
||||
|
||||
public IIcon getBaseTex() {
|
||||
return baseTexture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return Chisel.renderLayeredId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
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 net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockCarvablePackedIce extends Block implements ICarvable {
|
||||
|
||||
public CarvableHelper carverHelper;
|
||||
|
||||
public BlockCarvablePackedIce() {
|
||||
super(Material.ice);
|
||||
carverHelper = new CarvableHelper(this);
|
||||
this.slipperiness = Blocks.packed_ice.slipperiness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return ClientUtils.renderCTMId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return carverHelper.getIcon(side, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(int meta, int fortune, Random random) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
carverHelper.registerBlockIcons("Chisel", this, register);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
|
||||
carverHelper.registerSubBlocks(this, tabs, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) {
|
||||
super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
|
||||
|
||||
par2EntityPlayer.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(this)], 1);
|
||||
par2EntityPlayer.addExhaustion(0.025F);
|
||||
|
||||
/*
|
||||
* if(this.canSilkHarvest(par1World, par2EntityPlayer, par3, par4, par5, par6) && EnchantmentHelper.getSilkTouchModifier(par2EntityPlayer)) { ItemStack itemstack =
|
||||
* this.createStackedBlock(par6);
|
||||
*
|
||||
* if(itemstack != null) { this.dropBlockAsItem(par1World, par3, par4, par5, itemstack); } }
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(int meta) {
|
||||
return carverHelper.getVariation(meta);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
|
||||
import team.chisel.init.ChiselBlocks;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockCarvablePackedIceStairs extends BlockCarvableStairs {
|
||||
|
||||
public BlockCarvablePackedIceStairs(Block block, int meta, CarvableHelper helper) {
|
||||
super(block, meta, helper);
|
||||
|
||||
slipperiness = 0.98F;
|
||||
setTickRandomly(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) {
|
||||
ChiselBlocks.ice.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random par1Random) {
|
||||
return ChiselBlocks.ice.quantityDropped(par1Random);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
|
||||
ChiselBlocks.ice.updateTick(par1World, par2, par3, par4, par5Random);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMobilityFlag() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
|
||||
import team.chisel.client.render.RendererCTMPane;
|
||||
import team.chisel.init.ChiselTabs;
|
||||
import net.minecraft.block.BlockPane;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockCarvablePane extends BlockPane implements ICarvable {
|
||||
|
||||
public CarvableHelper carverHelper;
|
||||
public boolean isAlpha;
|
||||
|
||||
public BlockCarvablePane(Material material, boolean drops) {
|
||||
super("", "", material, drops);
|
||||
|
||||
carverHelper = new CarvableHelper(this);
|
||||
|
||||
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
|
||||
}
|
||||
|
||||
public BlockCarvablePane setStained(boolean a) {
|
||||
this.isAlpha = a;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderBlockPass() {
|
||||
return isAlpha ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return RendererCTMPane.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return carverHelper.getIcon(side, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
carverHelper.registerBlockIcons("Chisel", this, register);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
|
||||
carverHelper.registerSubBlocks(this, tabs, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(int meta) {
|
||||
return carverHelper.getVariation(meta);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class BlockCarvablePowered extends BlockCarvable {
|
||||
|
||||
public BlockCarvablePowered(Material m) {
|
||||
super(m);
|
||||
}
|
||||
|
||||
/**
|
||||
* Can this block provide power. Only wire currently seems to have this change based on its state.
|
||||
*/
|
||||
@Override
|
||||
public boolean canProvidePower() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the block is emitting indirect/weak redstone power on the specified side. If isBlockNormalCube returns true, standard redstone propagation rules will apply instead and this will
|
||||
* not be called. Args: World, X, Y, Z, side. Note that the side is reversed - eg it is 1 (up) when checking the bottom of the block.
|
||||
*/
|
||||
@Override
|
||||
public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) {
|
||||
return 15;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.entity.EntityChiselSnowman;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockPumpkin;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.monster.EntityIronGolem;
|
||||
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 cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockCarvablePumpkin extends BlockPumpkin implements ICarvable {
|
||||
|
||||
public CarvableHelper carverHelper;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon top, face;
|
||||
|
||||
private String faceLocation;
|
||||
|
||||
public BlockCarvablePumpkin(boolean isOn) {
|
||||
super(isOn);
|
||||
this.setStepSound(Block.soundTypeWood);
|
||||
if (isOn)
|
||||
setLightLevel(10.0F);
|
||||
carverHelper = new CarvableHelper(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z) {
|
||||
if (world.getBlock(x, y - 1, z) == Blocks.snow && world.getBlock(x, y - 2, z) == Blocks.snow) {
|
||||
if (!world.isRemote) {
|
||||
// Let's grab the pumpkin before we start
|
||||
ItemStack pumpkin = new ItemStack(world.getBlock(x, y, z), world.getBlockMetadata(x, y, z));
|
||||
|
||||
world.setBlock(x, y, z, Blocks.air, 0, 2);
|
||||
world.setBlock(x, y - 1, z, Blocks.air, 0, 2);
|
||||
world.setBlock(x, y - 2, z, Blocks.air, 0, 2);
|
||||
EntityChiselSnowman snowman = new EntityChiselSnowman(world);
|
||||
snowman.setCurrentItemOrArmor(2, pumpkin);
|
||||
snowman.setLocationAndAngles(x + 0.5D, y - 1.95D, z + 0.5D, 0.0F, 0.0F);
|
||||
world.spawnEntityInWorld(snowman);
|
||||
world.notifyBlockChange(x, y, z, Blocks.air);
|
||||
world.notifyBlockChange(x, y - 1, z, Blocks.air);
|
||||
world.notifyBlockChange(x, y - 2, z, Blocks.air);
|
||||
}
|
||||
|
||||
// Spawn some lovely particles
|
||||
for (int c = 0; c < 120; ++c) {
|
||||
world.spawnParticle("snowshovel", x + world.rand.nextDouble(), y - 2 + world.rand.nextDouble() * 2.5D, z + world.rand.nextDouble(), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
} else if (world.getBlock(x, y - 1, z) == Blocks.iron_block || world.getBlock(x, y - 2, z) == Blocks.iron_block) {
|
||||
boolean flag = world.getBlock(x - 1, y - 1, z) == Blocks.iron_block && world.getBlock(x + 1, y - 1, z) == Blocks.iron_block;
|
||||
boolean flag1 = world.getBlock(x, y - 1, z - 1) == Blocks.iron_block && world.getBlock(x, y - 1, z + 1) == Blocks.iron_block;
|
||||
|
||||
if (flag || flag1) {
|
||||
world.setBlock(x, y, z, Blocks.air, 0, 2);
|
||||
world.setBlock(x, y - 1, z, Blocks.air, 0, 2);
|
||||
world.setBlock(x, y - 2, z, Blocks.air, 0, 2);
|
||||
|
||||
if (flag) {
|
||||
world.setBlock(x - 1, y - 1, z, Blocks.air, 0, 2);
|
||||
world.setBlock(x + 1, y - 1, z, Blocks.air, 0, 2);
|
||||
} else {
|
||||
world.setBlock(x, y - 1, z - 1, Blocks.air, 0, 2);
|
||||
world.setBlock(x, y - 1, z + 1, Blocks.air, 0, 2);
|
||||
}
|
||||
|
||||
EntityIronGolem ironGolem = new EntityIronGolem(world);
|
||||
ironGolem.setPlayerCreated(true);
|
||||
ironGolem.setLocationAndAngles(x + 0.5D, y - 1.95D, z + 0.5D, 0.0F, 0.0F);
|
||||
world.spawnEntityInWorld(ironGolem);
|
||||
|
||||
world.notifyBlockChange(x, y, z, Blocks.air);
|
||||
world.notifyBlockChange(x, y - 1, z, Blocks.air);
|
||||
world.notifyBlockChange(x, y - 2, z, Blocks.air);
|
||||
|
||||
if (flag) {
|
||||
world.notifyBlockChange(x - 1, y - 1, z, Blocks.air);
|
||||
world.notifyBlockChange(x + 1, y - 1, z, Blocks.air);
|
||||
} else {
|
||||
world.notifyBlockChange(x, y - 1, z - 1, Blocks.air);
|
||||
world.notifyBlockChange(x, y - 1, z + 1, Blocks.air);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return side == 1 ? top : (side == 0 ? top : (meta == 2 && side == 2 ? face : (meta == 3 && side == 5 ? face
|
||||
: (meta == 0 && side == 3 ? face : (meta == 1 && side == 4 ? face : this.blockIcon)))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister icon) {
|
||||
top = icon.registerIcon(Chisel.MOD_ID + ":pumpkin/pumpkin_top");
|
||||
face = icon.registerIcon(Chisel.MOD_ID + ":" + faceLocation);
|
||||
this.blockIcon = icon.registerIcon(Chisel.MOD_ID + ":pumpkin/pumpkin_side");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(int meta) {
|
||||
return carverHelper.getVariation(meta);
|
||||
}
|
||||
|
||||
public void setInformation(String textureLocation) {
|
||||
this.faceLocation = textureLocation;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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 team.chisel.Chisel;
|
||||
import team.chisel.init.ChiselTabs;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockSand;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockCarvableSand extends BlockSand implements ICarvable {
|
||||
|
||||
public CarvableHelper carverHelper;
|
||||
private boolean isAlpha;
|
||||
|
||||
public BlockCarvableSand() {
|
||||
super();
|
||||
carverHelper = new CarvableHelper(this);
|
||||
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
|
||||
}
|
||||
|
||||
public BlockCarvableSand setStained(boolean a) {
|
||||
this.isAlpha = a;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderBlockPass() {
|
||||
return isAlpha ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return carverHelper.getIcon(side, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return carverHelper.getIcon(world, x, y, z, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
carverHelper.registerBlockIcons("Chisel", this, register);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
|
||||
carverHelper.registerSubBlocks(this, tabs, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return ClientUtils.renderCTMId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(int meta) {
|
||||
return carverHelper.getVariation(meta);
|
||||
}
|
||||
|
||||
public static class SoundType extends Block.SoundType {
|
||||
|
||||
public final String soundNameStep;
|
||||
public final String soundNameBreak;
|
||||
public final String soundNamePlace;
|
||||
|
||||
/**
|
||||
* Creates a SoundType with automatic names for step and break sounds. Sound names dig.soundName and step.soundName must be specified in the sounds.json
|
||||
*
|
||||
* @param soundName
|
||||
* block of the sound. Will automatically be expanded to "mod:dig.soundName" and "mod:step.soundName" respectively)
|
||||
* @param volume
|
||||
* default 1.0f
|
||||
* @param frequency
|
||||
* default 1.0f
|
||||
*/
|
||||
public SoundType(String soundName, float volume, float frequency) {
|
||||
super(soundName, volume, frequency);
|
||||
this.soundNameStep = null;
|
||||
this.soundNameBreak = null;
|
||||
this.soundNamePlace = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a SoundType with manual names for step and break sounds. Sound names must be specified in the sounds.json
|
||||
*
|
||||
* @param soundNameBreak
|
||||
* block break sound
|
||||
* @param soundNameStep
|
||||
* block step sound
|
||||
* @param volume
|
||||
* default 1.0f
|
||||
* @param frequency
|
||||
* default 1.0f
|
||||
*/
|
||||
public SoundType(String soundNameBreak, String soundNameStep, float volume, float frequency) {
|
||||
super(soundNameStep, volume, frequency);
|
||||
this.soundNameStep = soundNameStep;
|
||||
this.soundNameBreak = soundNameBreak;
|
||||
this.soundNamePlace = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a SoundType with manual names for step, break and place sounds. Sound names must be specified in the sounds.json
|
||||
*
|
||||
* @param soundNameBreak
|
||||
* block break sound
|
||||
* @param soundNameStep
|
||||
* block step sound
|
||||
* @param soundNamePlace
|
||||
* block place sound
|
||||
* @param volume
|
||||
* default 1.0f
|
||||
* @param frequency
|
||||
* default 1.0f
|
||||
*/
|
||||
public SoundType(String soundNameBreak, String soundNameStep, String soundNamePlace, float volume, float frequency) {
|
||||
super(soundNameStep, volume, frequency);
|
||||
this.soundNameStep = soundNameStep;
|
||||
this.soundNameBreak = soundNameBreak;
|
||||
this.soundNamePlace = soundNamePlace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBreakSound() {
|
||||
if (soundNameBreak == null)
|
||||
return Chisel.MOD_ID + ":dig." + this.soundName;
|
||||
else
|
||||
return this.soundNameBreak;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStepResourcePath() {
|
||||
if (soundNameStep == null)
|
||||
return Chisel.MOD_ID + ":step." + this.soundName;
|
||||
else
|
||||
return this.soundNameStep;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String func_150496_b() {
|
||||
if (soundNamePlace == null)
|
||||
return getBreakSound();
|
||||
else
|
||||
return this.soundNamePlace;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
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;
|
||||
public BlockCarvableSlab bottom;
|
||||
public BlockCarvableSlab top;
|
||||
public boolean isBottom;
|
||||
|
||||
public BlockCarvableSlab(BlockCarvable marble) {
|
||||
opaque = true;
|
||||
|
||||
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
|
||||
|
||||
master = marble;
|
||||
bottom = this;
|
||||
top = new BlockCarvableSlab(this);
|
||||
|
||||
isBottom = true;
|
||||
}
|
||||
|
||||
public BlockCarvableSlab(BlockCarvableSlab bottomBlock) {
|
||||
super();
|
||||
setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
master = bottomBlock.master;
|
||||
bottom = bottomBlock;
|
||||
top = this;
|
||||
|
||||
carverHelper = bottomBlock.carverHelper;
|
||||
isBottom = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) {
|
||||
if (isBottom) {
|
||||
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
|
||||
} else {
|
||||
setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsForItemRender() {
|
||||
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) {
|
||||
setBlockBoundsBasedOnState(par1World, par2, par3, par4);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int meta) {
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int par1, Random par2Random, int par3) {
|
||||
return Item.getItemFromBlock(bottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemStack getPickBlock(MovingObjectPosition mop, World world, int x, int y, int z) {
|
||||
return new ItemStack(bottom, 1, world.getBlockMetadata(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return carverHelper.getIcon(side, metadata);
|
||||
// return master.getIcon(side, metadata);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public void getSubBlocks(Item block, CreativeTabs tabs, List list) {
|
||||
if (isBottom)
|
||||
super.getSubBlocks(block, tabs, list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the block is a solid face on the given side, used by placement logic.
|
||||
*
|
||||
* @param world
|
||||
* The current world
|
||||
* @param x
|
||||
* X Position
|
||||
* @param y
|
||||
* Y position
|
||||
* @param z
|
||||
* Z position
|
||||
* @param side
|
||||
* The side to check
|
||||
* @return True if the block is solid on the specified side.
|
||||
*/
|
||||
@Override
|
||||
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
return !isBottom && (side == UP);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
|
||||
import team.chisel.client.render.RendererStairs;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockCarvableStairs extends BlockStairs implements ICarvable {
|
||||
|
||||
CarvableHelper carverHelper;
|
||||
int blockMeta;
|
||||
|
||||
public BlockCarvableStairs(Block block, int meta, CarvableHelper helper) {
|
||||
super(block, meta);
|
||||
|
||||
this.useNeighborBrightness = true;
|
||||
carverHelper = helper;
|
||||
blockMeta = meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return carverHelper.getIcon(side, blockMeta + metadata / 8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int i) {
|
||||
return i / 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
if (blockMeta == 0)
|
||||
carverHelper.registerBlockIcons("Chisel", this, register);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void getSubBlocks(Item block, CreativeTabs tabs, List list) {
|
||||
list.add(new ItemStack(block, 1, 0));
|
||||
list.add(new ItemStack(block, 1, 8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return RendererStairs.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack) {
|
||||
int meta = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
|
||||
// 0->2 2->3 3->0 1->1
|
||||
meta = meta == 0 ? 2 : meta == 2 ? 3 : meta == 3 ? 0 : 1;
|
||||
|
||||
meta += par1World.getBlockMetadata(par2, par3, par4) % 8; // add upside-down-ness
|
||||
|
||||
if (par6ItemStack.getItemDamage() >= 8) {
|
||||
meta += 8;
|
||||
}
|
||||
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, meta, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onBlockPlaced(World world, int x, int y, int z, int side, float hx, float hy, float hz, int damage) {
|
||||
return side != 0 && (side == 1 || hy <= 0.5D) ? damage : damage + 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(blockMeta + (metadata / 8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(int meta) {
|
||||
return carverHelper.getVariation(blockMeta + (meta / 8));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.init.ChiselTabs;
|
||||
import net.minecraft.block.BlockTorch;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockCarvableTorch extends BlockTorch implements ICarvable {
|
||||
|
||||
public CarvableHelper carverHelper;
|
||||
private String texLocation;
|
||||
protected boolean emitsParticles = true;
|
||||
public int idx;
|
||||
|
||||
public BlockCarvableTorch(int idx, String tex) {
|
||||
super();
|
||||
carverHelper = new CarvableHelper(this);
|
||||
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
|
||||
setLightLevel(0.9375F);
|
||||
setBlockName("torch");
|
||||
this.idx = idx;
|
||||
this.texLocation = tex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(int meta) {
|
||||
return carverHelper.getVariation(meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister icon) {
|
||||
this.blockIcon = icon.registerIcon(Chisel.MOD_ID + ":torch/" + texLocation);
|
||||
}
|
||||
|
||||
public BlockCarvableTorch disableParticles() {
|
||||
this.emitsParticles = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) {
|
||||
if (emitsParticles) {
|
||||
int l = p_149734_1_.getBlockMetadata(p_149734_2_, p_149734_3_, p_149734_4_);
|
||||
double d0 = p_149734_2_ + 0.5F;
|
||||
double d1 = p_149734_3_ + 0.7F;
|
||||
double d2 = p_149734_4_ + 0.5F;
|
||||
double d3 = 0.2199999988079071D;
|
||||
double d4 = 0.27000001072883606D;
|
||||
|
||||
if (l == 1) {
|
||||
p_149734_1_.spawnParticle("smoke", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
|
||||
p_149734_1_.spawnParticle("flame", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
|
||||
} else if (l == 2) {
|
||||
p_149734_1_.spawnParticle("smoke", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
|
||||
p_149734_1_.spawnParticle("flame", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
|
||||
} else if (l == 3) {
|
||||
p_149734_1_.spawnParticle("smoke", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
|
||||
p_149734_1_.spawnParticle("flame", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
|
||||
} else if (l == 4) {
|
||||
p_149734_1_.spawnParticle("smoke", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
|
||||
p_149734_1_.spawnParticle("flame", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
|
||||
} else {
|
||||
p_149734_1_.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
|
||||
p_149734_1_.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockWall;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class BlockCarvableWall extends BlockWall {
|
||||
|
||||
CarvableHelper carverHelper;
|
||||
|
||||
public BlockCarvableWall(Block block) {
|
||||
super(block);
|
||||
|
||||
carverHelper = new CarvableHelper(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return carverHelper.getIcon(side, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
carverHelper.registerBlockIcons("Chisel", this, register);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void getSubBlocks(Item block, CreativeTabs tabs, List list) {
|
||||
carverHelper.registerSubBlocks(this, tabs, list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import team.chisel.config.Configurations;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockCloud extends BlockCarvable {
|
||||
|
||||
public BlockCloud() {
|
||||
super(Material.ice);
|
||||
useNeighborBrightness = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity) {
|
||||
entity.fallDistance = 0.0F;
|
||||
|
||||
if (entity.motionY < 0.0D) {
|
||||
entity.motionY *= 0.0050000000000000001D;
|
||||
} else if (entity.motionY > 0) {
|
||||
entity.motionY += 0.0285;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass() {
|
||||
return Configurations.ghostCloud ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (block == this) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return super.shouldSideBeRendered(world, x, y, z, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k) {
|
||||
return AxisAlignedBB.getBoundingBox(i + 0.2, j, k + 0.2, i + 0.8, j + 0.2, k + 0.8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int par1, Random rand, int par3) {
|
||||
return Item.getItemFromBlock(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random rand) {
|
||||
return rand.nextInt(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int meta) {
|
||||
return meta;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import team.chisel.client.GeneralChiselClient;
|
||||
import team.chisel.config.Configurations;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class BlockConcrete extends BlockCarvable {
|
||||
|
||||
public BlockConcrete() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) {
|
||||
if (Configurations.fullBlockConcrete)
|
||||
return AxisAlignedBB.getBoundingBox(par2, par3, par4, (par2 + 1), ((par3 + 1)), (par4 + 1));
|
||||
else
|
||||
return AxisAlignedBB.getBoundingBox(par2, par3, par4, (par2 + 1), ((par3 + 1) - 0.125F), (par4 + 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() != Side.CLIENT)
|
||||
return;
|
||||
if (Configurations.concreteVelocity == 0)
|
||||
return;
|
||||
|
||||
GeneralChiselClient.speedupPlayer(world, entity, Configurations.concreteVelocity);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
|
||||
public class BlockEldritch extends BlockCarvable {
|
||||
|
||||
public BlockEldritch() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return Chisel.renderEldritchId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.client.GeneralChiselClient;
|
||||
import team.chisel.utils.General;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockGrimstone extends BlockCarvable {
|
||||
|
||||
public IIcon iconStar;
|
||||
|
||||
public BlockGrimstone(Material m) {
|
||||
super(m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
|
||||
if (General.rand.nextInt(4) == 0 && world.isRemote)
|
||||
GeneralChiselClient.spawnGrimstoneFX(world, this, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
super.registerBlockIcons(register);
|
||||
|
||||
iconStar = register.registerIcon(Chisel.MOD_ID + ":grimstone/particles/star");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import team.chisel.client.GeneralChiselClient;
|
||||
import team.chisel.utils.General;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockHolystone extends BlockCarvable {
|
||||
|
||||
public IIcon iconStar;
|
||||
|
||||
public BlockHolystone(Material m) {
|
||||
super(m);
|
||||
|
||||
this.setLightLevel(0.25F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
|
||||
if (General.rand.nextInt(4) == 0 && world.isRemote)
|
||||
GeneralChiselClient.spawnHolystoneFX(world, this, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
super.registerBlockIcons(register);
|
||||
|
||||
iconStar = register.registerIcon("Chisel:holystone/particles/star");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import team.chisel.client.GeneralChiselClient;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockLavastone extends BlockMultiLayer {
|
||||
|
||||
public BlockLavastone(Material mat, String baseIcon) {
|
||||
super(mat, baseIcon);
|
||||
setLightLevel(1F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
|
||||
if (random.nextInt(8) == 0 && world.isRemote)
|
||||
GeneralChiselClient.spawnLavastoneFX(world, this, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
public class BlockLeaf extends BlockCarvable {
|
||||
|
||||
public BlockLeaf(Material material) {
|
||||
super(material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return Blocks.leaves.isOpaqueCube();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class BlockMultiLayer extends BlockMultiLayerBase implements ICarvable {
|
||||
|
||||
public CarvableHelper carverHelper;
|
||||
|
||||
public BlockMultiLayer(Material mat, String baseIcon) {
|
||||
super(mat, baseIcon);
|
||||
|
||||
carverHelper = new CarvableHelper(this);
|
||||
}
|
||||
|
||||
public BlockMultiLayer(Material mat, Block block) {
|
||||
super(mat, block);
|
||||
|
||||
carverHelper = new CarvableHelper(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return carverHelper.getIcon(side, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
super.registerBlockIcons(register);
|
||||
|
||||
carverHelper.registerBlockIcons("Chisel", this, register);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void getSubBlocks(Item block, CreativeTabs tabs, List list) {
|
||||
carverHelper.registerSubBlocks(this, tabs, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(int meta) {
|
||||
return carverHelper.getVariation(meta);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import team.chisel.client.render.RendererMultiLayer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
|
||||
public abstract class BlockMultiLayerBase extends Block {
|
||||
|
||||
public Block base;
|
||||
public IIcon icon;
|
||||
String iconFile;
|
||||
|
||||
public BlockMultiLayerBase(Material mat, Block base) {
|
||||
super(mat);
|
||||
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
public BlockMultiLayerBase(Material mat, String iconFile) {
|
||||
super(mat);
|
||||
|
||||
this.iconFile = iconFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return RendererMultiLayer.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderInPass(int pass) {
|
||||
ForgeHooksClient.setRenderPass(pass);
|
||||
return pass == 1 || pass == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
if (iconFile != null)
|
||||
icon = register.registerIcon(iconFile);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.block.tileentity.TileEntityPresent;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockPresent extends Block implements ICarvable {
|
||||
|
||||
public CarvableHelper carverHelper;
|
||||
|
||||
private float minX, minY, minZ, maxX, maxY, maxZ;
|
||||
|
||||
public BlockPresent() {
|
||||
super(Material.wood);
|
||||
carverHelper = new CarvableHelper(this);
|
||||
minX = 0.0625F;
|
||||
minZ = 0.0625F;
|
||||
maxX = 0.9375F;
|
||||
maxY = 0.875F;
|
||||
maxZ = 0.9375F;
|
||||
setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
public String getModelTexture(int type) {
|
||||
return "textures/blocks/present/presentChest" + type;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
list.add(new ItemStack(item, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
|
||||
super.onBlockPlacedBy(world, x, y, z, player, stack);
|
||||
int heading = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||
TileEntityPresent te = (TileEntityPresent) world.getTileEntity(x, y, z);
|
||||
world.setBlockMetadataWithNotify(x, y, z, stack.getItemDamage(), 3);
|
||||
te.setRotation(heading);
|
||||
te.findConnections();
|
||||
if (te.isConnected()) {
|
||||
TileEntityPresent other = te.getConnection();
|
||||
other.setRotation(heading);
|
||||
}
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block present, int meta) {
|
||||
|
||||
TileEntityPresent tileEntityPresent = (TileEntityPresent) world.getTileEntity(x, y, z);
|
||||
|
||||
if (tileEntityPresent != null) {
|
||||
for (int c = 0; c < tileEntityPresent.getTrueSizeInventory(); c++) {
|
||||
ItemStack itemStack = tileEntityPresent.getTrueStackInSlot(c);
|
||||
|
||||
if (itemStack != null) {
|
||||
dropBlockAsItem(world, x, y, z, itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
world.func_147453_f(x, y, z, this);
|
||||
}
|
||||
|
||||
super.breakBlock(world, x, y, z, this, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int hitX, float hitY, float hitZ, float p_149727_9_) {
|
||||
if (!world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)) {
|
||||
player.openGui(Chisel.instance, 2, world, x, y, z);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
|
||||
if (world.getTileEntity(x, y, z) instanceof TileEntityPresent)
|
||||
return getBoundingBox((TileEntityPresent) world.getTileEntity(x, y, z));
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
|
||||
if (world.getTileEntity(x, y, z) instanceof TileEntityPresent)
|
||||
return getBoundingBox((TileEntityPresent) world.getTileEntity(x, y, z));
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public AxisAlignedBB getBoundingBox(TileEntityPresent me) {
|
||||
if (me == null) {
|
||||
return AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
int x = me.xCoord, y = me.yCoord, z = me.zCoord;
|
||||
if (me.isConnected()) {
|
||||
ForgeDirection dir = me.getConnectionDir();
|
||||
// warning: magic below! Do not change this conditional
|
||||
if (dir == ForgeDirection.EAST || (me.isParent() && dir == ForgeDirection.SOUTH) || (!me.isParent() && dir == ForgeDirection.SOUTH)) {
|
||||
return AxisAlignedBB.getBoundingBox(x + minX, y + minY, z + minZ, x + maxX + dir.offsetX, y + maxY, z + maxZ + dir.offsetZ);
|
||||
} else {
|
||||
return AxisAlignedBB.getBoundingBox(x + dir.offsetX + minX, y + minY, z + dir.offsetZ + minZ, x + maxX, y + maxY, z + maxZ);
|
||||
}
|
||||
}
|
||||
return AxisAlignedBB.getBoundingBox(x + minX, y + minY, z + minZ, x + maxX, y + maxY, z + maxZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
|
||||
TileEntityPresent te = (TileEntityPresent) world.getTileEntity(x, y, z);
|
||||
if (!te.isConnected()) {
|
||||
setBlockBounds(0.0625F, 0, 0.0625F, 0.9375F, 0.875F, 0.9365F);
|
||||
} else {
|
||||
ForgeDirection dir = te.getConnectionDir();
|
||||
switch (dir) {
|
||||
case EAST:
|
||||
setBlockBounds(0.0625F, 0, 0.0625F, 1, 0.875F, 0.9365F);
|
||||
break;
|
||||
case NORTH:
|
||||
setBlockBounds(0.0625F, 0, 0, 0.9375F, 0.875F, 0.9365F);
|
||||
break;
|
||||
case SOUTH:
|
||||
setBlockBounds(0.0625F, 0, 0.0625F, 0.9375F, 0.875F, 1);
|
||||
break;
|
||||
case WEST:
|
||||
setBlockBounds(0, 0, 0.0625F, 0.9375F, 0.875F, 0.9365F);
|
||||
break;
|
||||
default:
|
||||
setBlockBounds(0.0625F, 0, 0.0625F, 0.9375F, 0.875F, 0.9365F);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(int metadata) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, int metadata) {
|
||||
return new TileEntityPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(World world, int x, int y, int z, int strength) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (te instanceof TileEntityPresent) {
|
||||
return Container.calcRedstoneFromInventory((TileEntityPresent) te);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int meta) {
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
|
||||
return new ItemStack(this, 1, world.getBlockMetadata(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
this.blockIcon = register.registerIcon("planks_oak");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IVariationInfo getManager(int meta) {
|
||||
return carverHelper.getVariation(meta);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.config.Configurations;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockRoadLine extends BlockCarvable {
|
||||
|
||||
public IIcon aloneIcon[] = new IIcon[4];
|
||||
public IIcon halfLineIcon[] = new IIcon[4];
|
||||
public IIcon fullLineIcon[] = new IIcon[4];
|
||||
|
||||
public BlockRoadLine() {
|
||||
super(Material.circuits);
|
||||
|
||||
if (Configurations.useRoadLineTool) {
|
||||
this.setHarvestLevel(Configurations.getRoadLineTool, Configurations.roadLineToolLevel);
|
||||
}
|
||||
this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 0.00390625f, 1.0f);
|
||||
// this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return Chisel.roadLineId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) {
|
||||
return World.doesBlockHaveSolidTopSurface(par1World, par2, par3 - 1, par4) || par1World.getBlock(par2, par3 - 1, par4).equals(Blocks.glowstone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block block) {
|
||||
if (par1World.isRemote)
|
||||
return;
|
||||
|
||||
if (!this.canPlaceBlockAt(par1World, par2, par3, par4)) {
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, 0, 0);
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
}
|
||||
|
||||
super.onNeighborBlockChange(par1World, par2, par3, par4, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reg) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
String[] texNames = { "white", "yellow", "double-white", "double-yellow" };
|
||||
aloneIcon[i] = reg.registerIcon("Chisel:line-marking/" + texNames[i] + "-center");
|
||||
halfLineIcon[i] = reg.registerIcon("Chisel:line-marking/" + texNames[i] + "-side");
|
||||
fullLineIcon[i] = reg.registerIcon("Chisel:line-marking/" + texNames[i] + "-long");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return aloneIcon[metadata % aloneIcon.length];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return getIcon(side, world.getBlockMetadata(x, y, z));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,546 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import team.chisel.client.render.RendererSnakeStone;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockSnakestone extends Block {
|
||||
|
||||
static final int SEC_HEAD = 0;
|
||||
static final int SEC_DOWN = 4;
|
||||
static final int SEC_UP = 8;
|
||||
static final int SEC_HOR = 12;
|
||||
|
||||
static final int SIDE_B = 0;
|
||||
static final int SIDE_T = 1;
|
||||
static final int SIDE_N = 2;
|
||||
static final int SIDE_S = 3;
|
||||
static final int SIDE_W = 4;
|
||||
static final int SIDE_E = 5;
|
||||
|
||||
String iconPrefix;
|
||||
IIcon iconFaceLeft;
|
||||
IIcon iconFaceRight;
|
||||
IIcon iconCross;
|
||||
IIcon iconFace;
|
||||
IIcon iconTopTip;
|
||||
IIcon iconTopSide;
|
||||
IIcon iconBottom;
|
||||
IIcon iconBottomSide;
|
||||
IIcon iconBottomTip;
|
||||
IIcon iconLeftDown;
|
||||
IIcon iconRightDown;
|
||||
IIcon iconLeftUp;
|
||||
IIcon iconRightUp;
|
||||
IIcon iconLeftTip;
|
||||
IIcon iconSide;
|
||||
IIcon iconRightTip;
|
||||
IIcon iconTop;
|
||||
|
||||
public boolean flipTopTextures;
|
||||
|
||||
public BlockSnakestone(String iconPrefix) {
|
||||
super(Material.rock);
|
||||
setHardness(1.5F);
|
||||
setResistance(10.0F);
|
||||
setStepSound(Block.soundTypeStone);
|
||||
flipTopTextures = false;
|
||||
|
||||
this.iconPrefix = iconPrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return RendererSnakeStone.id;
|
||||
}
|
||||
|
||||
static final int[] rotRemap = { 0, 3, 1, 2 };
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta > 3)
|
||||
return;
|
||||
|
||||
if (rotateHead(world, x, y, z) != -1)
|
||||
return;
|
||||
|
||||
int rot = rotRemap[(MathHelper.floor_double(entity.rotationYaw * 4.0 / 360.0 + 0.5)) & 3];
|
||||
|
||||
world.setBlockMetadataWithNotify(x, y, z, rot, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onBlockPlaced(World world, int x, int y, int z, int side, float hx, float hy, float hz, int meta) {
|
||||
if (meta <= 3)
|
||||
return meta;
|
||||
|
||||
if (rotateBodyPart(world, x, y, z)) {
|
||||
return world.getBlockMetadata(x, y, z);
|
||||
}
|
||||
|
||||
if (side == 0 || side == 1)
|
||||
meta = 14;
|
||||
if (side == 2 || side == 3)
|
||||
meta = 13;
|
||||
if (side == 4 || side == 5)
|
||||
meta = 12;
|
||||
|
||||
world.setBlockMetadataWithNotify(x, y, z, meta, 2);
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
|
||||
int kind = world.getBlockMetadata(x, y, z) & 0xC;
|
||||
|
||||
if (kind == 0) {
|
||||
rotateHead(world, x, y, z);
|
||||
} else {
|
||||
rotateBodyPart(world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
public int[] getConnections(World world, int ox, int oy, int oz) {
|
||||
int index = 0;
|
||||
int[] res = { -1, -1, -1, -1, -1, -1, -1 };
|
||||
|
||||
for (int direction = 0; direction < 6; direction++) {
|
||||
int x = ox, y = oy, z = oz;
|
||||
switch (direction) {
|
||||
case 0:
|
||||
z--;
|
||||
break;
|
||||
case 1:
|
||||
z++;
|
||||
break;
|
||||
case 2:
|
||||
x--;
|
||||
break;
|
||||
case 3:
|
||||
x++;
|
||||
break;
|
||||
case 4:
|
||||
y--;
|
||||
break;
|
||||
case 5:
|
||||
y++;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!world.getBlock(x, y, z).equals(this))
|
||||
continue;
|
||||
boolean match = false;
|
||||
|
||||
int px1 = x, px2 = x;
|
||||
int py1 = y, py2 = y;
|
||||
int pz1 = z, pz2 = z;
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if ((meta & 0xc) == 4 || (meta & 0xc) == 8) {
|
||||
if ((meta & 4) == 4)
|
||||
py1--;
|
||||
else
|
||||
py1++;
|
||||
|
||||
switch (meta & 3) {
|
||||
case 0:
|
||||
pz2--;
|
||||
break;
|
||||
case 1:
|
||||
pz2++;
|
||||
break;
|
||||
case 2:
|
||||
px2--;
|
||||
break;
|
||||
case 3:
|
||||
px2++;
|
||||
break;
|
||||
}
|
||||
} else if (meta == 12) {
|
||||
px1--;
|
||||
px2++;
|
||||
} else if (meta == 13) {
|
||||
pz1--;
|
||||
pz2++;
|
||||
} else if (meta == 14) {
|
||||
py1--;
|
||||
py2++;
|
||||
} else if (meta == 15) {
|
||||
match = true;
|
||||
} else if (meta < 4) {
|
||||
match = true;
|
||||
}
|
||||
|
||||
if (!match) {
|
||||
Block b1 = world.getBlock(px1, py1, pz1);
|
||||
Block b2 = world.getBlock(px2, py2, pz2);
|
||||
|
||||
if (b1 != this || b2 != this)
|
||||
match = true;
|
||||
|
||||
if (ox == px1 && oy == py1 && oz == pz1)
|
||||
match = true;
|
||||
|
||||
if (ox == px2 && oy == py2 && oz == pz2)
|
||||
match = true;
|
||||
}
|
||||
|
||||
if (match)
|
||||
res[index++] = direction;
|
||||
}
|
||||
|
||||
if (index != 5)
|
||||
res[index] = -1;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean rotateBodyPart(World world, int x, int y, int z) {
|
||||
int[] con = getConnections(world, x, y, z);
|
||||
int blockMeta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if (con[1] == -1)
|
||||
return false;
|
||||
if (con[2] != -1)
|
||||
return false;
|
||||
|
||||
int meta = 15;
|
||||
|
||||
if (con[0] == 2 && con[1] == 3) {
|
||||
meta = 12;
|
||||
} else if (con[0] == 0 && con[1] == 1) {
|
||||
meta = 13;
|
||||
} else if (con[0] == 4 && con[1] == 5) {
|
||||
meta = 14;
|
||||
} else if (con[1] == 4) {
|
||||
meta = SEC_DOWN | con[0];
|
||||
} else if (con[1] == 5) {
|
||||
meta = SEC_UP | con[0];
|
||||
}
|
||||
|
||||
if (blockMeta != meta)
|
||||
world.setBlockMetadataWithNotify(x, y, z, meta, 3);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int rotateHead(World world, int x, int y, int z) {
|
||||
int[] con = getConnections(world, x, y, z);
|
||||
|
||||
if (con[1] >= 0 && con[1] < 4)
|
||||
return -1;
|
||||
|
||||
int meta = -1;
|
||||
switch (con[0]) {
|
||||
case 0:
|
||||
meta = 1;
|
||||
break;
|
||||
case 1:
|
||||
meta = 0;
|
||||
break;
|
||||
case 2:
|
||||
meta = 3;
|
||||
break;
|
||||
case 3:
|
||||
meta = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
if (meta == -1)
|
||||
return -1;
|
||||
|
||||
world.setBlock(x, y, z, this, meta, 3);
|
||||
return meta;
|
||||
}
|
||||
|
||||
public boolean connectedTo(World par1World, int x, int y, int z, int direction) {
|
||||
switch (direction) {
|
||||
case 0:
|
||||
return par1World.getBlock(x, y, z - 1).equals(this);
|
||||
case 1:
|
||||
return par1World.getBlock(x, y, z + 1).equals(this);
|
||||
case 2:
|
||||
return par1World.getBlock(x - 1, y, z).equals(this);
|
||||
case 3:
|
||||
return par1World.getBlock(x + 1, y, z).equals(this);
|
||||
case 4:
|
||||
return par1World.getBlock(x, y - 1, z).equals(this);
|
||||
case 5:
|
||||
return par1World.getBlock(x, y + 1, z).equals(this);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
|
||||
switch (meta | (side << 4)) {
|
||||
|
||||
case (SEC_HOR | 0 | (SIDE_B << 4)):
|
||||
return iconBottomTip;
|
||||
case (SEC_HOR | 0 | (SIDE_T << 4)):
|
||||
return iconTopSide;
|
||||
case (SEC_HOR | 0 | (SIDE_N << 4)):
|
||||
return iconSide;
|
||||
case (SEC_HOR | 0 | (SIDE_S << 4)):
|
||||
return iconSide;
|
||||
case (SEC_HOR | 0 | (SIDE_W << 4)):
|
||||
return iconCross;
|
||||
case (SEC_HOR | 0 | (SIDE_E << 4)):
|
||||
return iconCross;
|
||||
|
||||
case (SEC_HOR | 1 | (SIDE_B << 4)):
|
||||
return iconBottomTip;
|
||||
case (SEC_HOR | 1 | (SIDE_T << 4)):
|
||||
return iconTopSide;
|
||||
case (SEC_HOR | 1 | (SIDE_N << 4)):
|
||||
return iconCross;
|
||||
case (SEC_HOR | 1 | (SIDE_S << 4)):
|
||||
return iconCross;
|
||||
case (SEC_HOR | 1 | (SIDE_W << 4)):
|
||||
return iconSide;
|
||||
case (SEC_HOR | 1 | (SIDE_E << 4)):
|
||||
return iconSide;
|
||||
|
||||
case (SEC_HOR | 2 | (SIDE_B << 4)):
|
||||
return iconCross;
|
||||
case (SEC_HOR | 2 | (SIDE_T << 4)):
|
||||
return iconCross;
|
||||
case (SEC_HOR | 2 | (SIDE_N << 4)):
|
||||
return iconSide;
|
||||
case (SEC_HOR | 2 | (SIDE_S << 4)):
|
||||
return iconSide;
|
||||
case (SEC_HOR | 2 | (SIDE_W << 4)):
|
||||
return iconSide;
|
||||
case (SEC_HOR | 2 | (SIDE_E << 4)):
|
||||
return iconSide;
|
||||
|
||||
case (SEC_HOR | 3 | (SIDE_B << 4)):
|
||||
return iconBottom;
|
||||
case (SEC_HOR | 3 | (SIDE_T << 4)):
|
||||
return iconTop;
|
||||
case (SEC_HOR | 3 | (SIDE_N << 4)):
|
||||
return iconSide;
|
||||
case (SEC_HOR | 3 | (SIDE_S << 4)):
|
||||
return iconSide;
|
||||
case (SEC_HOR | 3 | (SIDE_W << 4)):
|
||||
return iconSide;
|
||||
case (SEC_HOR | 3 | (SIDE_E << 4)):
|
||||
return iconSide;
|
||||
|
||||
case (SEC_DOWN | 0 | (SIDE_B << 4)):
|
||||
return iconCross;
|
||||
case (SEC_DOWN | 0 | (SIDE_T << 4)):
|
||||
return iconTopTip;
|
||||
case (SEC_DOWN | 0 | (SIDE_N << 4)):
|
||||
return iconCross;
|
||||
case (SEC_DOWN | 0 | (SIDE_S << 4)):
|
||||
return iconRightTip;
|
||||
case (SEC_DOWN | 0 | (SIDE_W << 4)):
|
||||
return iconLeftDown;
|
||||
case (SEC_DOWN | 0 | (SIDE_E << 4)):
|
||||
return iconRightDown;
|
||||
|
||||
case (SEC_DOWN | 1 | (SIDE_B << 4)):
|
||||
return iconCross;
|
||||
case (SEC_DOWN | 1 | (SIDE_T << 4)):
|
||||
return iconTopTip;
|
||||
case (SEC_DOWN | 1 | (SIDE_N << 4)):
|
||||
return iconLeftTip;
|
||||
case (SEC_DOWN | 1 | (SIDE_S << 4)):
|
||||
return iconCross;
|
||||
case (SEC_DOWN | 1 | (SIDE_W << 4)):
|
||||
return iconRightDown;
|
||||
case (SEC_DOWN | 1 | (SIDE_E << 4)):
|
||||
return iconLeftDown;
|
||||
|
||||
case (SEC_DOWN | 2 | (SIDE_B << 4)):
|
||||
return iconCross;
|
||||
case (SEC_DOWN | 2 | (SIDE_T << 4)):
|
||||
return iconTopTip;
|
||||
case (SEC_DOWN | 2 | (SIDE_N << 4)):
|
||||
return iconRightDown;
|
||||
case (SEC_DOWN | 2 | (SIDE_S << 4)):
|
||||
return iconLeftDown;
|
||||
case (SEC_DOWN | 2 | (SIDE_W << 4)):
|
||||
return iconCross;
|
||||
case (SEC_DOWN | 2 | (SIDE_E << 4)):
|
||||
return iconLeftTip;
|
||||
|
||||
case (SEC_DOWN | 3 | (SIDE_B << 4)):
|
||||
return iconCross;
|
||||
case (SEC_DOWN | 3 | (SIDE_T << 4)):
|
||||
return iconTopTip;
|
||||
case (SEC_DOWN | 3 | (SIDE_N << 4)):
|
||||
return iconLeftDown;
|
||||
case (SEC_DOWN | 3 | (SIDE_S << 4)):
|
||||
return iconRightDown;
|
||||
case (SEC_DOWN | 3 | (SIDE_W << 4)):
|
||||
return iconRightTip;
|
||||
case (SEC_DOWN | 3 | (SIDE_E << 4)):
|
||||
return iconCross;
|
||||
|
||||
case (SEC_UP | 0 | (SIDE_B << 4)):
|
||||
return iconBottomSide;
|
||||
case (SEC_UP | 0 | (SIDE_T << 4)):
|
||||
return iconCross;
|
||||
case (SEC_UP | 0 | (SIDE_N << 4)):
|
||||
return iconCross;
|
||||
case (SEC_UP | 0 | (SIDE_S << 4)):
|
||||
return iconLeftTip;
|
||||
case (SEC_UP | 0 | (SIDE_W << 4)):
|
||||
return iconLeftUp;
|
||||
case (SEC_UP | 0 | (SIDE_E << 4)):
|
||||
return iconRightUp;
|
||||
|
||||
case (SEC_UP | 1 | (SIDE_B << 4)):
|
||||
return iconBottomSide;
|
||||
case (SEC_UP | 1 | (SIDE_T << 4)):
|
||||
return iconCross;
|
||||
case (SEC_UP | 1 | (SIDE_N << 4)):
|
||||
return iconRightTip;
|
||||
case (SEC_UP | 1 | (SIDE_S << 4)):
|
||||
return iconCross;
|
||||
case (SEC_UP | 1 | (SIDE_W << 4)):
|
||||
return iconRightUp;
|
||||
case (SEC_UP | 1 | (SIDE_E << 4)):
|
||||
return iconLeftUp;
|
||||
|
||||
case (SEC_UP | 2 | (SIDE_B << 4)):
|
||||
return iconBottomSide;
|
||||
case (SEC_UP | 2 | (SIDE_T << 4)):
|
||||
return iconCross;
|
||||
case (SEC_UP | 2 | (SIDE_N << 4)):
|
||||
return iconRightUp;
|
||||
case (SEC_UP | 2 | (SIDE_S << 4)):
|
||||
return iconLeftUp;
|
||||
case (SEC_UP | 2 | (SIDE_W << 4)):
|
||||
return iconCross;
|
||||
case (SEC_UP | 2 | (SIDE_E << 4)):
|
||||
return iconRightTip;
|
||||
|
||||
case (SEC_UP | 3 | (SIDE_B << 4)):
|
||||
return iconBottomSide;
|
||||
case (SEC_UP | 3 | (SIDE_T << 4)):
|
||||
return iconCross;
|
||||
case (SEC_UP | 3 | (SIDE_N << 4)):
|
||||
return iconLeftUp;
|
||||
case (SEC_UP | 3 | (SIDE_S << 4)):
|
||||
return iconRightUp;
|
||||
case (SEC_UP | 3 | (SIDE_W << 4)):
|
||||
return iconLeftTip;
|
||||
case (SEC_UP | 3 | (SIDE_E << 4)):
|
||||
return iconCross;
|
||||
|
||||
case (SEC_HEAD | 0 | (SIDE_B << 4)):
|
||||
return iconBottomSide;
|
||||
case (SEC_HEAD | 0 | (SIDE_T << 4)):
|
||||
return iconTopTip;
|
||||
case (SEC_HEAD | 0 | (SIDE_N << 4)):
|
||||
return iconFace;
|
||||
case (SEC_HEAD | 0 | (SIDE_S << 4)):
|
||||
return iconCross;
|
||||
case (SEC_HEAD | 0 | (SIDE_W << 4)):
|
||||
return iconFaceLeft;
|
||||
case (SEC_HEAD | 0 | (SIDE_E << 4)):
|
||||
return iconFaceRight;
|
||||
|
||||
case (SEC_HEAD | 1 | (SIDE_B << 4)):
|
||||
return iconBottomSide;
|
||||
case (SEC_HEAD | 1 | (SIDE_T << 4)):
|
||||
return iconTopTip;
|
||||
case (SEC_HEAD | 1 | (SIDE_N << 4)):
|
||||
return iconCross;
|
||||
case (SEC_HEAD | 1 | (SIDE_S << 4)):
|
||||
return iconFace;
|
||||
case (SEC_HEAD | 1 | (SIDE_W << 4)):
|
||||
return iconFaceRight;
|
||||
case (SEC_HEAD | 1 | (SIDE_E << 4)):
|
||||
return iconFaceLeft;
|
||||
|
||||
case (SEC_HEAD | 2 | (SIDE_B << 4)):
|
||||
return iconBottomSide;
|
||||
case (SEC_HEAD | 2 | (SIDE_T << 4)):
|
||||
return iconTopTip;
|
||||
case (SEC_HEAD | 2 | (SIDE_N << 4)):
|
||||
return iconFaceRight;
|
||||
case (SEC_HEAD | 2 | (SIDE_S << 4)):
|
||||
return iconFaceLeft;
|
||||
case (SEC_HEAD | 2 | (SIDE_W << 4)):
|
||||
return iconFace;
|
||||
case (SEC_HEAD | 2 | (SIDE_E << 4)):
|
||||
return iconCross;
|
||||
|
||||
case (SEC_HEAD | 3 | (SIDE_B << 4)):
|
||||
return iconBottomSide;
|
||||
case (SEC_HEAD | 3 | (SIDE_T << 4)):
|
||||
return iconTopTip;
|
||||
case (SEC_HEAD | 3 | (SIDE_N << 4)):
|
||||
return iconFaceLeft;
|
||||
case (SEC_HEAD | 3 | (SIDE_S << 4)):
|
||||
return iconFaceRight;
|
||||
case (SEC_HEAD | 3 | (SIDE_W << 4)):
|
||||
return iconCross;
|
||||
case (SEC_HEAD | 3 | (SIDE_E << 4)):
|
||||
return iconFace;
|
||||
|
||||
}
|
||||
|
||||
return iconCross;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
|
||||
list.add(new ItemStack(item, 1, 1));
|
||||
list.add(new ItemStack(item, 1, 13));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int meta) {
|
||||
if (meta < 4) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 13;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
iconFaceLeft = register.registerIcon(iconPrefix + "face-left");
|
||||
iconFaceRight = register.registerIcon(iconPrefix + "face-right");
|
||||
iconFace = register.registerIcon(iconPrefix + "face");
|
||||
|
||||
iconLeftUp = register.registerIcon(iconPrefix + "left-up");
|
||||
iconLeftDown = register.registerIcon(iconPrefix + "left-down");
|
||||
iconLeftTip = register.registerIcon(iconPrefix + "left-tip");
|
||||
|
||||
iconRightUp = register.registerIcon(iconPrefix + "right-up");
|
||||
iconRightDown = register.registerIcon(iconPrefix + "right-down");
|
||||
iconRightTip = register.registerIcon(iconPrefix + "right-tip");
|
||||
|
||||
iconTop = register.registerIcon(iconPrefix + "top");
|
||||
iconTopTip = register.registerIcon(iconPrefix + "top-tip");
|
||||
iconTopSide = register.registerIcon(iconPrefix + "top-side");
|
||||
|
||||
iconBottom = register.registerIcon(iconPrefix + "bot");
|
||||
iconBottomTip = register.registerIcon(iconPrefix + "bot-tip");
|
||||
iconBottomSide = register.registerIcon(iconPrefix + "bot-side");
|
||||
|
||||
iconCross = register.registerIcon(iconPrefix + "crosssection");
|
||||
iconSide = register.registerIcon(iconPrefix + "side");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import team.chisel.client.GeneralChiselClient;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockSnakestoneObsidian extends BlockSnakestone {
|
||||
|
||||
public static IIcon[] particles = new IIcon[8];
|
||||
|
||||
public BlockSnakestoneObsidian(String iconPrefix) {
|
||||
super(iconPrefix);
|
||||
|
||||
flipTopTextures = true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
|
||||
GeneralChiselClient.spawnSnakestoneObsidianFX(world, this, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
super.registerBlockIcons(register);
|
||||
|
||||
for (int i = 0; i < particles.length; i++) {
|
||||
particles[i] = register.registerIcon(iconPrefix + "particles/" + i);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
public class BlockWaterstone extends BlockMultiLayer {
|
||||
|
||||
public BlockWaterstone(Material mat, String baseIcon) {
|
||||
super(mat, baseIcon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
||||
|
||||
import team.chisel.init.ChiselTabs;
|
||||
import team.chisel.item.ItemCarvable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class CarvableStairsMaker {
|
||||
|
||||
public CarvableHelper carverHelper;
|
||||
// int idStart;
|
||||
Block blockBase;
|
||||
String blockName;
|
||||
|
||||
public CarvableStairsMaker(Block base) {
|
||||
carverHelper = new CarvableHelper(base);
|
||||
blockBase = base;
|
||||
}
|
||||
|
||||
public void create(String name, Block[] blocks) {
|
||||
create(null, name, blocks);
|
||||
}
|
||||
|
||||
public void create(IStairsCreator creator, String name, Block[] blocks) {
|
||||
for (int i = 0; i < blocks.length; i++) {
|
||||
String n = name + "." + i;
|
||||
blocks[i] = creator == null ? new BlockCarvableStairs(blockBase, i * 2, carverHelper) : creator.create(blockBase, i * 2, carverHelper);
|
||||
|
||||
blocks[i].setBlockName("chisel." + n).setCreativeTab(ChiselTabs.tabStairChiselBlocks);
|
||||
GameRegistry.registerBlock(blocks[i], ItemCarvable.class, n);
|
||||
|
||||
for (int meta = 0; meta < 2 && i * 2 + meta < carverHelper.infoList.size(); meta++) {
|
||||
IVariationInfo info = carverHelper.infoList.get(i * 2 + meta);
|
||||
|
||||
carverHelper.registerVariation(name, info);
|
||||
|
||||
GameRegistry.addRecipe(new ItemStack(blocks[i], 4, meta * 8), "* ", "** ", "***", '*', new ItemStack(blockBase, 1, i * 2 + meta));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package team.chisel.block;
|
||||
|
||||
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
public interface IStairsCreator {
|
||||
|
||||
public BlockCarvableStairs create(Block block, int meta, CarvableHelper helper);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package team.chisel.block.tileentity;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IDoubleChest {
|
||||
|
||||
/**
|
||||
* @return The size of this specific chest's inventory. Does not account for the connection.
|
||||
*/
|
||||
int getTrueSizeInventory();
|
||||
|
||||
/**
|
||||
* @param slot
|
||||
* The true slot index.
|
||||
* @return The actual stack in this chest's slot. Does not account for the connection.
|
||||
*/
|
||||
ItemStack getTrueStackInSlot(int slot);
|
||||
|
||||
/**
|
||||
* Puts a stack in this chest's real slot at the given true index.
|
||||
*
|
||||
* @param slot
|
||||
* The true slot index.
|
||||
* @param stack
|
||||
* The ItemStack to place in the slot.
|
||||
*/
|
||||
void putStackInTrueSlot(int slot, ItemStack stack);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,450 @@
|
||||
package team.chisel.block.tileentity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cricketcraft.chisel.api.IChiselItem;
|
||||
|
||||
import team.chisel.carving.Carving;
|
||||
import team.chisel.client.GeneralChiselClient;
|
||||
import team.chisel.init.ChiselItems;
|
||||
import team.chisel.network.PacketHandler;
|
||||
import team.chisel.network.message.MessageAutoChisel;
|
||||
import team.chisel.network.message.MessageSlotUpdate;
|
||||
import team.chisel.utils.General;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityAutoChisel extends TileEntity implements ISidedInventory {
|
||||
|
||||
public enum Upgrade {
|
||||
SPEED,
|
||||
AUTOMATION,
|
||||
STACK,
|
||||
REVERSION;
|
||||
|
||||
public String getUnlocalizedName() {
|
||||
return ChiselItems.upgrade.getUnlocalizedName() + "_" + this.name().toLowerCase();
|
||||
}
|
||||
|
||||
public String getLocalizedName() {
|
||||
return StatCollector.translateToLocal(getUnlocalizedName() + ".name");
|
||||
}
|
||||
}
|
||||
|
||||
public static final int BASE = 0, TARGET = 1, OUTPUT = 2, CHISEL = 3, MIN_UPGRADE = 4;
|
||||
private static final int FAST_SPEED = 1, SLOW_SPEED = 4;
|
||||
|
||||
private int progress = 0;
|
||||
|
||||
private static EntityItem ghostItem;
|
||||
boolean equal = false;
|
||||
private ItemStack[] inventory = new ItemStack[8];
|
||||
private String name = "autoChisel";
|
||||
|
||||
// client animation fields
|
||||
|
||||
// used for floating target
|
||||
public float xRot, yRot, zRot;
|
||||
|
||||
// used for chisel item rotation
|
||||
public static final int maxRot = 60;
|
||||
public static final int rotAmnt = 15;
|
||||
public float chiselRot;
|
||||
public boolean chiseling = false, breakChisel = false;;
|
||||
public int toChisel = 1;
|
||||
|
||||
private ItemStack lastBase;
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int size) {
|
||||
if (inventory[slot] != null) {
|
||||
ItemStack is;
|
||||
if (inventory[slot].stackSize <= size) {
|
||||
is = inventory[slot];
|
||||
inventory[slot] = null;
|
||||
return is;
|
||||
} else {
|
||||
is = inventory[slot].splitStack(size);
|
||||
if (inventory[slot].stackSize == 0)
|
||||
inventory[slot] = null;
|
||||
return is;
|
||||
}
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
NBTTagList tags = nbt.getTagList("Items", 10);
|
||||
inventory = new ItemStack[getSizeInventory()];
|
||||
|
||||
for (int i = 0; i < tags.tagCount(); i++) {
|
||||
NBTTagCompound data = tags.getCompoundTagAt(i);
|
||||
int j = data.getByte("Slot") & 255;
|
||||
|
||||
if (j >= 0 && j < inventory.length) {
|
||||
inventory[j] = ItemStack.loadItemStackFromNBT(data);
|
||||
}
|
||||
}
|
||||
|
||||
if (nbt.hasKey("CustomName", 8)) {
|
||||
this.name = nbt.getString("CustomName");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
ItemStack base = inventory[BASE], target = getTarget(), output = inventory[OUTPUT];
|
||||
|
||||
if (!worldObj.isRemote && hasChisel() && base != null && target != null) {
|
||||
if (canBeMadeFrom(base, target)) {
|
||||
if (progress >= (hasUpgrade(Upgrade.SPEED) ? FAST_SPEED : SLOW_SPEED)) {
|
||||
|
||||
// reset progress
|
||||
progress = 0;
|
||||
|
||||
// the max possible for this craft
|
||||
int canBeMade = target.getMaxStackSize();
|
||||
|
||||
// if there are items in the output, they count towards the max we can make
|
||||
if (output != null) {
|
||||
canBeMade -= output.stackSize;
|
||||
}
|
||||
|
||||
// can't make more than we have
|
||||
canBeMade = Math.min(base.stackSize, canBeMade);
|
||||
|
||||
// if we can't make any, forget it
|
||||
if (canBeMade <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// result will always be a copy of the target
|
||||
ItemStack chiseled = target.copy();
|
||||
|
||||
// if we have the stack upgrade, boost the stack size to the max possible, otherwise just one
|
||||
chiseled.stackSize = hasUpgrade(Upgrade.STACK) ? canBeMade : 1;
|
||||
|
||||
if (canChisel(chiseled)) {
|
||||
// if our output is empty, just use the current result
|
||||
if (output == null) {
|
||||
setInventorySlotContents(OUTPUT, chiseled);
|
||||
} else {
|
||||
// otherwise just add our result to the existing stack
|
||||
inventory[OUTPUT].stackSize += chiseled.stackSize;
|
||||
slotChanged(OUTPUT);
|
||||
}
|
||||
|
||||
chiselItem(chiseled.stackSize, target);
|
||||
|
||||
// remove what we made from the stack
|
||||
base.stackSize -= chiseled.stackSize;
|
||||
if (base.stackSize <= 0) {
|
||||
setInventorySlotContents(BASE, null); // clear out 0 size itemstacks
|
||||
}
|
||||
}
|
||||
} else if (worldObj.getTotalWorldTime() % 10 == 0) {
|
||||
progress++;
|
||||
}
|
||||
}
|
||||
} else if (worldObj.isRemote) {
|
||||
if (chiseling) {
|
||||
chiselRot += rotAmnt;
|
||||
if (chiselRot >= maxRot) {
|
||||
chiselItem(0, getTarget());
|
||||
}
|
||||
} else {
|
||||
chiselRot = Math.max(chiselRot - rotAmnt, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ItemStack getTarget() {
|
||||
if (inventory[BASE] != null && hasUpgrade(Upgrade.REVERSION)) {
|
||||
// if we have a reversion upgrade, use that for the target
|
||||
List<ItemStack> possible = Carving.chisel.getItemsForChiseling(inventory[BASE]);
|
||||
return possible.isEmpty() ? null : possible.get(0);
|
||||
} else {
|
||||
return inventory[TARGET];
|
||||
}
|
||||
}
|
||||
|
||||
// lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target
|
||||
private boolean canBeMadeFrom(ItemStack from, ItemStack to) {
|
||||
List<ItemStack> results = Carving.chisel.getItemsForChiseling(from);
|
||||
for (ItemStack s : results) {
|
||||
if (s.getItem() == to.getItem() && s.getItemDamage() == to.getItemDamage()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean canChisel(ItemStack toMerge) {
|
||||
// if the output slot is empty we can merge without checking
|
||||
if (inventory[OUTPUT] == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// need to check NBT as well as item
|
||||
if (!toMerge.isItemEqual(inventory[OUTPUT]) || !ItemStack.areItemStackTagsEqual(toMerge, inventory[OUTPUT])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// we only care about metadata if the item has subtypes
|
||||
if (toMerge.getHasSubtypes() && toMerge.getItemDamage() != inventory[OUTPUT].getItemDamage()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ((IChiselItem) inventory[CHISEL].getItem()).canChisel(worldObj, inventory[CHISEL], General.getVariation(getTarget()));
|
||||
}
|
||||
|
||||
private boolean hasChisel() {
|
||||
return inventory[CHISEL] != null && inventory[CHISEL].getItem() instanceof IChiselItem && inventory[CHISEL].stackSize >= 1;
|
||||
}
|
||||
|
||||
/** Calls IChiselItem#onChisel() and sends the chisel packet for sound/animation */
|
||||
private void chiselItem(int chiseled, ItemStack target) {
|
||||
if (!worldObj.isRemote) {
|
||||
boolean breakChisel = false;
|
||||
if (((IChiselItem) inventory[CHISEL].getItem()).onChisel(worldObj, inventory[CHISEL], General.getVariation(target))) {
|
||||
inventory[CHISEL].setItemDamage(inventory[CHISEL].getItemDamage() + 1);
|
||||
if (inventory[CHISEL].getItemDamage() >= inventory[CHISEL].getMaxDamage()) {
|
||||
setInventorySlotContents(CHISEL, null);
|
||||
breakChisel = true;
|
||||
}
|
||||
}
|
||||
PacketHandler.INSTANCE.sendToDimension(new MessageAutoChisel(this, chiseled, true, breakChisel), worldObj.provider.dimensionId);
|
||||
} else {
|
||||
if (breakChisel) {
|
||||
worldObj.playSound(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "random.break", 0.8F, 0.8F + worldObj.rand.nextFloat() * 0.4F, false);
|
||||
}
|
||||
GeneralChiselClient.spawnAutoChiselFX(this, lastBase != null ? lastBase : inventory[BASE]);
|
||||
chiseling = false;
|
||||
if (lastBase != null) {
|
||||
lastBase.stackSize -= toChisel;
|
||||
if (lastBase.stackSize <= 0) {
|
||||
lastBase = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
NBTTagList tags = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < inventory.length; i++) {
|
||||
if (inventory[i] != null) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setByte("Slot", (byte) i);
|
||||
inventory[i].writeToNBT(data);
|
||||
tags.appendTag(data);
|
||||
}
|
||||
}
|
||||
|
||||
nbt.setTag("Items", tags);
|
||||
|
||||
if (this.hasCustomInventoryName()) {
|
||||
nbt.setString("CustomName", this.name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return inventory.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return inventory[slot];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
if (inventory[slot] != null) {
|
||||
ItemStack is = inventory[slot];
|
||||
inventory[slot] = null;
|
||||
return is;
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
inventory[slot] = stack;
|
||||
|
||||
if (stack != null && stack.stackSize > getInventoryStackLimit()) {
|
||||
stack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
|
||||
if (worldObj.isRemote && slot == BASE && stack != null) {
|
||||
lastBase = stack.copy();
|
||||
}
|
||||
|
||||
if (!worldObj.isRemote) {
|
||||
slotChanged(slot);
|
||||
}
|
||||
}
|
||||
|
||||
private void slotChanged(int slot) {
|
||||
PacketHandler.INSTANCE.sendToDimension(new MessageSlotUpdate(this, slot, inventory[slot]), worldObj.provider.dimensionId);
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return new int[] { BASE, TARGET, OUTPUT, CHISEL };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack itemStack) {
|
||||
if (itemStack == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (slot) {
|
||||
case BASE:
|
||||
case TARGET:
|
||||
return !Carving.chisel.getItemsForChiseling(itemStack).isEmpty();
|
||||
case OUTPUT:
|
||||
return false;
|
||||
case CHISEL:
|
||||
return itemStack.getItem() instanceof IChiselItem;
|
||||
default:
|
||||
return itemStack.getItem() == ChiselItems.upgrade && Upgrade.values()[slot - MIN_UPGRADE].ordinal() == itemStack.getItemDamage();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack itemStack, int side) {
|
||||
return hasUpgrade(Upgrade.AUTOMATION) && (slot == BASE || slot == TARGET || slot == CHISEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack itemStack, int side) {
|
||||
return hasUpgrade(Upgrade.AUTOMATION) && slot == OUTPUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public EntityItem getItemForRendering(int slot) {
|
||||
if (ghostItem == null) {
|
||||
ghostItem = new EntityItem(worldObj);
|
||||
ghostItem.hoverStart = 0.0F;
|
||||
}
|
||||
|
||||
if (slot == BASE && lastBase != null) {
|
||||
ghostItem.setEntityItemStack(lastBase.copy());
|
||||
return ghostItem;
|
||||
} else if (slot == TARGET) {
|
||||
ItemStack target = getTarget();
|
||||
if (target != null) {
|
||||
ghostItem.setEntityItemStack(target);
|
||||
return ghostItem;
|
||||
}
|
||||
return null;
|
||||
} else if (inventory[slot] == null) {
|
||||
return null;
|
||||
} else {
|
||||
ghostItem.setEntityItemStack(inventory[slot].copy());
|
||||
return ghostItem;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeToNBT(tag);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
|
||||
readFromNBT(packet.func_148857_g());
|
||||
}
|
||||
|
||||
public boolean hasUpgrade(Upgrade upgrade) {
|
||||
ItemStack stack = inventory[MIN_UPGRADE + upgrade.ordinal()];
|
||||
if (stack != null) {
|
||||
return stack.getItem() == ChiselItems.upgrade && stack.getItemDamage() == upgrade.ordinal();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getSlotTooltipUnloc(int slotNumber) {
|
||||
String base = "autochisel.slot.%s.tooltip";
|
||||
String name = null;
|
||||
if (slotNumber < MIN_UPGRADE) {
|
||||
if (slotNumber == TARGET) {
|
||||
name = "target";
|
||||
} else if (slotNumber == CHISEL) {
|
||||
name = "chisel";
|
||||
}
|
||||
return name == null ? null : String.format(base, name);
|
||||
} else {
|
||||
return Upgrade.values()[slotNumber - MIN_UPGRADE].getUnlocalizedName() + ".name";
|
||||
}
|
||||
}
|
||||
|
||||
public void doChiselAnim(ItemStack lastChiseled, int chiseled, boolean playSound, boolean breakChisel) {
|
||||
this.lastBase = lastChiseled == null ? null : lastChiseled.copy();
|
||||
this.toChisel = chiseled;
|
||||
if (playSound) {
|
||||
this.chiseling = true;
|
||||
}
|
||||
this.breakChisel = breakChisel;
|
||||
}
|
||||
|
||||
public ItemStack getLastBase() {
|
||||
return lastBase == null ? null : lastBase.copy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package team.chisel.block.tileentity;
|
||||
|
||||
import net.minecraft.tileentity.TileEntityBeacon;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityCarvableBeacon extends TileEntityBeacon {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
return INFINITE_EXTENT_AABB;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,365 @@
|
||||
package team.chisel.block.tileentity;
|
||||
|
||||
import team.chisel.init.ChiselBlocks;
|
||||
import team.chisel.network.PacketHandler;
|
||||
import team.chisel.network.message.MessagePresentConnect;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityPresent extends TileEntity implements IInventory, IDoubleChest {
|
||||
|
||||
private TileEntityPresent connection = null;
|
||||
// If cachedDir is non-null, but connection is null, this present must be
|
||||
// connected to an unloaded present. This is handled appropriately.
|
||||
private ForgeDirection cachedDir = null;
|
||||
private boolean isParent;
|
||||
private final ItemStack[] inventory = new ItemStack[27];
|
||||
private int rotation;
|
||||
private boolean autoSearch = true;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (!isConnected() && autoSearch && worldObj != null /* ugh */) {
|
||||
if (cachedDir != null) {
|
||||
connectTo(cachedDir);
|
||||
} else if (!worldObj.isRemote) {
|
||||
findConnections();
|
||||
}
|
||||
autoSearch = false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
return connection != null;
|
||||
}
|
||||
|
||||
private boolean connectTo(TileEntityPresent present, ForgeDirection dir) {
|
||||
if (present.getBlockMetadata() == getBlockMetadata() && !present.isConnected() && (present.cachedDir == null || present.cachedDir == dir.getOpposite())
|
||||
&& Math.abs(present.xCoord - xCoord + present.yCoord - yCoord + present.zCoord - zCoord) == 1) {
|
||||
connection = present;
|
||||
connection.connection = this;
|
||||
connection.cachedDir = dir.getOpposite();
|
||||
connection.markDirty();
|
||||
cachedDir = dir;
|
||||
isParent = !present.isParent;
|
||||
markDirty();
|
||||
PacketHandler.INSTANCE.sendToDimension(new MessagePresentConnect(this, dir, true), worldObj.provider.dimensionId);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean connectTo(ForgeDirection dir) {
|
||||
int x = xCoord + dir.offsetX, y = yCoord + dir.offsetY, z = zCoord + dir.offsetZ;
|
||||
TileEntity te = getTileSafe(x, y, z);
|
||||
if (te instanceof TileEntityPresent) {
|
||||
return connectTo((TileEntityPresent) te, dir);
|
||||
}
|
||||
return !exists(x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param preserveDir
|
||||
* If true, this is only a virtual disconnect, meaning the other chest still exists, but is still loaded, so maintain a cachedDir for reconnection upon chunk load.
|
||||
*/
|
||||
public void disconnect(boolean preserveDir) {
|
||||
if (isConnected()) {
|
||||
if (!preserveDir) {
|
||||
this.connection.cachedDir = null;
|
||||
this.cachedDir = null;
|
||||
}
|
||||
this.connection.connection = null;
|
||||
this.connection.markDirty();
|
||||
this.connection = null;
|
||||
this.markDirty();
|
||||
PacketHandler.INSTANCE.sendToDimension(new MessagePresentConnect(this, ForgeDirection.UNKNOWN, false, preserveDir), worldObj.provider.dimensionId);
|
||||
}
|
||||
}
|
||||
|
||||
public TileEntityPresent getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
public ForgeDirection getConnectionDir() {
|
||||
return cachedDir == null ? ForgeDirection.UNKNOWN : cachedDir;
|
||||
}
|
||||
|
||||
public boolean isParent() {
|
||||
return isParent || !isConnected();
|
||||
}
|
||||
|
||||
public int getRotation() {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
public void setRotation(int rot) {
|
||||
this.rotation = rot;
|
||||
}
|
||||
|
||||
public void findConnections() {
|
||||
if (!isConnected()) {
|
||||
if (cachedDir != null) {
|
||||
if (connectTo(cachedDir)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if (dir != ForgeDirection.UP && dir != ForgeDirection.DOWN) {
|
||||
if (connectTo(dir)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TileEntityPresent getParent() {
|
||||
return isParent || connection == null ? this : connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
return ChiselBlocks.present.getBoundingBox(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < getTrueSizeInventory(); ++i) {
|
||||
if (inventory[i] != null) {
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
nbttagcompound1.setByte("Slot", (byte) i);
|
||||
inventory[i].writeToNBT(nbttagcompound1);
|
||||
nbttaglist.appendTag(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
|
||||
tag.setTag("Items", nbttaglist);
|
||||
tag.setBoolean("isParent", isParent);
|
||||
tag.setInteger("rotation", rotation);
|
||||
if (cachedDir != null) {
|
||||
tag.setInteger("conDir", cachedDir.ordinal());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
NBTTagList nbttaglist = tag.getTagList("Items", 10);
|
||||
|
||||
for (int i = 0; i < nbttaglist.tagCount(); ++i) {
|
||||
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
|
||||
int j = nbttagcompound1.getByte("Slot") & 255;
|
||||
|
||||
if (j >= 0 && j < getTrueSizeInventory()) {
|
||||
inventory[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
|
||||
this.isParent = tag.getBoolean("isParent");
|
||||
|
||||
this.rotation = tag.getInteger("rotation");
|
||||
if (tag.hasKey("conDir")) {
|
||||
cachedDir = ForgeDirection.values()[tag.getInteger("conDir")];
|
||||
}
|
||||
autoSearch = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeToNBT(tag);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
|
||||
readFromNBT(packet.func_148857_g());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRefresh(Block oldBlock, Block newBlock, int oldMeta, int newMeta, World world, int x, int y, int z) {
|
||||
// prevent losing TE data when in-world chiseling
|
||||
return oldBlock != newBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
if (isConnected()) {
|
||||
disconnect(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
if (isConnected()) {
|
||||
disconnect(true);
|
||||
}
|
||||
}
|
||||
|
||||
private int getAdjustedSlot(int slot) {
|
||||
slot %= getSizeInventory();
|
||||
if (isConnected() && !isParent) {
|
||||
slot = (slot + getTrueSizeInventory()) % getSizeInventory();
|
||||
}
|
||||
return slot;
|
||||
}
|
||||
|
||||
private TileEntity getTileSafe(int x, int y, int z) {
|
||||
if (exists(x, y, z)) {
|
||||
return worldObj.getTileEntity(x, y, z);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// private Block getBlockSafe(int x, int y, int z) {
|
||||
// if (exists(x, y, z)) {
|
||||
// return worldObj.getBlock(x, y, z);
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// private int getMetaSafe(int x, int y, int z) {
|
||||
// if (exists(x, y, z)) {
|
||||
// return worldObj.getBlockMetadata(x, y, z);
|
||||
// }
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
private boolean exists(int x, int y, int z) {
|
||||
return worldObj.blockExists(x, y, z);
|
||||
}
|
||||
|
||||
/* IInventory */
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return isConnected() ? getTrueSizeInventory() + connection.getTrueSizeInventory() : getTrueSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
slot = getAdjustedSlot(slot);
|
||||
if (slot >= getTrueSizeInventory()) {
|
||||
return isConnected() ? connection.inventory[slot % getTrueSizeInventory()] : null;
|
||||
} else {
|
||||
return inventory[slot];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
slot = getAdjustedSlot(slot);
|
||||
ItemStack[] inv = inventory;
|
||||
if (isConnected() && slot >= getTrueSizeInventory()) {
|
||||
inv = connection.inventory;
|
||||
slot %= getTrueSizeInventory();
|
||||
connection.markDirty();
|
||||
}
|
||||
|
||||
if (inv[slot] != null) {
|
||||
ItemStack itemstack;
|
||||
|
||||
if (inv[slot].stackSize <= amount) {
|
||||
itemstack = inv[slot];
|
||||
inv[slot] = null;
|
||||
this.markDirty();
|
||||
return itemstack;
|
||||
} else {
|
||||
itemstack = inv[slot].splitStack(amount);
|
||||
|
||||
if (inv[slot].stackSize == 0) {
|
||||
inv[slot] = null;
|
||||
}
|
||||
|
||||
this.markDirty();
|
||||
return itemstack;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
return getStackInSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
slot = getAdjustedSlot(slot);
|
||||
if (slot < getTrueSizeInventory()) {
|
||||
inventory[slot] = stack;
|
||||
} else if (isConnected()) {
|
||||
connection.inventory[slot % getTrueSizeInventory()] = stack;
|
||||
connection.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "chisel.present";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer p_70300_1_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* IDoubleChest */
|
||||
|
||||
@Override
|
||||
public int getTrueSizeInventory() {
|
||||
return inventory.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getTrueStackInSlot(int slot) {
|
||||
return inventory[slot % getTrueSizeInventory()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStackInTrueSlot(int slot, ItemStack stack) {
|
||||
inventory[slot % getTrueSizeInventory()] = stack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
package team.chisel.carving;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
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;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class Carving implements ICarvingRegistry {
|
||||
|
||||
GroupList groups = new GroupList();
|
||||
|
||||
public static final ICarvingRegistry chisel = new Carving();
|
||||
public static final Carving needle = new Carving();
|
||||
|
||||
static {
|
||||
CarvingUtils.chisel = chisel;
|
||||
}
|
||||
|
||||
public static void construct() {
|
||||
}
|
||||
|
||||
private Carving() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICarvingVariation getVariation(Block block, int metadata) {
|
||||
ICarvingGroup g = getGroup(block, metadata);
|
||||
if (g != null) {
|
||||
for (ICarvingVariation v : g.getVariations()) {
|
||||
if (v.getBlock() == block && v.getBlockMeta() == metadata) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ICarvingVariation> getGroupVariations(Block block, int metadata) {
|
||||
ICarvingGroup group = getGroup(block, metadata);
|
||||
if (group == null)
|
||||
return null;
|
||||
|
||||
return group.getVariations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOreName(Block block, int metadata) {
|
||||
ICarvingGroup group = getGroup(block, metadata);
|
||||
if (group == null)
|
||||
return null;
|
||||
|
||||
return group.getOreName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getItemsForChiseling(ItemStack chiseledItem) {
|
||||
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
|
||||
|
||||
ICarvingGroup group = null;
|
||||
|
||||
int[] oreids = OreDictionary.getOreIDs(chiseledItem);
|
||||
for (int i : oreids) {
|
||||
group = groups.getGroupByOre(OreDictionary.getOreName(i));
|
||||
if (group != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (group == null) {
|
||||
group = getGroup(Block.getBlockFromItem(chiseledItem.getItem()), chiseledItem.getItemDamage());
|
||||
}
|
||||
|
||||
if (group == null)
|
||||
return items;
|
||||
|
||||
HashMap<String, Integer> mapping = new HashMap<String, Integer>();
|
||||
|
||||
List<ICarvingVariation> variations = group.getVariations();
|
||||
|
||||
if (!group.getVariations().isEmpty()) {
|
||||
for (ICarvingVariation v : variations) {
|
||||
|
||||
String key = Block.getIdFromBlock(v.getBlock()) + "|" + v.getItemMeta();
|
||||
if (mapping.containsKey(key))
|
||||
continue;
|
||||
mapping.put(key, 1);
|
||||
|
||||
items.add(new ItemStack(v.getBlock(), 1, v.getItemMeta()));
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<ItemStack> ores;
|
||||
String oreName = group.getOreName();
|
||||
if (oreName != null && ((ores = OreDictionary.getOres(oreName)) != null)) {
|
||||
for (ItemStack stack : ores) {
|
||||
|
||||
String key = Item.getIdFromItem(stack.getItem()) + "|" + stack.getItemDamage();
|
||||
if (mapping.containsKey(key))
|
||||
continue;
|
||||
mapping.put(key, 2);
|
||||
|
||||
items.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICarvingGroup getGroup(Block block, int metadata) {
|
||||
int[] ids = OreDictionary.getOreIDs(new ItemStack(block, 1, metadata));
|
||||
if (ids.length > 0) {
|
||||
for (int id : ids) {
|
||||
ICarvingGroup oreGroup = groups.getGroupByOre(OreDictionary.getOreName(id));
|
||||
if (oreGroup != null) {
|
||||
return oreGroup;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return groups.getGroup(block, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICarvingGroup getGroup(String name) {
|
||||
return groups.getGroupByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICarvingGroup removeGroup(String groupName) {
|
||||
ICarvingGroup g = groups.getGroupByName(groupName);
|
||||
return groups.remove(g) ? g : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICarvingVariation removeVariation(Block block, int metadata) {
|
||||
return removeVariation(block, metadata, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICarvingVariation removeVariation(Block block, int metadata, String group) {
|
||||
return groups.removeVariation(block, metadata, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addVariation(String groupName, Block block, int metadata, int order) {
|
||||
if (block == null) {
|
||||
throw new NullPointerException("Cannot add variation in group " + groupName + " for null block.");
|
||||
}
|
||||
|
||||
ICarvingVariation variation = CarvingUtils.getDefaultVariationFor(block, metadata, order);
|
||||
addVariation(groupName, variation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addVariation(String groupName, ICarvingVariation variation) {
|
||||
if (groupName == null) {
|
||||
throw new NullPointerException("Cannot add variation to null group name.");
|
||||
} else if (variation == null) {
|
||||
throw new NullPointerException("Cannot add variation in group " + groupName + " for null variation.");
|
||||
}
|
||||
|
||||
ICarvingGroup group = groups.getGroupByName(groupName);
|
||||
|
||||
if (group == null) {
|
||||
group = CarvingUtils.getDefaultGroupFor(groupName);
|
||||
addGroup(group);
|
||||
}
|
||||
|
||||
groups.addVariation(groupName, variation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGroup(ICarvingGroup group) {
|
||||
groups.add(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerOre(String name, String oreName) {
|
||||
ICarvingGroup group = groups.getGroupByName(name);
|
||||
if (group != null) {
|
||||
group.setOreName(oreName);
|
||||
} else {
|
||||
throw new NullPointerException("Cannot register ore name for group " + name + ", as it does not exist.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVariationSound(String name, String sound) {
|
||||
ICarvingGroup group = groups.getGroupByName(name);
|
||||
if (group != null) {
|
||||
group.setSound(sound);
|
||||
} else {
|
||||
throw new NullPointerException("Cannot set sound for group " + name + ", as it does not exist.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVariationSound(Block block, int metadata) {
|
||||
return getVariationSound(Item.getItemFromBlock(block), metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVariationSound(Item item, int metadata) {
|
||||
ICarvingGroup group = groups.getGroup(Block.getBlockFromItem(item), metadata);
|
||||
String sound = group == null ? null : group.getSound();
|
||||
return sound == null ? Chisel.MOD_ID + ":chisel.fallback" : sound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSortedGroupNames() {
|
||||
List<String> names = new ArrayList<String>();
|
||||
names.addAll(groups.getNames());
|
||||
Collections.sort(names);
|
||||
return names;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
package team.chisel.carving;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingGroup;
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
public class GroupList implements Set<ICarvingGroup> {
|
||||
|
||||
private class VariationWrapper {
|
||||
|
||||
private ICarvingVariation v;
|
||||
|
||||
private VariationWrapper(ICarvingVariation v) {
|
||||
this.v = v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof ICarvingVariation) {
|
||||
ICarvingVariation v2 = (ICarvingVariation) obj;
|
||||
return v.getBlock() == v2.getBlock() && (v.getBlockMeta() == v2.getBlockMeta() || v.getItemMeta() == v2.getItemMeta());
|
||||
} else if (obj instanceof VariationWrapper) {
|
||||
return equals(((VariationWrapper) obj).v);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return v.getBlock().hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
private class VariationKey implements ICarvingVariation {
|
||||
|
||||
Pair<Block, Integer> data;
|
||||
|
||||
private VariationKey(Block block, int blockMeta) {
|
||||
data = Pair.of(block, blockMeta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock() {
|
||||
return data.getLeft();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockMeta() {
|
||||
return data.getRight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemMeta() {
|
||||
return data.getRight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return data.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private HashMap<String, ICarvingGroup> groups = Maps.newHashMap();
|
||||
private HashMap<VariationWrapper, ICarvingGroup> lookup = Maps.newHashMap();
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return groups.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return groups.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
if (o instanceof ICarvingGroup) {
|
||||
return groups.containsKey(((ICarvingGroup) o).getName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<ICarvingGroup> iterator() {
|
||||
return groups.values().iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return groups.values().toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(T[] arr) {
|
||||
return groups.values().toArray(arr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(ICarvingGroup group) {
|
||||
String key = group.getName();
|
||||
if (groups.containsKey(key)) {
|
||||
return false;
|
||||
}
|
||||
for (ICarvingVariation v : group.getVariations()) {
|
||||
ICarvingGroup g = lookup.get(v);
|
||||
if (g == null) {
|
||||
lookup.put(new VariationWrapper(v), group);
|
||||
}
|
||||
}
|
||||
groups.put(key, group);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
if (o instanceof ICarvingGroup) {
|
||||
List<VariationWrapper> toRemove = Lists.newArrayList();
|
||||
for (VariationWrapper v : lookup.keySet()) {
|
||||
if (lookup.get(v).getName().equals(((ICarvingGroup) o).getName())) {
|
||||
toRemove.add(v);
|
||||
}
|
||||
}
|
||||
for (VariationWrapper v : toRemove) {
|
||||
lookup.remove(v);
|
||||
}
|
||||
return groups.remove(((ICarvingGroup) o).getName()) != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
for (Object o : c) {
|
||||
if (!(o instanceof ICarvingGroup)) {
|
||||
return false;
|
||||
}
|
||||
if (!groups.containsKey(((ICarvingGroup) o).getName())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends ICarvingGroup> c) {
|
||||
boolean ret = false;
|
||||
for (ICarvingGroup g : c) {
|
||||
ret |= add(g);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> c) {
|
||||
boolean ret = false;
|
||||
for (Object o : c) {
|
||||
ret |= remove(o);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> c) {
|
||||
throw new UnsupportedOperationException(); // not using it, not gonna bother
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
groups.clear();
|
||||
}
|
||||
|
||||
public ICarvingGroup getGroup(Block block, int metadata) {
|
||||
return lookup.get(new VariationWrapper(new VariationKey(block, metadata)));
|
||||
}
|
||||
|
||||
public void addVariation(String name, ICarvingVariation variation) {
|
||||
ICarvingGroup g = groups.get(name);
|
||||
if (g == null) {
|
||||
throw new NullPointerException("No group exists for name " + name);
|
||||
}
|
||||
g.addVariation(variation);
|
||||
lookup.put(new VariationWrapper(variation), g);
|
||||
}
|
||||
|
||||
public ICarvingGroup getGroupByName(String groupName) {
|
||||
return groups.get(groupName);
|
||||
}
|
||||
|
||||
public ICarvingGroup getGroupByOre(String oreName) {
|
||||
for (ICarvingGroup group : groups.values()) {
|
||||
if (oreName.equals(group.getOreName())) {
|
||||
return group;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Collection<? extends String> getNames() {
|
||||
return groups.keySet();
|
||||
}
|
||||
|
||||
public ICarvingVariation removeVariation(Block block, int metadata, String group) {
|
||||
ICarvingGroup g = null;
|
||||
if (group != null) {
|
||||
g = groups.get(group);
|
||||
if (g == null) {
|
||||
throw new IllegalArgumentException("No such group " + group);
|
||||
}
|
||||
groups.remove(g.getName());
|
||||
}
|
||||
List<VariationWrapper> toRemove = Lists.newArrayList();
|
||||
for (VariationWrapper v : lookup.keySet()) {
|
||||
if ((g == null || lookup.get(v).getName().equals(g.getName())) && v.equals(new VariationWrapper(new VariationKey(block, metadata)))) {
|
||||
lookup.get(v).removeVariation(v.v);
|
||||
toRemove.add(v);
|
||||
}
|
||||
}
|
||||
for (VariationWrapper v : toRemove) {
|
||||
lookup.remove(v);
|
||||
}
|
||||
return toRemove.isEmpty() ? null : toRemove.get(0).v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return groups.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
package team.chisel.client;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import team.chisel.block.BlockGrimstone;
|
||||
import team.chisel.block.BlockHolystone;
|
||||
import team.chisel.block.BlockLavastone;
|
||||
import team.chisel.block.BlockSnakestoneObsidian;
|
||||
import team.chisel.block.tileentity.TileEntityAutoChisel;
|
||||
import team.chisel.carving.Carving;
|
||||
import team.chisel.config.Configurations;
|
||||
import team.chisel.entity.fx.EntityBallOMossFX;
|
||||
import team.chisel.entity.fx.EntityGrimstoneFX;
|
||||
import team.chisel.entity.fx.EntityHolystoneFX;
|
||||
import team.chisel.entity.fx.EntitySnakestoneObsidianFX;
|
||||
import team.chisel.utils.GeneralClient;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.particle.EffectRenderer;
|
||||
import net.minecraft.client.particle.EntityDiggingFX;
|
||||
import net.minecraft.client.particle.EntityLavaFX;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class GeneralChiselClient {
|
||||
|
||||
public static Random rand = new Random();
|
||||
public static int tick = 0;
|
||||
|
||||
public static void spawnLavastoneFX(World world, BlockLavastone block, int x, int y, int z) {
|
||||
if (Configurations.particlesTickrate != 0 && tick++ % Configurations.particlesTickrate != 0 || Minecraft.getMinecraft().gameSettings.particleSetting != 0)
|
||||
return;
|
||||
|
||||
float f = 0.15F;
|
||||
double x1 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F) + f + block.getBlockBoundsMinX();
|
||||
double y1 = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - f * 2.0F) + f + block.getBlockBoundsMinY();
|
||||
double z1 = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - f * 2.0F) + f + block.getBlockBoundsMinZ();
|
||||
|
||||
switch (rand.nextInt(6)) {
|
||||
case 0:
|
||||
y1 = y + block.getBlockBoundsMinY() - f;
|
||||
y--;
|
||||
break;
|
||||
case 1:
|
||||
y1 = y + block.getBlockBoundsMaxY() + f;
|
||||
y++;
|
||||
break;
|
||||
case 2:
|
||||
z1 = z + block.getBlockBoundsMinZ() - f;
|
||||
z--;
|
||||
break;
|
||||
case 3:
|
||||
z1 = z + block.getBlockBoundsMaxZ() + f;
|
||||
z++;
|
||||
break;
|
||||
case 4:
|
||||
x1 = x + block.getBlockBoundsMinX() - f;
|
||||
x--;
|
||||
break;
|
||||
case 5:
|
||||
x1 = x + block.getBlockBoundsMaxX() + f;
|
||||
x++;
|
||||
break;
|
||||
}
|
||||
|
||||
if (world.getBlock(x, y, z).isOpaqueCube())
|
||||
return;
|
||||
|
||||
EntityLavaFX res = new EntityLavaFX(world, x1, y1, z1);
|
||||
double multiplier = 0.45;
|
||||
res.motionX = -multiplier * (x1 - x - 0.5);
|
||||
res.motionY = multiplier * (y1 - y - 0.5);
|
||||
res.motionZ = -multiplier * (z1 - z - 0.5);
|
||||
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect(res);
|
||||
}
|
||||
|
||||
public static void spawnHolystoneFX(World world, BlockHolystone block, int x, int y, int z) {
|
||||
if (Configurations.particlesTickrate != 0 && tick++ % Configurations.particlesTickrate != 0 || Minecraft.getMinecraft().gameSettings.particleSetting != 0)
|
||||
return;
|
||||
|
||||
float f = 0.15F;
|
||||
double x1 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F) + f + block.getBlockBoundsMinX();
|
||||
double y1 = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - f * 2.0F) + f + block.getBlockBoundsMinY();
|
||||
double z1 = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - f * 2.0F) + f + block.getBlockBoundsMinZ();
|
||||
|
||||
switch (rand.nextInt(6)) {
|
||||
case 0:
|
||||
y1 = y + block.getBlockBoundsMinY() - f;
|
||||
y--;
|
||||
break;
|
||||
case 1:
|
||||
y1 = y + block.getBlockBoundsMaxY() + f;
|
||||
y++;
|
||||
break;
|
||||
case 2:
|
||||
z1 = z + block.getBlockBoundsMinZ() - f;
|
||||
z--;
|
||||
break;
|
||||
case 3:
|
||||
z1 = z + block.getBlockBoundsMaxZ() + f;
|
||||
z++;
|
||||
break;
|
||||
case 4:
|
||||
x1 = x + block.getBlockBoundsMinX() - f;
|
||||
x--;
|
||||
break;
|
||||
case 5:
|
||||
x1 = x + block.getBlockBoundsMaxX() + f;
|
||||
x++;
|
||||
break;
|
||||
}
|
||||
|
||||
if (world.getBlock(x, y, z).isOpaqueCube())
|
||||
return;
|
||||
|
||||
EntityHolystoneFX res = new EntityHolystoneFX(world, block, x1, y1, z1);
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect(res);
|
||||
}
|
||||
|
||||
public static void spawnGrimstoneFX(World world, BlockGrimstone block, int x, int y, int z) {
|
||||
if (Configurations.particlesTickrate != 0 && tick++ % Configurations.particlesTickrate != 0)
|
||||
return;
|
||||
|
||||
float f = 0.15F;
|
||||
double x1 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F) + f + block.getBlockBoundsMinX();
|
||||
double y1 = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - f * 2.0F) + f + block.getBlockBoundsMinY();
|
||||
double z1 = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - f * 2.0F) + f + block.getBlockBoundsMinZ();
|
||||
|
||||
switch (rand.nextInt(6)) {
|
||||
case 0:
|
||||
y1 = y + block.getBlockBoundsMinY() - f;
|
||||
y--;
|
||||
break;
|
||||
case 1:
|
||||
y1 = y + block.getBlockBoundsMaxY() + f;
|
||||
y++;
|
||||
break;
|
||||
case 2:
|
||||
z1 = z + block.getBlockBoundsMinZ() - f;
|
||||
z--;
|
||||
break;
|
||||
case 3:
|
||||
z1 = z + block.getBlockBoundsMaxZ() + f;
|
||||
z++;
|
||||
break;
|
||||
case 4:
|
||||
x1 = x + block.getBlockBoundsMinX() - f;
|
||||
x--;
|
||||
break;
|
||||
case 5:
|
||||
x1 = x + block.getBlockBoundsMaxX() + f;
|
||||
x++;
|
||||
break;
|
||||
}
|
||||
|
||||
if (world.getBlock(x, y, z).isOpaqueCube())
|
||||
return;
|
||||
|
||||
EntityGrimstoneFX res = new EntityGrimstoneFX(world, block, x1, y1, z1);
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect(res);
|
||||
}
|
||||
|
||||
public static void spawnSnakestoneObsidianFX(World world, BlockSnakestoneObsidian block, int x, int y, int z) {
|
||||
if (Configurations.particlesTickrate != 0 || tick++ % Configurations.particlesTickrate != 0 || Minecraft.getMinecraft().gameSettings.particleSetting != 0) {
|
||||
EntitySnakestoneObsidianFX res = new EntitySnakestoneObsidianFX(world, block, x, y, z);
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect(res);
|
||||
}
|
||||
}
|
||||
|
||||
public static void spawnBallOMossFX(World world, double x, double y, double z) {
|
||||
if (Configurations.particlesTickrate == 0 || tick++ % Configurations.particlesTickrate == 0 || Minecraft.getMinecraft().gameSettings.particleSetting != 0) {
|
||||
EntityBallOMossFX res = new EntityBallOMossFX(world, x, y, z);
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect(res);
|
||||
}
|
||||
}
|
||||
|
||||
public static EntityDiggingFX addBlockHitEffects(World world, int x, int y, int z, int side) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (block.isAir(world, x, y, z) || Minecraft.getMinecraft().gameSettings.particleSetting != 0)
|
||||
return null;
|
||||
|
||||
EffectRenderer renderer = Minecraft.getMinecraft().effectRenderer;
|
||||
|
||||
float f = 0.1F;
|
||||
double d0 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F) + f + block.getBlockBoundsMinX();
|
||||
double d1 = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - f * 2.0F) + f + block.getBlockBoundsMinY();
|
||||
double d2 = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - f * 2.0F) + f + block.getBlockBoundsMinZ();
|
||||
|
||||
switch (side) {
|
||||
case 0:
|
||||
d1 = y + block.getBlockBoundsMinY() - f;
|
||||
break;
|
||||
case 1:
|
||||
d1 = y + block.getBlockBoundsMaxY() + f;
|
||||
break;
|
||||
case 2:
|
||||
d2 = z + block.getBlockBoundsMinZ() - f;
|
||||
break;
|
||||
case 3:
|
||||
d2 = z + block.getBlockBoundsMaxZ() + f;
|
||||
break;
|
||||
case 4:
|
||||
d0 = x + block.getBlockBoundsMinX() - f;
|
||||
break;
|
||||
case 5:
|
||||
d0 = x + block.getBlockBoundsMaxX() + f;
|
||||
break;
|
||||
}
|
||||
|
||||
EntityDiggingFX res = new EntityDiggingFX(world, d0, d1, d2, 0.0D, 0.0D, 0.0D, block, world.getBlockMetadata(x, y, z), side);
|
||||
res.motionX = d0 - (x + 0.5);
|
||||
res.motionY = d1 - (y + 0.5);
|
||||
res.motionZ = d2 - (z + 0.5);
|
||||
|
||||
renderer.addEffect(res);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void spawnChiselEffect(int x, int y, int z, String sound) {
|
||||
World world = Minecraft.getMinecraft().theWorld;
|
||||
for (int side = 0; side < 6; side++) {
|
||||
for (int j = 0; j < 16; j++) {
|
||||
EntityDiggingFX fx = addBlockHitEffects(Minecraft.getMinecraft().theWorld, x, y, z, side);
|
||||
if (fx == null)
|
||||
return;
|
||||
|
||||
fx.multipleParticleScaleBy(0.25f + 0.5f * rand.nextFloat());
|
||||
fx.multiplyVelocity(0.3f * rand.nextFloat());
|
||||
}
|
||||
}
|
||||
|
||||
GeneralClient.playChiselSound(world, x, y, z, sound);
|
||||
}
|
||||
|
||||
public static void speedupPlayer(World world, Entity entity, double concreteVelocity) {
|
||||
double velocity = Math.sqrt(entity.motionX * entity.motionX + entity.motionZ * entity.motionZ);
|
||||
|
||||
if (!(entity instanceof EntityPlayerSP))
|
||||
return;
|
||||
if (velocity == 0)
|
||||
return;
|
||||
if (velocity >= Configurations.concreteVelocity)
|
||||
return;
|
||||
|
||||
EntityPlayerSP player = (EntityPlayerSP) entity;
|
||||
|
||||
if (Math.abs(player.movementInput.moveForward) < 0.75f && Math.abs(player.movementInput.moveStrafe) < 0.75f)
|
||||
return;
|
||||
|
||||
entity.motionX = Configurations.concreteVelocity * entity.motionX / velocity;
|
||||
entity.motionZ = Configurations.concreteVelocity * entity.motionZ / velocity;
|
||||
}
|
||||
|
||||
public static void spawnAutoChiselFX(TileEntityAutoChisel te, ItemStack base) {
|
||||
if (base != null && Minecraft.getMinecraft().gameSettings.particleSetting == 0) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
EntityDiggingFX particle = new EntityDiggingFX(te.getWorldObj(), te.xCoord + 0.5, te.yCoord + 0.95, te.zCoord + 0.5, 0, 0, 0, Block.getBlockFromItem(base.getItem()),
|
||||
base.getItemDamage());
|
||||
particle.setVelocity((te.getWorldObj().rand.nextDouble() / 4) - 0.125, te.getWorldObj().rand.nextDouble() / 8, (te.getWorldObj().rand.nextDouble() / 4) - 0.125);
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect(particle);
|
||||
}
|
||||
String sound = Carving.chisel.getVariationSound(base.getItem(), base.getItemDamage());
|
||||
GeneralClient.playChiselSound(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, sound);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package team.chisel.client.gui;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import team.chisel.block.tileentity.TileEntityAutoChisel;
|
||||
import team.chisel.inventory.ContainerAutoChisel;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class GuiAutoChisel extends GuiContainer {
|
||||
|
||||
private static final ResourceLocation gui = new ResourceLocation("chisel:textures/autochisel-gui.png");
|
||||
|
||||
private TileEntityAutoChisel autochisel;
|
||||
|
||||
public GuiAutoChisel(InventoryPlayer inventoryPlayer, TileEntityAutoChisel tileEntityAutoChisel) {
|
||||
super(new ContainerAutoChisel(inventoryPlayer, tileEntityAutoChisel));
|
||||
autochisel = tileEntityAutoChisel;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
|
||||
int x = (this.width - this.xSize) / 2;
|
||||
int y = (this.height - this.ySize) / 2;
|
||||
|
||||
for (Slot slot : (List<Slot>) inventorySlots.inventorySlots) {
|
||||
if (!slot.getHasStack() && mouseInside(slot, mouseX - x, mouseY - y)) {
|
||||
if (slot.slotNumber < autochisel.getSizeInventory()) {
|
||||
String tt = autochisel.getSlotTooltipUnloc(slot.slotNumber);
|
||||
if (!Strings.isNullOrEmpty(tt)) {
|
||||
this.func_146283_a(Lists.newArrayList(StatCollector.translateToLocal(tt)), mouseX - x, mouseY - y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
}
|
||||
|
||||
private boolean mouseInside(Slot slot, int x, int y) {
|
||||
return x >= slot.xDisplayPosition && x <= slot.xDisplayPosition + 16 && y >= slot.yDisplayPosition && y <= slot.yDisplayPosition + 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.renderEngine.bindTexture(gui);
|
||||
int x = (width - xSize) / 2;
|
||||
int y = (height - ySize) / 2;
|
||||
this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
|
||||
|
||||
for (int i = TileEntityAutoChisel.BASE; i < TileEntityAutoChisel.CHISEL; i++) {
|
||||
if (autochisel.getStackInSlot(i) == null) {
|
||||
drawSlotOverlay(this, x, y, inventorySlots.getSlot(i), xSize, 0, 8);
|
||||
}
|
||||
}
|
||||
|
||||
if (autochisel.getStackInSlot(TileEntityAutoChisel.CHISEL) == null) {
|
||||
drawSlotOverlay(this, x, y, inventorySlots.getSlot(TileEntityAutoChisel.CHISEL), xSize, 24, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawSlotOverlay(GuiContainer gui, int x, int y, Slot slot, int u, int v, int padding) {
|
||||
padding /= 2;
|
||||
gui.drawTexturedModalRect(x + (slot.xDisplayPosition - padding), y + (slot.yDisplayPosition - padding), u, v, 18 + padding, 18 + padding);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package team.chisel.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.cricketcraft.chisel.api.IAdvancedChisel;
|
||||
import com.cricketcraft.chisel.api.IChiselItem;
|
||||
import com.cricketcraft.chisel.api.carving.IChiselMode;
|
||||
|
||||
import team.chisel.inventory.ContainerChisel;
|
||||
import team.chisel.inventory.InventoryChiselSelection;
|
||||
import team.chisel.inventory.SlotChiselInput;
|
||||
import team.chisel.item.chisel.ChiselMode;
|
||||
import team.chisel.network.PacketHandler;
|
||||
import team.chisel.network.message.MessageChiselMode;
|
||||
import team.chisel.utils.General;
|
||||
import team.chisel.utils.GeneralClient;
|
||||
|
||||
public class GuiChisel extends GuiContainer {
|
||||
|
||||
public EntityPlayer player;
|
||||
public ContainerChisel container;
|
||||
private IChiselMode currentMode;
|
||||
|
||||
public GuiChisel(InventoryPlayer iinventory, InventoryChiselSelection menu) {
|
||||
super(new ContainerChisel(iinventory, menu));
|
||||
player = iinventory.player;
|
||||
xSize = 252;
|
||||
ySize = 202;
|
||||
|
||||
container = (ContainerChisel) inventorySlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
inventorySlots.onContainerClosed(player);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
currentMode = General.getChiselMode(container.chisel);
|
||||
|
||||
if (showMode()) {
|
||||
int x = this.width / 2 - 120;
|
||||
int y = this.height / 2 - 6;
|
||||
buttonList.add(new GuiButton(0, x, y, 53, 20, ""));
|
||||
setButtonText();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
ItemStack held = player.getCurrentEquippedItem();
|
||||
if (held == null || !(held.getItem() instanceof IChiselItem)) {
|
||||
mc.displayGuiScreen(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void setButtonText() {
|
||||
((GuiButton) buttonList.get(0)).displayString = I18n.format(container.inventory.getInventoryName() + ".mode." + currentMode.name().toLowerCase());
|
||||
}
|
||||
|
||||
private boolean showMode() {
|
||||
if (container.chisel != null && container.chisel.getItem() instanceof IChiselItem) {
|
||||
return ((IChiselItem) container.chisel.getItem()).hasModes(container.chisel);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int j, int i) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
String line = I18n.format(this.container.inventory.getInventoryName() + ".title");
|
||||
fontRendererObj.drawSplitString(line, 50 - fontRendererObj.getStringWidth(line) / 2, 60, 40, 0x404040);
|
||||
|
||||
if (showMode()) {
|
||||
line = I18n.format(this.container.inventory.getInventoryName() + ".mode");
|
||||
fontRendererObj.drawString(line, fontRendererObj.getStringWidth(line) / 2 + 6, 85, 0x404040);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) {
|
||||
drawDefaultBackground();
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
int i = width - xSize >> 1;
|
||||
int j = height - ySize >> 1;
|
||||
|
||||
String texture = "chisel:textures/chisel2Gui.png";
|
||||
|
||||
GeneralClient.bind(texture);
|
||||
drawTexturedModalRect(i, j, 0, 0, xSize, ySize);
|
||||
|
||||
int x = (width - xSize) / 2;
|
||||
int y = (height - ySize) / 2;
|
||||
|
||||
Slot main = (Slot) container.inventorySlots.get(InventoryChiselSelection.normalSlots);
|
||||
if (main.getStack() == null) {
|
||||
GuiAutoChisel.drawSlotOverlay(this, x + 14, y + 14, main, 0, ySize, 60);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
if (button.id == 0) {
|
||||
if (container.chisel != null && container.chisel.getItem() instanceof IAdvancedChisel) {
|
||||
IAdvancedChisel item = (IAdvancedChisel) container.chisel.getItem();
|
||||
currentMode = item.getNextMode(container.chisel, currentMode);
|
||||
PacketHandler.INSTANCE.sendToServer(new MessageChiselMode(currentMode));
|
||||
} else {
|
||||
currentMode = ChiselMode.next(currentMode);
|
||||
PacketHandler.INSTANCE.sendToServer(new MessageChiselMode(currentMode));
|
||||
setButtonText();
|
||||
}
|
||||
}
|
||||
super.actionPerformed(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void func_146977_a(Slot slot) {
|
||||
if (slot instanceof SlotChiselInput) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(2, 2, 2);
|
||||
slot.xDisplayPosition -= 16;
|
||||
slot.yDisplayPosition -= 16;
|
||||
super.func_146977_a(slot);
|
||||
slot.xDisplayPosition += 16;
|
||||
slot.yDisplayPosition += 16;
|
||||
GL11.glPopMatrix();
|
||||
} else {
|
||||
super.func_146977_a(slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package team.chisel.client.gui;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.config.Configurations;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.common.config.ConfigCategory;
|
||||
import net.minecraftforge.common.config.ConfigElement;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import cpw.mods.fml.client.config.GuiConfig;
|
||||
|
||||
public class GuiChiselConfig extends GuiConfig {
|
||||
|
||||
public GuiChiselConfig(GuiScreen parent) {
|
||||
super(parent, new ConfigElement<ConfigCategory>(Configurations.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), Chisel.MOD_ID, false, false, GuiConfig
|
||||
.getAbridgedConfigPath(Configurations.config.toString()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package team.chisel.client.gui;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import cpw.mods.fml.client.IModGuiFactory;
|
||||
|
||||
public class GuiFactory implements IModGuiFactory {
|
||||
|
||||
@Override
|
||||
public void initialize(Minecraft minecraftInstance) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiScreen> mainConfigGuiClass() {
|
||||
return GuiChiselConfig.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package team.chisel.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import team.chisel.block.tileentity.TileEntityPresent;
|
||||
import team.chisel.inventory.ContainerPresent;
|
||||
|
||||
public class GuiPresent extends GuiContainer {
|
||||
|
||||
private static final ResourceLocation gui = new ResourceLocation("chisel:textures/present-gui.png");
|
||||
private int rows;
|
||||
|
||||
public GuiPresent(InventoryPlayer inventoryPlayer, TileEntityPresent tileEntityPresent) {
|
||||
super(new ContainerPresent(inventoryPlayer, tileEntityPresent));
|
||||
rows = tileEntityPresent.getSizeInventory() / 9;
|
||||
this.ySize = 114 + rows * 18;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(gui);
|
||||
int x = (this.width - this.xSize) / 2;
|
||||
int y = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.rows * 18 + 17);
|
||||
this.drawTexturedModalRect(x, y + this.rows * 18 + 17, 0, 126, this.xSize, 96);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,294 @@
|
||||
package team.chisel.client.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class RenderBlocksEldritch extends RenderBlocks {
|
||||
|
||||
RenderBlocksEldritch() {
|
||||
super();
|
||||
}
|
||||
|
||||
static double displacementMap[] = { +0.1165, -0.0352, -0.1208, +0.0906, -0.0295, +0.0302, -0.0973, +0.0548, -0.1077, +0.0662, -0.0932, -0.0925, -0.1161, +0.0073, -0.1084, +0.1136, +0.0307,
|
||||
+0.0316, -0.1066, -0.0237, +0.0614, -0.0864, +0.0837, +0.1218, +0.0502, -0.0529, -0.0942, +0.1209, -0.0418, +0.1035, +0.0066, -0.0255, +0.0830, -0.0361, +0.0965, +0.0646, +0.1124,
|
||||
+0.0890, -0.0037, +0.0467, +0.1025, +0.1161, +0.0014, +0.0365, +0.0755, -0.0025, +0.0739, +0.0656, +0.0571, -0.0813, -0.0062, -0.0904, -0.0005, +0.0612, -0.0227, +0.0138, -0.0899,
|
||||
-0.0019, -0.1047, +0.1191, -0.1197, -0.1123, +0.0999, +0.0638, +0.0865, +0.0029, -0.0084, +0.1132, -0.0433, +0.0115, +0.0850, +0.0439, +0.0748, +0.0460, -0.0441, +0.0839, +0.0162,
|
||||
-0.0229, +0.0774, -0.0647, -0.0636, -0.0709, -0.0719, -0.0194, +0.1070, -0.0466, -0.1200, -0.0996, -0.0298, -0.1035, -0.0006, +0.0530, -0.0939, -0.1210, +0.0176, +0.0924, +0.0343,
|
||||
-0.0777, +0.1050, -0.0729, -0.0062, -0.1107, -0.0434, -0.0042, +0.0232, +0.0269, +0.0709, -0.0388, +0.0342, +0.0240, -0.0192, +0.0491, +0.0017, -0.1240, +0.0687, -0.1160, +0.1123,
|
||||
-0.0332, -0.0260, +0.0476, -0.0049, -0.0893, -0.0243, -0.0371, -0.0230, +0.0656, +0.1080, +0.0781, -0.0648, +0.0082, -0.1086, -0.0451, -0.0594, -0.1155, -0.0623, -0.0152, +0.0131,
|
||||
-0.0754, +0.0607, +0.0876, -0.0657, +0.0366, -0.0981, +0.1164, -0.0623, +0.0181, -0.0475, +0.0722, -0.0293, +0.0486, -0.0195, +0.1041, +0.1011, +0.0042, -0.0045, -0.1031, +0.0110,
|
||||
+0.0058, +0.0083, -0.0782, -0.1003, -0.0082, -0.0304, -0.0971, -0.0097, -0.0208, -0.1059, -0.0239, -0.0385, +0.0505, +0.0537, -0.1098, -0.0022, -0.0165, -0.0027, -0.0208, +0.0305,
|
||||
+0.0592, +0.0301, +0.0055, +0.1138, -0.0338, -0.0901, +0.1015, +0.0061, +0.0861, -0.1057, -0.0889, -0.0972, +0.0783, -0.1052, -0.0932, -0.1103, +0.0497, +0.1222, -0.0146, +0.0632,
|
||||
-0.0240, -0.0193, +0.0676, -0.1128, -0.0886, +0.0926, +0.0538, -0.0175, -0.0966, -0.0369, +0.1124, -0.0820, -0.1013, -0.0836, -0.0981, -0.0502, +0.0573, +0.0616, -0.0458, +0.0294,
|
||||
+0.0108, -0.0782, +0.0692, +0.0234, -0.0178, -0.0171, -0.0505, -0.0313, +0.0538, +0.0462, -0.0758, +0.0556, -0.0023, -0.1086, -0.0100, -0.0897, -0.0409, -0.1161, +0.0212, +0.1229,
|
||||
-0.0945, +0.0341, +0.1238, +0.0893, -0.1189, -0.1098, -0.0125, +0.1137, -0.0202, +0.0239, -0.0408, +0.0920, +0.0777, -0.0085, -0.0572, -0.0293, -0.0131, +0.0272, +0.0991, };
|
||||
|
||||
static int dmap1 = displacementMap.length * 1 / 6;
|
||||
static int dmap2 = displacementMap.length * 2 / 6;
|
||||
static int dmap3 = displacementMap.length * 3 / 6;
|
||||
static int dmap4 = displacementMap.length * 4 / 6;
|
||||
static int dmap5 = displacementMap.length * 5 / 6;
|
||||
static int dmap = displacementMap.length;
|
||||
|
||||
Tessellator tessellator;
|
||||
double[] X = new double[14];
|
||||
double[] Y = new double[14];
|
||||
double[] Z = new double[14];
|
||||
double[] U = new double[14];
|
||||
double[] V = new double[14];
|
||||
int[] L = new int[14];
|
||||
float[] R = new float[14];
|
||||
float[] G = new float[14];
|
||||
float[] B = new float[14];
|
||||
|
||||
@Override
|
||||
public boolean renderStandardBlock(Block block, int x, int y, int z) {
|
||||
int index = x + y * 34573 + z * 32465781;
|
||||
if (index < 0)
|
||||
index = -index;
|
||||
|
||||
X[0] = x;
|
||||
Z[0] = z;
|
||||
Y[0] = y;
|
||||
|
||||
X[1] = x;
|
||||
Z[1] = z;
|
||||
Y[1] = y + 1;
|
||||
|
||||
X[2] = x + 1;
|
||||
Z[2] = z;
|
||||
Y[2] = y + 1;
|
||||
|
||||
X[3] = x + 1;
|
||||
Z[3] = z;
|
||||
Y[3] = y;
|
||||
|
||||
X[4] = x;
|
||||
Z[4] = z + 1;
|
||||
Y[4] = y;
|
||||
|
||||
X[5] = x;
|
||||
Z[5] = z + 1;
|
||||
Y[5] = y + 1;
|
||||
|
||||
X[6] = x + 1;
|
||||
Z[6] = z + 1;
|
||||
Y[6] = y + 1;
|
||||
|
||||
X[7] = x + 1;
|
||||
Z[7] = z + 1;
|
||||
Y[7] = y;
|
||||
|
||||
X[8] = x + 0.5 + displacementMap[(index + 0) % dmap];
|
||||
Z[8] = z - displacementMap[(index + 10) % dmap];
|
||||
Y[8] = y + 0.5 + displacementMap[(index + 20) % dmap];
|
||||
|
||||
X[9] = x - displacementMap[(index + 0 + dmap1) % dmap];
|
||||
Z[9] = z + 0.5 + displacementMap[(index + 10 + dmap1) % dmap];
|
||||
Y[9] = y + 0.5 + displacementMap[(index + 20 + dmap1) % dmap];
|
||||
|
||||
X[10] = x + 0.5 + displacementMap[(index + 0 + dmap2) % dmap];
|
||||
Z[10] = z + 1 + displacementMap[(index + 10 + dmap2) % dmap];
|
||||
Y[10] = y + 0.5 + displacementMap[(index + 20 + dmap2) % dmap];
|
||||
|
||||
X[11] = x + 1 + displacementMap[(index + 0 + dmap3) % dmap];
|
||||
Z[11] = z + 0.5 + displacementMap[(index + 10 + dmap3) % dmap];
|
||||
Y[11] = y + 0.5 + displacementMap[(index + 20 + dmap3) % dmap];
|
||||
|
||||
X[12] = x + 0.5 + displacementMap[(index + 0 + dmap4) % dmap];
|
||||
Z[12] = z + 0.5 + displacementMap[(index + 10 + dmap4) % dmap];
|
||||
Y[12] = y + 1;// +displacementMap[(index+20+dmap4)%dmap];
|
||||
|
||||
X[13] = x + 0.5 + displacementMap[(index + 0 + dmap5) % dmap];
|
||||
Z[13] = z + 0.5 + displacementMap[(index + 10 + dmap5) % dmap];
|
||||
Y[13] = y + 0;// +displacementMap[(index+20+dmap5)%dmap];
|
||||
|
||||
tessellator = Tessellator.instance;
|
||||
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
|
||||
|
||||
return super.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
void setupSides(IIcon icon, int a, int b, int c, int d, int e, int ta, int tb, int tc, int td) {
|
||||
L[a] = brightnessBottomLeft;
|
||||
L[b] = brightnessBottomRight;
|
||||
L[c] = brightnessTopRight;
|
||||
L[d] = brightnessTopLeft;
|
||||
L[e] = (brightnessBottomLeft + brightnessTopLeft + brightnessTopRight + brightnessBottomRight) / 4;
|
||||
|
||||
R[a] = colorRedBottomLeft;
|
||||
R[b] = colorRedBottomRight;
|
||||
R[c] = colorRedTopRight;
|
||||
R[d] = colorRedTopLeft;
|
||||
R[e] = (colorRedBottomLeft + colorRedTopLeft + colorRedTopRight + colorRedBottomRight) / 4;
|
||||
|
||||
G[a] = colorGreenBottomLeft;
|
||||
G[b] = colorGreenBottomRight;
|
||||
G[c] = colorGreenTopRight;
|
||||
G[d] = colorGreenTopLeft;
|
||||
G[e] = (colorGreenBottomLeft + colorGreenTopLeft + colorGreenTopRight + colorGreenBottomRight) / 4;
|
||||
|
||||
B[a] = colorBlueBottomLeft;
|
||||
B[b] = colorBlueBottomRight;
|
||||
B[c] = colorBlueTopRight;
|
||||
B[d] = colorBlueTopLeft;
|
||||
B[e] = (colorBlueBottomLeft + colorBlueTopLeft + colorBlueTopRight + colorBlueBottomRight) / 4;
|
||||
|
||||
double u0 = icon.getMaxU();
|
||||
double u1 = icon.getMinU();
|
||||
double v0 = icon.getMaxV();
|
||||
double v1 = icon.getMinV();
|
||||
|
||||
U[ta] = u0;
|
||||
U[tb] = u0;
|
||||
U[tc] = u1;
|
||||
U[td] = u1;
|
||||
U[e] = icon.getInterpolatedU(8.0D);
|
||||
|
||||
V[ta] = v0;
|
||||
V[tb] = v1;
|
||||
V[tc] = v1;
|
||||
V[td] = v0;
|
||||
V[e] = icon.getInterpolatedV(8.0D);
|
||||
}
|
||||
|
||||
void vert(int index) {
|
||||
if (enableAO) {
|
||||
tessellator.setColorOpaque_F(R[index], G[index], B[index]);
|
||||
tessellator.setBrightness(L[index]);
|
||||
}
|
||||
|
||||
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) {
|
||||
setupSides(icon, 1, 0, 4, 5, 9, 4, 5, 1, 0);
|
||||
vert(1);
|
||||
vert(0);
|
||||
vert(9);
|
||||
vert(9);
|
||||
vert(0);
|
||||
vert(4);
|
||||
vert(9);
|
||||
vert(9);
|
||||
vert(4);
|
||||
vert(5);
|
||||
vert(9);
|
||||
vert(9);
|
||||
vert(5);
|
||||
vert(1);
|
||||
vert(9);
|
||||
vert(9);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon) {
|
||||
setupSides(icon, 3, 2, 6, 7, 11, 3, 2, 6, 7);
|
||||
vert(6);
|
||||
vert(7);
|
||||
vert(11);
|
||||
vert(11);
|
||||
vert(7);
|
||||
vert(3);
|
||||
vert(11);
|
||||
vert(11);
|
||||
vert(3);
|
||||
vert(2);
|
||||
vert(11);
|
||||
vert(11);
|
||||
vert(2);
|
||||
vert(6);
|
||||
vert(11);
|
||||
vert(11);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon) {
|
||||
setupSides(icon, 2, 3, 0, 1, 8, 0, 1, 2, 3);
|
||||
vert(0);
|
||||
vert(1);
|
||||
vert(8);
|
||||
vert(8);
|
||||
vert(1);
|
||||
vert(2);
|
||||
vert(8);
|
||||
vert(8);
|
||||
vert(2);
|
||||
vert(3);
|
||||
vert(8);
|
||||
vert(8);
|
||||
vert(3);
|
||||
vert(0);
|
||||
vert(8);
|
||||
vert(8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon) {
|
||||
setupSides(icon, 4, 7, 6, 5, 10, 7, 6, 5, 4);
|
||||
vert(5);
|
||||
vert(4);
|
||||
vert(10);
|
||||
vert(10);
|
||||
vert(6);
|
||||
vert(5);
|
||||
vert(10);
|
||||
vert(10);
|
||||
vert(7);
|
||||
vert(6);
|
||||
vert(10);
|
||||
vert(10);
|
||||
vert(4);
|
||||
vert(7);
|
||||
vert(10);
|
||||
vert(10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon) {
|
||||
setupSides(icon, 0, 3, 7, 4, 13, 0, 3, 7, 4);
|
||||
vert(0);
|
||||
vert(3);
|
||||
vert(13);
|
||||
vert(13);
|
||||
vert(3);
|
||||
vert(7);
|
||||
vert(13);
|
||||
vert(13);
|
||||
vert(7);
|
||||
vert(4);
|
||||
vert(13);
|
||||
vert(13);
|
||||
vert(4);
|
||||
vert(0);
|
||||
vert(13);
|
||||
vert(13);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceYPos(Block block, double x, double y, double z, IIcon icon) {
|
||||
setupSides(icon, 2, 1, 5, 6, 12, 2, 1, 5, 6);
|
||||
|
||||
vert(2);
|
||||
vert(1);
|
||||
vert(12);
|
||||
vert(12);
|
||||
vert(1);
|
||||
vert(5);
|
||||
vert(12);
|
||||
vert(12);
|
||||
vert(5);
|
||||
vert(6);
|
||||
vert(12);
|
||||
vert(12);
|
||||
vert(6);
|
||||
vert(2);
|
||||
vert(12);
|
||||
vert(12);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package team.chisel.client.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.model.ModelSnowMan;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.entity.RenderLiving;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import team.chisel.entity.EntityChiselSnowman;
|
||||
import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED;
|
||||
import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D;
|
||||
|
||||
public class RenderChiselSnowman extends RenderLiving {
|
||||
|
||||
private static final ResourceLocation snowManTextures = new ResourceLocation("textures/entity/snowman.png");
|
||||
private ModelSnowMan snowMan;
|
||||
|
||||
public RenderChiselSnowman() {
|
||||
super(new ModelSnowMan(), 0.5F);
|
||||
snowMan = (ModelSnowMan) super.mainModel;
|
||||
setRenderPassModel(this.snowMan);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderEquippedItems(EntityLivingBase entityLivingBase, float size) {
|
||||
this.renderEquippedItems((EntityChiselSnowman) entityLivingBase, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(Entity entity) {
|
||||
return this.getEntityTexture((EntityChiselSnowman) entity);
|
||||
}
|
||||
|
||||
protected ResourceLocation getEntityTexture(EntityChiselSnowman snowman) {
|
||||
return snowManTextures;
|
||||
}
|
||||
|
||||
protected void renderEquippedItems(EntityChiselSnowman snowman, float size) {
|
||||
super.renderEquippedItems(snowman, size);
|
||||
ItemStack itemStack = snowman.getEquipmentInSlot(2);
|
||||
|
||||
if (itemStack.getItem() instanceof ItemBlock) {
|
||||
GL11.glPushMatrix();
|
||||
this.snowMan.head.postRender(0.0625F);
|
||||
|
||||
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemStack, EQUIPPED);
|
||||
boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemStack, BLOCK_3D));
|
||||
|
||||
if (is3D || RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemStack.getItem()).getRenderType())) {
|
||||
float f1 = 0.625F;
|
||||
GL11.glTranslatef(0.0F, -0.34375F, 0.0F);
|
||||
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glScalef(f1, -f1, f1);
|
||||
}
|
||||
this.renderManager.itemRenderer.renderItem(snowman, itemStack, 0);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package team.chisel.client.render;
|
||||
|
||||
import com.cricketcraft.chisel.api.rendering.ClientUtils;
|
||||
import com.cricketcraft.ctmlib.CTMRenderer;
|
||||
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class RendererCTM extends CTMRenderer {
|
||||
|
||||
public RendererCTM() {
|
||||
super(RenderingRegistry.getNextAvailableRenderId());
|
||||
ClientUtils.renderCTMId = getRenderId();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,324 @@
|
||||
package team.chisel.client.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockPane;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.cricketcraft.ctmlib.Drawing;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class RendererCTMPane implements ISimpleBlockRenderingHandler {
|
||||
|
||||
public static int id;
|
||||
|
||||
public RendererCTMPane() {
|
||||
id = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int meta, int modelID, RenderBlocks renderer) {
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
GL11.glScalef(1.25f, 1.25f, 1.25f);
|
||||
renderer.setRenderBounds(0.0f, 0.0f, 0.5f - 0.0625f, 1.0f, 1.0f, 0.5f + 0.0625f);
|
||||
Drawing.drawBlock(block, meta, renderer);
|
||||
}
|
||||
|
||||
class PaneRenderer {
|
||||
|
||||
Tessellator tessellator;
|
||||
|
||||
double i0u0;
|
||||
double i0uh;
|
||||
double i0u1;
|
||||
double i0v0;
|
||||
double i0v1;
|
||||
|
||||
double i1u0;
|
||||
double i1u1;
|
||||
double i1v0;
|
||||
double i1vh;
|
||||
double i1v1;
|
||||
double i1v;
|
||||
|
||||
double i2u0;
|
||||
double i2u1;
|
||||
double i2v0;
|
||||
double i2v1;
|
||||
double i2v;
|
||||
|
||||
double x0;
|
||||
double xh;
|
||||
double x1;
|
||||
double xp0;
|
||||
double xp1;
|
||||
|
||||
double z0;
|
||||
double zh;
|
||||
double z1;
|
||||
double zp0;
|
||||
double zp1;
|
||||
|
||||
double y0;
|
||||
double y1;
|
||||
|
||||
void set(double x, double y, double z, IIcon icon, IIcon icon1, IIcon icon2) {
|
||||
tessellator = Tessellator.instance;
|
||||
|
||||
i0u0 = icon.getMinU();
|
||||
i0uh = icon.getInterpolatedU(8.0D);
|
||||
i0u1 = icon.getMaxU();
|
||||
i0v0 = icon.getMinV();
|
||||
i0v1 = icon.getMaxV();
|
||||
|
||||
i1u0 = icon1.getInterpolatedU(7.0D);
|
||||
i1u1 = icon1.getInterpolatedU(9.0D);
|
||||
i1v0 = icon1.getMinV();
|
||||
i1vh = icon1.getInterpolatedV(8.0D);
|
||||
i1v1 = icon1.getMaxV();
|
||||
i1v = i1v1 - i1v0;
|
||||
|
||||
i2u0 = icon2.getInterpolatedU(7.0D);
|
||||
i2u1 = icon2.getInterpolatedU(9.0D);
|
||||
i2v0 = icon2.getMinV();
|
||||
i2v1 = icon2.getMaxV();
|
||||
i2v = i2v1 - i2v0;
|
||||
|
||||
x0 = x;
|
||||
xh = x0 + 0.5D;
|
||||
x1 = x + 1;
|
||||
xp0 = x0 + 0.5D - 0.0625D;
|
||||
xp1 = x0 + 0.5D + 0.0625D;
|
||||
|
||||
z0 = z;
|
||||
zh = z0 + 0.5D;
|
||||
z1 = z + 1;
|
||||
zp0 = z0 + 0.5D - 0.0625D;
|
||||
zp1 = z0 + 0.5D + 0.0625D;
|
||||
|
||||
y0 = y;
|
||||
y1 = y + 1;
|
||||
}
|
||||
|
||||
public void renderNorthPane() {
|
||||
tessellator.addVertexWithUV(xh, y1, z0, i0uh, i0v0);
|
||||
tessellator.addVertexWithUV(xh, y0, z0, i0uh, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y0, zh, i0u0, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y1, zh, i0u0, i0v0);
|
||||
tessellator.addVertexWithUV(xh, y1, zh, i0u0, i0v0);
|
||||
tessellator.addVertexWithUV(xh, y0, zh, i0u0, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y0, z0, i0uh, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y1, z0, i0uh, i0v0);
|
||||
}
|
||||
|
||||
public void renderSouthPane() {
|
||||
tessellator.addVertexWithUV(xh, y1, zh, i0u1, i0v0);
|
||||
tessellator.addVertexWithUV(xh, y0, zh, i0u1, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y0, z1, i0uh, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y1, z1, i0uh, i0v0);
|
||||
tessellator.addVertexWithUV(xh, y1, z1, i0uh, i0v0);
|
||||
tessellator.addVertexWithUV(xh, y0, z1, i0uh, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y0, zh, i0u1, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y1, zh, i0u1, i0v0);
|
||||
}
|
||||
|
||||
public void renderWestPane() {
|
||||
tessellator.addVertexWithUV(x0, y1, zh, i0uh, i0v0);
|
||||
tessellator.addVertexWithUV(x0, y0, zh, i0uh, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y0, zh, i0u0, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y1, zh, i0u0, i0v0);
|
||||
tessellator.addVertexWithUV(xh, y1, zh, i0u0, i0v0);
|
||||
tessellator.addVertexWithUV(xh, y0, zh, i0u0, i0v1);
|
||||
tessellator.addVertexWithUV(x0, y0, zh, i0uh, i0v1);
|
||||
tessellator.addVertexWithUV(x0, y1, zh, i0uh, i0v0);
|
||||
}
|
||||
|
||||
public void renderEastPane() {
|
||||
tessellator.addVertexWithUV(xh, y1, zh, i0u1, i0v0);
|
||||
tessellator.addVertexWithUV(xh, y0, zh, i0u1, i0v1);
|
||||
tessellator.addVertexWithUV(x1, y0, zh, i0uh, i0v1);
|
||||
tessellator.addVertexWithUV(x1, y1, zh, i0uh, i0v0);
|
||||
tessellator.addVertexWithUV(x1, y1, zh, i0uh, i0v0);
|
||||
tessellator.addVertexWithUV(x1, y0, zh, i0uh, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y0, zh, i0u1, i0v1);
|
||||
tessellator.addVertexWithUV(xh, y1, zh, i0u1, i0v0);
|
||||
}
|
||||
|
||||
public void renderVerticalNS(double y, double zoff0, double zoff1, double v0, double v1) {
|
||||
tessellator.addVertexWithUV(xp0, y0 + y, z0 + zoff0, i1u0, i1v0 + i1v * v0);
|
||||
tessellator.addVertexWithUV(xp0, y0 + y, z0 + zoff1, i1u0, i1v0 + i1v * v1);
|
||||
tessellator.addVertexWithUV(xp1, y0 + y, z0 + zoff1, i1u1, i1v0 + i1v * v1);
|
||||
tessellator.addVertexWithUV(xp1, y0 + y, z0 + zoff0, i1u1, i1v0 + i1v * v0);
|
||||
tessellator.addVertexWithUV(xp0, y0 + y, z0 + zoff1, i1u0, i1v0 + i1v * v1);
|
||||
tessellator.addVertexWithUV(xp0, y0 + y, z0 + zoff0, i1u0, i1v0 + i1v * v0);
|
||||
tessellator.addVertexWithUV(xp1, y0 + y, z0 + zoff0, i1u1, i1v0 + i1v * v0);
|
||||
tessellator.addVertexWithUV(xp1, y0 + y, z0 + zoff1, i1u1, i1v0 + i1v * v1);
|
||||
}
|
||||
|
||||
public void renderVerticalWE(double y, double xoff0, double xoff1, double v0, double v1) {
|
||||
tessellator.addVertexWithUV(x0 + xoff0, y0 + y, zp1, i1u1, i1v0 + i1v * v0);
|
||||
tessellator.addVertexWithUV(x0 + xoff1, y0 + y, zp1, i1u1, i1v0 + i1v * v1);
|
||||
tessellator.addVertexWithUV(x0 + xoff1, y0 + y, zp0, i1u0, i1v0 + i1v * v1);
|
||||
tessellator.addVertexWithUV(x0 + xoff0, y0 + y, zp0, i1u0, i1v0 + i1v * v0);
|
||||
tessellator.addVertexWithUV(x0 + xoff1, y0 + y, zp1, i1u1, i1v0 + i1v * v1);
|
||||
tessellator.addVertexWithUV(x0 + xoff0, y0 + y, zp1, i1u1, i1v0 + i1v * v0);
|
||||
tessellator.addVertexWithUV(x0 + xoff0, y0 + y, zp0, i1u0, i1v0 + i1v * v0);
|
||||
tessellator.addVertexWithUV(x0 + xoff1, y0 + y, zp0, i1u0, i1v0 + i1v * v1);
|
||||
}
|
||||
|
||||
public void renderHorizontalNS(double zoff, double v0, double v1) {
|
||||
tessellator.addVertexWithUV(xp0, y1, z0 + zoff, i2u0, i2v0 + i2v * v1);
|
||||
tessellator.addVertexWithUV(xp0, y0, z0 + zoff, i2u0, i2v0 + i2v * v0);
|
||||
tessellator.addVertexWithUV(xp1, y0, z0 + zoff, i2u1, i2v0 + i2v * v0);
|
||||
tessellator.addVertexWithUV(xp1, y1, z0 + zoff, i2u1, i2v0 + i2v * v1);
|
||||
tessellator.addVertexWithUV(xp1, y1, z0 + zoff, i2u1, i2v0 + i2v * v1);
|
||||
tessellator.addVertexWithUV(xp1, y0, z0 + zoff, i2u1, i2v0 + i2v * v0);
|
||||
tessellator.addVertexWithUV(xp0, y0, z0 + zoff, i2u0, i2v0 + i2v * v0);
|
||||
tessellator.addVertexWithUV(xp0, y1, z0 + zoff, i2u0, i2v0 + i2v * v1);
|
||||
|
||||
}
|
||||
|
||||
public void renderHorizontalWE(double xoff, double v0, double v1) {
|
||||
tessellator.addVertexWithUV(x0 + xoff, y1, zp0, i2u0, i2v0 + i2v * v1);
|
||||
tessellator.addVertexWithUV(x0 + xoff, y0, zp0, i2u0, i2v0 + i2v * v0);
|
||||
tessellator.addVertexWithUV(x0 + xoff, y0, zp1, i2u1, i2v0 + i2v * v0);
|
||||
tessellator.addVertexWithUV(x0 + xoff, y1, zp1, i2u1, i2v0 + i2v * v1);
|
||||
tessellator.addVertexWithUV(x0 + xoff, y1, zp1, i2u1, i2v0 + i2v * v1);
|
||||
tessellator.addVertexWithUV(x0 + xoff, y0, zp1, i2u1, i2v0 + i2v * v0);
|
||||
tessellator.addVertexWithUV(x0 + xoff, y0, zp0, i2u0, i2v0 + i2v * v0);
|
||||
tessellator.addVertexWithUV(x0 + xoff, y1, zp0, i2u0, i2v0 + i2v * v1);
|
||||
}
|
||||
}
|
||||
|
||||
PaneRenderer paneRenderer = new PaneRenderer();
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block b, int modelId, RenderBlocks renderer) {
|
||||
BlockPane block = (BlockPane) b;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||
|
||||
float f = 1.0F;
|
||||
int i1 = block.colorMultiplier(world, x, y, z);
|
||||
float f1 = (i1 >> 16 & 255) / 255.0F;
|
||||
float f2 = (i1 >> 8 & 255) / 255.0F;
|
||||
float f3 = (i1 & 255) / 255.0F;
|
||||
|
||||
if (EntityRenderer.anaglyphEnable) {
|
||||
float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
|
||||
float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
|
||||
float f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
|
||||
f1 = f4;
|
||||
f2 = f5;
|
||||
f3 = f6;
|
||||
}
|
||||
tessellator.setColorOpaque_F(f * f1, f * f2, f * f3);
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
IIcon iconPane = block.getIcon(2, meta);
|
||||
IIcon iconTop = block.getIcon(1, meta);
|
||||
IIcon iconSide = block.getIcon(0, meta);
|
||||
if (iconPane == null || iconTop == null || iconSide == null)
|
||||
return false;
|
||||
|
||||
if (renderer.hasOverrideBlockTexture()) {
|
||||
paneRenderer.set(x, y, z, renderer.overrideBlockTexture, renderer.overrideBlockTexture, renderer.overrideBlockTexture);
|
||||
} else {
|
||||
paneRenderer.set(x, y, z, iconPane, iconTop, iconSide);
|
||||
}
|
||||
|
||||
boolean connectsNorth = block.canPaneConnectToBlock(world.getBlock(x, y, z - 1));
|
||||
boolean connectsSouth = block.canPaneConnectToBlock(world.getBlock(x, y, z + 1));
|
||||
boolean connectsWest = block.canPaneConnectToBlock(world.getBlock(x - 1, y, z));
|
||||
boolean connectsEast = block.canPaneConnectToBlock(world.getBlock(x + 1, y, z));
|
||||
boolean connectsTop = block.canPaneConnectToBlock(world.getBlock(x, y + 1, z));
|
||||
boolean connectsBottom = block.canPaneConnectToBlock(world.getBlock(x, y - 1, z));
|
||||
|
||||
boolean connectsTopNorth = block.canPaneConnectToBlock(world.getBlock(x, y + 1, z - 1));
|
||||
boolean connectsTopSouth = block.canPaneConnectToBlock(world.getBlock(x, y + 1, z + 1));
|
||||
boolean connectsTopWest = block.canPaneConnectToBlock(world.getBlock(x - 1, y + 1, z));
|
||||
boolean connectsTopEast = block.canPaneConnectToBlock(world.getBlock(x + 1, y + 1, z));
|
||||
|
||||
boolean connectsBottomNorth = block.canPaneConnectToBlock(world.getBlock(x, y - 1, z - 1));
|
||||
boolean connectsBottomSouth = block.canPaneConnectToBlock(world.getBlock(x, y - 1, z + 1));
|
||||
boolean connectsBottomWest = block.canPaneConnectToBlock(world.getBlock(x - 1, y - 1, z));
|
||||
boolean connectsBottomEast = block.canPaneConnectToBlock(world.getBlock(x + 1, y - 1, z));
|
||||
|
||||
boolean isolatedTop = !connectsTopNorth && !connectsTopSouth && !connectsTopWest && !connectsTopEast;
|
||||
boolean isolatedBottom = !connectsBottomNorth && !connectsBottomSouth && !connectsBottomWest && !connectsBottomEast;
|
||||
|
||||
if (!connectsNorth && !connectsSouth && !connectsWest && !connectsEast) {
|
||||
connectsNorth = connectsSouth = connectsWest = connectsEast = true;
|
||||
}
|
||||
|
||||
int connections = 0;
|
||||
if (connectsNorth) {
|
||||
paneRenderer.renderNorthPane();
|
||||
if (!connectsBottom || !connectsBottomNorth && !isolatedBottom)
|
||||
paneRenderer.renderVerticalNS(-0.0003, 0.0, 0.5, 0.5, 0.0);
|
||||
if (!connectsTop || !connectsTopNorth && !isolatedTop)
|
||||
paneRenderer.renderVerticalNS(+1.0003, 0.0, 0.5, 0.5, 0.0);
|
||||
connections++;
|
||||
}
|
||||
if (connectsSouth) {
|
||||
paneRenderer.renderSouthPane();
|
||||
if (!connectsBottom || !connectsBottomSouth && !isolatedBottom)
|
||||
paneRenderer.renderVerticalNS(-0.0004, 0.5, 1.0, 1.0, 0.5);
|
||||
if (!connectsTop || !connectsTopSouth && !isolatedTop)
|
||||
paneRenderer.renderVerticalNS(+1.0004, 0.5, 1.0, 1.0, 0.5);
|
||||
connections++;
|
||||
}
|
||||
if (connectsWest) {
|
||||
paneRenderer.renderWestPane();
|
||||
if (!connectsBottom || !connectsBottomWest && !isolatedBottom)
|
||||
paneRenderer.renderVerticalWE(-0.0001, 0.0, 0.5, 0.5, 0.0);
|
||||
if (!connectsTop || !connectsTopWest && !isolatedTop)
|
||||
paneRenderer.renderVerticalWE(+1.0001, 0.0, 0.5, 0.5, 0.0);
|
||||
connections++;
|
||||
}
|
||||
if (connectsEast) {
|
||||
paneRenderer.renderEastPane();
|
||||
if (!connectsBottom || !connectsBottomEast && !isolatedBottom)
|
||||
paneRenderer.renderVerticalWE(-0.0002, 0.5, 1.0, 1.0, 0.5);
|
||||
if (!connectsTop || !connectsTopEast && !isolatedTop)
|
||||
paneRenderer.renderVerticalWE(+1.0002, 0.5, 1.0, 1.0, 0.5);
|
||||
connections++;
|
||||
}
|
||||
|
||||
if (connections == 1) {
|
||||
if (connectsNorth)
|
||||
paneRenderer.renderHorizontalNS(0.5, 1.0, 0.0);
|
||||
if (connectsSouth)
|
||||
paneRenderer.renderHorizontalNS(0.5, 0.0, 1.0);
|
||||
if (connectsEast)
|
||||
paneRenderer.renderHorizontalWE(0.5, 0.0, 1.0);
|
||||
if (connectsWest)
|
||||
paneRenderer.renderHorizontalWE(0.5, 1.0, 0.0);
|
||||
} else if (connections == 4) {
|
||||
paneRenderer.renderHorizontalNS(0.0, 1.0, 0.0);
|
||||
paneRenderer.renderHorizontalNS(1.0, 0.0, 1.0);
|
||||
paneRenderer.renderHorizontalWE(0.0, 0.0, 1.0);
|
||||
paneRenderer.renderHorizontalWE(1.0, 1.0, 0.0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int renderId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package team.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 team.chisel.Chisel;
|
||||
|
||||
import com.cricketcraft.ctmlib.Drawing;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class RendererEldritch implements ISimpleBlockRenderingHandler {
|
||||
|
||||
public RendererEldritch() {
|
||||
Chisel.renderEldritchId = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
Drawing.drawBlock(block, metadata, renderer);
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
|
||||
RenderBlocksEldritch renderer = new RenderBlocksEldritch();
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks rendererOld) {
|
||||
|
||||
// tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x,
|
||||
// y, z));
|
||||
/*
|
||||
* double d0 = 0.4000000059604645D; double d1 = 0.5D - d0; double d2 = 0.20000000298023224D;
|
||||
*/
|
||||
// renderer.renderTorchAtAngle(Block.torchWood, x - d1, y + d2, z, -d0,
|
||||
// 0.0D, 0);
|
||||
/*
|
||||
* Icon icon = block.getIcon(2, meta); double u0 = icon.getMinU(); double v0 = icon.getMaxV(); double u1 = icon.getMaxU(); double v1 = icon.getMinV(); double uu = icon.getInterpolatedU(8.0D);
|
||||
* double vv = icon.getInterpolatedV(8.0D);
|
||||
*
|
||||
*
|
||||
* int lyp=block.getMixedBrightnessForBlock(world, x, y+1, z); int lym=block.getMixedBrightnessForBlock(world, x, y-1, z); int lxp=block.getMixedBrightnessForBlock(world, x+1, y, z); int
|
||||
* lxm=block.getMixedBrightnessForBlock(world, x-1, y, z); int lzp=block.getMixedBrightnessForBlock(world, x, y, z+1); int lzm=block.getMixedBrightnessForBlock(world, x, y, z-1);
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* icon = block.getIcon(0, meta); u0 = icon.getMinU(); v0 = icon.getMinV(); u1 = icon.getMaxU(); v1 = icon.getMaxV(); vertex(1,u0,v0); vertex(5,u1,v0); vertex(6,u1,v1); vertex(2,u0,v1);
|
||||
*
|
||||
* icon = block.getIcon(1, meta); u0 = icon.getMinU(); v0 = icon.getMinV(); u1 = icon.getMaxU(); v1 = icon.getMaxV(); vertex(0,u0,v0); vertex(3,u0,v1); vertex(7,u1,v1); vertex(4,u1,v0);
|
||||
*/
|
||||
|
||||
renderer.blockAccess = world;
|
||||
renderer.renderMaxX = 1.0;
|
||||
renderer.renderMaxY = 1.0;
|
||||
renderer.renderMaxZ = 1.0;
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
return true;
|
||||
/*
|
||||
*
|
||||
* boolean flag = renderer.renderStandardBlock(block, x, y, z);
|
||||
*
|
||||
* return flag;
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int renderId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return Chisel.renderEldritchId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package team.chisel.client.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.block.BlockCarvableGlow;
|
||||
import team.chisel.config.Configurations;
|
||||
import team.chisel.utils.GeneralClient;
|
||||
|
||||
import com.cricketcraft.ctmlib.Drawing;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class RendererLayeredGlow implements ISimpleBlockRenderingHandler {
|
||||
|
||||
public RendererLayeredGlow() {
|
||||
Chisel.renderGlowId = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
GeneralClient.setGLColorFromInt(Configurations.configColors[metadata]);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
Drawing.drawBlock(block, ((BlockCarvableGlow) block).getGlowTexture(), renderer);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
Drawing.drawBlock(block, metadata, renderer);
|
||||
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 renderer) {
|
||||
Tessellator.instance.setColorOpaque_I(Configurations.configColors[world.getBlockMetadata(x, y, z)]);
|
||||
Tessellator.instance.setBrightness(0xF000F0);
|
||||
Drawing.renderAllFaces(renderer, block, x, y, z, ((BlockCarvableGlow) block).getGlowTexture());
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return Chisel.renderGlowId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package team.chisel.client.render;
|
||||
|
||||
import team.chisel.block.BlockMultiLayerBase;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
|
||||
import com.cricketcraft.ctmlib.Drawing;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
public class RendererMultiLayer implements ISimpleBlockRenderingHandler {
|
||||
|
||||
float bot = -0.001f, top = 1.0f - bot;
|
||||
public static int id;
|
||||
|
||||
public RendererMultiLayer() {
|
||||
id = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block blck, int meta, int modelID, RenderBlocks renderer) {
|
||||
if (blck == null || !(blck instanceof BlockMultiLayerBase))
|
||||
return;
|
||||
|
||||
BlockMultiLayerBase block = (BlockMultiLayerBase) blck;
|
||||
|
||||
if (block.icon != null) {
|
||||
renderer.overrideBlockTexture = block.icon;
|
||||
renderer.renderBlockAsItem(Blocks.stone, meta, 1.0f);
|
||||
renderer.overrideBlockTexture = null;
|
||||
} else if (block.base != null) {
|
||||
renderer.renderBlockAsItem(block.base, meta, 1.0f);
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
renderer.setRenderBounds(bot, bot, bot, top, top, top);
|
||||
glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
Drawing.drawBlock(block, meta, renderer);
|
||||
glDisable(GL_BLEND);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block blck, int modelId, RenderBlocks renderer) {
|
||||
if (blck == null || !(blck instanceof BlockMultiLayerBase))
|
||||
return false;
|
||||
BlockMultiLayerBase block = (BlockMultiLayerBase) blck;
|
||||
|
||||
if (MinecraftForgeClient.getRenderPass() == 0) {
|
||||
if (block.icon != null) {
|
||||
renderer.overrideBlockTexture = block.icon;
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.overrideBlockTexture = null;
|
||||
return true;
|
||||
} else if (block.base != null) {
|
||||
renderer.renderBlockByRenderType(block.base, x, y, z);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
renderer.setRenderBounds(0, 0, 0, 1, 1, 1);
|
||||
return renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package team.chisel.client.render;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.block.BlockRoadLine;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.cricketcraft.ctmlib.Drawing;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class RendererRoadLine implements ISimpleBlockRenderingHandler {
|
||||
|
||||
public RendererRoadLine() {
|
||||
Chisel.roadLineId = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int meta, int modelID, RenderBlocks renderer) {
|
||||
renderer.setRenderBoundsFromBlock(block);
|
||||
Drawing.drawBlock(block, meta, renderer);
|
||||
}
|
||||
|
||||
public void renderTopFace(double y, IIcon icon) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
tessellator.addVertexWithUV(1, y, 0, icon.getMaxU(), icon.getMinV());
|
||||
tessellator.addVertexWithUV(0, y, 0, icon.getMinU(), icon.getMinV());
|
||||
tessellator.addVertexWithUV(0, y, 1, icon.getMinU(), icon.getMaxV());
|
||||
tessellator.addVertexWithUV(1, y, 1, icon.getMaxU(), icon.getMaxV());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block b, int modelId, RenderBlocks renderer) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
BlockRoadLine block = (BlockRoadLine) b;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||
|
||||
float f = 1.0F;
|
||||
int i1 = block.colorMultiplier(world, x, y, z);
|
||||
float f1 = (i1 >> 16 & 255) / 255.0F;
|
||||
float f2 = (i1 >> 8 & 255) / 255.0F;
|
||||
float f3 = (i1 & 255) / 255.0F;
|
||||
|
||||
if (EntityRenderer.anaglyphEnable) {
|
||||
float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
|
||||
float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
|
||||
float f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
|
||||
f1 = f4;
|
||||
f2 = f5;
|
||||
f3 = f6;
|
||||
}
|
||||
tessellator.setColorOpaque_F(f * f1, f * f2, f * f3);
|
||||
|
||||
boolean N = world.getBlock(x, y, z - 1).equals(block) && world.getBlockMetadata(x, y, z - 1) == meta;
|
||||
boolean S = world.getBlock(x, y, z + 1).equals(block) && world.getBlockMetadata(x, y, z + 1) == meta;
|
||||
boolean W = world.getBlock(x - 1, y, z).equals(block) && world.getBlockMetadata(x - 1, y, z) == meta;
|
||||
boolean E = world.getBlock(x + 1, y, z).equals(block) && world.getBlockMetadata(x + 1, y, z) == meta;
|
||||
|
||||
if (!N && !S && !W && !E) {
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (N && S) {
|
||||
renderer.uvRotateTop = 0;
|
||||
renderer.overrideBlockTexture = block.fullLineIcon[meta];
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
} else {
|
||||
if (N) {
|
||||
renderer.uvRotateTop = 0;
|
||||
renderer.overrideBlockTexture = block.halfLineIcon[meta];
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
if (S) {
|
||||
renderer.uvRotateTop = 3;
|
||||
renderer.overrideBlockTexture = block.halfLineIcon[meta];
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (E && W) {
|
||||
renderer.uvRotateTop = 1;
|
||||
renderer.overrideBlockTexture = block.fullLineIcon[meta];
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
} else {
|
||||
if (E) {
|
||||
renderer.uvRotateTop = 1;
|
||||
renderer.overrideBlockTexture = block.halfLineIcon[meta];
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
if (W) {
|
||||
renderer.uvRotateTop = 2;
|
||||
renderer.overrideBlockTexture = block.halfLineIcon[meta];
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
renderer.uvRotateTop = 0;
|
||||
renderer.overrideBlockTexture = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int renderId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return Chisel.roadLineId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package team.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 team.chisel.Chisel;
|
||||
import team.chisel.block.BlockCarvableLayered;
|
||||
|
||||
import com.cricketcraft.ctmlib.Drawing;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class RendererSimpleLayered implements ISimpleBlockRenderingHandler {
|
||||
|
||||
public RendererSimpleLayered() {
|
||||
Chisel.renderLayeredId = 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, ((BlockCarvableLayered) block).getBaseTex(), renderer);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
Drawing.drawBlock(block, metadata, renderer);
|
||||
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 renderer) {
|
||||
renderer.setOverrideBlockTexture(((BlockCarvableLayered) block).getBaseTex());
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.clearOverrideBlockTexture();
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return Chisel.renderLayeredId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package team.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 team.chisel.block.BlockSnakestone;
|
||||
|
||||
import com.cricketcraft.ctmlib.Drawing;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class RendererSnakeStone implements ISimpleBlockRenderingHandler {
|
||||
|
||||
public static int id;
|
||||
|
||||
public RendererSnakeStone() {
|
||||
id = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int meta, int modelID, RenderBlocks renderer) {
|
||||
setRenderRotate(renderer, (BlockSnakestone) block, meta);
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
Drawing.drawBlock(block, meta, renderer);
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
restoreRendererRotate(renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
setRenderRotate(renderer, (BlockSnakestone) block, meta);
|
||||
boolean didRender = renderer.renderStandardBlock(block, x, y, z);
|
||||
restoreRendererRotate(renderer);
|
||||
|
||||
return didRender;
|
||||
}
|
||||
|
||||
private void restoreRendererRotate(RenderBlocks renderer) {
|
||||
renderer.uvRotateSouth = 0;
|
||||
renderer.uvRotateEast = 0;
|
||||
renderer.uvRotateWest = 0;
|
||||
renderer.uvRotateNorth = 0;
|
||||
renderer.uvRotateTop = 0;
|
||||
renderer.uvRotateBottom = 0;
|
||||
}
|
||||
|
||||
private void setRenderRotate(RenderBlocks renderer, BlockSnakestone block, int meta) {
|
||||
int type = meta & 0xC;
|
||||
int orient = meta & 0x3;
|
||||
|
||||
if (type == 0) {
|
||||
switch (orient) {
|
||||
case 0:
|
||||
renderer.uvRotateTop = 1;
|
||||
renderer.uvRotateBottom = 2;
|
||||
break;
|
||||
case 1:
|
||||
renderer.uvRotateTop = 1;
|
||||
renderer.uvRotateBottom = 1;
|
||||
break;
|
||||
case 2:
|
||||
renderer.uvRotateTop = 0;
|
||||
renderer.uvRotateBottom = 3;
|
||||
break;
|
||||
case 3:
|
||||
renderer.uvRotateTop = 0;
|
||||
renderer.uvRotateBottom = 0;
|
||||
}
|
||||
|
||||
} else if ((type == 4) || (type == 8)) {
|
||||
switch (orient) {
|
||||
case 0:
|
||||
renderer.uvRotateTop = block.flipTopTextures ? 1 : 2;
|
||||
renderer.uvRotateBottom = 1;
|
||||
renderer.uvRotateWest = 2;
|
||||
break;
|
||||
case 1:
|
||||
renderer.uvRotateTop = 1;
|
||||
renderer.uvRotateBottom = 1;
|
||||
renderer.uvRotateEast = 2;
|
||||
break;
|
||||
case 2:
|
||||
renderer.uvRotateTop = block.flipTopTextures ? 0 : 3;
|
||||
renderer.uvRotateBottom = 0;
|
||||
renderer.uvRotateSouth = 2;
|
||||
break;
|
||||
case 3:
|
||||
renderer.uvRotateTop = 0;
|
||||
renderer.uvRotateBottom = 0;
|
||||
renderer.uvRotateNorth = 2;
|
||||
}
|
||||
|
||||
} else if (type == 12) {
|
||||
switch (orient) {
|
||||
case 0:
|
||||
renderer.uvRotateTop = 0;
|
||||
renderer.uvRotateBottom = 0;
|
||||
break;
|
||||
case 1:
|
||||
renderer.uvRotateTop = 1;
|
||||
renderer.uvRotateBottom = 1;
|
||||
break;
|
||||
case 2:
|
||||
renderer.uvRotateNorth = 2;
|
||||
renderer.uvRotateSouth = 2;
|
||||
renderer.uvRotateEast = 2;
|
||||
renderer.uvRotateWest = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int renderId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package team.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 team.chisel.block.BlockCarvableStairs;
|
||||
|
||||
import com.cricketcraft.ctmlib.Drawing;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class RendererStairs implements ISimpleBlockRenderingHandler {
|
||||
|
||||
public static int id;
|
||||
|
||||
public RendererStairs() {
|
||||
id = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int meta, int modelID, RenderBlocks renderer) {
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.5F);
|
||||
Drawing.drawBlock(block, meta, renderer);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.5F, 1.0F, 0.5F, 1.0F);
|
||||
Drawing.drawBlock(block, meta, renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block blck, int modelId, RenderBlocks renderer) {
|
||||
if (blck == null || !(blck instanceof BlockCarvableStairs))
|
||||
return false;
|
||||
BlockCarvableStairs block = (BlockCarvableStairs) blck;
|
||||
|
||||
renderer.renderBlockStairs(block, x, y, z);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int renderId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getRenderBlockPass() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package team.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.ctmlib.RenderBlocksCTM;
|
||||
import com.cricketcraft.ctmlib.TextureSubmap;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SubmapManagerAntiblock extends SubmapManagerBase {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static class RenderBlocksCTMFullbright extends 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);
|
||||
}
|
||||
};
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static RenderBlocksCTMFullbright rb;
|
||||
|
||||
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
|
||||
@SideOnly(Side.CLIENT)
|
||||
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
|
||||
@SideOnly(Side.CLIENT)
|
||||
public RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) {
|
||||
if (rb == null) {
|
||||
rb = new RenderBlocksCTMFullbright();
|
||||
}
|
||||
rb.setRenderBoundsFromBlock(block);
|
||||
rb.submap = submap;
|
||||
rb.submapSmall = submapSmall;
|
||||
return rb;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package team.chisel.client.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
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.ctmlib.ISubmapManager;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public abstract class SubmapManagerBase implements ISubmapManager {
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return getIcon(side, world.getBlockMetadata(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void preRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void postRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package team.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.ctmlib.RenderBlocksCTM;
|
||||
import com.cricketcraft.ctmlib.TextureSubmap;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SubmapManagerCarpetFloor extends SubmapManagerBase {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static RenderBlocksCTM rb;
|
||||
|
||||
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
|
||||
@SideOnly(Side.CLIENT)
|
||||
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
|
||||
@SideOnly(Side.CLIENT)
|
||||
public RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) {
|
||||
if (rb == null) {
|
||||
rb = new RenderBlocksCTM();
|
||||
}
|
||||
rb.setRenderBoundsFromBlock(block);
|
||||
rb.submap = submap;
|
||||
rb.submapSmall = submapSmall;
|
||||
return rb;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
package team.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.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
|
||||
import com.cricketcraft.chisel.api.carving.CarvingUtils;
|
||||
import com.cricketcraft.chisel.api.rendering.TextureType;
|
||||
import com.cricketcraft.chisel.api.rendering.TextureType.AbstractSubmapManager;
|
||||
import com.cricketcraft.ctmlib.RenderBlocksCTM;
|
||||
import com.cricketcraft.ctmlib.TextureSubmap;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SubmapManagerCombinedCTM extends SubmapManagerBase {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private class RenderBlocksCombinedCTM extends RenderBlocksCTM {
|
||||
|
||||
@Override
|
||||
public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon) {
|
||||
setIcons(rType, x, y, z, ForgeDirection.WEST);
|
||||
super.renderFaceXNeg(block, x, y, z, inWorld ? submapSmall.getSubIcon(0, 0) : icon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon) {
|
||||
setIcons(rType, x, y, z, ForgeDirection.EAST);
|
||||
super.renderFaceXPos(block, x, y, z, inWorld ? submapSmall.getSubIcon(0, 0) : icon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon) {
|
||||
setIcons(rType, x, y, z, ForgeDirection.DOWN);
|
||||
super.renderFaceYNeg(block, x, y, z, inWorld ? submapSmall.getSubIcon(0, 0) : icon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceYPos(Block block, double x, double y, double z, IIcon icon) {
|
||||
setIcons(rType, x, y, z, ForgeDirection.UP);
|
||||
super.renderFaceYPos(block, x, y, z, inWorld ? submapSmall.getSubIcon(0, 0) : icon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon) {
|
||||
setIcons(rType, x, y, z, ForgeDirection.NORTH);
|
||||
super.renderFaceZNeg(block, x, y, z, inWorld ? submapSmall.getSubIcon(0, 0) : icon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon) {
|
||||
setIcons(rType, x, y, z, ForgeDirection.SOUTH);
|
||||
super.renderFaceZPos(block, x, y, z, inWorld ? submapSmall.getSubIcon(0, 0) : icon);
|
||||
}
|
||||
|
||||
private void setIcons(TextureType type, double x, double y, double z, ForgeDirection side) {
|
||||
int ix = MathHelper.floor_double(x);
|
||||
int iy = MathHelper.floor_double(y);
|
||||
int iz = MathHelper.floor_double(z);
|
||||
if (type == TextureType.V4 || type == TextureType.V9) {
|
||||
submap = (TextureSubmap) TextureType.getVIcon(rType, SubmapManagerCombinedCTM.this.submap, ix, iy, iz, side.ordinal());
|
||||
submapSmall = (TextureSubmap) TextureType.getVIcon(rType, SubmapManagerCombinedCTM.this.smallSubmap, ix, iy, iz, side.ordinal());
|
||||
} else {
|
||||
submap = (TextureSubmap) TextureType.getRIcon(rType, SubmapManagerCombinedCTM.this.submap, ix, iy, iz, side.ordinal());
|
||||
submapSmall = (TextureSubmap) TextureType.getRIcon(rType, SubmapManagerCombinedCTM.this.smallSubmap, ix, iy, iz, side.ordinal());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class Submap extends TextureSubmap {
|
||||
|
||||
private TextureSubmap[][] submap;
|
||||
|
||||
public Submap(IIcon base, int wh, TextureSubmap[][] submap) {
|
||||
super(base, wh, wh);
|
||||
this.submap = submap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void texturesStitched() {
|
||||
for (int i = 0; i < icons.length; i++) {
|
||||
for (int j = 0; j < icons[i].length; j++) {
|
||||
icons[i][j] = submap[i][j];
|
||||
submap[i][j].texturesStitched();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private RenderBlocksCTM rb;
|
||||
|
||||
private TextureSubmap submap, smallSubmap;
|
||||
private int size;
|
||||
private String texturePath;
|
||||
private int meta;
|
||||
private IIcon defaultIcon;
|
||||
private TextureType rType;
|
||||
|
||||
public SubmapManagerCombinedCTM(int meta, String texturePath, TextureType rType) {
|
||||
assert rType == TextureType.R16 || rType == TextureType.R9 || rType == TextureType.R4 || rType == TextureType.V4 || rType == TextureType.V9 : "Not a valid random type!";
|
||||
|
||||
this.meta = meta;
|
||||
this.texturePath = texturePath;
|
||||
this.size = Integer.parseInt(rType.name().substring(1, rType.name().length())); // >.>
|
||||
this.rType = rType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return defaultIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) {
|
||||
if (rb == null) {
|
||||
rb = new RenderBlocksCombinedCTM();
|
||||
}
|
||||
rb.setRenderBoundsFromBlock(block);
|
||||
return rb;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(String modName, Block block, IIconRegister register) {
|
||||
IIcon base = register.registerIcon(modName + ":" + texturePath);
|
||||
int wh = (int) Math.sqrt(size);
|
||||
TextureSubmap[][] submaps = new TextureSubmap[wh][wh];
|
||||
TextureSubmap[][] submapsSmall = new TextureSubmap[wh][wh];
|
||||
for (int i = 0; i < size; i++) {
|
||||
AbstractSubmapManager manager = (AbstractSubmapManager) TextureType.CTMX.createManagerFor(CarvingUtils.getDefaultVariationFor(block, meta, 0), texturePath + "-" + i);
|
||||
manager.registerIcons(modName, block, register);
|
||||
Object cached = manager.getCachedObject();
|
||||
Triple<IIcon, TextureSubmap, TextureSubmap> triple = (Triple<IIcon, TextureSubmap, TextureSubmap>) cached;
|
||||
submaps[i % wh][i / wh] = triple.getMiddle();
|
||||
submapsSmall[i % wh][i / wh] = triple.getRight();
|
||||
if (i == 0) {
|
||||
defaultIcon = triple.getRight().getBaseIcon();
|
||||
}
|
||||
}
|
||||
submap = new Submap(base, wh, submaps);
|
||||
smallSubmap = new Submap(base, wh, submapsSmall);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package team.chisel.client.render;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.init.ChiselBlocks;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.cricketcraft.ctmlib.CTM;
|
||||
import com.cricketcraft.ctmlib.TextureSubmap;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import static com.cricketcraft.ctmlib.Dir.*;
|
||||
|
||||
public class SubmapManagerFakeController extends SubmapManagerBase {
|
||||
|
||||
private TextureSubmap map;
|
||||
private CTM ctm = CTM.getInstance();
|
||||
private int meta;
|
||||
private String texturePath;
|
||||
|
||||
public SubmapManagerFakeController(int meta, String texture) {
|
||||
ctm.disableObscuredFaceCheck = Optional.of(true);
|
||||
this.meta = meta;
|
||||
texturePath = texture;
|
||||
}
|
||||
|
||||
public SubmapManagerFakeController(int meta) {
|
||||
ctm.disableObscuredFaceCheck = Optional.of(true);
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return map.getSubIcon(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
ctm.buildConnectionMap(world, x, y, z, side, ChiselBlocks.futura, meta);
|
||||
|
||||
if (ctm.connectedAnd(TOP, TOP_RIGHT, RIGHT, BOTTOM_RIGHT, BOTTOM, BOTTOM_LEFT, LEFT, TOP_LEFT)) {
|
||||
return map.getSubIcon(1, 1);
|
||||
} else if (ctm.connectedAnd(TOP, BOTTOM)) {
|
||||
return map.getSubIcon(0, 1);
|
||||
} else if (ctm.connectedAnd(LEFT, RIGHT)) {
|
||||
return map.getSubIcon(1, 0);
|
||||
} else {
|
||||
return map.getSubIcon(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(String modName, Block block, IIconRegister register) {
|
||||
|
||||
if (texturePath != null) {
|
||||
map = new TextureSubmap(register.registerIcon(modName + ":" + texturePath), 2, 2);
|
||||
} else {
|
||||
Chisel.logger.info("SubmapManagerFakeController was called on block " + block.getUnlocalizedName() + " without declaring texture, using a default texture instead.");
|
||||
map = new TextureSubmap(register.registerIcon(modName + ":futura/WIP/controller"), 2, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package team.chisel.client.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class SubmapManagerLeaves extends SubmapManagerBase {
|
||||
|
||||
private String name;
|
||||
private IIcon normal, opaque;
|
||||
|
||||
public SubmapManagerLeaves(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return Blocks.leaves.isOpaqueCube() ? opaque : normal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(String modName, Block block, IIconRegister register) {
|
||||
this.normal = register.registerIcon(modName + ":" + name);
|
||||
this.opaque = register.registerIcon(modName + ":" + name + "_opaque");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package team.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.ctmlib.ISubmapManager;
|
||||
import com.cricketcraft.ctmlib.RenderBlocksCTM;
|
||||
import com.cricketcraft.ctmlib.TextureSubmap;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SubmapManagerSlab implements ISubmapManager {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static RenderBlocksCTM rb;
|
||||
|
||||
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
|
||||
@SideOnly(Side.CLIENT)
|
||||
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
|
||||
@SideOnly(Side.CLIENT)
|
||||
public RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) {
|
||||
if (rb == null) {
|
||||
rb = new RenderBlocksCTM();
|
||||
}
|
||||
rb.setRenderBoundsFromBlock(block);
|
||||
rb.submap = submap;
|
||||
rb.submapSmall = submapSmall;
|
||||
return rb;
|
||||
}
|
||||
|
||||
private boolean hadOverride = false;
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void preRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
RenderBlocksCTM rbctm = (RenderBlocksCTM) renderer;
|
||||
if (side.ordinal() < 2 && !rbctm.rendererOld.hasOverrideBlockTexture()) {
|
||||
rbctm.rendererOld.setOverrideBlockTexture(sideTexture);
|
||||
hadOverride = false;
|
||||
} else {
|
||||
hadOverride = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void postRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
if (!hadOverride) {
|
||||
((RenderBlocksCTM) renderer).rendererOld.clearOverrideBlockTexture();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package team.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.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.cricketcraft.chisel.api.carving.CarvingUtils;
|
||||
import com.cricketcraft.chisel.api.rendering.TextureType;
|
||||
import com.cricketcraft.ctmlib.ISubmapManager;
|
||||
import com.cricketcraft.ctmlib.RenderBlocksCTM;
|
||||
import com.cricketcraft.ctmlib.TextureSubmap;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SubmapManagerVoidstone extends SubmapManagerBase {
|
||||
|
||||
// TODO there must be a better more generic way to do this...
|
||||
@SideOnly(Side.CLIENT)
|
||||
private class RenderBlocksVoidstone extends RenderBlocksCTM {
|
||||
|
||||
@Override
|
||||
public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon) {
|
||||
super.renderFaceXNeg(block, x, y, z, icon);
|
||||
renderMinX += 0.001;
|
||||
setOverrideBlockTexture(getBase(x, y, z, ForgeDirection.WEST.ordinal()));
|
||||
super.renderFaceXNeg(block, x, y, z, null);
|
||||
clearOverrideBlockTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon) {
|
||||
super.renderFaceXPos(block, x, y, z, icon);
|
||||
setOverrideBlockTexture(getBase(x, y, z, ForgeDirection.EAST.ordinal()));
|
||||
renderMaxX -= 0.001;
|
||||
super.renderFaceXPos(block, x, y, z, null);
|
||||
clearOverrideBlockTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon) {
|
||||
super.renderFaceYNeg(block, x, y, z, icon);
|
||||
setOverrideBlockTexture(getBase(x, y, z, ForgeDirection.DOWN.ordinal()));
|
||||
renderMinY += 0.001;
|
||||
super.renderFaceYNeg(block, x, y, z, null);
|
||||
clearOverrideBlockTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceYPos(Block block, double x, double y, double z, IIcon icon) {
|
||||
super.renderFaceYPos(block, x, y, z, icon);
|
||||
setOverrideBlockTexture(getBase(x, y, z, ForgeDirection.UP.ordinal()));
|
||||
renderMaxY -= 0.001;
|
||||
super.renderFaceYPos(block, x, y, z, null);
|
||||
clearOverrideBlockTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon) {
|
||||
super.renderFaceZNeg(block, x, y, z, icon);
|
||||
setOverrideBlockTexture(getBase(x, y, z, ForgeDirection.NORTH.ordinal()));
|
||||
renderMinZ += 0.001;
|
||||
super.renderFaceZNeg(block, x, y, z, null);
|
||||
clearOverrideBlockTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon) {
|
||||
super.renderFaceZPos(block, x, y, z, icon);
|
||||
setOverrideBlockTexture(getBase(x, y, z, ForgeDirection.SOUTH.ordinal()));
|
||||
renderMaxZ -= 0.001;
|
||||
super.renderFaceZPos(block, x, y, z, null);
|
||||
clearOverrideBlockTexture();
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private RenderBlocksVoidstone rb;
|
||||
|
||||
private ISubmapManager overlay;
|
||||
private TextureSubmap base;
|
||||
|
||||
private IIcon getBase(double x, double y, double z, int side) {
|
||||
return TextureType.getVIcon(TextureType.V4, base, MathHelper.floor_double(x), MathHelper.floor_double(y), MathHelper.floor_double(z), side);
|
||||
}
|
||||
|
||||
private String texture;
|
||||
private int meta;
|
||||
|
||||
public SubmapManagerVoidstone(String texture, int meta) {
|
||||
this.texture = texture;
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return overlay.getIcon(side, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return overlay.getIcon(world, x, y, z, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(String modName, Block block, IIconRegister register) {
|
||||
overlay = TextureType.getTypeFor(null, modName, texture).createManagerFor(CarvingUtils.getDefaultVariationFor(block, meta, 0), texture);
|
||||
overlay.registerIcons(modName, block, register);
|
||||
base = new TextureSubmap(register.registerIcon(modName + ":" + "animations/hadesX32"), 2, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) {
|
||||
if (rb == null) {
|
||||
rb = new RenderBlocksVoidstone();
|
||||
}
|
||||
RenderBlocks ctx = overlay.createRenderContext(rendererOld, block, world);
|
||||
rb.setRenderBoundsFromBlock(block);
|
||||
if (ctx instanceof RenderBlocksCTM) {
|
||||
rb.submap = ((RenderBlocksCTM) ctx).submap;
|
||||
rb.submapSmall = ((RenderBlocksCTM) ctx).submapSmall;
|
||||
}
|
||||
return rb;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package team.chisel.client.render.item;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class ItemChiselRenderer implements IItemRenderer {
|
||||
|
||||
RenderBlocks renderBlock = new RenderBlocks();
|
||||
RenderItem renderItem = new RenderItem();
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return type == IItemRenderer.ItemRenderType.INVENTORY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack stack, Object... data) {
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
renderItem.renderItemIntoGUI(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().renderEngine, stack, 0, 0);
|
||||
|
||||
if (stack.stackTagCompound == null)
|
||||
return;
|
||||
|
||||
ItemStack chiselTarget = ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("chiselTarget"));
|
||||
if (chiselTarget == null)
|
||||
return;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(0.65f, 0.65f, 0.65f);
|
||||
GL11.glTranslatef(-8f, -8f, 0.0f);
|
||||
|
||||
renderItem.renderItemIntoGUI(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().renderEngine, chiselTarget, 8, 8);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
package team.chisel.client.render.tile;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.block.tileentity.TileEntityAutoChisel;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.client.model.obj.Face;
|
||||
import net.minecraftforge.client.model.obj.GroupObject;
|
||||
import net.minecraftforge.client.model.obj.TextureCoordinate;
|
||||
import net.minecraftforge.client.model.obj.Vertex;
|
||||
import net.minecraftforge.client.model.obj.WavefrontObject;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
public class RenderAutoChisel extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler, IItemRenderer {
|
||||
|
||||
private static final WavefrontObject model = new WavefrontObject(new ResourceLocation(Chisel.MOD_ID, "models/autoChisel/autoChisel.obj"));
|
||||
private static final ResourceLocation texture = new ResourceLocation(Chisel.MOD_ID, "textures/blocks/autoChisel/autoChisel.png");
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
return helper == ItemRendererHelper.INVENTORY_BLOCK || helper == ItemRendererHelper.ENTITY_BOBBING || helper == ItemRendererHelper.ENTITY_ROTATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
switch (type) {
|
||||
case ENTITY:
|
||||
glTranslatef(-0.5f, 0, 0.5f);
|
||||
break;
|
||||
case EQUIPPED:
|
||||
glRotatef(20, 0, 1, 0);
|
||||
glRotatef(-15, 1, 0, -1);
|
||||
glScalef(0.65f, 0.65f, 0.65f);
|
||||
glTranslatef(0.75f, -0.5f, 1.25f);
|
||||
break;
|
||||
case EQUIPPED_FIRST_PERSON:
|
||||
glRotatef(20, 0, 0, 1);
|
||||
glRotatef(30, 0, 1, 0);
|
||||
glTranslatef(0.2f, 0, -0.1f);
|
||||
glScalef(0.5f, 0.5f, 0.5f);
|
||||
break;
|
||||
case FIRST_PERSON_MAP:
|
||||
break;
|
||||
case INVENTORY:
|
||||
glTranslatef(-0.5f, -0.5f, 0.5f);
|
||||
break;
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
|
||||
model.renderAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
Tessellator tes = Tessellator.instance;
|
||||
IIcon icon = renderer.hasOverrideBlockTexture() ? renderer.overrideBlockTexture : block.getIcon(0, 0);
|
||||
tes.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||
tes.setColorOpaque_F(1, 1, 1);
|
||||
tes.addTranslation(x, y, z + 1);
|
||||
for (GroupObject go : model.groupObjects) {
|
||||
for (Face f : go.faces) {
|
||||
Vertex n = f.faceNormal;
|
||||
tes.setNormal(n.x, n.y, n.z);
|
||||
for (int i = 0; i < f.vertices.length; i++) {
|
||||
Vertex vert = f.vertices[i];
|
||||
TextureCoordinate t = f.textureCoordinates[i];
|
||||
if (!renderer.hasOverrideBlockTexture()) {
|
||||
tes.addVertexWithUV(vert.x, vert.y, vert.z, icon.getInterpolatedU(t.u * 16), icon.getInterpolatedV(t.v * 16));
|
||||
} else {
|
||||
tes.addVertexWithUV(vert.x, vert.y, vert.z, icon.getInterpolatedU((t.u * 64) % 16), icon.getInterpolatedV((t.v * 64) % 16));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tes.addTranslation(-x, -y, -z - 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return Chisel.renderAutoChiselId;
|
||||
}
|
||||
|
||||
private final RenderItem renderItem;
|
||||
|
||||
public RenderAutoChisel() {
|
||||
Chisel.renderAutoChiselId = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
renderItem = new RenderItem() {
|
||||
|
||||
@Override
|
||||
public boolean shouldBob() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
renderItem.setRenderManager(RenderManager.instance);
|
||||
}
|
||||
|
||||
private static final Random rand = new Random();
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float scale) {
|
||||
|
||||
// Render Blocks
|
||||
TileEntityAutoChisel autoChisel = (TileEntityAutoChisel) tile;
|
||||
EntityItem item = autoChisel.getItemForRendering(TileEntityAutoChisel.TARGET);
|
||||
|
||||
rand.setSeed(tile.xCoord + tile.yCoord + tile.zCoord);
|
||||
rand.nextBoolean();
|
||||
|
||||
float max = 0.35f;
|
||||
|
||||
if (!Minecraft.getMinecraft().isGamePaused()) {
|
||||
autoChisel.xRot += (rand.nextFloat() * max) - (max / 2);
|
||||
autoChisel.yRot += (rand.nextFloat() * max) - (max / 2);
|
||||
autoChisel.zRot += (rand.nextFloat() * max) - (max / 2);
|
||||
}
|
||||
|
||||
if (item != null) {
|
||||
glPushMatrix();
|
||||
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
||||
glTranslated(x + 0.5, y + 1.5, z + 0.5);
|
||||
glRotatef(autoChisel.xRot, 1, 0, 0);
|
||||
glRotatef(autoChisel.yRot, 0, 1, 0);
|
||||
glRotatef(autoChisel.zRot, 0, 0, 1);
|
||||
glEnable(GL_BLEND);
|
||||
glDepthMask(false);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA);
|
||||
renderItem.doRender(item, 0, 0, 0, 0, 0);
|
||||
glPopMatrix();
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
item = autoChisel.getItemForRendering(TileEntityAutoChisel.BASE);
|
||||
if (item != null) {
|
||||
glPushMatrix();
|
||||
glTranslated(x + 0.35, y + 0.934, z + 0.5);
|
||||
item.getEntityItem().stackSize = autoChisel.getLastBase() == null ? 1 : autoChisel.getLastBase().stackSize;
|
||||
renderItem.doRender(item, 0, 0, 0, 0, 0);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
GameSettings settings = Minecraft.getMinecraft().gameSettings;
|
||||
item = autoChisel.getItemForRendering(TileEntityAutoChisel.CHISEL);
|
||||
if (item != null) {
|
||||
glPushMatrix();
|
||||
glTranslated(x + 0.7, y + 1.01, z + 0.5);
|
||||
float rot = autoChisel.chiselRot == 0 ? 0 : autoChisel.chiseling ? autoChisel.chiselRot + (TileEntityAutoChisel.rotAmnt * scale) : autoChisel.chiselRot
|
||||
- (TileEntityAutoChisel.rotAmnt * scale);
|
||||
glRotatef(rot, 0, 0, 1);
|
||||
glTranslated(-0.12, 0, 0);
|
||||
glScalef(0.9f, 0.9f, 0.9f);
|
||||
boolean was = settings.fancyGraphics;
|
||||
settings.fancyGraphics = true;
|
||||
renderItem.doRender(item, 0, 0, 0, 0, 0);
|
||||
settings.fancyGraphics = was;
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
package team.chisel.client.render.tile;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityBeaconRenderer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemDye;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import team.chisel.block.tileentity.TileEntityCarvableBeacon;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class RenderCarvableBeacon extends TileEntityBeaconRenderer implements ISimpleBlockRenderingHandler {
|
||||
|
||||
private static final ResourceLocation texture = new ResourceLocation("textures/entity/beacon_beam.png");
|
||||
|
||||
private int renderId;
|
||||
|
||||
public RenderCarvableBeacon() {
|
||||
this.renderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
public void renderTileEntityAt(TileEntityCarvableBeacon beacon, double x, double y, double z, float partialTicks) {
|
||||
float f1 = beacon.func_146002_i();
|
||||
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
|
||||
if (f1 > 0.1F) {
|
||||
Color color = new Color(ItemDye.field_150922_c[beacon.getWorldObj().getBlockMetadata(beacon.xCoord, beacon.yCoord, beacon.zCoord)]);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
this.bindTexture(texture);
|
||||
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F);
|
||||
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glDepthMask(true);
|
||||
OpenGlHelper.glBlendFunc(770, 1, 1, 0);
|
||||
float f2 = beacon.getWorldObj().getTotalWorldTime() + partialTicks;
|
||||
float f3 = -f2 * 0.2F - MathHelper.floor_float(-f2 * 0.1F);
|
||||
byte b0 = 1;
|
||||
double d3 = f2 * 0.025D * (1.0D - (b0 & 1) * 2.5D);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA(color.getRed(), color.getGreen(), color.getBlue(), 32);
|
||||
double d5 = b0 * 0.2D;
|
||||
double d7 = 0.5D + Math.cos(d3 + 2.356194490192345D) * d5;
|
||||
double d9 = 0.5D + Math.sin(d3 + 2.356194490192345D) * d5;
|
||||
double d11 = 0.5D + Math.cos(d3 + (Math.PI / 4D)) * d5;
|
||||
double d13 = 0.5D + Math.sin(d3 + (Math.PI / 4D)) * d5;
|
||||
double d15 = 0.5D + Math.cos(d3 + 3.9269908169872414D) * d5;
|
||||
double d17 = 0.5D + Math.sin(d3 + 3.9269908169872414D) * d5;
|
||||
double d19 = 0.5D + Math.cos(d3 + 5.497787143782138D) * d5;
|
||||
double d21 = 0.5D + Math.sin(d3 + 5.497787143782138D) * d5;
|
||||
double d23 = 256.0F * f1;
|
||||
double d25 = 0.0D;
|
||||
double d27 = 1.0D;
|
||||
double d28 = -1.0F + f3;
|
||||
double d29 = 256.0F * f1 * (0.5D / d5) + d28;
|
||||
tessellator.addVertexWithUV(x + d7, y + d23, z + d9, d27, d29);
|
||||
tessellator.addVertexWithUV(x + d7, y, z + d9, d27, d28);
|
||||
tessellator.addVertexWithUV(x + d11, y, z + d13, d25, d28);
|
||||
tessellator.addVertexWithUV(x + d11, y + d23, z + d13, d25, d29);
|
||||
tessellator.addVertexWithUV(x + d19, y + d23, z + d21, d27, d29);
|
||||
tessellator.addVertexWithUV(x + d19, y, z + d21, d27, d28);
|
||||
tessellator.addVertexWithUV(x + d15, y, z + d17, d25, d28);
|
||||
tessellator.addVertexWithUV(x + d15, y + d23, z + d17, d25, d29);
|
||||
tessellator.addVertexWithUV(x + d11, y + d23, z + d13, d27, d29);
|
||||
tessellator.addVertexWithUV(x + d11, y, z + d13, d27, d28);
|
||||
tessellator.addVertexWithUV(x + d19, y, z + d21, d25, d28);
|
||||
tessellator.addVertexWithUV(x + d19, y + d23, z + d21, d25, d29);
|
||||
tessellator.addVertexWithUV(x + d15, y + d23, z + d17, d27, d29);
|
||||
tessellator.addVertexWithUV(x + d15, y, z + d17, d27, d28);
|
||||
tessellator.addVertexWithUV(x + d7, y, z + d9, d25, d28);
|
||||
tessellator.addVertexWithUV(x + d7, y + d23, z + d9, d25, d29);
|
||||
tessellator.draw();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
GL11.glDepthMask(false);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA(color.getRed(), color.getGreen(), color.getBlue(), 32);
|
||||
double d30 = 0.2D;
|
||||
double d4 = 0.2D;
|
||||
double d6 = 0.8D;
|
||||
double d8 = 0.2D;
|
||||
double d10 = 0.2D;
|
||||
double d12 = 0.8D;
|
||||
double d14 = 0.8D;
|
||||
double d16 = 0.8D;
|
||||
double d18 = 256.0F * f1;
|
||||
double d20 = 0.0D;
|
||||
double d22 = 1.0D;
|
||||
double d24 = -1.0F + f3;
|
||||
double d26 = 256.0F * f1 + d24;
|
||||
tessellator.addVertexWithUV(x + d30, y + d18, z + d4, d22, d26);
|
||||
tessellator.addVertexWithUV(x + d30, y, z + d4, d22, d24);
|
||||
tessellator.addVertexWithUV(x + d6, y, z + d8, d20, d24);
|
||||
tessellator.addVertexWithUV(x + d6, y + d18, z + d8, d20, d26);
|
||||
tessellator.addVertexWithUV(x + d14, y + d18, z + d16, d22, d26);
|
||||
tessellator.addVertexWithUV(x + d14, y, z + d16, d22, d24);
|
||||
tessellator.addVertexWithUV(x + d10, y, z + d12, d20, d24);
|
||||
tessellator.addVertexWithUV(x + d10, y + d18, z + d12, d20, d26);
|
||||
tessellator.addVertexWithUV(x + d6, y + d18, z + d8, d22, d26);
|
||||
tessellator.addVertexWithUV(x + d6, y, z + d8, d22, d24);
|
||||
tessellator.addVertexWithUV(x + d14, y, z + d16, d20, d24);
|
||||
tessellator.addVertexWithUV(x + d14, y + d18, z + d16, d20, d26);
|
||||
tessellator.addVertexWithUV(x + d10, y + d18, z + d12, d22, d26);
|
||||
tessellator.addVertexWithUV(x + d10, y, z + d12, d22, d24);
|
||||
tessellator.addVertexWithUV(x + d30, y, z + d4, d20, d24);
|
||||
tessellator.addVertexWithUV(x + d30, y + d18, z + d4, d20, d26);
|
||||
tessellator.draw();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glDepthMask(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks) {
|
||||
this.renderTileEntityAt((TileEntityCarvableBeacon) tile, x, y, z, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
renderer.renderBlockAsItem(Blocks.beacon, 0, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
float f = 0.1875F;
|
||||
renderer.setOverrideBlockTexture(renderer.getBlockIcon(Blocks.glass));
|
||||
renderer.renderStandardBlockWithAmbientOcclusion(block, x, y, z, 1, 1, 1);
|
||||
renderer.renderAllFaces = true;
|
||||
renderer.setOverrideBlockTexture(renderer.getBlockIcon(Blocks.obsidian));
|
||||
renderer.setRenderBounds(0.125D, 0.00625D, 0.125D, 0.875D, f, 0.875D);
|
||||
renderer.renderStandardBlockWithAmbientOcclusion(block, x, y, z, 1, 1, 1);
|
||||
renderer.setOverrideBlockTexture(renderer.getBlockIcon(Blocks.beacon));
|
||||
renderer.setRenderBounds(0.1875D, f, 0.1875D, 0.8125D, 0.875D, 0.8125D);
|
||||
renderer.renderStandardBlockWithAmbientOcclusion(block, x, y, z, 1, 1, 1);
|
||||
renderer.renderAllFaces = false;
|
||||
renderer.clearOverrideBlockTexture();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return renderId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package team.chisel.client.render.tile;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.client.model.ModelChest;
|
||||
import net.minecraft.client.model.ModelLargeChest;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.block.tileentity.TileEntityPresent;
|
||||
import team.chisel.init.ChiselBlocks;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
|
||||
public class RenderPresent extends TileEntitySpecialRenderer implements IItemRenderer {
|
||||
|
||||
private ModelChest smallChest = new ModelChest();
|
||||
private ModelChest largeChest = new ModelLargeChest();
|
||||
|
||||
private HashMap<Integer, ResourceLocation> textureCache = Maps.newHashMap();
|
||||
|
||||
public void renderTileEntityAt(TileEntityPresent present, double x, double y, double z, float partialTicks) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
|
||||
GL11.glScalef(1.0F, -1.0F, -1.0F);
|
||||
int rotation = present.getRotation();
|
||||
bindTexture(present);
|
||||
if (!present.isConnected()) {
|
||||
GL11.glRotatef(90 * rotation + 180, 0, 1, 0);
|
||||
switch (rotation) {
|
||||
case 0:
|
||||
GL11.glTranslatef(-1, 0, -1);
|
||||
break;
|
||||
case 1:
|
||||
GL11.glTranslatef(0, 0, -1);
|
||||
break;
|
||||
case 3:
|
||||
GL11.glTranslatef(-1, 0, 0);
|
||||
break;
|
||||
}
|
||||
smallChest.renderAll();
|
||||
} else if (present.isParent()) {
|
||||
ForgeDirection dir = present.getConnectionDir();
|
||||
switch (dir) {
|
||||
case NORTH:
|
||||
GL11.glRotatef(-90, 0, 1, 0);
|
||||
GL11.glTranslatef(0, 0, -1);
|
||||
break;
|
||||
case SOUTH:
|
||||
GL11.glRotatef(-90, 0, 1, 0);
|
||||
GL11.glTranslatef(-1, 0, -1);
|
||||
break;
|
||||
case WEST:
|
||||
GL11.glTranslatef(-1, 0, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (rotation == 0 || rotation == 3) {
|
||||
GL11.glRotatef(180, 0, 1, 0);
|
||||
GL11.glTranslatef(-2, 0, -1);
|
||||
}
|
||||
largeChest.renderAll();
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void bindTexture(TileEntityPresent present) {
|
||||
int idx = present.getWorldObj().getBlockMetadata(present.xCoord, present.yCoord, present.zCoord) + (present.isConnected() ? 0 : 16);
|
||||
ResourceLocation rl = textureCache.get(idx);
|
||||
if (rl == null) {
|
||||
String res = ChiselBlocks.present.getModelTexture(idx % 16);
|
||||
res += present.isConnected() ? "_double.png" : ".png";
|
||||
rl = new ResourceLocation("chisel", res);
|
||||
textureCache.put(idx, rl);
|
||||
}
|
||||
bindTexture(rl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTicks) {
|
||||
this.renderTileEntityAt((TileEntityPresent) tileEntity, x, y, z, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return type != ItemRenderType.FIRST_PERSON_MAP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(new ResourceLocation(Chisel.MOD_ID, ChiselBlocks.present.getModelTexture(item.getItemDamage()) + ".png"));
|
||||
switch (type) {
|
||||
case ENTITY:
|
||||
renderBlock(0.0F, 1.0F, 0.0F);
|
||||
break;
|
||||
case EQUIPPED:
|
||||
renderBlock(0.5F, 1.5F, 0.5F);
|
||||
break;
|
||||
case EQUIPPED_FIRST_PERSON:
|
||||
renderBlock(0.5F, 1.0F, 0.5F);
|
||||
break;
|
||||
case INVENTORY:
|
||||
renderInventory(1.0F, 1.0F, 1.0F);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void renderBlock(float x, float y, float z) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(x, y, z);
|
||||
GL11.glScaled(-1, -1, 1);
|
||||
smallChest.renderAll();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void renderInventory(float x, float y, float z) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(x, y, z);
|
||||
GL11.glRotatef(180F, 1F, 0, 0);
|
||||
GL11.glRotatef(-90F, 0, 1F, 0);
|
||||
GL11.glScalef(1.0F, 1.0F, 1.0F);
|
||||
smallChest.renderAll();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,290 @@
|
||||
package team.chisel.compat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.pahimar.ee3.api.exchange.RecipeRegistryProxy;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.carving.Carving;
|
||||
import team.chisel.init.ChiselBlocks;
|
||||
import team.chisel.init.ChiselItems;
|
||||
import team.chisel.utils.RecipeUtil;
|
||||
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingGroup;
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class Compatibility {
|
||||
|
||||
public static String[] rockColorNames = { "gray", "lightgray", "brown", "tan", "reddish", "bluish", "greenish" };
|
||||
|
||||
public static Map<Integer, String> tconMap = Maps.newHashMap();
|
||||
|
||||
static {
|
||||
tconMap.put(0, "obsidian");
|
||||
tconMap.put(1, "sandstone");
|
||||
tconMap.put(2, "netherrack");
|
||||
tconMap.put(3, "stonebricksmooth");
|
||||
tconMap.put(12, "end_stone");
|
||||
}
|
||||
|
||||
public static void init(FMLPostInitializationEvent event) {
|
||||
|
||||
/* Proj Red */
|
||||
addSupport("ProjRed|Exploration", "projectred.exploration.stone", "marble", 0, 99);
|
||||
addSupport("ProjRed|Exploration", "projectred.exploration.stone", "marble", 1, 99);
|
||||
|
||||
/* Bluepower */
|
||||
addSupport("bluepower", "marble", "marble", 0, 99);
|
||||
|
||||
/* Artifice */
|
||||
addSupport("Artifice", "artifice.marble", "marble", 0, 99);
|
||||
addSupport("Artifice", "artifice.marble.slab", "marble_slab", 0, 99);
|
||||
for (String s : rockColorNames) {
|
||||
addSupport("Artifice", "artifice.limestone." + s, "limestone", 0, 99);
|
||||
}
|
||||
|
||||
/* Mariculture */
|
||||
Block block = GameRegistry.findBlock("mariculture", "limestone");
|
||||
if (block != null) {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
addSupport("limestone", block, i, 99);
|
||||
}
|
||||
}
|
||||
|
||||
/* Geologica */
|
||||
addSupport("PFAAGeologica", "strongStone", "marble", 5, 99);
|
||||
addSupport("PFAAGeologica", "strongStoneSlab", "marbleSlab", 5, 99);
|
||||
addSupport("PFAAGeologica", "strongStoneBrickStairs.marble", "marbleStairs", 0, 99);
|
||||
addSupport("PFAAGeologica", "mediumStone", "limestone", 0, 99);
|
||||
addSupport("PFAAGeologica", "mediumStoneSlab", "limestoneSlab", 0, 99);
|
||||
addSupport("PFAAGeologica", "mediumStoneBrickStairs.limestone", "limestoneStairs", 0, 99);
|
||||
addSupport("PFAAGeologica", "strongStoneBrick", "stoneBrick", 3, 99);
|
||||
addSupport("PFAAGeologica", "strongCobble", "cobblestone", 3, 99);
|
||||
|
||||
/* Thaumcraft TODO There is probably a cleaner way of doing this */
|
||||
if (Loader.isModLoaded("Thaumcraft")) {
|
||||
loadThaumcraftAspects();
|
||||
}
|
||||
|
||||
for (Integer i : tconMap.keySet()) {
|
||||
addSupport("TConstruct", "decoration.multibrick", tconMap.get(i), i, 99);
|
||||
addSupport("TConstruct", "decoration.multibrickfancy", tconMap.get(i), i, 99);
|
||||
}
|
||||
|
||||
addSupport("TConstruct", "decoration.multibrickfancy", "stonebricksmooth", 14, 99);
|
||||
addSupport("TConstruct", "decoration.multibrickfancy", "stonebricksmooth", 15, 99);
|
||||
|
||||
addSupport("Botania", "endStoneBrick", "end_stone", 0, 0);
|
||||
addSupport("Botania", "endStoneBrick", "end_stone", 1, 0);
|
||||
|
||||
if (Loader.isModLoaded("EE3")) {
|
||||
loadEE3Values();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void addSupport(String modname, String blockname, String name, int metadata, int order) {
|
||||
if (Loader.isModLoaded(modname) && GameRegistry.findBlock(modname, blockname) != null) {
|
||||
addSupport(name, GameRegistry.findBlock(modname, blockname), metadata, order);
|
||||
}
|
||||
}
|
||||
|
||||
public static void addSupport(String name, Block block, int metadata, int order) {
|
||||
Carving.chisel.addVariation(name, block, metadata, order);
|
||||
}
|
||||
|
||||
private static void loadThaumcraftAspects() {
|
||||
// ThaumcraftApi.registerObjectTag(new ItemStack(ChiselBlocks.cobblestone, 1, OreDictionary.WILDCARD_VALUE), (new AspectList()).add(Aspect.ENTROPY, 1).add(Aspect.EARTH, 1));
|
||||
// ThaumcraftApi.registerObjectTag(new ItemStack(ChiselBlocks.cobblestoneWall, 1, OreDictionary.WILDCARD_VALUE), (new AspectList()).add(Aspect.ENTROPY, 1).add(Aspect.EARTH, 1));
|
||||
}
|
||||
|
||||
private static void loadEE3Values() {
|
||||
for (String groupName : Carving.chisel.getSortedGroupNames()){
|
||||
ICarvingGroup group = Carving.chisel.getGroup(groupName);
|
||||
List<ItemStack> baseStacks = new ArrayList<ItemStack>();
|
||||
for (ICarvingVariation variation : group.getVariations()){
|
||||
if (RecipeUtil.isCreatable(new ItemStack(variation.getBlock(), 1, variation.getBlockMeta()))){
|
||||
baseStacks.add(new ItemStack(variation.getBlock(), 1, variation.getBlockMeta()));
|
||||
}
|
||||
}
|
||||
for (ICarvingVariation variation : group.getVariations()){
|
||||
ItemStack stack = new ItemStack(variation.getBlock(), 1, variation.getBlockMeta());
|
||||
for (ItemStack baseStack : baseStacks) {
|
||||
// if (baseStack==null){
|
||||
// Chisel.logger.error("Base Stack is null");
|
||||
// if (stack!=null){
|
||||
// Chisel.logger.info("Non base for base stack is "+stack);
|
||||
// }
|
||||
// continue;
|
||||
// }
|
||||
// if (stack==null){
|
||||
// Chisel.logger.error("Non Base stack is null");
|
||||
// Chisel.logger.info("Base stack for null stack is "+baseStack);
|
||||
// continue;
|
||||
// }
|
||||
//Chisel.logger.info("Adding emc recipe for "+baseStack+" to "+stack);
|
||||
RecipeRegistryProxy.addRecipe(stack, Arrays.asList(baseStack));
|
||||
}
|
||||
}
|
||||
}
|
||||
// FMLLog.log(Chisel.MOD_ID, Level.INFO, "[Chisel 2] Oooh is that Equivalent Exchange I see?");
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselItems.ballomoss, 1), 16);
|
||||
//
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.sand_snakestone, 1, 1), 8);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.sand_snakestone, 1, 13), 8);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.cloud, 1, 0), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.cloud, 1, 1), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.cloud, 1, 2), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.cloud, 1, 3), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.cloud, 1, 4), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.glass_pane, 1, 1), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.glass_pane, 1, 2), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.glass_pane, 1, 3), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.glass_pane, 1, 4), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.glass_pane, 1, 12), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.glass_pane, 1, 13), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.glass_pane, 1, 14), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.glass_pane, 1, 15), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.present, 1, 4), 80);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.road_line, 1, 0), 24);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.road_line, 1, 1), 24);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.road_line, 1, 2), 24);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.road_line, 1, 3), 24);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.technical2, 1, 0), 24);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.technical2, 1, 1), 24);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.technical2, 1, 2), 24);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.technical2, 1, 3), 24);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.glass2, 1), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.technical2, 1, 0), 32);
|
||||
//
|
||||
// for (int x = 0; x < ChiselBlocks.pumpkin.length; x++) {
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.pumpkin[x], 1), 144);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.jackolantern[x], 1), 153);
|
||||
// }
|
||||
//
|
||||
// for (int x = 0; x < ChiselBlocks.torches.length; x++) {
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.torches[x], 1), 9);
|
||||
// }
|
||||
//
|
||||
// for (int x = 0; x < 10; x++) {
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.valentines, 1, x), 3);
|
||||
// }
|
||||
//
|
||||
// for (int x = 0; x < 16; x++) {
|
||||
// if (x <= 10)
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.concrete, 1, x), 8);
|
||||
// if (x <= 14)
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.grimstone, 1, x), 5);
|
||||
// if (x < 14)
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.grimstone, 1, x), 7);
|
||||
// if (x < 12)
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.dirt, 1, x), 1);
|
||||
// if (x < 5) {
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.rebel, 1, x), 39);
|
||||
// }
|
||||
//
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.fantasyblock, 1, x), 29444);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.fantasyblock, 1, x), 31444);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.limestone, 1, x), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.marble, 1, x), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.marble_pillar, 1, x), 8);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.marble_pillar_slab, 1, x), 4);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.sandstone_scribbles, 1, x), 4);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.stonebricksmooth, 1, x), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.templeblock, 1, x), 108);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.mossy_templeblock, 1, x), 108);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.glowstone, 1, x), 1536);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.ice, 1, x), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.woolen_clay, 1, x), 153);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.factoryblock, 1, x), 32);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.hexPlating, 1, x), 37);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.gold_block, 1, x), 18432);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.iron_block, 1, x), 2304);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.laboratoryblock, 1, x), 33);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.technical, 1, x), 32);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.tyrian, 1, x), 33);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.hexLargePlating, 1, x), 37);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.circuits, 1, x), 37);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.factoryblock2, 1, x), 32);
|
||||
//
|
||||
// if (x < 15)
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.warningSign, 1, x), 6);
|
||||
//
|
||||
// if (x < 4)
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.factoryblock2, 1, x), 32);
|
||||
//
|
||||
// for (int c = 0; c < ChiselBlocks.stainedGlass.length; c++) {
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.stainedGlass[c], 1, x), 1);
|
||||
// }
|
||||
//
|
||||
// for (int c = 0; c < ChiselBlocks.stainedGlassPane.length; c++) {
|
||||
// if (x <= 13)
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.stainedGlassPane[c], 1, x), 1);
|
||||
// }
|
||||
//
|
||||
// if (x > 0) {
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.cobblestone, 1, x), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.mossy_cobblestone, 1, x), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.netherrack, 1, x), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.obsidian, 1, x), 64);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.sandstone, 1, x), 4);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.voidstonerunic, 1, x), 160);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.glass, 1, x), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.redstone_block, 1, x), 288);
|
||||
// if (x <= 8)
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.bookshelf, 1, x), 528);
|
||||
// if (x <= 12) {
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.diamond_block, 1, x), 73728);
|
||||
// if (x != 12)
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.emerald_block, 1, x), 73728);
|
||||
// }
|
||||
//
|
||||
// for (int c = 0; c < ChiselBlocks.planks.length; c++) {
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.planks[c], 1, x), 8);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (int x = 0; x <= 6; x++) {
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.andesite, 1, x), 129);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.diorite, 1, x), 257);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.granite, 1, x), 513);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.lavastone, 1, x), 9);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.lavastone, 1, 7), 9);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.voidstone, 1, x), 160);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.voidstone, 1, 7), 160);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.voidstone2, 1, x), 256);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.voidstone2, 1, 7), 256);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.waterstone, 1, x), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.ice_pillar, 1, x), 1);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.iron_bars, 1, x), 96);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.iron_bars, 1, 7), 96);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.iron_bars, 1, 8), 96);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.iron_bars, 1, 9), 96);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.paperwall, 1, x), 32);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.paperwall, 1, 7), 32);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.paperwall, 1, 8), 32);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.paperwall_block, 1, x), 32);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.paperwall_block, 1, 7), 32);
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.paperwall_block, 1, 8), 32);
|
||||
// if (x > 0) {
|
||||
// EnergyValueRegistryProxy.addPreAssignedEnergyValue(new ItemStack(ChiselBlocks.brickCustom, 1, x), 256);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package team.chisel.compat;
|
||||
|
||||
import com.cricketcraft.chisel.api.IMC;
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingRegistry;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.carving.Carving;
|
||||
import net.minecraft.block.Block;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
|
||||
public class IMCHandler {
|
||||
|
||||
public static final IMCHandler INSTANCE = new IMCHandler();
|
||||
|
||||
private int order = 1000;
|
||||
|
||||
private IMCHandler() {
|
||||
}
|
||||
|
||||
public void handleMessage(IMCMessage message) {
|
||||
for (IMC imc : IMC.values()) {
|
||||
if (imc.key.equals(message.key)) {
|
||||
handle(message, imc, message.getStringValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handle(IMCMessage message, IMC type, String value) {
|
||||
ICarvingRegistry reg = Carving.chisel;
|
||||
String[] data = value.split("\\|");
|
||||
try {
|
||||
switch (type) {
|
||||
case ADD_VARIATION:
|
||||
case REMOVE_VARIATION:
|
||||
Block block = (Block) Block.blockRegistry.getObject(data[1]);
|
||||
int meta = Short.parseShort(data[2]);
|
||||
if (type == IMC.ADD_VARIATION) {
|
||||
reg.addVariation(data[0], block, meta, order++);
|
||||
} else {
|
||||
reg.removeVariation(block, meta, data[0]);
|
||||
}
|
||||
break;
|
||||
case REGISTER_GROUP_ORE:
|
||||
reg.registerOre(data[0], data[1]);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid IMC constant! How...what...?");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Chisel.logger.error("Could not handle data {} for IMC type {}. This was sent from mod {}.\n" + "!! This is a bug in that mod !!\nSwallowing error and continuing...", value, type.name(),
|
||||
message.getSender());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package team.chisel.compat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.IWailaRegistrar;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class WailaCompat implements IWailaDataProvider {
|
||||
|
||||
private WailaCompat() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler configHandler) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack stack, List<String> strings, IWailaDataAccessor accessor, IWailaConfigHandler configHandler) {
|
||||
return strings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack stack, List<String> strings, IWailaDataAccessor accessor, IWailaConfigHandler configHandler) {
|
||||
if (accessor.getBlock() instanceof ICarvable) {
|
||||
ICarvable block = (ICarvable) accessor.getBlock();
|
||||
MovingObjectPosition pos = accessor.getPosition();
|
||||
strings.add(block.getManager(accessor.getWorld(), pos.blockX, pos.blockY, pos.blockZ, accessor.getMetadata()).getDescription());
|
||||
}
|
||||
return strings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack stack, List<String> strings, IWailaDataAccessor accessor, IWailaConfigHandler configHandler) {
|
||||
return strings;
|
||||
}
|
||||
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static void register(IWailaRegistrar registrar) {
|
||||
registrar.registerBodyProvider(new WailaCompat(), ICarvable.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package team.chisel.compat.fmp;
|
||||
|
||||
import team.chisel.init.ChiselBlocks;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
import codechicken.lib.vec.BlockCoord;
|
||||
import codechicken.multipart.MultiPartRegistry;
|
||||
import codechicken.multipart.MultiPartRegistry.IPartConverter;
|
||||
import codechicken.multipart.MultiPartRegistry.IPartFactory;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class FMPCompat implements IPartFactory, IPartConverter {
|
||||
|
||||
public void init() {
|
||||
MultiPartRegistry.registerConverter(this);
|
||||
MultiPartRegistry.registerParts(this, new String[] { "chisel_torch" });
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Block> blockTypes() {
|
||||
return Lists.newArrayList(ChiselBlocks.torches);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TMultiPart convert(World world, BlockCoord bc) {
|
||||
Block block = world.getBlock(bc.x, bc.y, bc.z);
|
||||
for (int i = 0; i < ChiselBlocks.torches.length; i++) {
|
||||
if (block == ChiselBlocks.torches[i]) {
|
||||
return new PartChiselTorch(i, world.getBlockMetadata(bc.x, bc.y, bc.z));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TMultiPart createPart(String type, boolean client) {
|
||||
if (type.equals("chisel_torch")) {
|
||||
return new PartChiselTorch();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package team.chisel.compat.fmp;
|
||||
|
||||
import team.chisel.block.BlockCarvableTorch;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import codechicken.lib.vec.BlockCoord;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import codechicken.multipart.TileMultipart;
|
||||
import codechicken.multipart.minecraft.TorchPart;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemBlockChiselTorchPart extends ItemBlock {
|
||||
|
||||
private BlockCarvableTorch torch;
|
||||
|
||||
// Blame FML for the duped params, these references will always be the same
|
||||
public ItemBlockChiselTorchPart(Block block, BlockCarvableTorch torch) {
|
||||
super(block);
|
||||
this.torch = torch;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean func_150936_a(World world, int x, int y, int z, int side, EntityPlayer player, ItemStack stack) {
|
||||
return (placePart(world, new BlockCoord(x, y, z).offset(side), stack, side, false)) || (super.func_150936_a(world, x, y, z, side, player, stack));
|
||||
}
|
||||
|
||||
public TMultiPart createMultiPart(World world, BlockCoord pos, ItemStack item, int side) {
|
||||
return new PartChiselTorch(torch.idx, TorchPart.sideMetaMap[side ^ 1]);
|
||||
}
|
||||
|
||||
public boolean placePart(World world, BlockCoord pos, ItemStack item, int side, boolean doPlace) {
|
||||
TileMultipart tile = TileMultipart.getOrConvertTile(world, pos);
|
||||
if (tile == null) {
|
||||
return false;
|
||||
}
|
||||
TMultiPart part = createMultiPart(world, pos, item, side);
|
||||
if (part == null) {
|
||||
return false;
|
||||
}
|
||||
if (tile.canAddPart(part)) {
|
||||
if (doPlace) {
|
||||
TileMultipart.addPart(world, pos, part);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
BlockCoord pos = new BlockCoord(x, y, z);
|
||||
if (!block.isReplaceable(world, x, y, z)) {
|
||||
pos = new BlockCoord(x, y, z).offset(side);
|
||||
}
|
||||
if (placePart(world, pos, stack, side, !world.isRemote)) {
|
||||
world.playSoundEffect(pos.x + 0.5F, pos.y + 0.5F, pos.z + 0.5F, field_150939_a.stepSound.func_150496_b(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
|
||||
stack.stackSize -= 1;
|
||||
return true;
|
||||
}
|
||||
return super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package team.chisel.compat.fmp;
|
||||
|
||||
import team.chisel.init.ChiselBlocks;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import codechicken.lib.data.MCDataInput;
|
||||
import codechicken.lib.data.MCDataOutput;
|
||||
import codechicken.multipart.minecraft.TorchPart;
|
||||
|
||||
public class PartChiselTorch extends TorchPart {
|
||||
|
||||
private int idx;
|
||||
|
||||
public PartChiselTorch() {
|
||||
}
|
||||
|
||||
public PartChiselTorch(int idx, int meta) {
|
||||
super(meta);
|
||||
this.idx = idx;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDesc(MCDataOutput packet) {
|
||||
super.writeDesc(packet);
|
||||
packet.writeInt(idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readDesc(MCDataInput packet) {
|
||||
super.readDesc(packet);
|
||||
this.idx = packet.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(NBTTagCompound tag) {
|
||||
super.save(tag);
|
||||
tag.setInteger("idx", idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(NBTTagCompound tag) {
|
||||
super.load(tag);
|
||||
this.idx = tag.getInteger("idx");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock() {
|
||||
return ChiselBlocks.torches[idx];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "chisel_torch";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package team.chisel.compat.nei;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.client.gui.GuiChisel;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.IConfigureNEI;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class NEIChiselConfig implements IConfigureNEI {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return Chisel.MOD_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return Chisel.VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadConfig() {
|
||||
API.hideItem(new ItemStack(GameRegistry.findBlock("chisel", "limestone_slab_top")));
|
||||
API.hideItem(new ItemStack(GameRegistry.findBlock("chisel", "marble_slab_top")));
|
||||
API.hideItem(new ItemStack(GameRegistry.findBlock("chisel", "marble_pillar_slab_top")));
|
||||
|
||||
RecipeHandlerChisel handler = new RecipeHandlerChisel();
|
||||
API.registerRecipeHandler(handler);
|
||||
API.registerUsageHandler(handler);
|
||||
API.setGuiOffset(GuiChisel.class, -50, 40);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
package team.chisel.compat.nei;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.cricketcraft.chisel.api.carving.CarvingUtils;
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingGroup;
|
||||
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
|
||||
|
||||
import team.chisel.carving.Carving;
|
||||
import team.chisel.client.gui.GuiChisel;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public class RecipeHandlerChisel extends TemplateRecipeHandler {
|
||||
|
||||
private static final int SLOTS_PER_PAGE = 45;
|
||||
|
||||
public class CachedChiselRecipe extends CachedRecipe {
|
||||
|
||||
private List<PositionedStack> input = new ArrayList<PositionedStack>();
|
||||
private List<PositionedStack> outputs = new ArrayList<PositionedStack>();
|
||||
public Point focus;
|
||||
|
||||
public CachedChiselRecipe(List<ItemStack> variations, ItemStack base, ItemStack focus) {
|
||||
PositionedStack pStack = new PositionedStack(base != null ? base : variations, 74, 4);
|
||||
pStack.setMaxSize(1);
|
||||
this.input.add(pStack);
|
||||
|
||||
int row = 0;
|
||||
int col = 0;
|
||||
for (ItemStack v : variations) {
|
||||
this.outputs.add(new PositionedStack(v, 3 + 18 * col, 37 + 18 * row));
|
||||
|
||||
if (focus != null && NEIServerUtils.areStacksSameTypeCrafting(focus, v)) {
|
||||
this.focus = new Point(2 + 18 * col, 36 + 18 * row);
|
||||
}
|
||||
|
||||
col++;
|
||||
if (col > 8) {
|
||||
col = 0;
|
||||
row++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CachedChiselRecipe(List<ItemStack> variations) {
|
||||
this(variations, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients() {
|
||||
return this.getCycledIngredients(cycleticks / 20, this.input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getOtherStacks() {
|
||||
return this.outputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return "Chisel";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return "Chisel:textures/chiselNEI.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiContainer> getGuiClass() {
|
||||
return GuiChisel.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipeIndex) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GuiDraw.changeTexture(getGuiTexture());
|
||||
GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 166, 130);
|
||||
|
||||
Point focus = ((CachedChiselRecipe) this.arecipes.get(recipeIndex)).focus;
|
||||
if (focus != null) {
|
||||
GuiDraw.drawTexturedModalRect(focus.x, focus.y, 166, 0, 18, 18);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recipiesPerPage() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(75, 22, 15, 13), "chisel2.chisel", new Object[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results) {
|
||||
if (outputId.equals("chisel2.chisel")) {
|
||||
for (String name : Carving.chisel.getSortedGroupNames()) {
|
||||
ICarvingGroup g = Carving.chisel.getGroup(name);
|
||||
if (!g.getVariations().isEmpty()) {
|
||||
addCached(getVariationStacks(g));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
for (String name : Carving.chisel.getSortedGroupNames()) {
|
||||
ICarvingGroup g = Carving.chisel.getGroup(name);
|
||||
List<ItemStack> variations = getVariationStacks(g);
|
||||
for (ItemStack stack : variations) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(stack, result)) {
|
||||
addCached(variations, null, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
for (String name : Carving.chisel.getSortedGroupNames()) {
|
||||
ICarvingGroup g = Carving.chisel.getGroup(name);
|
||||
List<ItemStack> variations = getVariationStacks(g);
|
||||
for (ItemStack stack : variations) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(stack, ingredient)) {
|
||||
addCached(variations, ingredient, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addCached(List<ItemStack> variations, ItemStack base, ItemStack focus) {
|
||||
if (variations.size() > SLOTS_PER_PAGE) {
|
||||
List<List<ItemStack>> parts = new ArrayList<List<ItemStack>>();
|
||||
int size = variations.size();
|
||||
for (int i = 0; i < size; i += SLOTS_PER_PAGE) {
|
||||
parts.add(new ArrayList<ItemStack>(variations.subList(i, Math.min(size, i + SLOTS_PER_PAGE))));
|
||||
}
|
||||
for (List<ItemStack> part : parts) {
|
||||
this.arecipes.add(new CachedChiselRecipe(part, base, focus));
|
||||
}
|
||||
} else {
|
||||
this.arecipes.add(new CachedChiselRecipe(variations, base, focus));
|
||||
}
|
||||
}
|
||||
|
||||
private void addCached(List<ItemStack> variations) {
|
||||
addCached(variations, null, null);
|
||||
}
|
||||
|
||||
private static List<ItemStack> getVariationStacks(ICarvingGroup g) {
|
||||
List<ItemStack> stacks = new ArrayList<ItemStack>();
|
||||
for (ICarvingVariation v : g.getVariations()) {
|
||||
stacks.add(CarvingUtils.getStack(v));
|
||||
}
|
||||
String oreName = g.getOreName();
|
||||
if (oreName != null) {
|
||||
check: for (ItemStack ore : OreDictionary.getOres(oreName)) {
|
||||
for (ItemStack stack : stacks) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(stack, ore)) {
|
||||
continue check;
|
||||
}
|
||||
}
|
||||
stacks.add(ore.copy());
|
||||
}
|
||||
}
|
||||
return stacks;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package team.chisel.config;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.item.ItemDye;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.Features;
|
||||
|
||||
import com.cricketcraft.ctmlib.CTM;
|
||||
|
||||
public class Configurations {
|
||||
|
||||
public static Configuration config;
|
||||
|
||||
public static boolean configExists;
|
||||
|
||||
public static double concreteVelocity;
|
||||
public static boolean ghostCloud;
|
||||
public static int factoryBlockAmount;
|
||||
public static boolean allowMossy;
|
||||
public static boolean allowSmoothStone;
|
||||
public static boolean chiselRecipe;
|
||||
public static boolean enableFMP;
|
||||
public static boolean chiselStoneToCobbleBricks;
|
||||
public static boolean chiselBackToVanillaLeaves;
|
||||
|
||||
public static int marbleAmount;
|
||||
public static int limestoneAmount;
|
||||
public static int graniteAmount;
|
||||
public static int dioriteAmount;
|
||||
public static int andesiteAmount;
|
||||
|
||||
public static int particlesTickrate;
|
||||
public static boolean oldPillars;
|
||||
public static boolean disableCTM;
|
||||
public static boolean connectInsideCTM;
|
||||
public static boolean blockDescriptions;
|
||||
public static boolean imTooGoodForDescriptions;
|
||||
|
||||
public static boolean allowChiselDamage;
|
||||
public static int ironChiselMaxDamage;
|
||||
public static int diamondChiselMaxDamage;
|
||||
public static int obsidianChiselMaxDamage;
|
||||
public static boolean ironChiselCanLeftClick;
|
||||
public static boolean ironChiselHasModes;
|
||||
public static int ironChiselAttackDamage;
|
||||
public static int diamondChiselAttackDamage;
|
||||
public static int obsidianChiselAttackDamage;
|
||||
public static boolean allowChiselCrossColors;
|
||||
|
||||
public static boolean useRoadLineTool;
|
||||
public static String getRoadLineTool;
|
||||
public static int roadLineToolLevel;
|
||||
|
||||
public static int[] configColors = new int[ItemDye.field_150923_a.length];
|
||||
|
||||
public static boolean fullBlockConcrete;
|
||||
|
||||
public static boolean refreshConfig() {
|
||||
|
||||
String category;
|
||||
|
||||
/* general */
|
||||
category = "general";
|
||||
concreteVelocity = config.get(category, "concreteVelocity", 0.45,
|
||||
"Traversing concrete roads, players will acceleration to this velocity. For reference, normal running speed is about 0.28. Set to 0 to disable acceleration.").getDouble(0.45);
|
||||
fullBlockConcrete = config.get(category, "fullBlockConcrete", false, "Should concrete be a full block. This will also unavoidably disable speed increase if set to true.").getBoolean(false);
|
||||
ghostCloud = config.get(category, "doesCloudRenderLikeGhost", true).getBoolean(true);
|
||||
factoryBlockAmount = config.get(category, "amountYouGetFromFactoryBlockCrafting", 32).getInt(32);
|
||||
allowMossy = config.get(category, "allowBrickToMossyInChisel", true, "If true, you can chisel stone brick to mossy stone brick.").getBoolean(true);
|
||||
allowSmoothStone = config.get(category, "allowSmoothStoneToStoneBricksAndBack", true).getBoolean(true);
|
||||
chiselRecipe = config.get(category, "chiselAlternateRecipe", false, "Use alternative crafting recipe for the chisel").getBoolean(false);
|
||||
enableFMP = config.get(category, "enableFMP", true, "Do you want to enable FMP").getBoolean(true);
|
||||
chiselStoneToCobbleBricks = config.get(category, "chiselStoneToCobbleBricks", true, "Chisel stone to cobblestone and bricks by left clicking.").getBoolean(false);
|
||||
chiselBackToVanillaLeaves = config
|
||||
.get(category, "chiselBackToVanillaLeaves", false, "If this is true, you can chisel from the chisel leaves back to vanilla ones. If it is false, you cannot.").getBoolean(false);
|
||||
|
||||
/* worldgen */
|
||||
category = "worldgen";
|
||||
marbleAmount = config.get(category, "marbleAmount", 7, "Amount of marble to generate in the world; use 0 for none").getInt(7);
|
||||
limestoneAmount = config.get(category, "limestoneAmount", 8, "Amount of limestone to generate in the world; use 0 for none").getInt(8);
|
||||
graniteAmount = config.get(category, "graniteAmount", 8, "Amount of granite to generate in the world; use 0 for none.").getInt(8);
|
||||
dioriteAmount = config.get(category, "dioriteAmount", 8, "Amount of diorite to generate in the world; use 0 for none.").getInt(8);
|
||||
andesiteAmount = config.get(category, "andesiteAmount", 8, "Amount of andesite to generate in the world; use 0 for none.").getInt(8);
|
||||
|
||||
/* client */
|
||||
category = "client";
|
||||
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,
|
||||
"Choose whether the inside corner is disconnected on a CTM block - http://imgur.com/eUywLZ4").getBoolean(false);
|
||||
blockDescriptions = config.get(category, "tooltipsUseBlockDescriptions", true, "Make variations of blocks have the same name, and use the description in tooltip to distinguish them.")
|
||||
.getBoolean(true);
|
||||
imTooGoodForDescriptions = config.get(category, "imTooGoodForBlockDescriptions", false, "For those people who just hate block descriptions on the world gen!").getBoolean();
|
||||
|
||||
/* chisel */
|
||||
category = "chisel";
|
||||
allowChiselDamage = config.get(category, "allowChiselDamage", true, "Should the chisel be damageable and take damage when it chisels something.").getBoolean();
|
||||
ironChiselMaxDamage = config.getInt("ironChiselMaxDamage", category, 500, 1, Short.MAX_VALUE, "The max damage of the standard iron chisel.");
|
||||
diamondChiselMaxDamage = config.getInt("diamondChiselMaxDamage", category, 5000, 1, Short.MAX_VALUE, "The max damage of the diamond chisel.");
|
||||
obsidianChiselMaxDamage = config.getInt("obsidianChiselMaxDamage", category, 2500, 1, Short.MAX_VALUE, "The max damage of the obsidian chisel.");
|
||||
ironChiselCanLeftClick = config.get(category, "ironChiselCanLeftClick", true, "If this is true, the iron chisel can left click chisel blocks. If false, it cannot.").getBoolean();
|
||||
ironChiselHasModes = config.get(category, "ironChiselHasModes", false, "If this is true, the iron chisel can change its chisel mode just as the diamond chisel can.").getBoolean();
|
||||
allowChiselCrossColors = config.get(category, "allowChiselCrossColors", true, "Should someone be able to chisel something into a different color.").getBoolean();
|
||||
|
||||
ironChiselAttackDamage = config
|
||||
.get(category, "ironChiselAttackDamage", 2, "The extra attack damage points (in half hearts) that the iron chisel inflicts when it is used to attack an entity.").getInt();
|
||||
diamondChiselAttackDamage = config.get(category, "diamondChiselAttackDamage", 2,
|
||||
"The extra attack damage points (in half hearts) that the diamond chisel inflicts when it is used to attack an entity.").getInt();
|
||||
obsidianChiselAttackDamage = config.get(category, "obsidianChiselAttackDamage", 4,
|
||||
"The extra attack damage points (in half hearts) that the obsidian chisel inflicts when it is used to attack an entity.").getInt();
|
||||
|
||||
/* block */
|
||||
category = "block";
|
||||
useRoadLineTool = config.get(category, "useRoadLineTool", false, "Should the road line require a tool to break (If false, road lines can be broken in Adventure)").getBoolean();
|
||||
getRoadLineTool = config.get(category, "getRoadLineTool", "pickaxe", "The tool that is able to break roadLines (requires useRoadLineTool to be true to take effect)").getString();
|
||||
roadLineToolLevel = config.get(category, "roadLineToolLevel", 0,
|
||||
"The lowest harvest level of the tool able to break the road lines (requires useRoadLineTool to be true to take effect) (0 = Wood/Gold, 1 = Stone, 2 = Iron, 3 = Diamond) Default: 0")
|
||||
.getInt();
|
||||
|
||||
/* hexColors */
|
||||
category = "hexColors";
|
||||
|
||||
for (int i = 0; i < ItemDye.field_150923_a.length; i++) {
|
||||
// tterrag... don't kill me over this formatting.
|
||||
String temp = config.get(category, "hex" + ItemDye.field_150923_a[i], "#" + Integer.toHexString(ItemDye.field_150922_c[i]),
|
||||
Character.toUpperCase(ItemDye.field_150923_a[i].charAt(0)) + ItemDye.field_150923_a[i].substring(1) + " color for hex block overlay #RRGGBB").getString();
|
||||
// Or this
|
||||
try {
|
||||
configColors[i] = Integer.decode(temp);
|
||||
} catch (NumberFormatException e) {
|
||||
Chisel.logger.warn("Configuration error, " + temp + " was not recognized as a color. Using default: #" + Integer.toHexString(ItemDye.field_150922_c[i]));
|
||||
configColors[i] = ItemDye.field_150922_c[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (config.hasChanged()) {
|
||||
config.save();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean featureEnabled(Features feature) {
|
||||
return config.get("features", featureName(feature), true).getBoolean(true) && refreshConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the old camelCase names from the new CONSTANT_CASE names
|
||||
*/
|
||||
public static String featureName(Features feature) {
|
||||
String[] words = feature.name().toLowerCase(Locale.ENGLISH).split("_");
|
||||
if (words.length == 1) {
|
||||
return words[0];
|
||||
}
|
||||
|
||||
String ret = words[0];
|
||||
for (int i = 1; i < words.length; i++) {
|
||||
ret += StringUtils.capitalize(words[i]);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean featureEnabled(String feature) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package team.chisel.entity;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.client.GeneralChiselClient;
|
||||
import team.chisel.init.ChiselBlocks;
|
||||
import team.chisel.utils.General;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityBallOMoss extends EntityThrowable {
|
||||
|
||||
public EntityBallOMoss(World par1World) {
|
||||
super(par1World);
|
||||
}
|
||||
|
||||
public EntityBallOMoss(World par1World, EntityLivingBase par2EntityLiving) {
|
||||
super(par1World, par2EntityLiving);
|
||||
}
|
||||
|
||||
public EntityBallOMoss(World par1World, double x, double y, double z) {
|
||||
super(par1World, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onImpact(MovingObjectPosition movingobjectposition) {
|
||||
int x = movingobjectposition.blockX;
|
||||
int y = movingobjectposition.blockY;
|
||||
int z = movingobjectposition.blockZ;
|
||||
|
||||
switch (movingobjectposition.sideHit) {
|
||||
case 0:
|
||||
y--;
|
||||
break;
|
||||
case 1:
|
||||
y++;
|
||||
break;
|
||||
case 2:
|
||||
z--;
|
||||
break;
|
||||
case 3:
|
||||
z++;
|
||||
break;
|
||||
case 4:
|
||||
x--;
|
||||
break;
|
||||
case 5:
|
||||
x++;
|
||||
break;
|
||||
}
|
||||
|
||||
setDead();
|
||||
|
||||
if (worldObj.isRemote) {
|
||||
worldObj.playSound(x, y, z, Chisel.MOD_ID + ":random.squash", 1.0f, 1.0f, false);
|
||||
|
||||
for (int i = 0; i < 32; i++)
|
||||
GeneralChiselClient.spawnBallOMossFX(worldObj, posX, posY, posZ);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int radius = 5;
|
||||
int falloff = 3;
|
||||
|
||||
for (int xx = -radius; xx < radius; xx++) {
|
||||
for (int yy = -radius; yy < radius; yy++) {
|
||||
for (int zz = -radius; zz < radius; zz++) {
|
||||
double dist = (xx < 0 ? -xx : xx) + (yy < 0 ? -yy : yy) + (zz < 0 ? -zz : zz);
|
||||
|
||||
if (!(dist < falloff || General.rand.nextInt(radius * 3 - falloff) >= dist * 2))
|
||||
continue;
|
||||
|
||||
if (!worldObj.isRemote)
|
||||
turnToMoss(worldObj, x + xx, y + yy, z + zz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void turnToMoss(World world, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
Block resBlock = block;
|
||||
int resMeta = meta;
|
||||
|
||||
if (block.equals(Blocks.cobblestone)) {
|
||||
resBlock = Blocks.mossy_cobblestone;
|
||||
} else if (block.equals(Blocks.cobblestone_wall) && meta == 0) {
|
||||
resMeta = 1;
|
||||
} else if (block.equals(ChiselBlocks.cobblestone)) {
|
||||
resBlock = ChiselBlocks.mossy_cobblestone;
|
||||
} else if (block.equals(ChiselBlocks.templeblock)) {
|
||||
resBlock = ChiselBlocks.mossy_templeblock;
|
||||
} else if (block.equals(Blocks.stonebrick)) {
|
||||
resMeta = 1;
|
||||
}
|
||||
|
||||
if (resBlock.equals(block) && resMeta == meta)
|
||||
return;
|
||||
world.setBlock(x, y, z, resBlock, resMeta, 3);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package team.chisel.entity;
|
||||
|
||||
import net.minecraft.entity.monster.EntitySnowman;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityChiselSnowman extends EntitySnowman {
|
||||
|
||||
public EntityChiselSnowman(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
// No special features just needed to get around the hardcoding
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package team.chisel.entity;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import team.chisel.init.ChiselBlocks;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityCloudInABottle extends EntityThrowable {
|
||||
|
||||
Random rand = new Random();
|
||||
|
||||
public EntityCloudInABottle(World par1World) {
|
||||
super(par1World);
|
||||
}
|
||||
|
||||
public EntityCloudInABottle(World par1World, EntityLivingBase par2EntityLiving) {
|
||||
super(par1World, par2EntityLiving);
|
||||
}
|
||||
|
||||
public EntityCloudInABottle(World par1World, double x, double y, double z) {
|
||||
super(par1World, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onImpact(MovingObjectPosition movingobjectposition) {
|
||||
if (worldObj.isRemote)
|
||||
return;
|
||||
|
||||
int x = movingobjectposition.blockX;
|
||||
int y = movingobjectposition.blockY;
|
||||
int z = movingobjectposition.blockZ;
|
||||
|
||||
switch (movingobjectposition.sideHit) {
|
||||
case 0:
|
||||
y--;
|
||||
break;
|
||||
case 1:
|
||||
y++;
|
||||
break;
|
||||
case 2:
|
||||
z--;
|
||||
break;
|
||||
case 3:
|
||||
z++;
|
||||
break;
|
||||
case 4:
|
||||
x--;
|
||||
break;
|
||||
case 5:
|
||||
x++;
|
||||
break;
|
||||
}
|
||||
|
||||
generate(worldObj, rand, x, y, z, 40);
|
||||
|
||||
worldObj.playAuxSFX(2002, (int) Math.round(this.posX), (int) Math.round(this.posY), (int) Math.round(this.posZ), 2);
|
||||
setDead();
|
||||
}
|
||||
|
||||
public boolean generate(World world, Random random, int gx, int gy, int gz, int numberOfBlocks) {
|
||||
int X[] = new int[9];
|
||||
int Y[] = new int[9];
|
||||
int Z[] = new int[9];
|
||||
|
||||
for (int dir = 0; dir < 9; dir++) {
|
||||
X[dir] = gx;
|
||||
Y[dir] = gy;
|
||||
Z[dir] = gz;
|
||||
}
|
||||
int count = 0;
|
||||
while (count < numberOfBlocks) {
|
||||
for (int dir = 0; dir < 9; dir++) {
|
||||
if (count >= numberOfBlocks)
|
||||
break;
|
||||
|
||||
int dx = dir % 3 - 1;
|
||||
int dz = dir / 3 - 1;
|
||||
|
||||
if (dx == 0 && dz == 0)
|
||||
continue;
|
||||
|
||||
X[dir] += random.nextInt(3) - 1 + dx;
|
||||
Z[dir] += random.nextInt(3) - 1 + dz;
|
||||
Y[dir] += random.nextInt(2) * (random.nextInt(3) - 1);
|
||||
|
||||
int x = X[dir];
|
||||
int y = Y[dir];
|
||||
int z = Z[dir];
|
||||
|
||||
for (int j2 = x; j2 < x + random.nextInt(4) + 1; j2++) {
|
||||
for (int k2 = y; k2 < y + random.nextInt(1) + 2; k2++) {
|
||||
for (int l2 = z; l2 < z + random.nextInt(4) + 1; l2++) {
|
||||
if (world.getBlock(j2, k2, l2).isAir(world, j2, k2, l2) && Math.abs(j2 - x) + Math.abs(k2 - y) + Math.abs(l2 - z) < 4 * 1 + random.nextInt(2)) {
|
||||
world.setBlock(j2, k2, l2, ChiselBlocks.cloud);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// System.out.println("Created " + count + " cloud blocks.");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package team.chisel.entity;
|
||||
|
||||
import team.chisel.utils.General;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntitySmashingRock extends EntityThrowable {
|
||||
|
||||
public EntitySmashingRock(World par1World) {
|
||||
super(par1World);
|
||||
}
|
||||
|
||||
public EntitySmashingRock(World par1World, EntityLivingBase par2EntityLiving) {
|
||||
super(par1World, par2EntityLiving);
|
||||
}
|
||||
|
||||
public EntitySmashingRock(World par1World, double x, double y, double z) {
|
||||
super(par1World, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onImpact(MovingObjectPosition movingobjectposition) {
|
||||
int x = movingobjectposition.blockX;
|
||||
int y = movingobjectposition.blockY;
|
||||
int z = movingobjectposition.blockZ;
|
||||
|
||||
switch (movingobjectposition.sideHit) {
|
||||
case 0:
|
||||
y--;
|
||||
break;
|
||||
case 1:
|
||||
y++;
|
||||
break;
|
||||
case 2:
|
||||
z--;
|
||||
break;
|
||||
case 3:
|
||||
z++;
|
||||
break;
|
||||
case 4:
|
||||
x--;
|
||||
break;
|
||||
case 5:
|
||||
x++;
|
||||
break;
|
||||
}
|
||||
|
||||
setDead();
|
||||
|
||||
if (worldObj.isRemote) {
|
||||
worldObj.playSound(x, y, z, "chisel:squash", 1.0f, 1.0f, false);
|
||||
|
||||
// for(int i = 0; i < 32; i++)
|
||||
// GeneralChiselClient.spawn
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int radius = 5;
|
||||
int falloff = 3;
|
||||
|
||||
for (int xx = -radius; xx < radius; xx++) {
|
||||
for (int yy = -radius; yy < radius; yy++) {
|
||||
for (int zz = -radius; zz < radius; zz++) {
|
||||
double dist = (xx < 0 ? -xx : xx) + (yy < 0 ? -yy : yy) + (zz < 0 ? -zz : zz);
|
||||
|
||||
if (!(dist < falloff || General.rand.nextInt(radius * 3 - falloff) >= dist * 2))
|
||||
continue;
|
||||
|
||||
if (!worldObj.isRemote)
|
||||
smash(worldObj, x + xx, y + yy, z + zz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void smash(World world, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
Block resBlock = block;
|
||||
int resMeta = meta;
|
||||
|
||||
if (block.equals(Blocks.stone)) {
|
||||
resBlock = Blocks.cobblestone;
|
||||
} else if (block.equals(Blocks.stonebrick) && meta == 0) {
|
||||
resMeta = 2;
|
||||
} else if (block.equals(Blocks.cobblestone)) {
|
||||
resBlock = Blocks.gravel;
|
||||
} else if (block.equals(Blocks.gravel)) {
|
||||
resBlock = Blocks.sand;
|
||||
}
|
||||
|
||||
if (resBlock.equals(block) && resMeta == meta)
|
||||
return;
|
||||
world.setBlock(x, y, z, resBlock, resMeta, 3);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package team.chisel.entity.fx;
|
||||
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import team.chisel.block.BlockSnakestoneObsidian;
|
||||
import team.chisel.init.ChiselItems;
|
||||
import team.chisel.utils.General;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class EntityBallOMossFX extends EntityFX {
|
||||
|
||||
BlockSnakestoneObsidian block;
|
||||
double tx, ty, tz;
|
||||
double speed;
|
||||
|
||||
float u0, u1, v0, v1;
|
||||
IIcon icon;
|
||||
IIcon iconPlus = new IIcon() {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getIconWidth() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getIconHeight() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMinU() {
|
||||
return u0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMaxU() {
|
||||
return u1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getInterpolatedU(double d0) {
|
||||
return (float) (u0 + d0 * (u1 - u0) / 16.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMinV() {
|
||||
return v0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMaxV() {
|
||||
return v1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getInterpolatedV(double d0) {
|
||||
return (float) (v0 + d0 * (v1 - v0) / 16.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getIconName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public EntityBallOMossFX(World world, double x, double y, double z) {
|
||||
super(world, x, y + 0.5, z, 0, 0, 0);
|
||||
|
||||
particleScale = 0.5f + 0.5f * General.rand.nextFloat();
|
||||
speed = 0.4 + 0.4 * General.rand.nextDouble();
|
||||
|
||||
particleMaxAge = (int) (General.rand.nextDouble() * 10.0) + 5;
|
||||
if (General.rand.nextInt(10) == 0)
|
||||
particleMaxAge += General.rand.nextDouble() * 40.0;
|
||||
|
||||
motionX = (General.rand.nextDouble() - 0.5) * 0.7;
|
||||
motionY = (General.rand.nextDouble() * 0.5) * 0.7;
|
||||
motionZ = (General.rand.nextDouble() - 0.5) * 0.7;
|
||||
particleGravity = 2.0f;
|
||||
|
||||
// setParticleIcon(block.particles[General.rand.nextInt(block.particles.length)]);
|
||||
|
||||
icon = ChiselItems.ballomoss.getIconFromDamage(0);
|
||||
float width = 4.0f + General.rand.nextFloat() * 8.0f;
|
||||
float uu = General.rand.nextFloat() * (16.0f - width);
|
||||
float vv = General.rand.nextFloat() * (16.0f - width);
|
||||
u0 = icon.getInterpolatedU(uu);
|
||||
u1 = icon.getInterpolatedU(uu + width);
|
||||
v0 = icon.getInterpolatedV(vv);
|
||||
v1 = icon.getInterpolatedV(vv + width);
|
||||
|
||||
setParticleIcon(iconPlus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle(Tessellator tessellator, float partialTick, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
super.renderParticle(tessellator, partialTick, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
double remaining = particleMaxAge - particleAge;
|
||||
|
||||
if (remaining < 5) {
|
||||
particleAlpha = (float) (remaining / 5.0);
|
||||
} else {
|
||||
particleAlpha = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package team.chisel.entity.fx;
|
||||
|
||||
import team.chisel.block.BlockGrimstone;
|
||||
import team.chisel.utils.General;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityGrimstoneFX extends EntityFX {
|
||||
|
||||
float initialScale;
|
||||
float angleOffset;
|
||||
static final float fadetime = 20f;
|
||||
|
||||
public EntityGrimstoneFX(World world, BlockGrimstone block, double x, double y, double z) {
|
||||
super(world, x, y, z, 0, 0, 0);
|
||||
|
||||
initialScale = 1.0f + 1.0f * General.rand.nextFloat();
|
||||
angleOffset = rand.nextFloat() * 360;
|
||||
|
||||
particleMaxAge = (int) (Math.random() * 10.0D) + 80;
|
||||
|
||||
setPosition(x, y, z);
|
||||
prevPosX = posX;
|
||||
prevPosY = posY;
|
||||
prevPosZ = posZ;
|
||||
|
||||
noClip = true;
|
||||
|
||||
setParticleIcon(block.iconStar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle(Tessellator tessellator, float partialTick, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
||||
particleScale = 0.25f + initialScale * (float) Math.sin((particleAge + angleOffset) / 180.f);
|
||||
|
||||
if (particleAge < fadetime)
|
||||
particleAlpha = particleAge / fadetime;
|
||||
else if (particleAge + fadetime >= particleMaxAge)
|
||||
particleAlpha = (particleMaxAge - particleAge) / fadetime;
|
||||
else
|
||||
particleAlpha = 1.0f;
|
||||
|
||||
super.renderParticle(tessellator, partialTick, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
if (particleAge++ >= particleMaxAge) {
|
||||
setDead();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package team.chisel.entity.fx;
|
||||
|
||||
import team.chisel.block.BlockHolystone;
|
||||
import team.chisel.utils.General;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityHolystoneFX extends EntityFX {
|
||||
|
||||
float initialScale;
|
||||
float angleOffset;
|
||||
static final float fadetime = 20f;
|
||||
|
||||
public EntityHolystoneFX(World world, BlockHolystone block, double x, double y, double z) {
|
||||
super(world, x, y, z, 0, 0, 0);
|
||||
|
||||
initialScale = 1.0f + 1.0f * General.rand.nextFloat();
|
||||
angleOffset = rand.nextFloat() * 360;
|
||||
|
||||
particleMaxAge = (int) (Math.random() * 10.0D) + 80;
|
||||
|
||||
setPosition(x, y, z);
|
||||
prevPosX = posX;
|
||||
prevPosY = posY;
|
||||
prevPosZ = posZ;
|
||||
|
||||
noClip = true;
|
||||
|
||||
setParticleIcon(block.iconStar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle(Tessellator tessellator, float partialTick, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
||||
particleScale = 0.25f + initialScale * (float) Math.sin((particleAge + angleOffset) / 180.f);
|
||||
|
||||
if (particleAge < fadetime)
|
||||
particleAlpha = particleAge / fadetime;
|
||||
else if (particleAge + fadetime >= particleMaxAge)
|
||||
particleAlpha = (particleMaxAge - particleAge) / fadetime;
|
||||
else
|
||||
particleAlpha = 1.0f;
|
||||
|
||||
super.renderParticle(tessellator, partialTick, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
if (particleAge++ >= particleMaxAge) {
|
||||
setDead();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package team.chisel.entity.fx;
|
||||
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import team.chisel.block.BlockSnakestoneObsidian;
|
||||
import team.chisel.utils.General;
|
||||
|
||||
public class EntitySnakestoneObsidianFX extends EntityFX {
|
||||
|
||||
BlockSnakestoneObsidian block;
|
||||
double tx, ty, tz;
|
||||
double speed;
|
||||
|
||||
public EntitySnakestoneObsidianFX(World world, BlockSnakestoneObsidian b, int x, int y, int z) {
|
||||
super(world, x + 0.5, y + 0.5, z + 0.5, 0, 0, 0);
|
||||
|
||||
block = b;
|
||||
|
||||
particleScale = 0.5f + 0.5f * General.rand.nextFloat();
|
||||
speed = 0.04 + 0.04 * General.rand.nextDouble();
|
||||
|
||||
particleMaxAge = (int) (Math.random() * 10.0D) + 40;
|
||||
|
||||
tx = x + General.rand.nextDouble();
|
||||
ty = y + General.rand.nextDouble();
|
||||
tz = z + General.rand.nextDouble();
|
||||
switch (General.rand.nextInt(6)) {
|
||||
case 0:
|
||||
tx = x;
|
||||
break;
|
||||
case 1:
|
||||
tx = x + 1;
|
||||
break;
|
||||
case 2:
|
||||
ty = y;
|
||||
break;
|
||||
case 3:
|
||||
ty = y + 1;
|
||||
break;
|
||||
case 4:
|
||||
tz = z;
|
||||
break;
|
||||
case 5:
|
||||
tz = z + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
double dx = (tx - posX) * 3;
|
||||
double dy = (ty - posY) * 3;
|
||||
double dz = (tz - posZ) * 3;
|
||||
|
||||
setPosition(posX + dx, posY + dy, posZ + dz);
|
||||
prevPosX = posX;
|
||||
prevPosY = posY;
|
||||
prevPosZ = posZ;
|
||||
|
||||
noClip = true;
|
||||
|
||||
setParticleIcon(BlockSnakestoneObsidian.particles[General.rand.nextInt(BlockSnakestoneObsidian.particles.length)]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle(Tessellator tessellator, float partialTick, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
super.renderParticle(tessellator, partialTick, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
if (particleAge++ >= particleMaxAge) {
|
||||
setDead();
|
||||
return;
|
||||
}
|
||||
|
||||
double dx = tx - posX;
|
||||
double dy = ty - posY;
|
||||
double dz = tz - posZ;
|
||||
|
||||
double distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
||||
if (distance == 0) {
|
||||
setDead();
|
||||
return;
|
||||
}
|
||||
if (distance < 0.4) {
|
||||
particleAlpha = (float) (distance / 0.4);
|
||||
} else if (particleAge < 20) {
|
||||
particleAlpha = 1.0f * particleAge / 20;
|
||||
} else {
|
||||
particleAlpha = 1.0f;
|
||||
}
|
||||
|
||||
if (distance < speed) {
|
||||
speed = distance;
|
||||
}
|
||||
|
||||
prevPosX = posX;
|
||||
prevPosY = posY;
|
||||
prevPosZ = posZ;
|
||||
|
||||
double px = posX + dx / distance * speed;
|
||||
double py = posY + dy / distance * speed;
|
||||
double pz = posZ + dz / distance * speed;
|
||||
|
||||
setPosition(px, py, pz);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package team.chisel.init;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.block.*;
|
||||
import net.minecraft.block.Block;
|
||||
import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder;
|
||||
|
||||
@ObjectHolder(Chisel.MOD_ID)
|
||||
public final class ChiselBlocks {
|
||||
|
||||
public static final Block autoChisel = null;
|
||||
public static final BlockCarvable antiBlock = null;
|
||||
public static final BlockCarvableBeacon beacon = null;
|
||||
public static final BlockCarvable marble = null;
|
||||
public static final BlockCarvable marble_pillar = null;
|
||||
public static final BlockCarvable limestone = null;
|
||||
public static final BlockCarvableSlab marble_slab = null;
|
||||
public static final BlockCarvableSlab limestone_slab = null;
|
||||
public static final BlockCarvableSlab marble_pillar_slab = null;
|
||||
public static final BlockCarvable cobblestone = 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;
|
||||
public static final BlockCarvable sandstone = null;
|
||||
public static final BlockCarvable sandstone_scribbles = null;
|
||||
public static final BlockConcrete concrete = null;
|
||||
public static final BlockRoadLine road_line = null;
|
||||
public static final BlockCarvable iron_block = null;
|
||||
public static final BlockCarvable gold_block = null;
|
||||
public static final BlockCarvable diamond_block = null;
|
||||
public static final BlockCarvableGlowstone glowstone = null;
|
||||
public static final BlockCarvable lapis_block = null;
|
||||
public static final BlockCarvable emerald_block = null;
|
||||
public static final BlockCarvable rebel = null;
|
||||
public static final BlockCarvable nether_brick = null;
|
||||
public static final BlockCarvable netherrack = null;
|
||||
public static final BlockCarvable mossy_cobblestone = null;
|
||||
public static final BlockCarvable stonebricksmooth = null;
|
||||
public static final BlockCarvablePane iron_bars = null;
|
||||
public static final BlockCarvableIce ice = null;
|
||||
public static final BlockCarvableIce ice_pillar = null;
|
||||
public static final BlockCarvablePackedIce packedice = null;
|
||||
public static final BlockCarvablePackedIce packedice_pillar = null;
|
||||
public static final BlockCarvable obsidian = null;
|
||||
public static final BlockCarvable obsidian2 = null;
|
||||
public static final BlockCarvablePowered redstone_block = null;
|
||||
public static final BlockHolystone holystone = null;
|
||||
public static final BlockGrimstone grimstone = null;
|
||||
public static final BlockLavastone lavastone = null;
|
||||
public static final BlockWaterstone waterstone = null;
|
||||
public static final BlockCarvable leaves = null;
|
||||
public static final BlockCarvable fantasyblock = null;
|
||||
public static final BlockCarvable fantasyblock2 = null;
|
||||
public static final BlockCarvable carpet_block = 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;
|
||||
public static final BlockCloud cloud = null;
|
||||
public static final BlockCarvable templeblock = null;
|
||||
public static final BlockCarvable mossy_templeblock = null;
|
||||
public static final BlockCarvable factoryblock = null;
|
||||
public static final BlockCarvable factoryblock2 = null;
|
||||
public static final BlockCarvablePane paperwall = null;
|
||||
public static final BlockCarvable paperwall_block = null;
|
||||
public static final BlockCarvable woolen_clay = null;
|
||||
public static final BlockCarvable laboratoryblock = null;
|
||||
|
||||
public static final BlockCarvable voidstone = null;
|
||||
public static final BlockCarvable voidstone2 = null;
|
||||
public static final BlockCarvable voidstonerunic = null;
|
||||
public static final BlockCarvable voidstonePillar = null;
|
||||
public static final BlockCarvable voidstonePillar2 = null;
|
||||
public static final BlockSnakestone stone_snakestone = null;
|
||||
public static final BlockSnakestone sand_snakestone = null;
|
||||
public static final BlockSnakestoneObsidian obsidian_snakestone = null;
|
||||
public static final BlockCarvable hexPlating = null;
|
||||
public static final BlockCarvable hexLargePlating = null;
|
||||
public static final BlockCarvable technical = null;
|
||||
public static final BlockCarvableGlass technical2 = null;
|
||||
public static final BlockCarvable futura = null;
|
||||
public static final BlockCarvable circuits = null;
|
||||
public static final BlockCarvable brickCustom = null;
|
||||
public static final BlockCarvableLayered warningSign = null;
|
||||
public static final BlockCarvable arcane = null;
|
||||
public static final BlockCarvable thaumium = null;
|
||||
public static final BlockCarvable tallow = null;
|
||||
|
||||
public static final BlockCarvable copperblock = null;
|
||||
public static final BlockCarvable bronzeblock = null;
|
||||
public static final BlockCarvable aluminumblock = null;
|
||||
public static BlockCarvableStairs[] aluminumStairs = new BlockCarvableStairs[8];
|
||||
public static final BlockCarvable leadblock = null;
|
||||
public static final BlockCarvable silverblock = null;
|
||||
public static final BlockCarvable steelblock = null;
|
||||
public static final BlockCarvable tinblock = null;
|
||||
public static final BlockCarvable uraniumblock = null;
|
||||
|
||||
public static final BlockCarvable bloodRune = null;
|
||||
public static final BlockCarvable bloodBrick = null;
|
||||
|
||||
// Holidays
|
||||
public static final BlockCarvable valentines = null;
|
||||
public static final BlockPresent present = null;
|
||||
|
||||
// Arrays can't be final because of how @ObjectHolder works
|
||||
public static BlockCarvableStairs[] marbleStairs = new BlockCarvableStairs[8];
|
||||
public static BlockCarvableStairs[] limestoneStairs = new BlockCarvableStairs[8];
|
||||
public static BlockCarvableIceStairs[] iceStairs = new BlockCarvableIceStairs[8];
|
||||
public static BlockCarvablePackedIceStairs[] packediceStairs = new BlockCarvablePackedIceStairs[8];
|
||||
|
||||
public static Block[] torches = new BlockCarvableTorch[16];
|
||||
|
||||
public static BlockCarvable[] planks = new BlockCarvable[6];
|
||||
|
||||
public static BlockCarvablePumpkin[] pumpkin = new BlockCarvablePumpkin[16];
|
||||
public static BlockCarvablePumpkin[] jackolantern = new BlockCarvablePumpkin[16];
|
||||
|
||||
// 1.7
|
||||
public static BlockCarvableGlass[] stainedGlass = new BlockCarvableGlass[4];
|
||||
public static BlockCarvablePane[] stainedGlassPane = new BlockCarvablePane[8];
|
||||
|
||||
// 1.8 or at least so you think :P
|
||||
public static final BlockCarvable granite = null;
|
||||
public static final BlockCarvable diorite = null;
|
||||
public static final BlockCarvable andesite = null;
|
||||
|
||||
// 1.9... drull pls
|
||||
public static final BlockCarvable purpur = null;
|
||||
|
||||
private ChiselBlocks() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package team.chisel.init;
|
||||
|
||||
import team.chisel.Chisel;
|
||||
import team.chisel.item.ItemBallOMoss;
|
||||
import team.chisel.item.ItemCloudInABottle;
|
||||
import team.chisel.item.ItemSmashingRock;
|
||||
import team.chisel.item.ItemUpgrade;
|
||||
import team.chisel.item.chisel.ItemChisel;
|
||||
import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder;
|
||||
|
||||
@ObjectHolder(Chisel.MOD_ID)
|
||||
public final class ChiselItems {
|
||||
|
||||
public static final ItemChisel chisel = null;
|
||||
public static final ItemChisel diamondChisel = null;
|
||||
public static final ItemChisel obsidianChisel = null;
|
||||
public static final ItemCloudInABottle cloudinabottle = null;
|
||||
public static final ItemBallOMoss ballomoss = null;
|
||||
public static final ItemSmashingRock smashingrock = null;
|
||||
public static final ItemUpgrade upgrade = null;
|
||||
|
||||
private ChiselItems() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package team.chisel.init;
|
||||
|
||||
import team.chisel.Features;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ChiselTabs {
|
||||
|
||||
private static class CustomCreativeTab extends CreativeTabs {
|
||||
|
||||
private boolean search;
|
||||
|
||||
private ItemStack stack;
|
||||
|
||||
public CustomCreativeTab(String label, boolean searchbar) {
|
||||
super(label);
|
||||
this.search = searchbar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getTabIconItem() {
|
||||
return stack.getItem();
|
||||
}
|
||||
|
||||
public void setTabIconItemStack(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getIconItemStack() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getBackgroundImageName() {
|
||||
|
||||
return search ? "item_search.png" : super.getBackgroundImageName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSearchbarWidth() {
|
||||
|
||||
return 89;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSearchBar() {
|
||||
|
||||
return search;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean atLeastOneModIsLoaded = false;
|
||||
|
||||
public static final CustomCreativeTab tabChisel = new CustomCreativeTab("tabChisel", false);
|
||||
public static final CustomCreativeTab tabStoneChiselBlocks = new CustomCreativeTab("tabStoneChiselBlocks", true);
|
||||
public static final CustomCreativeTab tabWoodChiselBlocks = new CustomCreativeTab("tabWoodChiselBlocks", true);
|
||||
public static final CustomCreativeTab tabMetalChiselBlocks = new CustomCreativeTab("tabMetalChiselBlocks", true);
|
||||
public static final CustomCreativeTab tabOtherChiselBlocks = new CustomCreativeTab("tabOtherChiselBlocks", true);
|
||||
public static final CustomCreativeTab tabModdedChiselBlocks = new CustomCreativeTab("tabModdedChiselBlocks", true);
|
||||
public static final CustomCreativeTab tabStairChiselBlocks = new CustomCreativeTab("tabStairChiselBlocks", true);
|
||||
|
||||
// this serves mostly just to load the static initializers
|
||||
public static void preInit() {
|
||||
atLeastOneModIsLoaded = Features.oneModdedFeatureLoaded();
|
||||
}
|
||||
|
||||
public static void postInit() {
|
||||
|
||||
if (Features.CHISEL.enabled())
|
||||
tabChisel.setTabIconItemStack(new ItemStack(ChiselItems.chisel));
|
||||
else
|
||||
tabChisel.setTabIconItemStack(new ItemStack(Items.stick));
|
||||
if (Features.HOLYSTONE.enabled())
|
||||
tabStoneChiselBlocks.setTabIconItemStack(new ItemStack(ChiselBlocks.holystone));
|
||||
else
|
||||
tabStoneChiselBlocks.setTabIconItemStack(new ItemStack(Blocks.stonebrick));
|
||||
if (Features.WOOD.enabled())
|
||||
tabWoodChiselBlocks.setTabIconItemStack(new ItemStack(ChiselBlocks.planks[0], 1, 1));
|
||||
else
|
||||
tabWoodChiselBlocks.setTabIconItemStack(new ItemStack(Blocks.planks));
|
||||
if (Features.TECHNICAL.enabled())
|
||||
tabMetalChiselBlocks.setTabIconItemStack(new ItemStack(ChiselBlocks.technical));
|
||||
else
|
||||
tabMetalChiselBlocks.setTabIconItemStack(new ItemStack(Blocks.iron_block));
|
||||
if (Features.JACKOLANTERN.enabled())
|
||||
tabOtherChiselBlocks.setTabIconItemStack(new ItemStack(ChiselBlocks.jackolantern[0]));
|
||||
else
|
||||
tabOtherChiselBlocks.setTabIconItemStack(new ItemStack(Blocks.lit_pumpkin));
|
||||
if (Features.ICE_STAIRS.enabled())
|
||||
tabStairChiselBlocks.setTabIconItemStack(new ItemStack(ChiselBlocks.iceStairs[0]));
|
||||
else
|
||||
tabStairChiselBlocks.setTabIconItemStack(new ItemStack(Blocks.nether_brick_stairs));
|
||||
|
||||
if (atLeastOneModIsLoaded) {
|
||||
if (Features.ARCANE.enabled()) {
|
||||
tabModdedChiselBlocks.setTabIconItemStack(new ItemStack(ChiselBlocks.arcane));
|
||||
} else if (Features.BLOOD_RUNE.enabled()) {
|
||||
tabModdedChiselBlocks.setTabIconItemStack(new ItemStack(ChiselBlocks.bloodRune));
|
||||
} else {
|
||||
if (ChiselBlocks.voidstone != null)
|
||||
tabModdedChiselBlocks.setTabIconItemStack(new ItemStack(ChiselBlocks.voidstone));
|
||||
else
|
||||
tabModdedChiselBlocks.setTabIconItemStack(new ItemStack(Blocks.obsidian));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
package team.chisel.inventory;
|
||||
|
||||
import team.chisel.block.tileentity.TileEntityAutoChisel;
|
||||
import team.chisel.network.PacketHandler;
|
||||
import team.chisel.network.message.MessageAutoChisel;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerAutoChisel extends Container {
|
||||
|
||||
public TileEntityAutoChisel autoChisel;
|
||||
public EntityPlayer player;
|
||||
|
||||
public ContainerAutoChisel(InventoryPlayer player, TileEntityAutoChisel tileEntityAutoChisel) {
|
||||
|
||||
this.player = player.player;
|
||||
autoChisel = tileEntityAutoChisel;
|
||||
|
||||
addSlot(tileEntityAutoChisel, 0, 53, 15);
|
||||
addSlot(tileEntityAutoChisel, 1, 78, 52);
|
||||
addSlot(tileEntityAutoChisel, 2, 103, 15);
|
||||
addSlot(tileEntityAutoChisel, 3, 8, 62);
|
||||
addSlot(tileEntityAutoChisel, 4, 152, 5);
|
||||
addSlot(tileEntityAutoChisel, 5, 152, 25);
|
||||
addSlot(tileEntityAutoChisel, 6, 152, 45);
|
||||
addSlot(tileEntityAutoChisel, 7, 152, 65);
|
||||
|
||||
bindPlayerInventory(player);
|
||||
}
|
||||
|
||||
private void addSlot(IInventory inv, final int id, int x, int y) {
|
||||
addSlotToContainer(new Slot(inv, id, x, y) {
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack arg0) {
|
||||
return inventory.isItemValidForSlot(id, arg0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void bindPlayerInventory(InventoryPlayer invPlayer) {
|
||||
for (int row = 0; row < 3; row++) {
|
||||
for (int column = 0; column < 9; column++) {
|
||||
addSlotToContainer(new Slot(invPlayer, column + row * 9 + 9, 8 + column * 18, 84 + row * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int slotNumber = 0; slotNumber < 9; slotNumber++) {
|
||||
addSlotToContainer(new Slot(invPlayer, slotNumber, 8 + slotNumber * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return autoChisel.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slotNumber) {
|
||||
ItemStack itemStack = null;
|
||||
Slot slot = (Slot) this.inventorySlots.get(slotNumber);
|
||||
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
ItemStack itemStack1 = slot.getStack();
|
||||
itemStack = itemStack1.copy();
|
||||
|
||||
// if we are in the auto chisel
|
||||
if (slotNumber <= 7) {
|
||||
if (!this.mergeItemStack(itemStack1, 8, 42, false)) {
|
||||
return null;
|
||||
}
|
||||
// otherwise just put it in one of the machine slots
|
||||
} else if (!this.mergeItemStack(itemStack1, 0, 8, false)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (itemStack1.stackSize == 0) {
|
||||
slot.putStack(null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemStack1.stackSize == itemStack.stackSize) {
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onPickupFromSlot(player, itemStack1);
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick(int slotId, int p_75144_2_, int p_75144_3_, EntityPlayer player) {
|
||||
if (slotId >= 0 && slotId < this.inventorySlots.size()) {
|
||||
Slot slot = (Slot) this.inventorySlots.get(slotId);
|
||||
ItemStack stack = slot.getStack();
|
||||
ItemStack ret = super.slotClick(slotId, p_75144_2_, p_75144_3_, player);
|
||||
|
||||
if (!player.worldObj.isRemote && slot.slotNumber == TileEntityAutoChisel.BASE && !ItemStack.areItemStacksEqual(stack, slot.getStack())) {
|
||||
int chiseled = stack == null ? 0 : slot.getStack() == null ? stack.stackSize : stack.stackSize - slot.getStack().stackSize;
|
||||
PacketHandler.INSTANCE.sendToDimension(new MessageAutoChisel(autoChisel, chiseled, false, false), player.worldObj.provider.dimensionId);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
return super.slotClick(slotId, p_75144_2_, p_75144_3_, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Added validation of slot input
|
||||
*
|
||||
* @author CrazyPants
|
||||
*/
|
||||
@Override
|
||||
protected boolean mergeItemStack(ItemStack par1ItemStack, int fromIndex, int toIndex, boolean reversOrder) {
|
||||
|
||||
boolean result = false;
|
||||
int checkIndex = fromIndex;
|
||||
|
||||
if (reversOrder) {
|
||||
checkIndex = toIndex - 1;
|
||||
}
|
||||
|
||||
Slot slot;
|
||||
ItemStack itemstack1;
|
||||
|
||||
if (par1ItemStack.isStackable()) {
|
||||
|
||||
while (par1ItemStack.stackSize > 0 && (!reversOrder && checkIndex < toIndex || reversOrder && checkIndex >= fromIndex)) {
|
||||
slot = (Slot) this.inventorySlots.get(checkIndex);
|
||||
itemstack1 = slot.getStack();
|
||||
|
||||
if (itemstack1 != null && itemstack1.getItem() == par1ItemStack.getItem() && (!par1ItemStack.getHasSubtypes() || par1ItemStack.getItemDamage() == itemstack1.getItemDamage())
|
||||
&& ItemStack.areItemStackTagsEqual(par1ItemStack, itemstack1) && slot.isItemValid(par1ItemStack)) {
|
||||
|
||||
int mergedSize = itemstack1.stackSize + par1ItemStack.stackSize;
|
||||
int maxStackSize = Math.min(par1ItemStack.getMaxStackSize(), slot.getSlotStackLimit());
|
||||
if (mergedSize <= maxStackSize) {
|
||||
par1ItemStack.stackSize = 0;
|
||||
itemstack1.stackSize = mergedSize;
|
||||
slot.onSlotChanged();
|
||||
result = true;
|
||||
} else if (itemstack1.stackSize < maxStackSize) {
|
||||
par1ItemStack.stackSize -= maxStackSize - itemstack1.stackSize;
|
||||
itemstack1.stackSize = maxStackSize;
|
||||
slot.onSlotChanged();
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (reversOrder) {
|
||||
--checkIndex;
|
||||
} else {
|
||||
++checkIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackSize > 0) {
|
||||
if (reversOrder) {
|
||||
checkIndex = toIndex - 1;
|
||||
} else {
|
||||
checkIndex = fromIndex;
|
||||
}
|
||||
|
||||
while (!reversOrder && checkIndex < toIndex || reversOrder && checkIndex >= fromIndex) {
|
||||
slot = (Slot) this.inventorySlots.get(checkIndex);
|
||||
itemstack1 = slot.getStack();
|
||||
|
||||
if (itemstack1 == null && slot.isItemValid(par1ItemStack)) {
|
||||
ItemStack in = par1ItemStack.copy();
|
||||
in.stackSize = Math.min(in.stackSize, slot.getSlotStackLimit());
|
||||
|
||||
slot.putStack(in);
|
||||
slot.onSlotChanged();
|
||||
if (in.stackSize >= par1ItemStack.stackSize) {
|
||||
par1ItemStack.stackSize = 0;
|
||||
} else {
|
||||
par1ItemStack.stackSize -= in.stackSize;
|
||||
}
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (reversOrder) {
|
||||
--checkIndex;
|
||||
} else {
|
||||
++checkIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Loaded 100 of 132 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user