mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-24 06:04:38 +00:00
Begin refactor, make CarvingVariation and CarvingGroup interfaces
This commit is contained in:
1 parent
b268ebeca0
commit
155bc00f0e
12 files changed
+206
-75
No files matched your search
@@ -49,28 +49,28 @@ public final class ChiselController {
|
||||
z = event.z;
|
||||
Block block = event.world.getBlock(x, y, z);
|
||||
int metadata = event.world.getBlockMetadata(x, y, z);
|
||||
CarvingVariation[] variations = Carving.chisel.getVariations(block, metadata);
|
||||
CarvingVariation[] variations = Carving.chisel.getVariations(block, metadata).toArray(new CarvingVariation[] {});
|
||||
|
||||
if (variations != null && chisel.canChiselBlock(event.world, x, y, z, block, metadata)) {
|
||||
ItemStack target = General.getChiselTarget(held);
|
||||
|
||||
if (target != null) {
|
||||
for (CarvingVariation v : variations) {
|
||||
if (v.block == Block.getBlockFromItem(target.getItem()) && v.meta == target.getItemDamage()) {
|
||||
if (v.getBlock() == Block.getBlockFromItem(target.getItem()) && v.getBlockMeta() == target.getItemDamage()) {
|
||||
setVariation(event.entityPlayer, event.world, x, y, z, v, target);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < variations.length; i++) {
|
||||
CarvingVariation v = variations[i];
|
||||
if (v.block == block && v.meta == metadata) {
|
||||
if (v.getBlock() == block && v.getBlockMeta() == metadata) {
|
||||
variations = ArrayUtils.remove(variations, i--);
|
||||
}
|
||||
}
|
||||
|
||||
int index = event.world.rand.nextInt(variations.length);
|
||||
CarvingVariation newVar = variations[index];
|
||||
setVariation(event.entityPlayer, event.world, x, y, z, newVar, new ItemStack(newVar.block, 1, newVar.damage));
|
||||
setVariation(event.entityPlayer, event.world, x, y, z, newVar, new ItemStack(newVar.getBlock(), 1, newVar.getItemMeta()));
|
||||
event.entityPlayer.inventory.currentItem = slot;
|
||||
}
|
||||
}
|
||||
@@ -89,8 +89,7 @@ public final class ChiselController {
|
||||
*/
|
||||
private void setVariation(EntityPlayer player, World world, int x, int y, int z, CarvingVariation v, ItemStack target) {
|
||||
PacketHandler.INSTANCE.sendTo(new MessageChiselSound(x, y, z, v), (EntityPlayerMP) player);
|
||||
world.setBlock(x, y, z, v.block);
|
||||
world.setBlockMetadataWithNotify(x, y, z, v.meta, 3);
|
||||
world.setBlock(x, y, z, v.getBlock(), v.getBlockMeta(), 3);
|
||||
((IChiselItem) player.getCurrentEquippedItem().getItem()).onChisel(world, player.inventory, player.inventory.currentItem, player.getCurrentEquippedItem(), target);
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ import com.cricketcraft.chisel.api.ChiselMode;
|
||||
import com.cricketcraft.chisel.api.IChiselItem;
|
||||
import com.cricketcraft.chisel.carving.Carving;
|
||||
import com.cricketcraft.chisel.config.Configurations;
|
||||
import com.cricketcraft.chisel.init.ChiselBlocks;
|
||||
import com.cricketcraft.chisel.utils.GeneralClient;
|
||||
|
||||
public class ItemChisel extends Item implements IChiselItem {
|
||||
@@ -104,10 +103,8 @@ public class ItemChisel extends Item implements IChiselItem {
|
||||
String sound = carving.getVariationSound(target.getItem(), target.getItemDamage());
|
||||
EntityPlayer player = Chisel.proxy.getClientPlayer();
|
||||
GeneralClient.playChiselSound(world, MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ), sound);
|
||||
} else {
|
||||
if (chisel.getItemDamage() >= chisel.getMaxDamage()) {
|
||||
inv.decrStackSize(slot, 1);
|
||||
}
|
||||
} else if (chisel.getItemDamage() >= chisel.getMaxDamage()) {
|
||||
inv.decrStackSize(slot, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user