mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-21 04:42:25 +00:00
Change package name for realsies now :P
This commit is contained in:
1 parent
4d8df815cc
commit
dae454dc17
138 files changed
+491
-438
No files matched your search
@@ -0,0 +1,130 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.block.tileentity.TileEntityAutoChisel;
|
||||
import com.cricketcraft.chisel.init.ModBlocks;
|
||||
import com.cricketcraft.chisel.init.ModItems;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockAutoChisel extends BlockContainer{
|
||||
public BlockAutoChisel() {
|
||||
super(Material.rock);
|
||||
setHardness(1F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
if(player.isSneaking() && tile!= null && tile instanceof TileEntityAutoChisel){
|
||||
TileEntityAutoChisel autoChisel = (TileEntityAutoChisel) tile;
|
||||
System.out.println(player.getHeldItem());
|
||||
if(player.getItemInUse() == new ItemStack(ModItems.upgrade, 1, 0)){
|
||||
//If they are using the speed upgrade
|
||||
world.setBlock(x, y, z, ModBlocks.autoChisel, 1, 3);
|
||||
} else if(player.getItemInUse() == new ItemStack(ModItems.upgrade, 1, 1)){
|
||||
//If they are using the automation upgrade
|
||||
world.setBlock(x, y, z, ModBlocks.autoChisel, 2, 3);
|
||||
} else if(player.getItemInUse() == new ItemStack(ModItems.upgrade, 1, 2)){
|
||||
//If they are using the stack upgrade
|
||||
world.setBlock(x, y, z, ModBlocks.autoChisel, 3, 3);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int metadata){
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List subItems){
|
||||
for(int x = 0; x < 4; x++){
|
||||
subItems.add(new ItemStack(this, 1, x));
|
||||
}
|
||||
}
|
||||
|
||||
private void dropItems(World world, int x, int y, int z) {
|
||||
Random random = new Random();
|
||||
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 && stack.stackSize > 0) {
|
||||
float rx = random.nextFloat() * 0.8F + 0.1F;
|
||||
float ry = random.nextFloat() * 0.8F + 0.1F;
|
||||
float rz = random.nextFloat() * 0.8F + 0.1F;
|
||||
EntityItem entityItem = new EntityItem(world, x + rx, y + ry, z + rz, stack);
|
||||
|
||||
if (stack.hasTagCompound()) {
|
||||
entityItem.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy());
|
||||
}
|
||||
|
||||
float factor = 0.05F;
|
||||
entityItem.motionX = random.nextGaussian() * factor;
|
||||
entityItem.motionY = random.nextGaussian() * factor + 0.2F;
|
||||
entityItem.motionZ = random.nextGaussian() * factor;
|
||||
world.spawnEntityInWorld(entityItem);
|
||||
stack.stackSize = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1, int var2) {
|
||||
return new TileEntityAutoChisel();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
/**
|
||||
* Created by Pokefenn
|
||||
*/
|
||||
public class BlockBeaconBase extends BlockCarvable
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.init.ModTabs;
|
||||
|
||||
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);
|
||||
carverHelper = new CarvableHelper();
|
||||
setCreativeTab(ModTabs.tabChiselBlocks);
|
||||
}
|
||||
|
||||
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", this, register);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
|
||||
carverHelper.registerSubBlocks(this, tabs, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return Chisel.RenderCTMId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
|
||||
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,87 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.init.ModTabs;
|
||||
|
||||
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 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();
|
||||
setCreativeTab(ModTabs.tabChiselBlocks);
|
||||
}
|
||||
|
||||
public BlockCarvableGlass setStained(boolean a)
|
||||
{
|
||||
this.isAlpha = a;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return Chisel.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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tabs, List list)
|
||||
{
|
||||
carverHelper.registerSubBlocks(this, tabs, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(int metadata)
|
||||
{
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderBlockPass()
|
||||
{
|
||||
return isAlpha ? 1 : 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.client.render.BlockMarblePaneRenderer;
|
||||
import com.cricketcraft.chisel.init.ModTabs;
|
||||
|
||||
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 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();
|
||||
|
||||
setCreativeTab(ModTabs.tabChiselBlocks);
|
||||
}
|
||||
|
||||
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 BlockMarblePaneRenderer.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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tabs, List list)
|
||||
{
|
||||
carverHelper.registerSubBlocks(this, tabs, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(int metadata)
|
||||
{
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.cricketcraft.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,49 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
|
||||
import net.minecraft.block.BlockPumpkin;
|
||||
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 BlockCarvablePumpkin extends BlockPumpkin implements ICarvable{
|
||||
public CarvableHelper carverHelper;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon top;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon face;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon side;
|
||||
private int sideVal, faceVal;
|
||||
|
||||
public BlockCarvablePumpkin(boolean isOn, int sideTexture, int faceTexture) {
|
||||
super(isOn);
|
||||
sideVal = sideTexture;
|
||||
faceVal = faceTexture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
//if(side != 0 || side != 1){
|
||||
// if(side == ForgeDirection.)
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister icon){
|
||||
top = icon.registerIcon(this.getTextureName() + "_top_" + sideVal);
|
||||
side = icon.registerIcon(this.getTextureName() + "_side_" + sideVal);
|
||||
face = icon.registerIcon(this.getTextureName() + "_face_" + faceVal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.cricketcraft.chisel.Configurations;
|
||||
|
||||
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;
|
||||
|
||||
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
|
||||
public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) {
|
||||
return super.shouldSideBeRendered(iblockaccess, i, j, k, 1 - l);
|
||||
}
|
||||
|
||||
@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 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int meta) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import com.cricketcraft.chisel.Configurations;
|
||||
import com.cricketcraft.chisel.client.GeneralChiselClient;
|
||||
|
||||
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)
|
||||
{
|
||||
float f = 0.125F;
|
||||
return AxisAlignedBB.getBoundingBox(par2, par3, par4, (par2 + 1), ((par3 + 1) - f), (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,20 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
|
||||
|
||||
public class BlockEldritch extends BlockCarvable
|
||||
{
|
||||
|
||||
public BlockEldritch()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return Chisel.RenderEldritchId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.client.GeneralChiselClient;
|
||||
import com.cricketcraft.chisel.init.ModTabs;
|
||||
import com.cricketcraft.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);
|
||||
this.setCreativeTab(ModTabs.tabChiselBlocks);
|
||||
}
|
||||
|
||||
@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 com.cricketcraft.chisel.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.cricketcraft.chisel.client.GeneralChiselClient;
|
||||
import com.cricketcraft.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,32 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.cricketcraft.chisel.client.GeneralChiselClient;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockLavastone extends BlockMarbleTexturedOre
|
||||
{
|
||||
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,15 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
public class BlockLeaf extends BlockCarvable {
|
||||
|
||||
public BlockLeaf(Material material) {
|
||||
super(material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.cricketcraft.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;
|
||||
|
||||
public class BlockLightstoneCarvable extends BlockCarvable {
|
||||
public BlockLightstoneCarvable() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
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 BlockMarbleBookshelf extends BlockCarvable
|
||||
{
|
||||
|
||||
public BlockMarbleBookshelf()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
@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 par1Random)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return Items.book;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEnchantPowerBonus(World world, int x, int y, int z)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.init.ModTabs;
|
||||
|
||||
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 BlockMarbleCarpet extends BlockCarpet implements ICarvable
|
||||
{
|
||||
public CarvableHelper carverHelper;
|
||||
|
||||
public BlockMarbleCarpet(Material m)
|
||||
{
|
||||
carverHelper = new CarvableHelper();
|
||||
|
||||
setCreativeTab(ModTabs.tabChiselBlocks);
|
||||
}
|
||||
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tabs, List list)
|
||||
{
|
||||
carverHelper.registerSubBlocks(this, tabs, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return Chisel.RenderCarpetId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(int metadata)
|
||||
{
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.init.ModTabs;
|
||||
|
||||
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.World;
|
||||
|
||||
public class BlockMarbleIce extends BlockIce implements ICarvable
|
||||
{
|
||||
public CarvableHelper carverHelper;
|
||||
|
||||
public BlockMarbleIce()
|
||||
{
|
||||
super();
|
||||
carverHelper = new CarvableHelper();
|
||||
setCreativeTab(ModTabs.tabChiselBlocks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata)
|
||||
{
|
||||
return carverHelper.getIcon(side, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int i)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register)
|
||||
{
|
||||
carverHelper.registerBlockIcons("Chisel", this, register);
|
||||
}
|
||||
|
||||
@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 CarvableVariation getVariation(int metadata)
|
||||
{
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.init.ModBlocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockMarbleIceStairs extends BlockMarbleStairs
|
||||
{
|
||||
public BlockMarbleIceStairs(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)
|
||||
{
|
||||
ModBlocks.ice.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random par1Random)
|
||||
{
|
||||
return ModBlocks.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)
|
||||
{
|
||||
ModBlocks.ice.updateTick(par1World, par2, par3, par4, par5Random);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMobilityFlag()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.cricketcraft.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 BlockMarbleLamp extends BlockCarvable {
|
||||
BlockMarbleLamp blockUnpowered;
|
||||
BlockMarbleLamp blockPowered;
|
||||
boolean powered;
|
||||
|
||||
public BlockMarbleLamp() {
|
||||
super(Material.redstoneLight);
|
||||
|
||||
powered = false;
|
||||
blockUnpowered = this;
|
||||
blockPowered = new BlockMarbleLamp(this);
|
||||
|
||||
setHardness(0.3F);
|
||||
}
|
||||
|
||||
public BlockMarbleLamp(BlockMarbleLamp 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,40 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.client.render.BlockMarblePillarRenderer;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class BlockMarblePillar extends BlockCarvable {
|
||||
public IIcon sides[] = new IIcon[6];
|
||||
|
||||
public BlockMarblePillar(Material m) {
|
||||
super(m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return BlockMarblePillarRenderer.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return sides[side];
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return sides[side];
|
||||
}
|
||||
|
||||
public IIcon getCtmIcon(int index, int metadata) {
|
||||
CarvableVariation var = carverHelper.variations.get(metadata);
|
||||
|
||||
if (index >= 4) return var.iconTop;
|
||||
if (var.seamsCtmVert == null) return var.icon;
|
||||
return var.seamsCtmVert.icons[index];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.cricketcraft.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 cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockMarbleSlab extends BlockCarvable
|
||||
{
|
||||
public Block master;
|
||||
public BlockMarbleSlab bottom;
|
||||
public BlockMarbleSlab top;
|
||||
public boolean isBottom;
|
||||
|
||||
public BlockMarbleSlab(BlockCarvable marble)
|
||||
{
|
||||
opaque = true;
|
||||
|
||||
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
|
||||
|
||||
master = marble;
|
||||
bottom = this;
|
||||
top = new BlockMarbleSlab(this);
|
||||
|
||||
isBottom = true;
|
||||
}
|
||||
|
||||
public BlockMarbleSlab(BlockMarbleSlab 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);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item block, CreativeTabs tabs, List list)
|
||||
{
|
||||
if(isBottom)
|
||||
super.getSubBlocks(block, tabs, list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.client.render.BlockMarbleStairsRenderer;
|
||||
import com.cricketcraft.chisel.init.ModTabs;
|
||||
|
||||
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.World;
|
||||
|
||||
public class BlockMarbleStairs extends BlockStairs implements ICarvable
|
||||
{
|
||||
CarvableHelper carverHelper;
|
||||
int blockMeta;
|
||||
|
||||
public BlockMarbleStairs(Block block, int meta, CarvableHelper helper)
|
||||
{
|
||||
super(block, meta);
|
||||
|
||||
this.useNeighborBrightness = true;
|
||||
setCreativeTab(ModTabs.tabChiselBlocks);
|
||||
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 & 0x8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register)
|
||||
{
|
||||
if(blockMeta == 0)
|
||||
carverHelper.registerBlockIcons("Chisel", this, register);
|
||||
}
|
||||
|
||||
@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 BlockMarbleStairsRenderer.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack)
|
||||
{
|
||||
int l = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
int i1 = par1World.getBlockMetadata(par2, par3, par4) & 4;
|
||||
int odd = par6ItemStack.getItemDamage();
|
||||
|
||||
if(l == 0)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 2 | i1 + odd, 2);
|
||||
}
|
||||
|
||||
if(l == 1)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 1 | i1 + odd, 2);
|
||||
}
|
||||
|
||||
if(l == 2)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 3 | i1 + odd, 2);
|
||||
}
|
||||
|
||||
if(l == 3)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 0 | i1 + odd, 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int onBlockPlaced(World world, int x, int y, int z, int side, float hx, float hy, float hz, int damage)
|
||||
{
|
||||
// int res=super.onBlockPlaced();
|
||||
return side != 0 && (side == 1 || hy <= 0.5D) ? damage : damage | 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(int metadata)
|
||||
{
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.item.ItemCarvable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class BlockMarbleStairsMaker
|
||||
{
|
||||
public CarvableHelper carverHelper;
|
||||
BlockMarbleStairs blocks[];
|
||||
|
||||
//int idStart;
|
||||
Block blockBase;
|
||||
String blockName;
|
||||
|
||||
public BlockMarbleStairsMaker(Block base)
|
||||
{
|
||||
carverHelper = new CarvableHelper();
|
||||
blockBase = base;
|
||||
}
|
||||
|
||||
public void create(String name)
|
||||
{
|
||||
create(null, name);
|
||||
}
|
||||
|
||||
public void create(BlockMarbleStairsMakerCreator creator, String name)
|
||||
{
|
||||
blocks = new BlockMarbleStairs[carverHelper.variations.size() / 2];
|
||||
for(int i = 0; i < blocks.length; i++)
|
||||
{
|
||||
String n = name + "." + i;
|
||||
blocks[i] = creator == null ?
|
||||
new BlockMarbleStairs(blockBase, i * 2, carverHelper) :
|
||||
creator.create(blockBase, i * 2, carverHelper);
|
||||
|
||||
blocks[i].setBlockName(n);
|
||||
GameRegistry.registerBlock(blocks[i], ItemCarvable.class, n);
|
||||
|
||||
for(int meta = 0; meta < 2 && i * 2 + meta < carverHelper.variations.size(); meta++)
|
||||
{
|
||||
CarvableVariation variation = carverHelper.variations.get(i * 2 + meta);
|
||||
|
||||
for(int j = 0; j < 8; j++)
|
||||
carverHelper.registerVariation(name + ".orientation." + j, variation, blocks[i], j + meta * 8);
|
||||
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(blocks[i], 4, meta * 8), new Object[]{"* ", "** ", "***", '*', new ItemStack(blockBase, 1, i * 2 + meta)});
|
||||
}
|
||||
|
||||
CarvableHelper.chiselBlocks.add(blocks[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
public interface BlockMarbleStairsMakerCreator
|
||||
{
|
||||
public BlockMarbleStairs create(Block block, int meta, CarvableHelper helper);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.init.ModTabs;
|
||||
|
||||
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;
|
||||
|
||||
public class BlockMarbleTexturedOre extends BlockTexturedOre implements ICarvable
|
||||
{
|
||||
public CarvableHelper carverHelper;
|
||||
|
||||
public BlockMarbleTexturedOre(Material mat, String baseIcon)
|
||||
{
|
||||
super(mat, baseIcon);
|
||||
|
||||
carverHelper = new CarvableHelper();
|
||||
|
||||
setCreativeTab(ModTabs.tabChiselBlocks);
|
||||
}
|
||||
|
||||
public BlockMarbleTexturedOre(Material mat, Block block) {
|
||||
super(mat, block);
|
||||
|
||||
carverHelper = new CarvableHelper();
|
||||
|
||||
setCreativeTab(ModTabs.tabChiselBlocks);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item block, CreativeTabs tabs, List list)
|
||||
{
|
||||
carverHelper.registerSubBlocks(this, tabs, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(int metadata)
|
||||
{
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.init.ModTabs;
|
||||
|
||||
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 BlockMarbleWall extends BlockWall
|
||||
{
|
||||
CarvableHelper carverHelper;
|
||||
|
||||
public BlockMarbleWall(Block block)
|
||||
{
|
||||
super(block);
|
||||
|
||||
carverHelper = new CarvableHelper();
|
||||
|
||||
setCreativeTab(ModTabs.tabChiselBlocks);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item block, CreativeTabs tabs, List list)
|
||||
{
|
||||
carverHelper.registerSubBlocks(this, tabs, list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,440 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.Random;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.block.tileentity.TileEntityPresent;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.init.ModTabs;
|
||||
import com.cricketcraft.chisel.inventory.InventoryLargePresent;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.passive.EntityOcelot;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
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 BlockContainer implements ICarvable {
|
||||
private final Random random = new Random();
|
||||
public CarvableHelper carverHelper;
|
||||
private boolean isChristmas = true;
|
||||
|
||||
public BlockPresent() {
|
||||
super(Material.wood);
|
||||
carverHelper = new CarvableHelper();
|
||||
setCreativeTab(ModTabs.tabChiselBlocks);
|
||||
setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0875F, 0.9365F);
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
||||
if (calendar.get(2) + 1 == 12 && calendar.get(5) >= 25 && calendar.get(5) <= 26) {
|
||||
isChristmas = true;//<--- this would have been false before and it lasts for two days :)
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isCatSittingOnMe(World world, int x, int y, int z) {
|
||||
Iterator iterator = world.getEntitiesWithinAABB(EntityOcelot.class, AxisAlignedBB.getBoundingBox(x, y + 1, z, x + 1, y + 2, z + 1)).iterator();
|
||||
EntityOcelot ocelot;
|
||||
|
||||
do {
|
||||
if (!iterator.hasNext()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Entity entity = (Entity) iterator.next();
|
||||
ocelot = (EntityOcelot) entity;
|
||||
} while (!ocelot.isSitting());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public ResourceLocation getResourceSingle(int metadata) {
|
||||
if (isChristmas) {
|
||||
switch (metadata) {
|
||||
case 1:
|
||||
return new ResourceLocation(Chisel.MOD_ID, "textures/blocks/present/red.png");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
switch (metadata) {
|
||||
case 1:
|
||||
return new ResourceLocation(Chisel.MOD_ID, "textures/blocks/present/crate.png");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ResourceLocation getResourceDouble(int metadata) {
|
||||
if (isChristmas) {
|
||||
switch (metadata) {
|
||||
case 1:
|
||||
return new ResourceLocation(Chisel.MOD_ID, "textures/blocks/presentDouble/red.png");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
switch (metadata) {
|
||||
case 1:
|
||||
return new ResourceLocation(Chisel.MOD_ID, "textures/blocks/presentDouble/crate.png");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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 entityLivingBase, ItemStack itemStack) {
|
||||
Block front = world.getBlock(x, y, z - 1);
|
||||
Block back = world.getBlock(x, y, z + 1);
|
||||
Block left = world.getBlock(x - 1, y, z);
|
||||
Block right = world.getBlock(x + 1, y, z);
|
||||
byte metadata = 0;
|
||||
int rot = MathHelper.floor_double((entityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
|
||||
if (rot == 0) {
|
||||
metadata = 2;
|
||||
}
|
||||
|
||||
if (rot == 1) {
|
||||
metadata = 5;
|
||||
}
|
||||
|
||||
if (rot == 2) {
|
||||
metadata = 3;
|
||||
}
|
||||
|
||||
if (rot == 3) {
|
||||
metadata = 4;
|
||||
}
|
||||
|
||||
if (front != this && back != this && left != this && right != this) {
|
||||
world.setBlockMetadataWithNotify(x, y, z, metadata, 3);
|
||||
} else {
|
||||
if ((front == this || back == this) && (metadata == 4 || metadata == 5)) {
|
||||
if (front == this) {
|
||||
world.setBlockMetadataWithNotify(x, y, z - 1, metadata, 3);
|
||||
} else {
|
||||
world.setBlockMetadataWithNotify(x, y, z + 1, metadata, 3);
|
||||
}
|
||||
|
||||
world.setBlockMetadataWithNotify(x, y, z, metadata, 3);
|
||||
}
|
||||
|
||||
if ((left == this || right == this) && (metadata == 4 || metadata == 5)) {
|
||||
if (left == this) {
|
||||
world.setBlockMetadataWithNotify(x - 1, y, z, metadata, 3);
|
||||
} else {
|
||||
world.setBlockMetadataWithNotify(x + 1, y, z, metadata, 3);
|
||||
}
|
||||
|
||||
world.setBlockMetadataWithNotify(x, y, z, metadata, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt(World world, int x, int y, int z) {
|
||||
int l = 0;
|
||||
|
||||
if (world.getBlock(x - 1, y, z) == this) {
|
||||
++l;
|
||||
}
|
||||
|
||||
if (world.getBlock(x + 1, y, z) == this) {
|
||||
++l;
|
||||
}
|
||||
|
||||
if (world.getBlock(x, y, z - 1) == this) {
|
||||
++l;
|
||||
}
|
||||
|
||||
if (world.getBlock(x, y, z + 1) == this) {
|
||||
++l;
|
||||
}
|
||||
|
||||
return l > 1 ? false : (areSurroundingBlocksMe(world, x, y - 1, z) ? false : (areSurroundingBlocksMe(world, x, y + 1, z) ? false : (areSurroundingBlocksMe(world, x, y, z - 1) ? false : !areSurroundingBlocksMe(world, x, y, z + 1))));
|
||||
}
|
||||
|
||||
private boolean areSurroundingBlocksMe(World world, int x, int y, int z) {
|
||||
return world.getBlock(x, y, z) != this ? false : (world.getBlock(x - 1, y, z) == this ? true : (world.getBlock(x + 1, y, z) == this ? true : (world.getBlock(x, y, z - 1) == this ? true : world.getBlock(x, y, z + 1) == this)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block neighbor) {
|
||||
super.onNeighborBlockChange(world, x, y, z, neighbor);
|
||||
TileEntityPresent tileEntityPresent = (TileEntityPresent) world.getTileEntity(x, y, z);
|
||||
|
||||
if (tileEntityPresent != null) {
|
||||
tileEntityPresent.updateContainingBlockInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@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.getSizeInventory(); c++) {
|
||||
ItemStack itemStack = tileEntityPresent.getStackInSlot(c);
|
||||
|
||||
if (itemStack != null) {
|
||||
float f = random.nextFloat() * 0.8F + 0.1F;
|
||||
float f1 = random.nextFloat() * 0.8F + 0.1F;
|
||||
EntityItem entityItem;
|
||||
|
||||
for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemStack.stackSize > 0; world.spawnEntityInWorld(entityItem)) {
|
||||
int stack = random.nextInt(21) + 10;
|
||||
|
||||
if (stack > itemStack.stackSize) {
|
||||
stack = itemStack.stackSize;
|
||||
}
|
||||
|
||||
itemStack.stackSize -= stack;
|
||||
entityItem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemStack.getItem(), stack, itemStack.getItemDamage()));
|
||||
float motion = 0.05F;
|
||||
entityItem.motionX = random.nextGaussian() * motion;
|
||||
entityItem.motionY = random.nextGaussian() * motion + 0.2F;
|
||||
entityItem.motionZ = random.nextGaussian() * motion;
|
||||
|
||||
if (itemStack.hasTagCompound()) {
|
||||
entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 meta, float x1, float y1, float z1) {
|
||||
if (!world.isRemote) {
|
||||
player.openGui(Chisel.instance, 2, world, x, y, z);
|
||||
return true;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
|
||||
if (world.getBlock(x, y, z - 1) == this) {
|
||||
this.setBlockBounds(0.0625F, 0.0F, 0.0F, 0.9375F, 0.875F, 0.9375F);
|
||||
} else if (world.getBlock(x, y, z + 1) == this) {
|
||||
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
|
||||
} else if (world.getBlock(x - 1, y, z) == this) {
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0625F, 0.9375F, 0.875F, 1.0F);
|
||||
} else if (world.getBlock(x + 1, y, z) == this) {
|
||||
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 1.0F, 0.875F, 0.9375F);
|
||||
} else {
|
||||
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z) {
|
||||
super.onBlockAdded(world, x, y, z);
|
||||
this.changeMetadataBasedOffSpecs(world, x, y, z);
|
||||
Block back = world.getBlock(x, y, z - 1);
|
||||
Block front = world.getBlock(x, y, z + 1);
|
||||
Block left = world.getBlock(x - 1, y, z);
|
||||
Block right = world.getBlock(x + 1, y, z);
|
||||
|
||||
if (back == this) {
|
||||
this.changeMetadataBasedOffSpecs(world, x, y, z - 1);
|
||||
}
|
||||
|
||||
if (front == this) {
|
||||
this.changeMetadataBasedOffSpecs(world, x, y, z + 1);
|
||||
}
|
||||
|
||||
if (left == this) {
|
||||
this.changeMetadataBasedOffSpecs(world, x - 1, y, z);
|
||||
}
|
||||
|
||||
if (right == this) {
|
||||
this.changeMetadataBasedOffSpecs(world, x + 1, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
public void changeMetadataBasedOffSpecs(World world, int x, int y, int z) {
|
||||
if (!world.isRemote) {
|
||||
Block back = world.getBlock(x, y, z - 1);
|
||||
Block front = world.getBlock(x, y, z + 1);
|
||||
Block left = world.getBlock(x - 1, y, z);
|
||||
Block right = world.getBlock(x + 1, y, z);
|
||||
boolean flag = true, flag1;
|
||||
byte metadata;
|
||||
int x1, blockMeta, z1;
|
||||
Block backLeft, frontRight;
|
||||
|
||||
if (front != this && back != this) {
|
||||
if (left != this && right != this) {
|
||||
metadata = 3;
|
||||
|
||||
if (front.func_149730_j() && !back.func_149730_j()) {
|
||||
metadata = 3;
|
||||
}
|
||||
|
||||
if (back.func_149730_j() && !front.func_149730_j()) {
|
||||
metadata = 2;
|
||||
}
|
||||
|
||||
if (left.func_149730_j() && !right.func_149730_j()) {
|
||||
metadata = 5;
|
||||
}
|
||||
|
||||
if (right.func_149730_j() && !left.func_149730_j()) {
|
||||
metadata = 4;
|
||||
}
|
||||
} else {
|
||||
x1 = back == this ? x - 1 : x + 1;
|
||||
backLeft = world.getBlock(x1, y, z - 1);
|
||||
z1 = back == this ? z - 1 : z + 1;
|
||||
frontRight = world.getBlock(x + 1, y, z1);
|
||||
metadata = 5;
|
||||
flag1 = true;
|
||||
|
||||
if (back == this) {
|
||||
blockMeta = world.getBlockMetadata(x, y, z - 1);
|
||||
} else {
|
||||
blockMeta = world.getBlockMetadata(x, y, z + 1);
|
||||
}
|
||||
|
||||
if (blockMeta == 4) {
|
||||
metadata = 4;
|
||||
}
|
||||
|
||||
if ((left.func_149730_j() || backLeft.func_149730_j()) && !right.func_149730_j() && !frontRight.func_149730_j()) {
|
||||
metadata = 5;
|
||||
}
|
||||
|
||||
if ((right.func_149730_j() || frontRight.func_149730_j()) && !left.func_149730_j() && !backLeft.func_149730_j()) {
|
||||
metadata = 4;
|
||||
}
|
||||
}
|
||||
|
||||
world.setBlockMetadataWithNotify(x, y, z, metadata, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int par2) {
|
||||
return new TileEntityPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int strength) {
|
||||
if (!canProvidePower()) {
|
||||
return 0;
|
||||
} else {
|
||||
int players = ((TileEntityPresent) world.getTileEntity(x, y, z)).numPlayersUsing;
|
||||
return MathHelper.clamp_int(players, 0, 15);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int strength) {
|
||||
return strength == 1 ? isProvidingWeakPower(world, x, y, z, strength) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(World world, int x, int y, int z, int strength) {
|
||||
return Container.calcRedstoneFromInventory(getInventory(world, x, y, z));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
this.blockIcon = register.registerIcon("planks_oak");
|
||||
}
|
||||
|
||||
public IInventory getInventory(World world, int x, int y, int z) {
|
||||
Object object = (TileEntityPresent) world.getTileEntity(x, y, z);
|
||||
|
||||
if (object == null) {
|
||||
return null;
|
||||
} else if (world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)) {
|
||||
return null;
|
||||
} else if (isCatSittingOnMe(world, x, y, z)) {
|
||||
return null;
|
||||
} else if (world.getBlock(x - 1, y, z) == this && (world.isSideSolid(x - 1, y + 1, z, ForgeDirection.DOWN) || isCatSittingOnMe(world, x, y - 1, z))) {
|
||||
return null;
|
||||
} else if (world.getBlock(x + 1, y, z) == this && (world.isSideSolid(x + 1, y + 1, z, ForgeDirection.DOWN) || isCatSittingOnMe(world, x, y + 1, z))) {
|
||||
return null;
|
||||
} else if (world.getBlock(x, y, z - 1) == this && (world.isSideSolid(x, y + 1, z - 1, ForgeDirection.DOWN) || isCatSittingOnMe(world, x, y, z - 1))) {
|
||||
return null;
|
||||
} else if (world.getBlock(x, y, z + 1) == this && (world.isSideSolid(x, y + 1, z + 1, ForgeDirection.DOWN) || isCatSittingOnMe(world, x, y, z + 1))) {
|
||||
return null;
|
||||
} else {
|
||||
if (world.getBlock(x - 1, y, z) == this) {
|
||||
object = new InventoryLargePresent("container.chestDouble", (TileEntityPresent) world.getTileEntity(x - 1, y, z), (IInventory) object);
|
||||
}
|
||||
|
||||
if (world.getBlock(x + 1, y, z) == this) {
|
||||
object = new InventoryLargePresent("container.chestDouble", (TileEntityPresent) world.getTileEntity(x + 1, y, z), (IInventory) object);
|
||||
}
|
||||
|
||||
if (world.getBlock(x, y, z - 1) == this) {
|
||||
object = new InventoryLargePresent("container.chestDouble", (TileEntityPresent) world.getTileEntity(x, y, z - 1), (IInventory) object);
|
||||
}
|
||||
|
||||
if (world.getBlock(x, y, z + 1) == this) {
|
||||
object = new InventoryLargePresent("container.chestDouble", (TileEntityPresent) world.getTileEntity(x, y, z + 1), (IInventory) object);
|
||||
}
|
||||
|
||||
return (IInventory) object;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(int metadata) {
|
||||
return carverHelper.getVariation(metadata);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import com.cricketcraft.chisel.client.render.BlockRoadLineRenderer;
|
||||
import com.cricketcraft.chisel.init.ModTabs;
|
||||
|
||||
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.World;
|
||||
|
||||
public class BlockRoadLine extends Block
|
||||
{
|
||||
public IIcon aloneIcon;
|
||||
public IIcon halfLineIcon;
|
||||
public IIcon fullLineIcon;
|
||||
|
||||
public BlockRoadLine()
|
||||
{
|
||||
super(Material.circuits);
|
||||
|
||||
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);
|
||||
|
||||
setCreativeTab(ModTabs.tabChiselBlocks);
|
||||
}
|
||||
|
||||
@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 BlockRoadLineRenderer.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return par1World.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
|
||||
public void registerBlockIcons(IIconRegister reg)
|
||||
{
|
||||
blockIcon = aloneIcon = reg.registerIcon("Chisel:line-marking/white-center");
|
||||
halfLineIcon = reg.registerIcon("Chisel:line-marking/white-side");
|
||||
fullLineIcon = reg.registerIcon("Chisel:line-marking/white-long");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,576 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cricketcraft.chisel.client.render.BlockSnakeStoneRenderer;
|
||||
import com.cricketcraft.chisel.init.ModTabs;
|
||||
|
||||
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);
|
||||
setCreativeTab(ModTabs.tabChiselBlocks);
|
||||
flipTopTextures = false;
|
||||
|
||||
this.iconPrefix = iconPrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return BlockSnakeStoneRenderer.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);
|
||||
int kind = blockMeta & 0xc;
|
||||
|
||||
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)
|
||||
{
|
||||
int type = meta & 0xc;
|
||||
int orient = meta & 0x3;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@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,41 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.cricketcraft.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 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,80 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import com.cricketcraft.chisel.Configurations;
|
||||
import com.cricketcraft.chisel.client.GeneralChiselClient;
|
||||
import com.cricketcraft.chisel.client.render.BlockSpikesRenderer;
|
||||
import com.cricketcraft.chisel.utils.General;
|
||||
|
||||
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.Entity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class BlockSpikes extends Block
|
||||
{
|
||||
public IIcon iconBase;
|
||||
public IIcon iconSpike;
|
||||
|
||||
public BlockSpikes(Material mat)
|
||||
{
|
||||
super(Material.circuits);
|
||||
|
||||
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||
this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 1.0f / 16, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if(FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT)
|
||||
return;
|
||||
|
||||
double dy = entity.posY - entity.prevPosY;
|
||||
|
||||
GeneralChiselClient.speedupPlayer(world, entity, Configurations.concreteVelocity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return BlockSpikesRenderer.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int meta)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register)
|
||||
{
|
||||
blockIcon = iconBase = register.registerIcon(General.getName(this) + "base");
|
||||
iconSpike = register.registerIcon(General.getName(this) + "spike");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import com.cricketcraft.chisel.client.render.BlockTexturedOreRenderer;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class BlockTexturedOre extends Block
|
||||
{
|
||||
public int currentPass;
|
||||
public Block base;
|
||||
public IIcon icon;
|
||||
String iconFile;
|
||||
|
||||
public BlockTexturedOre(Material mat, Block base)
|
||||
{
|
||||
super(mat);
|
||||
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
public BlockTexturedOre(Material mat, String iconFile)
|
||||
{
|
||||
super(mat);
|
||||
|
||||
this.iconFile = iconFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return BlockTexturedOreRenderer.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderInPass(int pass)
|
||||
{
|
||||
currentPass = pass;
|
||||
|
||||
return pass == 1 || pass == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register)
|
||||
{
|
||||
if(iconFile != null)
|
||||
icon = register.registerIcon(iconFile);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
public class BlockVoidstone extends BlockMarbleTexturedOre {
|
||||
|
||||
public BlockVoidstone(String s) {
|
||||
super(Material.rock, s);
|
||||
setHardness(5.0F);
|
||||
setResistance(10.0F);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.init.ModTabs;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class BlockVoidstonePillar extends Block implements ICarvable{
|
||||
|
||||
public static IIcon topBottom, pillarSide;
|
||||
public CarvableHelper carvableHelper;
|
||||
private boolean isAnimated;
|
||||
|
||||
public BlockVoidstonePillar(boolean isAnimated) {
|
||||
super(Material.rock);
|
||||
carvableHelper = new CarvableHelper();
|
||||
setHardness(5.0F);
|
||||
setResistance(10.0F);
|
||||
setCreativeTab(ModTabs.tabChiselBlocks);
|
||||
this.isAnimated = isAnimated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta){
|
||||
if(side == 0 || side == 1){
|
||||
return topBottom;
|
||||
} else {
|
||||
return pillarSide;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister icon){
|
||||
if(this.isAnimated)
|
||||
topBottom = icon.registerIcon(Chisel.MOD_ID + ":voidstone/animated/pillar-top");
|
||||
else
|
||||
topBottom = icon.registerIcon(Chisel.MOD_ID + ":voidstone/pillar-top");
|
||||
|
||||
pillarSide = icon.registerIcon(Chisel.MOD_ID + ":voidstone/pillar-side");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarvableVariation getVariation(int metadata) {
|
||||
return carvableHelper.getVariation(metadata);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
public class BlockWaterstone extends BlockMarbleTexturedOre {
|
||||
public BlockWaterstone(Material mat, String baseIcon) {
|
||||
super(mat, baseIcon);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.cricketcraft.chisel.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class ItemBlockAutoChisel extends ItemBlock{
|
||||
|
||||
private final String[] names = {"base", "speed", "automation", "stack"};
|
||||
private int metadata;
|
||||
|
||||
public ItemBlockAutoChisel(Block block) {
|
||||
super(block);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int meta){
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemStack){
|
||||
return getUnlocalizedName() + "." + names[itemStack.getItemDamage()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4){
|
||||
list.add(StatCollector.translateToLocal(getUnlocalizedName() + "." + names[itemStack.getItemDamage()] + ".desc"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
package com.cricketcraft.chisel.block.tileentity;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
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 cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityAutoChisel extends TileEntity implements ISidedInventory {
|
||||
|
||||
private static EntityItem ghostItem;
|
||||
boolean equal = false;
|
||||
private ItemStack[] inventory = new ItemStack[3];
|
||||
private String name = "autoChisel";
|
||||
|
||||
@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() {
|
||||
if (!worldObj.isRemote && worldObj.getWorldTime() % 20 == 0) {
|
||||
if (inventory[0] != null && inventory[1] != null) {
|
||||
if (inventory[0].getItem() instanceof ItemBlock && inventory[1].getItem() instanceof ItemBlock) {
|
||||
if (inventory[0].getItem() == inventory[1].getItem()) {
|
||||
equal = true;
|
||||
} else {
|
||||
equal = false;
|
||||
}
|
||||
if (equal) {
|
||||
if (inventory[0].stackSize < 0) {
|
||||
inventory[0] = null;
|
||||
}
|
||||
|
||||
if (inventory[1].stackSize < 0) {
|
||||
inventory[1] = null;
|
||||
}
|
||||
|
||||
if (inventory[1].stackSize < 0) {
|
||||
inventory[1] = null;
|
||||
}
|
||||
|
||||
if (inventory[2] == null) {
|
||||
setInventorySlotContents(2, new ItemStack(inventory[1].getItem(), 1, inventory[1].getItemDamage()));
|
||||
decrStackSize(0, 1);
|
||||
} else {
|
||||
if (inventory[0].stackSize != 0 && inventory[2].stackSize <= getInventoryStackLimit()) {
|
||||
decrStackSize(0, 1);
|
||||
inventory[2].stackSize++;
|
||||
} else {
|
||||
inventory[0] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
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[3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack itemStack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack itemStack, int side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack itemStack, int side) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
NBTTagList tags = new NBTTagList();
|
||||
System.out.print(tags);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public EntityItem getItemForRendering(int slot) {
|
||||
if (ghostItem == null) {
|
||||
ghostItem = new EntityItem(worldObj);
|
||||
ghostItem.hoverStart = 0.0F;
|
||||
}
|
||||
|
||||
if (inventory[slot] == null) {
|
||||
return null;
|
||||
} else {
|
||||
ghostItem.setEntityItemStack(new ItemStack(inventory[slot].getItem(), 1, inventory[slot].getItemDamage()));
|
||||
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());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
package com.cricketcraft.chisel.block.tileentity;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.cricketcraft.chisel.block.BlockPresent;
|
||||
import com.cricketcraft.chisel.inventory.ContainerPresent;
|
||||
import com.cricketcraft.chisel.inventory.InventoryLargePresent;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
||||
public class TileEntityPresent extends TileEntityChest {
|
||||
|
||||
public TileEntityPresent() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return this.worldObj.getTileEntity(xCoord, yCoord, zCoord) != this ? false : player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64.0D;
|
||||
}
|
||||
|
||||
public void checkIfAdjacentBlocksAreMe(TileEntityPresent tile, int meta) {
|
||||
if (tile.isInvalid()) {
|
||||
this.adjacentChestChecked = false;
|
||||
} else if (this.adjacentChestChecked) {
|
||||
switch (meta) {
|
||||
case 0:
|
||||
if (this.adjacentChestZPos != tile) {
|
||||
this.adjacentChestChecked = false;
|
||||
}
|
||||
|
||||
break;
|
||||
case 1:
|
||||
if (this.adjacentChestXNeg != tile) {
|
||||
this.adjacentChestChecked = false;
|
||||
}
|
||||
|
||||
break;
|
||||
case 2:
|
||||
if (this.adjacentChestZNeg != tile) {
|
||||
this.adjacentChestChecked = false;
|
||||
}
|
||||
|
||||
break;
|
||||
case 3:
|
||||
if (this.adjacentChestXPos != tile) {
|
||||
this.adjacentChestChecked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkForAdjacentPresents() {
|
||||
if (!this.adjacentChestChecked) {
|
||||
TileEntityPresent zNeg = (TileEntityPresent) this.adjacentChestZNeg;
|
||||
TileEntityPresent xPos = (TileEntityPresent) this.adjacentChestXPos;
|
||||
TileEntityPresent xNeg = (TileEntityPresent) this.adjacentChestXNeg;
|
||||
TileEntityPresent zPos = (TileEntityPresent) this.adjacentChestZPos;
|
||||
this.adjacentChestChecked = true;
|
||||
|
||||
if (this.isBlockPresent(xCoord - 1, yCoord, zCoord)) {
|
||||
xNeg = (TileEntityPresent) this.worldObj.getTileEntity(xCoord - 1, yCoord, zCoord);
|
||||
}
|
||||
|
||||
if (this.isBlockPresent(xCoord + 1, yCoord, zCoord)) {
|
||||
xPos = (TileEntityPresent) this.worldObj.getTileEntity(xCoord + 1, yCoord, zCoord);
|
||||
}
|
||||
|
||||
if (this.isBlockPresent(xCoord, yCoord, zCoord - 1)) {
|
||||
zNeg = (TileEntityPresent) this.worldObj.getTileEntity(xCoord, yCoord, zCoord - 1);
|
||||
}
|
||||
|
||||
if (this.isBlockPresent(xCoord, yCoord, zCoord + 1)) {
|
||||
zPos = (TileEntityPresent) this.worldObj.getTileEntity(xCoord, yCoord, zCoord + 1);
|
||||
}
|
||||
|
||||
if (this.adjacentChestZNeg != null) {
|
||||
zNeg.checkIfAdjacentBlocksAreMe(this, 0);
|
||||
}
|
||||
|
||||
if (this.adjacentChestZPos != null) {
|
||||
zPos.checkIfAdjacentBlocksAreMe(this, 2);
|
||||
}
|
||||
|
||||
if (this.adjacentChestXPos != null) {
|
||||
xPos.checkIfAdjacentBlocksAreMe(this, 1);
|
||||
}
|
||||
|
||||
if (this.adjacentChestXNeg != null) {
|
||||
xNeg.checkIfAdjacentBlocksAreMe(this, 3);
|
||||
}
|
||||
|
||||
this.adjacentChestXNeg = xNeg;
|
||||
this.adjacentChestXPos = xPos;
|
||||
this.adjacentChestZPos = zPos;
|
||||
this.adjacentChestZNeg = zNeg;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isBlockPresent(int x, int y, int z) {
|
||||
if (this.worldObj == null) {
|
||||
return false;
|
||||
} else {
|
||||
Block block = this.worldObj.getBlock(x, y, z);
|
||||
return block instanceof BlockPresent;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
checkForAdjacentPresents();
|
||||
float f;
|
||||
|
||||
if (!worldObj.isRemote && numPlayersUsing != 0 && (+xCoord + yCoord + zCoord) % 200 == 0) {
|
||||
numPlayersUsing = 0;
|
||||
f = 5.0F;
|
||||
List<?> list = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord - f, yCoord - f, zCoord - f, (xCoord + 1) + f, (yCoord + 1) + f, (zCoord + 1) + f));
|
||||
Iterator<?> iterator = list.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
EntityPlayer player = (EntityPlayer) iterator.next();
|
||||
|
||||
if (player.openContainer instanceof ContainerPresent) {
|
||||
IInventory inventory = ((ContainerPresent) player.openContainer).getLowerPresentInventory();
|
||||
|
||||
if (inventory == this || inventory instanceof InventoryLargePresent && ((InventoryLargePresent) inventory).isPartOfLargePresent(this)) {
|
||||
++numPlayersUsing;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prevLidAngle = lidAngle;
|
||||
f = 0.1F;
|
||||
double d2;
|
||||
|
||||
if (numPlayersUsing > 0 && lidAngle == 0.0F && adjacentChestZNeg == null && adjacentChestXNeg == null) {
|
||||
double d1 = xCoord + 0.5D;
|
||||
d2 = xCoord + 0.5D;
|
||||
if (adjacentChestZPos != null) {
|
||||
d2 += 0.5D;
|
||||
}
|
||||
|
||||
if (adjacentChestXPos != null) {
|
||||
d1 += 0.5D;
|
||||
}
|
||||
|
||||
worldObj.playSoundEffect(d1, yCoord + 0.5D, d2, "random.chestopen", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F);
|
||||
}
|
||||
|
||||
if (numPlayersUsing == 0 && lidAngle > 0.0F || numPlayersUsing > 0 && lidAngle < 1.0F) {
|
||||
float f1 = lidAngle;
|
||||
|
||||
if (numPlayersUsing > 0) {
|
||||
lidAngle += f;
|
||||
} else {
|
||||
lidAngle -= f;
|
||||
}
|
||||
|
||||
if (lidAngle > 1.0F) {
|
||||
lidAngle = 1.0F;
|
||||
}
|
||||
|
||||
float f2 = 0.5F;
|
||||
|
||||
if (lidAngle < f2 && f1 >= f2 && adjacentChestZNeg == null && adjacentChestXNeg == null) {
|
||||
d2 = xCoord + 0.5D;
|
||||
double d0 = zCoord + 0.5D;
|
||||
|
||||
if (adjacentChestZPos != null) {
|
||||
d0 += 0.5D;
|
||||
}
|
||||
|
||||
if (adjacentChestXPos != null) {
|
||||
d2 += 0.5D;
|
||||
}
|
||||
|
||||
worldObj.playSoundEffect(d2, yCoord + 0.5D, d0, "random.chestclosed", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F);
|
||||
}
|
||||
|
||||
if (lidAngle < 0.0F) {
|
||||
lidAngle = 0.0F;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
if (numPlayersUsing < 0) {
|
||||
numPlayersUsing = 0;
|
||||
}
|
||||
|
||||
++numPlayersUsing;
|
||||
worldObj.addBlockEvent(xCoord, yCoord, zCoord, getBlockType(), 1, numPlayersUsing);
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType());
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, getBlockType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
if (getBlockType() instanceof BlockPresent) {
|
||||
--numPlayersUsing;
|
||||
worldObj.addBlockEvent(xCoord, yCoord, zCoord, getBlockType(), 1, numPlayersUsing);
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType());
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, getBlockType());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
updateContainingBlockInfo();
|
||||
checkForAdjacentPresents();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user