Made it so placed mimic blocks replace the block that you place it on unless you hold shift. Also worked on dungeon schematic saving/loading.
This commit is contained in:
parent
61b11a88bf
commit
80bf140ee5
11 changed files with 662 additions and 11 deletions
|
@ -1,9 +1,20 @@
|
|||
package WayofTime.bloodmagic.item.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.block.BlockMimic;
|
||||
import WayofTime.bloodmagic.tile.TileMimic;
|
||||
|
||||
public class ItemBlockMimic extends ItemBlock
|
||||
{
|
||||
|
@ -19,6 +30,59 @@ public class ItemBlockMimic extends ItemBlock
|
|||
return super.getUnlocalizedName(stack) + BlockMimic.names[stack.getItemDamage()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
IBlockState iblockstate = world.getBlockState(pos);
|
||||
Block block = iblockstate.getBlock();
|
||||
|
||||
if (player.isSneaking())
|
||||
{
|
||||
return super.onItemUse(stack, player, world, pos, hand, facing, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
if (stack.stackSize != 0 && player.canPlayerEdit(pos, facing, stack))
|
||||
{
|
||||
int i = this.getMetadata(stack.getMetadata());
|
||||
IBlockState iblockstate1 = this.block.onBlockPlaced(world, pos, facing, hitX, hitY, hitZ, i, player);
|
||||
|
||||
TileEntity tileReplaced = world.getTileEntity(pos);
|
||||
if (!canReplaceTile(i, tileReplaced))
|
||||
{
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
ItemStack replacedStack = block.getItem(world, pos, iblockstate);
|
||||
|
||||
if (placeBlockAt(stack, player, world, pos, facing, hitX, hitY, hitZ, iblockstate1))
|
||||
{
|
||||
SoundType soundtype = this.block.getSoundType();
|
||||
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
|
||||
--stack.stackSize;
|
||||
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileMimic)
|
||||
{
|
||||
TileMimic mimic = (TileMimic) tile;
|
||||
mimic.setInventorySlotContents(0, replacedStack);
|
||||
if (player.capabilities.isCreativeMode)
|
||||
{
|
||||
mimic.dropItemsOnBreak = false;
|
||||
}
|
||||
}
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
public boolean canReplaceTile(int meta, TileEntity tile)
|
||||
{
|
||||
return tile == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int meta)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue