Slight change to ItemRiftRemover.
Don't know if this works the same way, but it avoids some casting down the hierarchy.
This commit is contained in:
parent
8fd609db13
commit
d1b8124461
1 changed files with 11 additions and 6 deletions
|
@ -6,8 +6,6 @@ import com.zixiken.dimdoors.DimDoors;
|
||||||
import com.zixiken.dimdoors.core.DimLink;
|
import com.zixiken.dimdoors.core.DimLink;
|
||||||
import com.zixiken.dimdoors.core.PocketManager;
|
import com.zixiken.dimdoors.core.PocketManager;
|
||||||
import com.zixiken.dimdoors.tileentities.TileEntityRift;
|
import com.zixiken.dimdoors.tileentities.TileEntityRift;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
|
||||||
import net.minecraft.client.multiplayer.WorldClient;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -17,7 +15,6 @@ import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import com.zixiken.dimdoors.core.NewDimData;
|
import com.zixiken.dimdoors.core.NewDimData;
|
||||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
@ -32,7 +29,7 @@ public class ItemRiftRemover extends Item {
|
||||||
setUnlocalizedName(ID);
|
setUnlocalizedName(ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/* @Override
|
||||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||||
// We invoke PlayerControllerMP.onPlayerRightClick() from here so that Minecraft
|
// We invoke PlayerControllerMP.onPlayerRightClick() from here so that Minecraft
|
||||||
// will invoke onItemUseFirst() on the client side. We'll tell it to pass the
|
// will invoke onItemUseFirst() on the client side. We'll tell it to pass the
|
||||||
|
@ -54,7 +51,7 @@ public class ItemRiftRemover extends Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos,
|
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos,
|
||||||
|
@ -66,6 +63,14 @@ public class ItemRiftRemover extends Item {
|
||||||
// removal animation. That means we'll have a chance to check for the link before
|
// removal animation. That means we'll have a chance to check for the link before
|
||||||
// it's deleted. Otherwise the Rift Remover's durability wouldn't drop.
|
// it's deleted. Otherwise the Rift Remover's durability wouldn't drop.
|
||||||
|
|
||||||
|
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(world, player, true);
|
||||||
|
if (hit == null) return false;
|
||||||
|
pos = hit.getBlockPos();
|
||||||
|
NewDimData dimension = PocketManager.createDimensionData(world);
|
||||||
|
DimLink link = dimension.getLink(pos);
|
||||||
|
if (world.getBlockState(pos).getBlock() != DimDoors.blockRift || link == null ||
|
||||||
|
!player.canPlayerEdit(pos, hit.sideHit, stack)) return false;
|
||||||
|
|
||||||
// Tell the rift's tile entity to do its removal animation
|
// Tell the rift's tile entity to do its removal animation
|
||||||
TileEntity tileEntity = world.getTileEntity(pos);
|
TileEntity tileEntity = world.getTileEntity(pos);
|
||||||
if (tileEntity != null && tileEntity instanceof TileEntityRift) {
|
if (tileEntity != null && tileEntity instanceof TileEntityRift) {
|
||||||
|
@ -93,7 +98,7 @@ public class ItemRiftRemover extends Item {
|
||||||
*/
|
*/
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
@Override
|
@Override
|
||||||
public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) {
|
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
|
||||||
DimDoors.translateAndAdd("info.riftRemover",tooltip);
|
DimDoors.translateAndAdd("info.riftRemover",tooltip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue