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

The following examples show how to use net.minecraft.init.Items#SPAWN_EGG . 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 check out the related API usage on the sidebar.
Example 1
Source File: EntityDabSquirrel.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
@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
Source File: EntityShopkeeper.java    From ToroQuest with GNU General Public License v3.0 6 votes vote down vote up
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
Source File: EntityFallenMount.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
@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
Source File: CreativeTabCommunity.java    From CommunityMod with GNU Lesser General Public License v2.1 3 votes vote down vote up
@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);
	}

}