mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 00:38:35 +01:00
parent
6f90197087
commit
b5caedfeec
1 changed files with 20 additions and 21 deletions
|
@ -45,7 +45,6 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.*;
|
import net.minecraft.util.*;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
import net.minecraft.util.text.TextComponentString;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ForgeHooks;
|
import net.minecraftforge.common.ForgeHooks;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
@ -110,30 +109,30 @@ public class ItemDrill extends ItemEnergy{
|
||||||
if(StackUtil.isValid(upgrade)){
|
if(StackUtil.isValid(upgrade)){
|
||||||
int slot = ItemDrillUpgrade.getSlotToPlaceFrom(upgrade);
|
int slot = ItemDrillUpgrade.getSlotToPlaceFrom(upgrade);
|
||||||
if(slot >= 0 && slot < InventoryPlayer.getHotbarSize()){
|
if(slot >= 0 && slot < InventoryPlayer.getHotbarSize()){
|
||||||
ItemStack anEquip = player.inventory.getStackInSlot(slot);
|
ItemStack equip = player.inventory.getStackInSlot(slot);
|
||||||
if(StackUtil.isValid(anEquip) && anEquip != stack){
|
if(StackUtil.isValid(equip) && equip != stack){
|
||||||
ItemStack equip = anEquip.copy();
|
ItemStack toPlaceStack = equip.copy();
|
||||||
if(!world.isRemote){
|
|
||||||
//tryPlaceItemIntoWorld could throw an Exception
|
player.setHeldItem(hand, toPlaceStack);
|
||||||
try{
|
|
||||||
//Places the Block into the World
|
//tryPlaceItemIntoWorld could throw an Exception
|
||||||
if(equip.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ) != EnumActionResult.FAIL){
|
try{
|
||||||
if(!player.capabilities.isCreativeMode){
|
//Places the Block into the World
|
||||||
player.inventory.setInventorySlotContents(slot, StackUtil.validateCopy(equip));
|
if(toPlaceStack.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ) != EnumActionResult.FAIL){
|
||||||
}
|
if(!player.capabilities.isCreativeMode){
|
||||||
//Synchronizes the Client
|
player.setHeldItem(hand, StackUtil.validateCopy(toPlaceStack));
|
||||||
player.inventoryContainer.detectAndSendChanges();
|
|
||||||
return EnumActionResult.SUCCESS;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Notify the Player and log the Exception
|
|
||||||
catch(Exception e){
|
|
||||||
ModUtil.LOGGER.error("Player "+player.getName()+" who should place a Block using a Drill at "+player.posX+", "+player.posY+", "+player.posZ+" in World "+world.provider.getDimension()+" threw an Exception! Don't let that happen again!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else{
|
//Notify the Player and log the Exception
|
||||||
return EnumActionResult.SUCCESS;
|
catch(Exception e){
|
||||||
|
ModUtil.LOGGER.error("Player "+player.getName()+" who should place a Block using a Drill at "+player.posX+", "+player.posY+", "+player.posZ+" in World "+world.provider.getDimension()+" threw an Exception! Don't let that happen again!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player.inventory.setInventorySlotContents(slot, player.getHeldItem(hand));
|
||||||
|
player.setHeldItem(hand, stack);
|
||||||
|
|
||||||
|
return EnumActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue