Java Code Examples for net.minecraft.init.Items#clay_ball()

The following examples show how to use net.minecraft.init.Items#clay_ball() . 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: ClayRainMod.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
@SubscribeEvent
public void rain(TickEvent.WorldTickEvent e) {
    if (e.world.isRaining()) {
        if (e.world.rand.nextInt(5) == 0) {
            for (EntityPlayer player : e.world.playerEntities) {
                if (e.world.getBiome(player.getPosition()).canRain()) {
                    double x = e.world.rand.nextInt(maxRange * 2) - maxRange;
                    double y = 255;
                    if (player.posY < 100) y = 130;
                    double z = e.world.rand.nextInt(maxRange * 2) - maxRange;

                    EntityItem clay = new EntityItem(e.world, x + player.posX, y, z + player.posZ, new ItemStack(Items.CLAY_BALL));
                    clay.lifespan = 200;
                    e.world.spawnEntity(clay);
                }
            }
        }
    }
}
 
Example 2
Source File: GuiKnapping.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
private void highlightGrid(int id)
{
	for(int i = 0; i < 81; i++)
	{
		((GuiKnappingButton) this.buttonList.get(i)).highlight(true);
	}
	List<IRecipeTFC> recipes = CraftingManagerTFC.getInstance().getRecipeList(RecipeType.KNAPPING);
	if(PlayerManagerTFC.getInstance().getClientPlayer().specialCraftingType.getItem() == Items.CLAY_BALL)
		recipes = CraftingManagerTFC.getInstance().getRecipeList(RecipeType.POTTERY);
	IRecipeTFC rec = recipes.get(id - 81);
	for(int i = 0; i < rec.getRecipeSize(); i++)
	{
		int x = i % rec.getRecipeWidth();
		int y = i / rec.getRecipeWidth();
		if(PlayerManagerTFC.getInstance().getClientPlayer().specialCraftingType.getItem() == TFCItems.LooseRock)
		{
			if(rec.getRecipeItems().get(x+y*rec.getRecipeWidth()) != ItemStack.EMPTY)
				((GuiKnappingButton) this.buttonList.get(x+y*9)).highlight(false);
		}
		else
		{
			if(((ItemStack)(rec.getRecipeItems().get(x+y*rec.getRecipeWidth()))) == ItemStack.EMPTY)
				((GuiKnappingButton) this.buttonList.get(x+y*9)).highlight(false);
		}
	}
}
 
Example 3
Source File: ContainerSpecialCrafting.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Callback for when the crafting matrix is changed.
 */
@Override
public void onCraftMatrixChanged(IInventory ii)
{
	RecipeType rt = RecipeType.KNAPPING;
	PlayerInfo pi = PlayerManagerTFC.getInstance().getPlayerInfoFromPlayer(invPlayer.player);
	if(pi.specialCraftingType != null && pi.specialCraftingType.getItem() == Items.CLAY_BALL)
		rt = RecipeType.POTTERY;

	ItemStack result = CraftingManagerTFC.getInstance().findMatchingRecipe(rt, this.craftMatrix, worldObj);

	// Handle decreasing the stack of the held item used to open the interface.
	if (!decreasedStack && !isConstructing)
	{

		// A valid clay recipe has been formed.
		/*if (pi.specialCraftingType.getItem() == TFCItems.flatClay)
		{
			if (result != null)
			{
				setDecreasedStack(true); // Mark container so it won't decrease again.
				if (!this.worldObj.isRemote && invPlayer.getCurrentItem().getMaxStackSize() >= 5) // Server only to prevent it removing multiple times.
					invPlayer.decrStackSize(invPlayer.currentItem, 5);
				else // Clientside or if the player doesn't have enough clay, return before the output slot is set.
				{
					setDecreasedStack(false);
					return;
				}
			}
		}
		// A piece of rock or leather has been removed.
		else*/ if (hasPieceBeenRemoved(pi))
		{
			setDecreasedStack(true); // Mark container so it won't decrease again.
			if (!this.worldObj.isRemote) // Server only to prevent it removing multiple times.
			{
				int count = 1;

				if(invPlayer.getStackInSlot(invPlayer.currentItem).getItem() == Items.CLAY_BALL)
					count = 5;

				invPlayer.decrStackSize(invPlayer.currentItem, count);
			}
		}
	}

	// The crafting output is only set if the input was consumed
	if (decreasedStack)
	{
		this.craftResult.setInventorySlotContents(0, result);

		// Trigger Achievements
		if (result != ItemStack.EMPTY && invPlayer.player != null)
		{
			Item item = result.getItem();

		}
	}
}
 
Example 4
Source File: GuiKnappingButton.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void drawButton(Minecraft par1Minecraft, int xPos, int yPos)
{
	if (this.visible)
	{
		this.hovered = xPos >= this.xPosition && yPos >= this.yPosition && xPos < this.xPosition + this.width && yPos < this.yPosition + this.height;
		PlayerInfo pi = PlayerManagerTFC.getInstance().getClientPlayer();
		GL11.glScalef(0.5f, 0.5f, 1f);
		GL11.glTranslatef(xPosition, yPosition, 0);

		if (pi.specialCraftingType != null)
		{
			if(pi.specialCraftingType.getItem() == TFCItems.LooseRock)
			{
				Core.bindTexture(new ResourceLocation(Reference.ModID, "textures/blocks/rocks/" + StoneType.getStoneTypeFromMeta(pi.specialCraftingType.getItemDamage()).name() +" Raw.png"));

				//Same as drawTexturedModalRect except we need to set the UV ourselves
				drawLocal();
			}
			else if(pi.specialCraftingType.getItem() == Items.CLAY_BALL)
			{
				Core.bindTexture(new ResourceLocation(Reference.ModID, "textures/items/pottery/clay flat light.png"));

				//Same as drawTexturedModalRect except we need to set the UV ourselves
				drawLocal();
			}
			else
			{
				Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(pi.specialCraftingType, xPosition, yPosition);
			}
		}

		if (!this.enabled && pi.specialCraftingTypeAlternate != null)
		{
			if(pi.specialCraftingType.getItem() == TFCItems.LooseRock)
			{
				Core.bindTexture(new ResourceLocation(Reference.ModID, "textures/blocks/rocks/" + StoneType.getStoneTypeFromMeta(pi.specialCraftingTypeAlternate.getItemDamage()).name() +" Raw.png"));
				GL11.glColor4f(1f, 1f, 1f, 0.5f);
				//Same as drawTexturedModalRect except we need to set the UV ourselves
				drawLocal();
			}
			else if(pi.specialCraftingType.getItem() == Items.CLAY_BALL)
			{
				Core.bindTexture(new ResourceLocation(Reference.ModID, "textures/items/pottery/clay flat dark.png"));
				GL11.glColor4f(1f, 1f, 1f, 1.0f);
				//Same as drawTexturedModalRect except we need to set the UV ourselves
				drawLocal();
			}
			else
			{
				Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(pi.specialCraftingTypeAlternate, xPosition, yPosition);
			}
		}

		if(pi.shouldDrawKnappingHighlight && highlight)
		{
			Core.bindTexture(GuiKnapping.texture);

			GL11.glColor4f(1.0f, 1.0f, 1.0f, 0.4f);
			GlStateManager.enableBlend();
			//GlStateManager.colorMask(false, true, true, true);
			this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 239, 16, 16);
			//GlStateManager.colorMask(true, true, true, true);
			GlStateManager.disableBlend();
		}

		GL11.glTranslatef(-xPosition, -yPosition, 0);
		GL11.glScalef(2f, 2f, 1);
		GL11.glColor4f(1f, 1f, 1f, 1f);


		this.mouseDragged(par1Minecraft, this.xPosition, this.yPosition);
	}
}
 
Example 5
Source File: GuiKnapping.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void initGui()
{
	super.initGui();

	buttonList.clear();
	((ContainerSpecialCrafting) this.inventorySlots).setDecreasedStack(false);

	for (int y = 0; y < 9; y++)
	{
		for (int x = 0; x < 9; x++)
		{
			buttonList.add(new GuiKnappingButton(x + (y * 9), 16+guiLeft + (x * 8), 16+guiTop + (y * 8), 8, 8));
			// Normal Behavior
			if (!previouslyLoaded)
			{
				if (PlayerManagerTFC.getInstance().getClientPlayer().knappingInterface[y * 9 + x])
				{
					resetButton(y * 9 + x);
				}
			}
			// GUI has been reloaded, usually caused by looking up a recipe in NEI while having the interface open.
			else
			{
				/*
				 * For whatever reason all my attempts at implementing this for all crafting types just wouldn't work for the clay ones.
				 * Types that completely remove pieces (rocks, leather) work properly to save states when reloaded with this.
				 */
				/*if (PlayerManagerTFC.getInstance().getClientPlayer().specialCraftingType.getItem() != TFCItems.flatClay && 
						((ContainerSpecialCrafting) this.inventorySlots).craftMatrix.getStackInSlot(y * 5 + x) == null)
				{
					resetButton(y * 5 + x);
				}*/
			}
		}
	}

	List<IRecipeTFC> recipes = CraftingManagerTFC.getInstance().getRecipeList(RecipeType.KNAPPING);
	if(PlayerManagerTFC.getInstance().getClientPlayer().specialCraftingType.getItem() == Items.CLAY_BALL)
		recipes = CraftingManagerTFC.getInstance().getRecipeList(RecipeType.POTTERY);
	int x = 0, y = 0;
	for (int i = 0; i < recipes.size(); i++)
	{
		y = i / 4;
		x = i % 4;
		buttonList.add(81, new GuiKnappingRecipeButton(81 + i, 3+guiLeft+176 + (x * 18), 4+guiTop + (y * 19), 18, 18, recipes.get(i).getRecipeOutput()));
	}

	previouslyLoaded = true;
}
 
