aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/xmod/gregtech/api/items
diff options
context:
space:
mode:
authorJason Mitchell <mitchej@gmail.com>2023-05-01 02:45:56 -0700
committerGitHub <noreply@github.com>2023-05-01 11:45:56 +0200
commitb2c8cfb4ec8b82337a95f51364277964ec968b52 (patch)
treed4cf94acc93249cd649b33ec13c5b0d75f1f75db /src/main/java/gtPlusPlus/xmod/gregtech/api/items
parentd2eda84e457d549ad9a51f40e9dd159147a141f8 (diff)
downloadGT5-Unofficial-b2c8cfb4ec8b82337a95f51364277964ec968b52.tar.gz
GT5-Unofficial-b2c8cfb4ec8b82337a95f51364277964ec968b52.tar.bz2
GT5-Unofficial-b2c8cfb4ec8b82337a95f51364277964ec968b52.zip
ForgeDirection (#608)
* ForgeDirection WIP * Fix GTPP_Render_MachineBlock Fix handling of getTexture with facing mask for pipes Kill a bunch of magic numbers * spotlessApply (#612) Co-authored-by: GitHub GTNH Actions <> * Bump bw/tt deps --------- Co-authored-by: Léa Gris <lea.gris@noiraude.net> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/api/items')
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem_Base.java9
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaTool.java4
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/api/items/tools/GT_MetaGenTool.java5
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Wrench.java130
4 files changed, 40 insertions, 108 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem_Base.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem_Base.java
index 631e004178..5437f65aff 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem_Base.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem_Base.java
@@ -184,7 +184,7 @@ public abstract class Gregtech_MetaItem_Base extends Gregtech_Generic_Item
@Override
public boolean onItemUse(final ItemStack aStack, final EntityPlayer aPlayer, final World aWorld, final int aX,
- final int aY, final int aZ, final int aSide, final float hitX, final float hitY, final float hitZ) {
+ final int aY, final int aZ, final int ordinalSide, final float hitX, final float hitY, final float hitZ) {
this.use(aStack, 0, aPlayer);
this.isItemStackUsable(aStack);
final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors
@@ -192,7 +192,7 @@ public abstract class Gregtech_MetaItem_Base extends Gregtech_Generic_Item
if (tList != null) {
for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) {
try {
- if (tBehavior.onItemUse(this, aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ)) {
+ if (tBehavior.onItemUse(this, aStack, aPlayer, aWorld, aX, aY, aZ, ordinalSide, hitX, hitY, hitZ)) {
if (aStack.stackSize <= 0) {
aPlayer.destroyCurrentEquippedItem();
}
@@ -214,7 +214,7 @@ public abstract class Gregtech_MetaItem_Base extends Gregtech_Generic_Item
@Override
public boolean onItemUseFirst(final ItemStack aStack, final EntityPlayer aPlayer, final World aWorld, final int aX,
- final int aY, final int aZ, final int aSide, final float hitX, final float hitY, final float hitZ) {
+ final int aY, final int aZ, final int ordinalSide, final float hitX, final float hitY, final float hitZ) {
this.use(aStack, 0, aPlayer);
this.isItemStackUsable(aStack);
final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors
@@ -222,7 +222,8 @@ public abstract class Gregtech_MetaItem_Base extends Gregtech_Generic_Item
if (tList != null) {
for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) {
try {
- if (tBehavior.onItemUseFirst(this, aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ)) {
+ if (tBehavior
+ .onItemUseFirst(this, aStack, aPlayer, aWorld, aX, aY, aZ, ordinalSide, hitX, hitY, hitZ)) {
if (aStack.stackSize <= 0) {
aPlayer.destroyCurrentEquippedItem();
}
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaTool.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaTool.java
index 5c92944345..b5dd1ba16c 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaTool.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaTool.java
@@ -5,8 +5,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
-import mods.railcraft.api.core.items.IToolCrowbar;
-
import net.minecraft.block.Block;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
@@ -37,6 +35,7 @@ import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Utility;
import gtPlusPlus.core.creative.AddToCreativeTab;
import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_ToolStats;
+import mods.railcraft.api.core.items.IToolCrowbar;
/**
* This is an example on how you can create a Tool ItemStack, in this case a Bismuth Wrench:
@@ -289,6 +288,7 @@ public abstract class Gregtech_MetaTool extends GT_MetaGenerated_Tool
}
}
+ @Override
@SuppressWarnings("unchecked")
public void addAdditionalToolTips(final List aList, final ItemStack aStack, final EntityPlayer aPlayer) {
final long tMaxDamage = getToolMaxDamage(aStack);
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/tools/GT_MetaGenTool.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/tools/GT_MetaGenTool.java
index a7bc99e85c..91ad6d9d9c 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/tools/GT_MetaGenTool.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/tools/GT_MetaGenTool.java
@@ -408,6 +408,7 @@ public abstract class GT_MetaGenTool extends GT_MetaGenerated_Tool {
}
}
+ @Override
public boolean canWrench(final EntityPlayer player, final int x, final int y, final int z) {
System.out.println("canWrench");
if (player == null) {
@@ -423,6 +424,7 @@ public abstract class GT_MetaGenTool extends GT_MetaGenerated_Tool {
return (tStats != null) && tStats.isWrench();
}
+ @Override
public void wrenchUsed(final EntityPlayer player, final int x, final int y, final int z) {
if (player == null) {
return;
@@ -436,14 +438,17 @@ public abstract class GT_MetaGenTool extends GT_MetaGenerated_Tool {
}
}
+ @Override
public boolean canUse(final ItemStack stack, final EntityPlayer player, final int x, final int y, final int z) {
return this.canWrench(player, x, y, z);
}
+ @Override
public void used(final ItemStack stack, final EntityPlayer player, final int x, final int y, final int z) {
this.wrenchUsed(player, x, y, z);
}
+ @Override
public boolean shouldHideFacades(final ItemStack stack, final EntityPlayer player) {
if (player == null) {
return false;
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Wrench.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Wrench.java
index acd48785f4..e117c1b28e 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Wrench.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Wrench.java
@@ -31,32 +31,28 @@ public class ToolType_Wrench extends ToolType_Base {
}
public boolean onItemUseFirst(final GT_MetaBase_Item aItem, final ItemStack aStack, final EntityPlayer aPlayer,
- final World aWorld, final int aX, final int aY, final int aZ, final int aSide, final float hitX,
+ final World aWorld, final int aX, final int aY, final int aZ, final int ordinalSide, final float hitX,
final float hitY, final float hitZ) {
if (aWorld.isRemote) {
return false;
}
+ final ForgeDirection side = ForgeDirection.getOrientation(ordinalSide);
final Block aBlock = aWorld.getBlock(aX, aY, aZ);
if (aBlock == null) {
return false;
}
final byte aMeta = (byte) aWorld.getBlockMetadata(aX, aY, aZ);
- final byte aTargetSide = GT_Utility.determineWrenchingSide((byte) aSide, hitX, hitY, hitZ);
+ final ForgeDirection targetSide = GT_Utility.determineWrenchingSide(side, hitX, hitY, hitZ);
+ final byte ordinalTargetSide = (byte) targetSide.ordinal();
final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
try {
- if ((aTileEntity != null) && ((aTileEntity instanceof IWrenchable))) {
- if (((IWrenchable) aTileEntity).wrenchCanSetFacing(aPlayer, aTargetSide)) {
+ if ((aTileEntity != null) && ((aTileEntity instanceof IWrenchable wrenchable))) {
+ if (wrenchable.wrenchCanSetFacing(aPlayer, ordinalTargetSide)) {
if ((aPlayer.capabilities.isCreativeMode)
|| (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) {
- ((IWrenchable) aTileEntity).setFacing(aTargetSide);
- GT_Utility.sendSoundToPlayers(
- aWorld,
- GregTech_API.sSoundList.get(Integer.valueOf(100)),
- 1.0F,
- -1.0F,
- aX,
- aY,
- aZ);
+ wrenchable.setFacing(ordinalTargetSide);
+ GT_Utility
+ .sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, aX, aY, aZ);
}
return true;
}
@@ -76,14 +72,8 @@ public class ToolType_Wrench extends ToolType_Base {
}
}
aWorld.setBlockToAir(aX, aY, aZ);
- GT_Utility.sendSoundToPlayers(
- aWorld,
- GregTech_API.sSoundList.get(Integer.valueOf(100)),
- 1.0F,
- -1.0F,
- aX,
- aY,
- aZ);
+ GT_Utility
+ .sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, aX, aY, aZ);
}
return true;
}
@@ -94,14 +84,7 @@ public class ToolType_Wrench extends ToolType_Base {
if ((aPlayer.capabilities.isCreativeMode)
|| (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) {
aWorld.setBlockMetadataWithNotify(aX, aY, aZ, (aMeta + 4) % 12, 3);
- GT_Utility.sendSoundToPlayers(
- aWorld,
- GregTech_API.sSoundList.get(Integer.valueOf(100)),
- 1.0F,
- -1.0F,
- aX,
- aY,
- aZ);
+ GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, aX, aY, aZ);
}
return true;
}
@@ -109,14 +92,7 @@ public class ToolType_Wrench extends ToolType_Base {
if ((aPlayer.capabilities.isCreativeMode)
|| (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) {
aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ((aMeta / 4) * 4) + (((aMeta % 4) + 1) % 4), 3);
- GT_Utility.sendSoundToPlayers(
- aWorld,
- GregTech_API.sSoundList.get(Integer.valueOf(100)),
- 1.0F,
- -1.0F,
- aX,
- aY,
- aZ);
+ GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, aX, aY, aZ);
}
return true;
}
@@ -124,14 +100,7 @@ public class ToolType_Wrench extends ToolType_Base {
if ((aPlayer.capabilities.isCreativeMode)
|| (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) {
aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ((aMeta / 4) * 4) + (((aMeta % 4) + 1) % 4), 3);
- GT_Utility.sendSoundToPlayers(
- aWorld,
- GregTech_API.sSoundList.get(Integer.valueOf(100)),
- 1.0F,
- -1.0F,
- aX,
- aY,
- aZ);
+ GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, aX, aY, aZ);
}
return true;
}
@@ -141,18 +110,11 @@ public class ToolType_Wrench extends ToolType_Base {
aWorld.spawnEntityInWorld(
new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, new ItemStack(aBlock, 1, aMeta)));
aWorld.setBlockToAir(aX, aY, aZ);
- GT_Utility.sendSoundToPlayers(
- aWorld,
- GregTech_API.sSoundList.get(Integer.valueOf(100)),
- 1.0F,
- -1.0F,
- aX,
- aY,
- aZ);
+ GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, aX, aY, aZ);
}
return true;
}
- if (aMeta == aTargetSide) {
+ if (aMeta == ordinalTargetSide) {
if ((aBlock == Blocks.pumpkin) || (aBlock == Blocks.lit_pumpkin)
|| (aBlock == Blocks.piston)
|| (aBlock == Blocks.sticky_piston)
@@ -169,14 +131,7 @@ public class ToolType_Wrench extends ToolType_Base {
aWorld.spawnEntityInWorld(
new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, new ItemStack(aBlock, 1, 0)));
aWorld.setBlockToAir(aX, aY, aZ);
- GT_Utility.sendSoundToPlayers(
- aWorld,
- GregTech_API.sSoundList.get(Integer.valueOf(100)),
- 1.0F,
- -1.0F,
- aX,
- aY,
- aZ);
+ GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, aX, aY, aZ);
}
return true;
}
@@ -186,15 +141,8 @@ public class ToolType_Wrench extends ToolType_Base {
|| (aBlock == Blocks.dropper)) {
if ((aMeta < 6) && ((aPlayer.capabilities.isCreativeMode)
|| (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) {
- aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3);
- GT_Utility.sendSoundToPlayers(
- aWorld,
- GregTech_API.sSoundList.get(Integer.valueOf(100)),
- 1.0F,
- -1.0F,
- aX,
- aY,
- aZ);
+ aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ordinalTargetSide, 3);
+ GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, aX, aY, aZ);
}
return true;
}
@@ -204,52 +152,30 @@ public class ToolType_Wrench extends ToolType_Base {
|| (aBlock == Blocks.chest)
|| (aBlock == Blocks.ender_chest)
|| (aBlock == Blocks.trapped_chest)) {
- if ((aTargetSide > 1) && ((aPlayer.capabilities.isCreativeMode)
+ if ((targetSide.offsetY == 0) && ((aPlayer.capabilities.isCreativeMode)
|| (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) {
- aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3);
- GT_Utility.sendSoundToPlayers(
- aWorld,
- GregTech_API.sSoundList.get(Integer.valueOf(100)),
- 1.0F,
- -1.0F,
- aX,
- aY,
- aZ);
+ aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ordinalTargetSide, 3);
+ GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, aX, aY, aZ);
}
return true;
}
if (aBlock == Blocks.hopper) {
- if ((aTargetSide != 1) && ((aPlayer.capabilities.isCreativeMode)
+ if ((targetSide != ForgeDirection.UP) && ((aPlayer.capabilities.isCreativeMode)
|| (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) {
- aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3);
- GT_Utility.sendSoundToPlayers(
- aWorld,
- GregTech_API.sSoundList.get(Integer.valueOf(100)),
- 1.0F,
- -1.0F,
- aX,
- aY,
- aZ);
+ aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ordinalTargetSide, 3);
+ GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, aX, aY, aZ);
}
return true;
}
}
- if ((Arrays.asList(aBlock.getValidRotations(aWorld, aX, aY, aZ))
- .contains(ForgeDirection.getOrientation(aTargetSide)))
+ if ((Arrays.asList(aBlock.getValidRotations(aWorld, aX, aY, aZ)).contains(targetSide))
&& ((aPlayer.capabilities.isCreativeMode) || (!GT_ModHandler.isElectricItem(aStack))
|| (GT_ModHandler.canUseElectricItem(aStack, this.mCosts)))
- && (aBlock.rotateBlock(aWorld, aX, aY, aZ, ForgeDirection.getOrientation(aTargetSide)))) {
+ && (aBlock.rotateBlock(aWorld, aX, aY, aZ, targetSide))) {
if (!aPlayer.capabilities.isCreativeMode) {
((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts);
}
- GT_Utility.sendSoundToPlayers(
- aWorld,
- GregTech_API.sSoundList.get(Integer.valueOf(100)),
- 1.0F,
- -1.0F,
- aX,
- aY,
- aZ);
+ GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, aX, aY, aZ);
}
return false;
}