mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
gutted tool abilities, small fixes
This commit is contained in:
parent
776a203f8a
commit
14450d36de
@ -12,7 +12,6 @@ import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
@ -14,12 +14,9 @@ import com.hbm.inventory.recipes.CrystallizerRecipes;
|
||||
import com.hbm.inventory.recipes.ShredderRecipes;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.tool.IItemAbility;
|
||||
import com.hbm.util.EnchantmentUtil;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
@ -29,8 +26,10 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class ToolAbility {
|
||||
|
||||
public abstract void onDig(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, IItemAbility tool);
|
||||
|
||||
//how to potentially save this: cancel the event/operation so that ItemInWorldManager's harvest method falls short, then recreate it with a more sensible structure
|
||||
public void onDigPre(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, IItemAbility tool) { }
|
||||
public void onDigPost(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, IItemAbility tool) { }
|
||||
public abstract String getName();
|
||||
public abstract String getFullName();
|
||||
public abstract String getExtension();
|
||||
@ -47,7 +46,7 @@ public abstract class ToolAbility {
|
||||
private Set<ThreeInts> pos = new HashSet();
|
||||
|
||||
@Override
|
||||
public void onDig(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, IItemAbility tool) {
|
||||
public void onDigPre(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, IItemAbility tool) {
|
||||
|
||||
Block b = world.getBlock(x, y, z);
|
||||
|
||||
@ -161,7 +160,7 @@ public abstract class ToolAbility {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDig(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, IItemAbility tool) {
|
||||
public void onDigPre(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, IItemAbility tool) {
|
||||
|
||||
for(int a = x - range; a <= x + range; a++) {
|
||||
for(int b = y - range; b <= y + range; b++) {
|
||||
@ -200,7 +199,7 @@ public abstract class ToolAbility {
|
||||
public static class SilkAbility extends ToolAbility {
|
||||
|
||||
@Override
|
||||
public void onDig(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, IItemAbility tool) {
|
||||
public void onDigPre(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, IItemAbility tool) {
|
||||
|
||||
/*//if the tool is already enchanted, do nothing
|
||||
if(EnchantmentHelper.getSilkTouchModifier(player) || player.getHeldItem() == null)
|
||||
@ -216,7 +215,7 @@ public abstract class ToolAbility {
|
||||
world.setBlockToAir(x, y, z);
|
||||
player.getHeldItem().damageItem(1, player);*/
|
||||
|
||||
tool.breakBlockSpecial(world, x, y, z, block, meta, player, 0, true);
|
||||
//tool.breakBlockSpecial(world, x, y, z, block, meta, player, 0, true); //TODO: replace
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -249,7 +248,7 @@ public abstract class ToolAbility {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDig(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, IItemAbility tool) {
|
||||
public void onDigPre(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, IItemAbility tool) {
|
||||
|
||||
/*//if the tool is already enchanted, do nothing
|
||||
if(EnchantmentHelper.getFortuneModifier(player) > 0 || player.getHeldItem() == null)
|
||||
@ -267,7 +266,7 @@ public abstract class ToolAbility {
|
||||
|
||||
|
||||
|
||||
tool.breakBlockSpecial(world, x, y, z, block, meta, player, luck, false);
|
||||
//tool.breakBlockSpecial(world, x, y, z, block, meta, player, luck, false); //TODO: replace
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -294,7 +293,7 @@ public abstract class ToolAbility {
|
||||
public static class SmelterAbility extends ToolAbility {
|
||||
|
||||
@Override
|
||||
public void onDig(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, IItemAbility tool) {
|
||||
public void onDigPre(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, IItemAbility tool) {
|
||||
|
||||
List<ItemStack> drops = block.getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
|
||||
|
||||
@ -340,7 +339,7 @@ public abstract class ToolAbility {
|
||||
public static class ShredderAbility extends ToolAbility {
|
||||
|
||||
@Override
|
||||
public void onDig(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, IItemAbility tool) {
|
||||
public void onDigPre(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, IItemAbility tool) {
|
||||
|
||||
//a band-aid on a gaping wound
|
||||
if(block == Blocks.lit_redstone_ore)
|
||||
@ -380,7 +379,7 @@ public abstract class ToolAbility {
|
||||
public static class CentrifugeAbility extends ToolAbility {
|
||||
|
||||
@Override
|
||||
public void onDig(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, IItemAbility tool) {
|
||||
public void onDigPre(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, IItemAbility tool) {
|
||||
|
||||
//a band-aid on a gaping wound
|
||||
if(block == Blocks.lit_redstone_ore)
|
||||
@ -424,7 +423,7 @@ public abstract class ToolAbility {
|
||||
public static class CrystallizerAbility extends ToolAbility {
|
||||
|
||||
@Override
|
||||
public void onDig(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, IItemAbility tool) {
|
||||
public void onDigPre(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, IItemAbility tool) {
|
||||
|
||||
//a band-aid on a gaping wound
|
||||
if(block == Blocks.lit_redstone_ore)
|
||||
@ -464,7 +463,7 @@ public abstract class ToolAbility {
|
||||
public static class MercuryAbility extends ToolAbility {
|
||||
|
||||
@Override
|
||||
public void onDig(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, IItemAbility tool) {
|
||||
public void onDigPre(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, IItemAbility tool) {
|
||||
|
||||
//a band-aid on a gaping wound
|
||||
if(block == Blocks.lit_redstone_ore)
|
||||
@ -514,7 +513,7 @@ public abstract class ToolAbility {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDig(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, IItemAbility tool) {
|
||||
public void onDigPre(World world, int x, int y, int z, EntityPlayer player, Block block, int meta, IItemAbility tool) {
|
||||
|
||||
ExplosionNT ex = new ExplosionNT(player.worldObj, player, x + 0.5, y + 0.5, z + 0.5, strength);
|
||||
ex.addAttrib(ExAttrib.ALLDROP);
|
||||
|
||||
@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerCraneUnboxer extends Container {
|
||||
|
||||
@ -36,6 +37,35 @@ public class ContainerCraneUnboxer extends Container {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2) {
|
||||
ItemStack var3 = null;
|
||||
Slot var4 = (Slot) this.inventorySlots.get(par2);
|
||||
|
||||
if(var4 != null && var4.getHasStack()) {
|
||||
ItemStack var5 = var4.getStack();
|
||||
var3 = var5.copy();
|
||||
|
||||
if(par2 <= unboxer.getSizeInventory() - 1) {
|
||||
if(!this.mergeItemStack(var5, unboxer.getSizeInventory(), this.inventorySlots.size(), true)) {
|
||||
return null;
|
||||
}
|
||||
} else if(!this.mergeItemStack(var5, 0, unboxer.getSizeInventory(), false)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(var5.stackSize == 0) {
|
||||
var4.putStack((ItemStack) null);
|
||||
} else {
|
||||
var4.onSlotChanged();
|
||||
}
|
||||
|
||||
var4.onPickupFromSlot(p_82846_1_, var5);
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return unboxer.isUseableByPlayer(player);
|
||||
|
||||
@ -169,7 +169,7 @@ public class CyclotronRecipes extends SerializableRecipe {
|
||||
AStack inStack = this.readAStack(input);
|
||||
ItemStack outStack = this.readItemStack(output);
|
||||
|
||||
this.recipes.put(new Pair(partStack, inStack), new Pair(outStack, antimatter));
|
||||
this.recipes.put(new Pair(new ComparableStack(partStack), inStack), new Pair(outStack, antimatter));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,22 +1,15 @@
|
||||
package com.hbm.items.tool;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.play.client.C07PacketPlayerDigging;
|
||||
import net.minecraft.network.play.server.S23PacketBlockChange;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
|
||||
public interface IItemAbility {
|
||||
@ -93,113 +86,4 @@ public interface IItemAbility {
|
||||
Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C07PacketPlayerDigging(2, x, y, z, Minecraft.getMinecraft().objectMouseOver.sideHit));
|
||||
}
|
||||
}
|
||||
|
||||
public default void breakBlockSpecial(World world, int x, int y, int z, Block block, int meta, EntityPlayer playerEntity, int fortune, boolean silkTouch) {
|
||||
|
||||
if(world.isAirBlock(x, y, z))
|
||||
return;
|
||||
|
||||
if(!(playerEntity instanceof EntityPlayerMP))
|
||||
return;
|
||||
|
||||
EntityPlayerMP player = (EntityPlayerMP) playerEntity;
|
||||
|
||||
if(!ForgeHooks.canHarvestBlock(block, player, meta))
|
||||
return;
|
||||
|
||||
BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(world, player.theItemInWorldManager.getGameType(), player, x, y, z);
|
||||
if(event.isCanceled())
|
||||
return;
|
||||
|
||||
if(player.capabilities.isCreativeMode) {
|
||||
block.onBlockHarvested(world, x, y, z, meta, player);
|
||||
if(block.removedByPlayer(world, player, x, y, z, false))
|
||||
block.onBlockDestroyedByPlayer(world, x, y, z, meta);
|
||||
|
||||
if(!world.isRemote) {
|
||||
player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
player.getCurrentEquippedItem().func_150999_a(world, block, x, y, z, player);
|
||||
|
||||
if(!world.isRemote) {
|
||||
|
||||
block.onBlockHarvested(world, x, y, z, meta, player);
|
||||
|
||||
if(block.removedByPlayer(world, player, x, y, z, true)) {
|
||||
block.onBlockDestroyedByPlayer(world, x, y, z, meta);
|
||||
harvestBlock(world, player, x, y, z, block, meta, fortune, silkTouch);
|
||||
if(!silkTouch) block.dropXpOnBlockBreak(world, x, y, z, event.getExpToDrop());
|
||||
}
|
||||
|
||||
player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
|
||||
|
||||
} else {
|
||||
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
|
||||
if(block.removedByPlayer(world, player, x, y, z, true)) {
|
||||
block.onBlockDestroyedByPlayer(world, x, y, z, meta);
|
||||
}
|
||||
ItemStack itemstack = player.getCurrentEquippedItem();
|
||||
if(itemstack != null) {
|
||||
itemstack.func_150999_a(world, block, x, y, z, player);
|
||||
|
||||
if(itemstack.stackSize == 0) {
|
||||
player.destroyCurrentEquippedItem();
|
||||
}
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C07PacketPlayerDigging(2, x, y, z, Minecraft.getMinecraft().objectMouseOver.sideHit));
|
||||
}
|
||||
}
|
||||
|
||||
public default void harvestBlock(World world, EntityPlayer player, int x, int y, int z, Block block, int meta, int fortune, boolean silkTouch) {
|
||||
|
||||
player.addStat(StatList.mineBlockStatArray[block.getIdFromBlock(block)], 1);
|
||||
player.addExhaustion(0.025F);
|
||||
|
||||
if(block.canSilkHarvest(world, player, x, y, z, meta) && silkTouch) {
|
||||
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
|
||||
//block.createStackedBlock(meta);
|
||||
|
||||
/// createStackedBlock ///
|
||||
int j = 0;
|
||||
Item item = Item.getItemFromBlock(block);
|
||||
if(item != null && item.getHasSubtypes()) {
|
||||
j = meta;
|
||||
}
|
||||
ItemStack itemstack = new ItemStack(item, 1, j);
|
||||
/// createStackedBlock ///
|
||||
|
||||
if(itemstack != null) {
|
||||
items.add(itemstack);
|
||||
}
|
||||
|
||||
ForgeEventFactory.fireBlockHarvesting(items, world, block, x, y, z, meta, 0, 1.0f, true, player);
|
||||
for(ItemStack is : items) {
|
||||
dropBlockAsItem(world, x, y, z, is);
|
||||
}
|
||||
} else {
|
||||
//block.harvesters.set(player);
|
||||
block.dropBlockAsItem(world, x, y, z, meta, fortune);
|
||||
//block.harvesters.set(null);
|
||||
}
|
||||
}
|
||||
|
||||
public default void dropBlockAsItem(World world, int x, int y, int z, ItemStack stack) {
|
||||
if(!world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops") && !world.restoringBlockSnapshots) {
|
||||
/*if(captureDrops.get()) {
|
||||
capturedDrops.get().add(stack);
|
||||
return;
|
||||
}*/
|
||||
float f = 0.7F;
|
||||
double d0 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
|
||||
double d1 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
|
||||
double d2 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
|
||||
EntityItem entityitem = new EntityItem(world, (double) x + d0, (double) y + d1, (double) z + d2, stack);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,11 +130,16 @@ public class ItemToolAbility extends ItemTool implements IItemAbility, IDepthRoc
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if(!world.isRemote && canHarvestBlock(block, stack) && this.getCurrentAbility(stack) != null && canOperate(stack))
|
||||
this.getCurrentAbility(stack).onDig(world, x, y, z, player, block, meta, this);
|
||||
this.getCurrentAbility(stack).onDigPre(world, x, y, z, player, block, meta, this);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDigSpeed(ItemStack stack, Block block, int meta) {
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user