Example 6
Source File: EntityDireSlime.java    From EnderZoo with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
@Override
protected Item getDropItem() {
  return this.getSlimeSize() == 4 ? Item.getItemFromBlock(Blocks.CLAY) : Items.CLAY_BALL;
}
 
Example 7
Source File: ItemJunk.java    From minecraft-roguelike with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ItemStack getLootItem(Random rand, int level){

	if(level > 0 && rand.nextInt(200) == 0){
		if(level > 2 && rand.nextInt(10) == 0) return new ItemStack(Items.DIAMOND_HORSE_ARMOR, 1, 0);
		if(level > 1 && rand.nextInt(5) == 0) return new ItemStack(Items.GOLDEN_HORSE_ARMOR, 1, 0);
		if(rand.nextInt(3) == 0) return new ItemStack(Items.IRON_HORSE_ARMOR, 1, 0);
		return new ItemStack(Items.SADDLE);
	}

	if(rand.nextInt(100) == 0) return PotionMixture.getRandom(rand);
	
	if(level > 1 && rand.nextInt(100) == 0) return new ItemStack(Items.GHAST_TEAR);

	if(level < 3 && rand.nextInt(80) == 0) return new ItemStack(Items.BOOK);
	
	if(rand.nextInt(80) == 0) return Shield.get(rand);
	
	if(level > 1 && rand.nextInt(60) == 0) return TippedArrow.get(rand, 4 + rand.nextInt(level) * 2);
	
	if(level > 1 && rand.nextInt(50) == 0){			
		switch(rand.nextInt(6)){
		case 0: return new ItemStack(Items.GUNPOWDER, 1 + rand.nextInt(3));
		case 1: return new ItemStack(Items.BLAZE_POWDER, 1 + rand.nextInt(3));
		case 2: return new ItemStack(Items.GOLD_NUGGET, 1 + rand.nextInt(3));
		case 3: return new ItemStack(Items.REDSTONE, 1 + rand.nextInt(3));
		case 4: return new ItemStack(Items.GLOWSTONE_DUST, 1 + rand.nextInt(8));
		case 5: return new ItemStack(Items.DYE, 1 + rand.nextInt(3));
		}
	}

	if(rand.nextInt(60) == 0) return PotionMixture.getPotion(rand, PotionMixture.LAUDANUM);
	
	if(rand.nextInt(30) == 0) return new ItemStack(Blocks.TORCH, 6 + rand.nextInt(20));

	if(level > 0 && rand.nextInt(8) == 0){
		switch(rand.nextInt(8)){
		case 0: return new ItemStack(Items.SLIME_BALL);
		case 1: return new ItemStack(Items.SNOWBALL);
		case 2: return new ItemStack(Items.MUSHROOM_STEW);
		case 3: return new ItemStack(Items.CLAY_BALL);
		case 4: return new ItemStack(Items.FLINT);
		case 5: return new ItemStack(Items.FEATHER);
		case 6: return new ItemStack(Items.GLASS_BOTTLE);
		case 7: return new ItemStack(Items.LEATHER);
		}
	}

	switch(rand.nextInt(7)){
	case 0: return new ItemStack(Items.BONE);
	case 1: return new ItemStack(Items.ROTTEN_FLESH);
	case 2: return new ItemStack(Items.SPIDER_EYE);
	case 3: return new ItemStack(Items.PAPER);
	case 4: return new ItemStack(Items.STRING);
	case 5: return new ItemStack(Items.STICK);
	default: return new ItemStack(Items.STICK);
	}
}