mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-22 05:02:39 +00:00
[ci skip] spotlessApply with the new settings
This commit is contained in:
1 parent
83698cb73c
commit
84c2239244
561 files changed
+8872
-9300
No files matched your search
@@ -2,6 +2,7 @@ package tconstruct.library.tools;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -17,12 +18,14 @@ import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
|
||||
/* Base class for tools that should be harvesting blocks */
|
||||
|
||||
public abstract class HarvestTool extends ToolCore {
|
||||
|
||||
public HarvestTool(int baseDamage) {
|
||||
super(baseDamage);
|
||||
}
|
||||
@@ -84,7 +87,7 @@ public abstract class HarvestTool extends ToolCore {
|
||||
|
||||
@Override
|
||||
public String[] getTraits() {
|
||||
return new String[] {"harvest"};
|
||||
return new String[] { "harvest" };
|
||||
}
|
||||
|
||||
protected abstract Material[] getEffectiveMaterials();
|
||||
@@ -115,19 +118,11 @@ public abstract class HarvestTool extends ToolCore {
|
||||
|
||||
// Right-click
|
||||
@Override
|
||||
public boolean onItemUse(
|
||||
ItemStack stack,
|
||||
EntityPlayer player,
|
||||
World world,
|
||||
int x,
|
||||
int y,
|
||||
int z,
|
||||
int side,
|
||||
float clickX,
|
||||
float clickY,
|
||||
float clickZ) {
|
||||
/*if (world.isRemote)
|
||||
return true;*/
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side,
|
||||
float clickX, float clickY, float clickZ) {
|
||||
/*
|
||||
* if (world.isRemote) return true;
|
||||
*/
|
||||
|
||||
boolean used = false;
|
||||
int hotbarSlot = player.inventory.currentItem;
|
||||
@@ -165,8 +160,8 @@ public abstract class HarvestTool extends ToolCore {
|
||||
break;
|
||||
}
|
||||
|
||||
AxisAlignedBB blockBounds =
|
||||
AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX + 1, posY + 1, posZ + 1);
|
||||
AxisAlignedBB blockBounds = AxisAlignedBB
|
||||
.getBoundingBox(posX, posY, posZ, posX + 1, posY + 1, posZ + 1);
|
||||
AxisAlignedBB playerBounds = player.boundingBox;
|
||||
|
||||
if (item instanceof ItemBlock) {
|
||||
@@ -201,18 +196,15 @@ public abstract class HarvestTool extends ToolCore {
|
||||
}
|
||||
|
||||
/*
|
||||
if (used) //Update client
|
||||
{
|
||||
Packet103SetSlot packet = new Packet103SetSlot(player.openContainer.windowId, itemSlot, nearbyStack);
|
||||
((EntityPlayerMP)player).playerNetServerHandler.sendPacketToPlayer(packet);
|
||||
}
|
||||
*/
|
||||
* if (used) //Update client { Packet103SetSlot packet = new Packet103SetSlot(player.openContainer.windowId,
|
||||
* itemSlot, nearbyStack); ((EntityPlayerMP)player).playerNetServerHandler.sendPacketToPlayer(packet); }
|
||||
*/
|
||||
|
||||
return used;
|
||||
}
|
||||
|
||||
public void breakExtraBlock(
|
||||
World world, int x, int y, int z, int sidehit, EntityPlayer playerEntity, int refX, int refY, int refZ) {
|
||||
public void breakExtraBlock(World world, int x, int y, int z, int sidehit, EntityPlayer playerEntity, int refX,
|
||||
int refY, int refZ) {
|
||||
// prevent calling that stuff for air blocks, could lead to unexpected behaviour since it fires events
|
||||
if (world.isAirBlock(x, y, z)) return;
|
||||
|
||||
@@ -236,8 +228,8 @@ public abstract class HarvestTool extends ToolCore {
|
||||
if (!ForgeHooks.canHarvestBlock(block, player, meta) || refStrength / strength > 10f) return;
|
||||
|
||||
// send the blockbreak event
|
||||
BlockEvent.BreakEvent event =
|
||||
ForgeHooks.onBlockBreakEvent(world, player.theItemInWorldManager.getGameType(), player, x, y, z);
|
||||
BlockEvent.BreakEvent event = ForgeHooks
|
||||
.onBlockBreakEvent(world, player.theItemInWorldManager.getGameType(), player, x, y, z);
|
||||
if (event.isCanceled()) return;
|
||||
|
||||
if (player.capabilities.isCreativeMode) {
|
||||
@@ -265,8 +257,8 @@ public abstract class HarvestTool extends ToolCore {
|
||||
// ItemInWorldManager.removeBlock
|
||||
block.onBlockHarvested(world, x, y, z, meta, player);
|
||||
|
||||
if (block.removedByPlayer(
|
||||
world, player, x, y, z, true)) // boolean is if block can be harvested, checked above
|
||||
if (block.removedByPlayer(world, player, x, y, z, true)) // boolean is if block can be harvested, checked
|
||||
// above
|
||||
{
|
||||
block.onBlockDestroyedByPlayer(world, x, y, z, meta);
|
||||
block.harvestBlock(world, player, x, y, z, meta);
|
||||
@@ -300,11 +292,8 @@ public abstract class HarvestTool extends ToolCore {
|
||||
}
|
||||
|
||||
// send an update to the server, so we get an update back
|
||||
if (PHConstruct.extraBlockUpdates)
|
||||
Minecraft.getMinecraft()
|
||||
.getNetHandler()
|
||||
.addToSendQueue(new C07PacketPlayerDigging(
|
||||
2, x, y, z, Minecraft.getMinecraft().objectMouseOver.sideHit));
|
||||
if (PHConstruct.extraBlockUpdates) Minecraft.getMinecraft().getNetHandler().addToSendQueue(
|
||||
new C07PacketPlayerDigging(2, x, y, z, Minecraft.getMinecraft().objectMouseOver.sideHit));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user