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:
WayofTime 2016-08-22 14:22:18 -04:00
parent 61b11a88bf
commit 80bf140ee5
11 changed files with 662 additions and 11 deletions

View file

@ -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)
{

View file

@ -12,12 +12,11 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import WayofTime.bloodmagic.api.altar.IBloodAltar;
import WayofTime.bloodmagic.api.iface.IAltarReader;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.structures.DungeonTester;
import WayofTime.bloodmagic.entity.mob.EntityMimic;
import WayofTime.bloodmagic.tile.TileIncenseAltar;
import WayofTime.bloodmagic.util.ChatUtil;
import WayofTime.bloodmagic.util.helper.NumeralHelper;
@ -32,12 +31,26 @@ public class ItemSigilDivination extends ItemSigilBase implements IAltarReader
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{
if (world instanceof WorldServer)
// if (world instanceof WorldServer)
// {
// System.out.println("Testing...");
//// BuildTestStructure s = new BuildTestStructure();
//// s.placeStructureAtPosition(new Random(), Rotation.CLOCKWISE_180, (WorldServer) world, player.getPosition(), 0);
// DungeonTester.testDungeonElementWithOutput((WorldServer) world, player.getPosition());
// }
if (!world.isRemote)
{
System.out.println("Testing...");
// BuildTestStructure s = new BuildTestStructure();
// s.placeStructureAtPosition(new Random(), Rotation.CLOCKWISE_180, (WorldServer) world, player.getPosition(), 0);
DungeonTester.testDungeonElementWithOutput((WorldServer) world, player.getPosition());
EntityMimic mimic = new EntityMimic(world);
mimic.setPosition(player.posX, player.posY, player.posZ);
world.spawnEntityInWorld(mimic);
System.out.println("Spawning Mimic");
// EntityZombie zombie = new EntityZombie(world);
// zombie.setPosition(player.posX, player.posY, player.posZ);
// zombie.setItemStackToSlot(EntityEquipmentSlot.HEAD, new ItemStack(Blocks.CHEST));
// world.spawnEntityInWorld(zombie);
}
if (!world.isRemote)