Java Code Examples for net.minecraft.entity.player.EntityPlayer.renderBrokenItemStack()

The following are Jave code examples for showing how to use renderBrokenItemStack() of the net.minecraft.entity.player.EntityPlayer class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: minecraft-quiverbow   File: Seedling.java   View Source Code Vote up 5 votes
private void breakWeapon(World world, ItemStack stack, Entity entity)
{
	if (!(entity instanceof EntityPlayer)) // For QuiverMobs/Arms Assistants
	{
		this.setCooldown(stack, 40);
		return;
	}
	
	EntityPlayer player = (EntityPlayer) entity;
	
	player.renderBrokenItemStack(stack);
	player.destroyCurrentEquippedItem();	// Breaking
	stack.stackSize = 0;
	
	EntityItem piston = new EntityItem(world, player.posX, player.posY + 1.0F, player.posZ, new ItemStack(Blocks.piston));
	piston.delayBeforeCanPickup = 10;
	
	if (player.captureDrops) { player.capturedDrops.add(piston); }
	else { world.spawnEntityInWorld(piston); }
	
	EntityItem hook = new EntityItem(world, player.posX, player.posY + 1.0F, player.posZ, new ItemStack(Blocks.tripwire_hook));
	hook.delayBeforeCanPickup = 10;
	
	if (player.captureDrops) { player.capturedDrops.add(hook); }
	else { world.spawnEntityInWorld(hook); }
	
	world.playSoundAtEntity(player, "random.break", 1.0F, 1.5F);
}
 
Example 2
Project: uniquecrops   File: SeedBehavior.java   View Source Code Vote up 4 votes
public static boolean canPlantCrop(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, Block cropBlock) {
	
	if (side != EnumFacing.UP)
		return false;
	
	if (!world.isRemote && cropBlock instanceof BlockCropsBase && !((BlockCropsBase)cropBlock).canPlantCrop()) {
		UCPacketHandler.sendToNearbyPlayers(world, pos, new PacketUCEffect(EnumParticleTypes.BARRIER, pos.getX(), pos.getY() + 2, pos.getZ(), 0));
		return false;
	}
	else if (player.canPlayerEdit(pos, side, stack) && player.canPlayerEdit(pos.offset(EnumFacing.UP), side, stack)) {
		IBlockState state = world.getBlockState(pos);
		if (state.getBlock().canSustainPlant(state, world, pos, EnumFacing.UP, (IPlantable)stack.getItem()) && world.isAirBlock(pos.offset(EnumFacing.UP))) {
			if (cropBlock == UCBlocks.cropCollis) {
				if (!world.provider.isSurfaceWorld() || pos.getY() <= 100)
					return false;
			}
			if (cropBlock == UCBlocks.cropCinderbella) {
				long time = world.getWorldTime() % 24000L;
				if (time >= 18000)
					return false;
				
				BlockPos pos1 = pos.add(0, 1, 0);
				int pumpkins = 0;
				for (EnumFacing facing : EnumFacing.HORIZONTALS) {
					IBlockState pumpkin = world.getBlockState(pos1.offset(facing));
					if (pumpkin.getBlock() != null && pumpkin.getBlock() == Blocks.PUMPKIN && !world.isRemote) {
						pumpkins++;
					}
				}
				if (pumpkins >= 4) {
					cropBlock.onBlockPlacedBy(world, pos.offset(side), cropBlock.getDefaultState(), player, stack);
					return true;
				}
			}
			if (cropBlock == UCBlocks.cropFeroxia) {
				cropBlock.onBlockPlacedBy(world, pos.offset(side), cropBlock.getDefaultState(), player, stack);
				return true;
			}
			if (cropBlock == UCBlocks.cropEula) {
				player.openGui(UniqueCrops.instance, 1, world, (int)player.posX, (int)player.posY, (int)player.posZ);
			}
			if (cropBlock == UCBlocks.cropAbstract) {
				player.renderBrokenItemStack(stack);
				if (!player.worldObj.isRemote)
					setAbstractCropGrowth(player, true);
				return true;
			}
			if (cropBlock == UCBlocks.cropPetramia && pos.offset(side).getY() >= 10) {
				return false;
			}
			world.setBlockState(pos.offset(side), cropBlock.getDefaultState(), 3);
			return true;
		}
	}
	return false;
}