Chisel 1.5.3

This commit is contained in:
asiekierka committed 2014-03-18 19:29:34 +01:00
1 parent 1525907cdd
commit 48e0c168b6
20 files changed
+1301 -1839

No files matched your search

@@ -19,11 +19,11 @@ public class Carving {
public static Carving needle=new Carving();
String key(Item item,int metadata){
return item.getUnlocalizedName()+"|"+metadata;
return Item.itemRegistry.getNameForObject(item)+"|"+metadata;
}
String key(Block block, int metadata){
return block.getUnlocalizedName()+"|"+metadata;
return Block.blockRegistry.getNameForObject(block)+"|"+metadata;
}
public boolean isVariationOfSameClass(Block target,int metadata1, Block block2, int metadata2){
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -1,13 +1,8 @@
package info.jbcs.minecraft.chisel;
import info.jbcs.minecraft.utilities.General;
import info.jbcs.minecraft.utilities.packets.PacketData;
import info.jbcs.minecraft.utilities.packets.PacketHandler;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import info.jbcs.minecraft.utilities.General;
import pl.asie.lib.network.MessageHandlerBase;
import pl.asie.lib.network.Packet;
import net.minecraft.block.Block;
@@ -3,8 +3,8 @@ package info.jbcs.minecraft.chisel.block;
import net.minecraft.block.material.Material;
import net.minecraft.world.IBlockAccess;
public class BlockPoweredMarble extends BlockCarvable {
public BlockPoweredMarble(Material m) {
public class BlockCarvablePowered extends BlockCarvable {
public BlockCarvablePowered(Material m) {
super(m);
}
@@ -2,6 +2,7 @@ package info.jbcs.minecraft.chisel.block;
import info.jbcs.minecraft.chisel.CarvableHelper;
import info.jbcs.minecraft.chisel.Chisel;
import info.jbcs.minecraft.chisel.ChiselBlocks;
import java.util.Random;
@@ -19,12 +20,12 @@ public class BlockMarbleIceStairs extends BlockMarbleStairs {
@Override
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) {
Chisel.blockIce.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
ChiselBlocks.blockIce.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
}
@Override
public int quantityDropped(Random par1Random) {
return Chisel.blockIce.quantityDropped(par1Random);
return ChiselBlocks.blockIce.quantityDropped(par1Random);
}
@Override
public int damageDropped(int i) {
@@ -33,7 +34,7 @@ public class BlockMarbleIceStairs extends BlockMarbleStairs {
@Override
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
Chisel.blockIce.updateTick(par1World, par2, par3, par4, par5Random);
ChiselBlocks.blockIce.updateTick(par1World, par2, par3, par4, par5Random);
}
@Override
@@ -22,15 +22,15 @@ public class BlockMarbleStairsMaker {
blockBase=base;
}
public void create(){
create(null);
public void create(String name){
create(null, name);
}
public void create(BlockMarbleStairsMakerCreator creator){
public void create(BlockMarbleStairsMakerCreator creator, String name){
blocks=new BlockMarbleStairs[carverHelper.variations.size()/2];
for(int i=0;i<blocks.length;i++){
String n=blockName+"."+i;
String n=name+"."+i;
blocks[i]=creator==null?
new BlockMarbleStairs(blockBase, i*2, carverHelper):
creator.create(blockBase, i*2, carverHelper);
@@ -42,7 +42,7 @@ public class BlockMarbleStairsMaker {
CarvableVariation variation=carverHelper.variations.get(i*2+meta);
for(int j=0;j<8;j++)
carverHelper.registerVariation(blockName+".orientation."+j,variation,blocks[i],j+meta*8);
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)});
}
@@ -1,6 +1,7 @@
package info.jbcs.minecraft.chisel.entity;
import info.jbcs.minecraft.chisel.Chisel;
import info.jbcs.minecraft.chisel.ChiselBlocks;
import info.jbcs.minecraft.chisel.GeneralChiselClient;
import info.jbcs.minecraft.utilities.General;
import net.minecraft.block.Block;
@@ -91,10 +92,10 @@ public class EntityBallOMoss extends EntityThrowable {
resBlock = Blocks.mossy_cobblestone;
} else if(block.equals(Blocks.cobblestone_wall) && meta==0){
resMeta=1;
} else if(block.equals(Chisel.blockCobblestone)){
resBlock=Chisel.blockCobblestoneMossy;
} else if(block.equals(Chisel.blockTemple)){
resBlock=Chisel.blockTempleMossy;
} else if(block.equals(ChiselBlocks.blockCobblestone)){
resBlock=ChiselBlocks.blockCobblestoneMossy;
} else if(block.equals(ChiselBlocks.blockTemple)){
resBlock=ChiselBlocks.blockTempleMossy;
}
if(resBlock.equals(block) && resMeta==meta) return;
@@ -1,6 +1,7 @@
package info.jbcs.minecraft.chisel.entity;
import info.jbcs.minecraft.chisel.Chisel;
import info.jbcs.minecraft.chisel.ChiselBlocks;
import java.util.Random;
@@ -96,7 +97,7 @@ public class EntityCloudInABottle extends EntityThrowable {
for (int k2 = y; k2 < y + random.nextInt(1) + 2; k2++) {
for (int l2 = z; l2 < z + random.nextInt(4) + 1; l2++) {
if (world.getBlock(j2, k2, l2).isAir(world, j2, k2, l2) && Math.abs(j2 - x) + Math.abs(k2 - y) + Math.abs(l2 - z) < 4 * 1 + random.nextInt(2)) {
world.setBlock(j2, k2, l2, Chisel.blockCloud);
world.setBlock(j2, k2, l2, ChiselBlocks.blockCloud);
count++;
}
}
@@ -4,13 +4,11 @@ import info.jbcs.minecraft.chisel.CarvableHelper;
import info.jbcs.minecraft.chisel.Carving;
import info.jbcs.minecraft.chisel.CarvingVariation;
import info.jbcs.minecraft.chisel.Chisel;
import info.jbcs.minecraft.chisel.ChiselBlocks;
import info.jbcs.minecraft.chisel.GeneralChiselClient;
import info.jbcs.minecraft.chisel.Packets;
import info.jbcs.minecraft.utilities.General;
import info.jbcs.minecraft.utilities.packets.PacketData;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Random;
@@ -71,6 +69,8 @@ public class ItemChisel extends ItemTool {
@Override
public boolean onBlockStartBreak(ItemStack stack, final int x, final int y, final int z, EntityPlayer player){
if(!Chisel.enableChiseling) return true;
World world=player.worldObj;
Block block = world.getBlock(x, y, z);
int blockMeta=world.getBlockMetadata(x,y,z);
@@ -86,7 +86,11 @@ public class ItemChisel extends ItemTool {
boolean chiselHasBlockInside=true;
boolean noReplace = false;
if(chiselTarget==null){
chiselHasBlockInside=false;
Long useTime=chiselUseTime.get(player.getCommandSenderName());
String loc=chiselUseLocation.get(player.getCommandSenderName());
@@ -94,65 +98,76 @@ public class ItemChisel extends ItemTool {
long cooldown=20;
long time=world.getWorldInfo().getWorldTotalTime();
if(time>useTime-cooldown && time<useTime+cooldown)
return true;
//if(time>useTime-cooldown && time<useTime+cooldown) noReplace = true;
}
CarvingVariation[] variations=carving.getVariations(block, blockMeta);
if(variations==null || variations.length<2) return true;
int index=random.nextInt(variations.length-1);
if(variations[index].equals(block) && variations[index].meta==blockMeta){
index++;
if(index>=variations.length) index=0;
if(variations==null || variations.length<2) noReplace = true;
else {
int index=random.nextInt(variations.length-1);
while (variations[index].block.equals(block) && variations[index].damage==blockMeta){
index++;
if(index>=variations.length) index=0;
}
CarvingVariation var=variations[index];
chiselTarget=new ItemStack(var.block,1,var.damage);
}
CarvingVariation var=variations[index];
chiselTarget=new ItemStack(var.block,1,var.damage);
}
Item result = null;
int targetMeta = 0;
if(!noReplace) {
Item target = chiselTarget.getItem();
chiselHasBlockInside=false;
targetMeta=chiselTarget.getItemDamage();
boolean match = carving.isVariationOfSameClass(Block.getBlockFromItem(target),targetMeta,block,blockMeta);
result = target;
/* special case: stone can be carved to cobble and bricks */
if(Chisel.chiselStoneToCobbleBricks) {
if(!match && block.equals(Blocks.stone) && Block.getBlockFromItem(target).equals(ChiselBlocks.blockCobblestone))
match=true;
if(!match && block.equals(Blocks.stone) && Block.getBlockFromItem(target).equals(ChiselBlocks.stoneBrick))
match=true;
}
if(match == false) noReplace = true;
}
Item target = chiselTarget.getItem();
int updateValue = 2;
int targetMeta=chiselTarget.getItemDamage();
boolean match=carving.isVariationOfSameClass(Block.getBlockFromItem(target),targetMeta,block,blockMeta);
Item result = target;
if(noReplace) {
result = Item.getItemFromBlock(block);
targetMeta = blockMeta;
}
if(Block.getBlockFromItem(result).equals(block) && targetMeta == blockMeta) updateValue |= 4;
//if(Block.getBlockFromItem(result) == null) return true;
/* special case: stone can be carved to cobble and bricks */
if(!match && block.equals(Blocks.stone) && Block.getBlockFromItem(target).equals(Chisel.blockCobblestone))
match=true;
if(!match && block.equals(Blocks.stone) && Block.getBlockFromItem(target).equals(Chisel.stoneBrick))
match=true;
if(!match) return true;
if(result.equals(block) && targetMeta == blockMeta) return true;
if(! world.isRemote || chiselHasBlockInside)
world.setBlock(x, y, z, Block.getBlockFromItem(result), chiselTarget.getItemDamage(), 2);
if(! world.isRemote || chiselHasBlockInside) {
System.out.println("Changing to " + Item.itemRegistry.getNameForObject(result) + ":" + chiselTarget.getItemDamage());
world.setBlock(x, y, z, Block.getBlockFromItem(result), targetMeta, updateValue);
}
switch(FMLCommonHandler.instance().getEffectiveSide()){
case SERVER:
chiselUseTime.put(player.getCommandSenderName(), world.getWorldInfo().getWorldTotalTime());
chiselUseLocation.put(player.getCommandSenderName(),x+"|"+y+"|"+z);
try {
Packet packet = Chisel.packet.create(Packets.CHISELED).writeInt(x).writeInt(y).writeInt(z);
Chisel.packet.sendToAllAround(packet, new TargetPoint(player.dimension, x, y, z, 30.0f));
} catch(Exception e) { e.printStackTrace(); }
break;
case CLIENT:
if(chiselHasBlockInside){
String sound=carving.getVariationSound(result, chiselTarget.getItemDamage());
GeneralChiselClient.spawnChiselEffect(x, y, z, sound);
}
break;
default:
break;
case SERVER:
chiselUseTime.put(player.getCommandSenderName(), world.getWorldInfo().getWorldTotalTime());
chiselUseLocation.put(player.getCommandSenderName(),x+"|"+y+"|"+z);
try {
Packet packet = Chisel.packet.create(Packets.CHISELED).writeInt(x).writeInt(y).writeInt(z);
Chisel.packet.sendToAllAround(packet, new TargetPoint(player.dimension, x, y, z, 30.0f));
} catch(Exception e) { e.printStackTrace(); }
break;
case CLIENT:
if(chiselHasBlockInside){
String sound=carving.getVariationSound(result, chiselTarget.getItemDamage());
GeneralChiselClient.spawnChiselEffect(x, y, z, sound);
}
break;
default:
break;
}
stack.damageItem(1, player);
@@ -1,6 +1,7 @@
package info.jbcs.minecraft.chisel.render;
import info.jbcs.minecraft.chisel.Chisel;
import info.jbcs.minecraft.chisel.ChiselBlocks;
import info.jbcs.minecraft.utilities.Drawing;
import java.util.Random;
@@ -66,7 +67,7 @@ public class BlockSpikesRenderer implements ISimpleBlockRenderingHandler {
renderer.renderStandardBlock(block, x, y, z);
Tessellator tessellator=Tessellator.instance;
IIcon icon=Chisel.blockSpiketrap.iconSpike;
IIcon icon=ChiselBlocks.blockSpiketrap.iconSpike;
// Icon icon=Chisel.blockSpiketrap.iconBase;
double h=0.85;