Java Code Examples for net.minecraft.init.Items#SPAWN_EGG

The following examples show how to use net.minecraft.init.Items#SPAWN_EGG . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
@Override
public boolean processInteract(EntityPlayer player, EnumHand hand) {
	ItemStack itemstack = player.getHeldItem(hand);
	boolean flag = !itemstack.isEmpty();

	if (flag && itemstack.getItem() == Items.SPAWN_EGG) {
		return super.processInteract(player, hand);
	} else {
		if (!this.isChild()) {
			if (player.isSneaking()) {
				return false;
			}

			if (this.isBeingRidden()) {
				return super.processInteract(player, hand);
			}
		}

		if (this.isChild()) {
			return super.processInteract(player, hand);
		} else {
			this.mountTo(player);
			return true;
		}
	}
}
 
Example 2
public boolean processInteract(EntityPlayer player, EnumHand hand, @Nullable ItemStack stack) {
	boolean flag = stack != null && stack.getItem() == Items.SPAWN_EGG;

	if (!flag && isEntityAlive() && !isTrading() && !isChild() && !player.isSneaking()) {

		if (!this.world.isRemote) {

			RepData rep = getReputation(player);

			if (rep.rep.equals(ReputationLevel.OUTCAST) || rep.rep.equals(ReputationLevel.ENEMY) || rep.rep.equals(ReputationLevel.VILLAIN)) {
				chat(player, "I WILL NOT TRADE WITH A " + rep.rep);
			} else {
				this.setCustomer(player);
				player.displayVillagerTradeGui(this);
			}

		}

		player.addStat(StatList.TALKED_TO_VILLAGER);
		return true;
	} else {
		return super.processInteract(player, hand);
	}
}
 
Example 3
@Override
public boolean processInteract(EntityPlayer player, EnumHand hand) {
  ItemStack itemstack = player.inventory.getCurrentItem();
  if(itemstack.getItem() == Items.SPAWN_EGG) {
    return super.processInteract(player, hand);
  }
  return false;
}
 
Example 4
@Override
@SideOnly(Side.CLIENT)
public void displayAllRelevantItems(NonNullList<ItemStack> itemList) {

	super.displayAllRelevantItems(itemList);

	if (entityCache == null) {

		entityCache = new ArrayList<>();

		for (EntityEntry entityEntry : ForgeRegistries.ENTITIES.getValuesCollection()) {

			if (entityEntry.getRegistryName().getNamespace().equalsIgnoreCase(CommunityGlobals.MOD_ID)) {

				entityCache.add(entityEntry.getRegistryName());
			}
		}
	}

	for (final ResourceLocation id : entityCache) {

		final ItemStack spawner = new ItemStack(Items.SPAWN_EGG);
		ItemMonsterPlacer.applyEntityIdToItemStack(spawner, id);
		itemList.add(spawner);
	}

}