2015-08-18 20:40:55 -04:00
|
|
|
package team.chisel.block;
|
2014-12-15 00:11:48 +00:00
|
|
|
|
2015-08-18 20:40:55 -04:00
|
|
|
import com.cricketcraft.chisel.api.ICarvable;
|
|
|
|
|
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
|
|
|
|
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
|
|
|
|
|
|
|
|
|
import team.chisel.Chisel;
|
|
|
|
|
import team.chisel.entity.EntityChiselSnowman;
|
2015-02-22 02:29:43 +00:00
|
|
|
import net.minecraft.block.Block;
|
2015-01-07 19:50:18 -05:00
|
|
|
import net.minecraft.block.BlockPumpkin;
|
|
|
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
2015-03-08 16:48:05 -04:00
|
|
|
import net.minecraft.entity.monster.EntityIronGolem;
|
|
|
|
|
import net.minecraft.init.Blocks;
|
2015-01-15 13:09:34 -05:00
|
|
|
import net.minecraft.item.ItemStack;
|
2015-01-07 19:50:18 -05:00
|
|
|
import net.minecraft.util.IIcon;
|
2015-01-15 13:09:34 -05:00
|
|
|
import net.minecraft.world.IBlockAccess;
|
2015-04-23 20:33:29 -04:00
|
|
|
import net.minecraft.world.World;
|
2014-12-15 14:24:31 -05:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
|
2015-01-07 19:50:18 -05:00
|
|
|
public class BlockCarvablePumpkin extends BlockPumpkin implements ICarvable {
|
|
|
|
|
|
|
|
|
|
public CarvableHelper carverHelper;
|
|
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
|
private IIcon top, face;
|
|
|
|
|
|
|
|
|
|
private String faceLocation;
|
|
|
|
|
|
|
|
|
|
public BlockCarvablePumpkin(boolean isOn) {
|
|
|
|
|
super(isOn);
|
2015-02-22 02:29:43 +00:00
|
|
|
this.setStepSound(Block.soundTypeWood);
|
2015-01-07 19:50:18 -05:00
|
|
|
if (isOn)
|
|
|
|
|
setLightLevel(10.0F);
|
2015-04-23 20:33:29 -04:00
|
|
|
carverHelper = new CarvableHelper(this);
|
2015-01-07 19:50:18 -05:00
|
|
|
}
|
|
|
|
|
|
2015-08-06 00:00:22 -04:00
|
|
|
@Override
|
|
|
|
|
public void onBlockAdded(World world, int x, int y, int z) {
|
|
|
|
|
if (world.getBlock(x, y - 1, z) == Blocks.snow && world.getBlock(x, y - 2, z) == Blocks.snow) {
|
|
|
|
|
if (!world.isRemote) {
|
|
|
|
|
// Let's grab the pumpkin before we start
|
|
|
|
|
ItemStack pumpkin = new ItemStack(world.getBlock(x, y, z), world.getBlockMetadata(x, y, z));
|
|
|
|
|
|
|
|
|
|
world.setBlock(x, y, z, Blocks.air, 0, 2);
|
|
|
|
|
world.setBlock(x, y - 1, z, Blocks.air, 0, 2);
|
|
|
|
|
world.setBlock(x, y - 2, z, Blocks.air, 0, 2);
|
|
|
|
|
EntityChiselSnowman snowman = new EntityChiselSnowman(world);
|
|
|
|
|
snowman.setCurrentItemOrArmor(2, pumpkin);
|
|
|
|
|
snowman.setLocationAndAngles(x + 0.5D, y - 1.95D, z + 0.5D, 0.0F, 0.0F);
|
|
|
|
|
world.spawnEntityInWorld(snowman);
|
|
|
|
|
world.notifyBlockChange(x, y, z, Blocks.air);
|
|
|
|
|
world.notifyBlockChange(x, y - 1, z, Blocks.air);
|
|
|
|
|
world.notifyBlockChange(x, y - 2, z, Blocks.air);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Spawn some lovely particles
|
|
|
|
|
for (int c = 0; c < 120; ++c) {
|
|
|
|
|
world.spawnParticle("snowshovel", x + world.rand.nextDouble(), y - 2 + world.rand.nextDouble() * 2.5D, z + world.rand.nextDouble(), 0.0D, 0.0D, 0.0D);
|
|
|
|
|
}
|
|
|
|
|
} else if (world.getBlock(x, y - 1, z) == Blocks.iron_block || world.getBlock(x, y - 2, z) == Blocks.iron_block) {
|
|
|
|
|
boolean flag = world.getBlock(x - 1, y - 1, z) == Blocks.iron_block && world.getBlock(x + 1, y - 1, z) == Blocks.iron_block;
|
|
|
|
|
boolean flag1 = world.getBlock(x, y - 1, z - 1) == Blocks.iron_block && world.getBlock(x, y - 1, z + 1) == Blocks.iron_block;
|
|
|
|
|
|
|
|
|
|
if (flag || flag1) {
|
|
|
|
|
world.setBlock(x, y, z, Blocks.air, 0, 2);
|
|
|
|
|
world.setBlock(x, y - 1, z, Blocks.air, 0, 2);
|
|
|
|
|
world.setBlock(x, y - 2, z, Blocks.air, 0, 2);
|
|
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
|
world.setBlock(x - 1, y - 1, z, Blocks.air, 0, 2);
|
|
|
|
|
world.setBlock(x + 1, y - 1, z, Blocks.air, 0, 2);
|
|
|
|
|
} else {
|
|
|
|
|
world.setBlock(x, y - 1, z - 1, Blocks.air, 0, 2);
|
|
|
|
|
world.setBlock(x, y - 1, z + 1, Blocks.air, 0, 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EntityIronGolem ironGolem = new EntityIronGolem(world);
|
|
|
|
|
ironGolem.setPlayerCreated(true);
|
|
|
|
|
ironGolem.setLocationAndAngles(x + 0.5D, y - 1.95D, z + 0.5D, 0.0F, 0.0F);
|
|
|
|
|
world.spawnEntityInWorld(ironGolem);
|
|
|
|
|
|
|
|
|
|
world.notifyBlockChange(x, y, z, Blocks.air);
|
|
|
|
|
world.notifyBlockChange(x, y - 1, z, Blocks.air);
|
|
|
|
|
world.notifyBlockChange(x, y - 2, z, Blocks.air);
|
|
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
|
world.notifyBlockChange(x - 1, y - 1, z, Blocks.air);
|
|
|
|
|
world.notifyBlockChange(x + 1, y - 1, z, Blocks.air);
|
|
|
|
|
} else {
|
|
|
|
|
world.notifyBlockChange(x, y - 1, z - 1, Blocks.air);
|
|
|
|
|
world.notifyBlockChange(x, y - 1, z + 1, Blocks.air);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-03-08 16:48:05 -04:00
|
|
|
|
2015-01-07 19:50:18 -05:00
|
|
|
@Override
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
|
public IIcon getIcon(int side, int meta) {
|
|
|
|
|
return side == 1 ? top : (side == 0 ? top : (meta == 2 && side == 2 ? face : (meta == 3 && side == 5 ? face
|
|
|
|
|
: (meta == 0 && side == 3 ? face : (meta == 1 && side == 4 ? face : this.blockIcon)))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void registerBlockIcons(IIconRegister icon) {
|
|
|
|
|
top = icon.registerIcon(Chisel.MOD_ID + ":pumpkin/pumpkin_top");
|
|
|
|
|
face = icon.registerIcon(Chisel.MOD_ID + ":" + faceLocation);
|
|
|
|
|
this.blockIcon = icon.registerIcon(Chisel.MOD_ID + ":pumpkin/pumpkin_side");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2015-07-15 00:35:00 -04:00
|
|
|
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
|
2015-01-07 19:50:18 -05:00
|
|
|
return carverHelper.getVariation(metadata);
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-15 13:09:34 -05:00
|
|
|
@Override
|
2015-07-15 00:35:00 -04:00
|
|
|
public IVariationInfo getManager(int meta) {
|
|
|
|
|
return carverHelper.getVariation(meta);
|
2015-01-15 13:09:34 -05:00
|
|
|
}
|
|
|
|
|
|
2015-01-07 19:50:18 -05:00
|
|
|
public void setInformation(String textureLocation) {
|
|
|
|
|
this.faceLocation = textureLocation;
|
|
|
|
|
}
|
2014-10-08 18:57:34 +01:00
|
|
|
}
|