net.minecraft.init.Items Java Examples

The following examples show how to use net.minecraft.init.Items. 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 Project: seppuku   Author: seppukudevelopment   File: KillAuraModule.java    License: GNU General Public License v3.0 7 votes vote down vote up
@Listener
public void onWalkingUpdate(EventUpdateWalkingPlayer event) {
    if (event.getStage() == EventStageable.EventStage.PRE) {
        final Minecraft mc = Minecraft.getMinecraft();

        final Entity target = findTarget();

        if (target != null) {
            final float[] angle = MathUtil.calcAngle(mc.player.getPositionEyes(mc.getRenderPartialTicks()), target.getPositionEyes(mc.getRenderPartialTicks()));
            Seppuku.INSTANCE.getRotationManager().setPlayerRotations(angle[0], angle[1]);

            final float ticks = 20.0f - Seppuku.INSTANCE.getTickRateManager().getTickRate();

            final boolean canAttack = this.coolDown.getValue() ? (mc.player.getCooledAttackStrength(this.sync.getValue() ? -ticks : 0.0f) >= 1) : true;

            final ItemStack stack = mc.player.getHeldItem(EnumHand.OFF_HAND);

            //TODO interp
            if (this.teleport.getValue()) {
                Seppuku.INSTANCE.getPositionManager().setPlayerPosition(target.posX, target.posY, target.posZ);
            }

            if (canAttack) {
                if (stack != null && stack.getItem() == Items.SHIELD) {
                    mc.player.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, mc.player.getHorizontalFacing()));
                }

                mc.player.connection.sendPacket(new CPacketUseEntity(target));
                mc.player.swingArm(EnumHand.MAIN_HAND);
                mc.player.resetCooldown();
            }
        }
    }
}
 
Example #2
Source Project: GardenCollection   Author: jaquadro   File: TileEntityBloomeryFurnace.java    License: MIT License 6 votes vote down vote up
public static int getItemBurnTime (ItemStack stack) {
    if (stack == null)
        return 0;

    Item item = stack.getItem();

    if (item instanceof ItemBlock) {
        Block block = Block.getBlockFromItem(item);
        if (block == ModBlocks.stoneBlock && stack.getItemDamage() == 0)
            return ModBlocks.stoneBlock.getBurnTime(stack);
    }

    if (item == Items.coal && stack.getItemDamage() == 1)
        return 1600;

    return 0;
}
 
Example #3
Source Project: ToroQuest   Author: ToroCraft   File: EntityMage.java    License: GNU General Public License v3.0 6 votes vote down vote up
protected void handleDrinkingPotionUpdate() {
	if (this.attackTimer-- <= 0) {
		this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_DRINK, this.getSoundCategory(), 1.0F,
				0.8F + this.rand.nextFloat() * 0.4F);
		this.setAggressive(false);
		ItemStack itemstack = this.getHeldItemOffhand();
		this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, ItemStack.EMPTY);

		if (itemstack != null && itemstack.getItem() == Items.POTIONITEM) {
			List<PotionEffect> list = PotionUtils.getEffectsFromStack(itemstack);

			if (list != null) {
				for (PotionEffect potioneffect : list) {
					this.addPotionEffect(new PotionEffect(potioneffect));
				}
			}
		}

		this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).removeModifier(MODIFIER);
	}
}
 
Example #4
Source Project: WirelessRedstone   Author: Chicken-Bones   File: RedstoneEther.java    License: MIT License 6 votes vote down vote up
public static ItemStack[] getColourSetters() {
    if (coloursetters == null) {
        coloursetters = new ItemStack[]{
                new ItemStack(Items.dye, 1, 1),
                new ItemStack(Items.dye, 1, 2),
                new ItemStack(Items.dye, 1, 3),
                new ItemStack(Items.dye, 1, 4),
                new ItemStack(Items.dye, 1, 5),
                new ItemStack(Items.dye, 1, 6),
                new ItemStack(Items.dye, 1, 7),
                new ItemStack(Items.dye, 1, 8),
                new ItemStack(Items.dye, 1, 9),
                new ItemStack(Items.dye, 1, 10),
                new ItemStack(Items.dye, 1, 11),
                new ItemStack(Items.dye, 1, 12),
                new ItemStack(Items.dye, 1, 13),
                new ItemStack(Items.dye, 1, 14),
                new ItemStack(Items.redstone, 1)};
    }
    return coloursetters;
}
 
Example #5
Source Project: YouTubeModdingTutorial   Author: McJty   File: TileFloader.java    License: MIT License 6 votes vote down vote up
@Override
public void update() {
    if (!world.isRemote) {
        // Do something is we have a full water block below. We have a feather ready in our inventory
        // and we can find a tank that can accept 100mb of Fload
        IBlockState stateDown = world.getBlockState(pos.down());
        if (stateDown.getBlock() == Blocks.WATER) {
            if (stateDown.getValue(BlockStaticLiquid.LEVEL) == 0) {
                // Test extracting a feather
                ItemStack extracted = inputHandler.extractItem(0, 1, true);
                if (extracted.getItem() == Items.FEATHER) {
                    if (findTankAndFill()) {
                        // All is ok. Really extract the feature and remove the water block
                        world.setBlockToAir(pos.down());
                        inputHandler.extractItem(0, 1, false);
                    }
                }
            }
        }
    }
}
 
Example #6
Source Project: Electro-Magic-Tools   Author: TeamAmeriFrance   File: EntityArcher.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void dropFewItems(boolean par1, int par2) {
    int j;
    int k;

    j = this.rand.nextInt(3 + par2);

    for (k = 0; k < j; ++k) {
        this.dropItem(Items.arrow, 1);
    }
    j = this.rand.nextInt(3 + par2);

    for (k = 0; k < j; ++k) {
        this.dropItem(Items.bone, 1);
    }
}
 
Example #7
Source Project: Production-Line   Author: GoodTimeStudio   File: MixinTileEntityFurnace.java    License: MIT License 6 votes vote down vote up
@Inject(method = "update", at = @At("RETURN"))
private void onUpdate(CallbackInfo callbackInfo) {
    if (!this.world.isRemote) {
        if (this.isBurning()) {
            ItemStack itemStack = this.furnaceItemStacks[0];
            if (itemStack != null) {
                if (itemStack.getItem() instanceof ItemBlock) {
                    Block block = ((ItemBlock) itemStack.getItem()).block;
                    if (block.getMaterial(block.getStateFromMeta(itemStack.getMetadata())) == Material.TNT) {
                        this.doExplosion();
                    }
                } else if (itemStack.getItem() == Items.GUNPOWDER) {
                    this.doExplosion();
                } else if (itemStack.getItem() instanceof ItemFirework || itemStack.getItem()
                        instanceof ItemFireworkCharge) {
                    this.doExplosion();
                }
            }
        }
    }
}
 
Example #8
Source Project: archimedes-ships   Author: Ckathode   File: RecipeBalloon.java    License: MIT License 6 votes vote down vote up
@Override
public ItemStack getCraftingResult(InventoryCrafting inventorycrafting)
{
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			ItemStack itemstack = inventorycrafting.getStackInRowAndColumn(i, j);
			if (itemstack == null) continue;
			if (itemstack.getItem() == Item.getItemFromBlock(Blocks.wool))
			{
				ItemStack itemstack1 = inventorycrafting.getStackInRowAndColumn(i, j + 1);
				if (itemstack1 != null && itemstack1.getItem() == Items.string)
				{
					return new ItemStack(ArchimedesShipMod.blockBalloon, 1, itemstack.getItemDamage());
				}
				return null;
			}
			return null;
		}
	}
	return null;
}
 
Example #9
Source Project: seppuku   Author: seppukudevelopment   File: AutoTotemModule.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Listener
public void onUpdate(EventPlayerUpdate event) {
    if (event.getStage() == EventStageable.EventStage.PRE) {
        final Minecraft mc = Minecraft.getMinecraft();

        if(mc.currentScreen == null || mc.currentScreen instanceof GuiInventory) {
            if(mc.player.getHealth() <= this.health.getValue()) {
                final ItemStack offHand = mc.player.getHeldItemOffhand();

                if (offHand.getItem() == Items.TOTEM_OF_UNDYING) {
                    return;
                }

                final int slot = this.getItemSlot(Items.TOTEM_OF_UNDYING);

                if(slot != -1) {
                    mc.playerController.windowClick(mc.player.inventoryContainer.windowId, slot, 0, ClickType.PICKUP, mc.player);
                    mc.playerController.windowClick(mc.player.inventoryContainer.windowId, 45, 0, ClickType.PICKUP, mc.player);
                    mc.playerController.windowClick(mc.player.inventoryContainer.windowId, slot, 0, ClickType.PICKUP, mc.player);
                    mc.playerController.updateController();
                }
            }
        }
    }
}
 
Example #10
Source Project: NotEnoughItems   Author: Chicken-Bones   File: FireworkRecipeHandler.java    License: MIT License 6 votes vote down vote up
private void loadAllFireworks() {
    //charges
    Item[] shapes = new Item[]{null, Items.fire_charge, Items.gold_nugget, Items.feather, Items.skull};
    Item[] effects = new Item[]{null, Items.diamond, Items.glowstone_dust};
    for (Item shape : shapes)
        for (Item effect : effects)
            genRecipe(Items.gunpowder, shape, effect, Items.dye, Items.dye, 0);

    //fireworks
    genRecipe(Items.gunpowder, Items.paper, Items.firework_charge, 2);
    genRecipe(Items.gunpowder, Items.gunpowder, Items.paper, Items.firework_charge, 2);
    genRecipe(Items.gunpowder, Items.gunpowder, Items.gunpowder, Items.paper, Items.firework_charge, 2);

    //setup a valid charge to use for the recolour recipe
    for (int i = 0; i < 9; i++)
        inventoryCrafting.setInventorySlotContents(i, null);
    inventoryCrafting.setInventorySlotContents(0, new ItemStack(Items.gunpowder));
    inventoryCrafting.setInventorySlotContents(1, new ItemStack(Items.dye));
    recipeFireworks.matches(inventoryCrafting, null);
    ItemStack charge = recipeFireworks.getCraftingResult(null);
    genRecipe(charge, Items.dye, Items.dye, 1);
}
 
Example #11
Source Project: CommunityMod   Author: MinecraftModDevelopmentMods   File: TraverseCommon.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
public void init(FMLInitializationEvent event) {
	for (Block block : TraverseBlocks.oreDictNames.keySet()) {
		OreDictionary.registerOre(TraverseBlocks.oreDictNames.get(block), block);
	}
	for (TraverseWorld.TraverseBiomeEntry traverseBiome : TraverseWorld.biomeList) {
		BiomeManager.addBiome(traverseBiome.getType(), traverseBiome.getEntry());
		if (traverseBiome.hasVillages()) {
			BiomeManager.addVillageBiome(traverseBiome.getBiome(), traverseBiome.canSpawn());
		}
		if (traverseBiome.canSpawn()) {
			BiomeManager.addSpawnBiome(traverseBiome.getBiome());
		}
		BiomeProvider.allowedBiomes.add(traverseBiome.getBiome());
	}

	registerSmeltingRecipe(new ItemStack(Items.COAL, 1, 1), new ItemStack(TUtils.getBlock("fir_log")), 0.15F);
	registerSmeltingRecipe(new ItemStack(TUtils.getBlock("red_rock")), new ItemStack(TUtils.getBlock("red_rock_cobblestone")), 0.1F);
	registerSmeltingRecipe(new ItemStack(TUtils.getBlock("blue_rock")), new ItemStack(TUtils.getBlock("blue_rock_cobblestone")), 0.1F);
}
 
Example #12
Source Project: Artifacts   Author: Draco18s   File: ComponentMining.java    License: MIT License 6 votes vote down vote up
@Override
public float getDigSpeed(ItemStack itemStack, Block block, int meta) {
	ToolMaterial toolMaterial = ToolMaterial.values()[itemStack.stackTagCompound.getInteger("material")];
	if(toolMaterial == toolMaterial.WOOD) {
		return (Items.wooden_pickaxe.getDigSpeed(itemStack, block, meta) / 2 * ToolMaterial.values()[itemStack.stackTagCompound.getInteger("material")].getEfficiencyOnProperMaterial());
	}
	else if(toolMaterial == toolMaterial.STONE) {
		return (Items.stone_pickaxe.getDigSpeed(itemStack, block, meta) / 2 * ToolMaterial.values()[itemStack.stackTagCompound.getInteger("material")].getEfficiencyOnProperMaterial());
	}
	else if(toolMaterial == toolMaterial.GOLD) {
		return (Items.golden_pickaxe.getDigSpeed(itemStack, block, meta) / 2 * ToolMaterial.values()[itemStack.stackTagCompound.getInteger("material")].getEfficiencyOnProperMaterial());
	}
	else if(toolMaterial == toolMaterial.IRON) {
		return (Items.iron_pickaxe.getDigSpeed(itemStack, block, meta) / 2 * ToolMaterial.values()[itemStack.stackTagCompound.getInteger("material")].getEfficiencyOnProperMaterial());
	}
	else if(toolMaterial == toolMaterial.EMERALD) {
		return (Items.diamond_pickaxe.getDigSpeed(itemStack, block, meta) / 2 * ToolMaterial.values()[itemStack.stackTagCompound.getInteger("material")].getEfficiencyOnProperMaterial());
	}
	return (toolMaterial.values()[itemStack.stackTagCompound.getInteger("material")].getEfficiencyOnProperMaterial());
}
 
Example #13
Source Project: SkyblockAddons   Author: BiscuitDevelopment   File: BaitManager.java    License: MIT License 5 votes vote down vote up
/**
 * Check if our Player is holding a Fishing Rod, and filters out the Grapple Hook (If any more items are made that
 * are Items.fishing_rods but aren't used for fishing, add them here)
 *
 * @return True if it can be used for fishing
 */
public boolean isHoldingRod() {
    EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;

    if (player != null) {
        ItemStack item = player.getHeldItem();
        if (item == null || item.getItem() != Items.fishing_rod) return false;

        return !"GRAPPLING_HOOK".equals(ItemUtils.getSkyBlockItemID(item));
    }
    return false;
}
 
Example #14
Source Project: ToroQuest   Author: ToroCraft   File: ShopkeeperTradesForMoon.java    License: GNU General Public License v3.0 5 votes vote down vote up
private static ItemStack level1Sword() {
	ItemStack stack = new ItemStack(Items.IRON_SWORD);
	stack.setStackDisplayName("Moon Sword I");
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(17), 1);
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(18), 1);
	return stack;
}
 
Example #15
Source Project: OpenPeripheral-Addons   Author: OpenMods   File: TileEntityTicketMachine.java    License: MIT License 5 votes vote down vote up
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
	if (itemstack == null) return false;

	switch (i) {
		case SLOT_PAPER:
			return itemstack.getItem() == Items.paper;
		case SLOT_INK: {
			Set<ColorMeta> color = ColorUtils.stackToColor(itemstack);
			return color != null && color.contains(ColorMeta.BLACK);
		}
		default:
			return false;
	}
}
 
Example #16
Source Project: customstuff4   Author: cubex2   File: OreDictionaryEntryTests.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testRegistersEntry()
{
    OreDictionaryEntry entry = gson.fromJson("{ \"oreClass\": \"someEntry\", \"item\":\"minecraft:coal\" }", OreDictionaryEntry.class);
    entry.init(InitPhase.PRE_INIT, new TestContentHelper("{}", BlankContent.class));

    assertTrue(OreDictionary.doesOreNameExist("someEntry"));
    assertTrue(OreDictionary.containsMatch(true, OreDictionary.getOres("someEntry"), new ItemStack(Items.COAL)));
}
 
Example #17
Source Project: Gadomancy   Author: makeo   File: TileArcanePackager.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean isItemValidForSlot(int slot, ItemStack stack) {
    if (slot == 9) {
        return stack.getItem() == Items.leather;
    } else if (slot == 10) {
        return stack.getItem() == Items.string;
    } else if (slot == 11) {
        return false;
    }
    return true;
}
 
Example #18
Source Project: TFC2   Author: Deadrik   File: BlockWoodSupport.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void createFallingEntity(World world, BlockPos pos, IBlockState state)
{
	world.setBlockToAir(pos);
	EntityItem ei = new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.STICK, 1+world.rand.nextInt(3)));
	world.spawnEntity(ei);
}
 
Example #19
Source Project: customstuff4   Author: cubex2   File: ItemFilterDeserializerTest.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Test
public void test_machineInput_vanilla()
{
    Map<String, ItemFilter> map = gson.fromJson("{\"filter\": \"machineInput:vanilla\"}", new TypeToken<Map<String, ItemFilter>>() {}.getType());

    ItemFilter filter = map.get("filter");

    assertTrue(filter.accepts(new ItemStack(Blocks.IRON_ORE)));
    assertFalse(filter.accepts(new ItemStack(Items.GOLD_INGOT)));
}
 
Example #20
Source Project: ToroQuest   Author: ToroCraft   File: GraveyardGenerator.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected void addLootToChest(IInventory chest) {
	for (int i = 0; i < chest.getSizeInventory(); i++) {
		int roll = rand.nextInt(8);

		if (roll == 0) {
			chest.setInventorySlotContents(i, new ItemStack(Items.BONE, rand.nextInt(5) + 1));
		} else if (roll == 1) {
			chest.setInventorySlotContents(i, new ItemStack(Items.ROTTEN_FLESH, rand.nextInt(5) + 1));
		} else if (roll == 2) {
			if (rand.nextInt(20) == 0) {
				chest.setInventorySlotContents(i, new ItemStack(NICE_STUFF[rand.nextInt(NICE_STUFF.length)]));
			}
		}
	}
}
 
Example #21
Source Project: TofuCraftReload   Author: 0999312   File: TofuVillages.java    License: MIT License 5 votes vote down vote up
@Override
public void addMerchantRecipe(IMerchant merchant, MerchantRecipeList recipeList, Random random) {
    //Sell
    recipeList.add(new MerchantRecipe(new ItemStack(Items.EMERALD), new ItemStack(ItemLoader.tofu_material, 2 + random.nextInt(2))));
    recipeList.add(new MerchantRecipe(new ItemStack(Items.EMERALD), new ItemStack(ItemLoader.tofu_material, 8 + random.nextInt(4),2)));
    recipeList.add(new MerchantRecipe(new ItemStack(Items.EMERALD, 6 + random.nextInt(4)), new ItemStack(ItemLoader.tofustick)));
}
 
Example #22
Source Project: minecraft-roguelike   Author: Greymerk   File: ItemSpecialty.java    License: GNU General Public License v3.0 5 votes vote down vote up
private static ItemStack getBow(Random rand, Quality quality){
	
	ItemStack item = new ItemStack(Items.BOW);
	
	switch(quality){
	case WOOD:
	case STONE:
		item.addEnchantment(Enchant.getEnchant(Enchant.POWER), 1 + rand.nextInt(3));
		item.addEnchantment(Enchant.getEnchant(Enchant.UNBREAKING), 1);
		Loot.setItemName(item, "Yew Longbow");
		Loot.setItemLore(item, "Superior craftsmanship", TextFormat.DARKGREEN);
		return item;
	case IRON:
		item.addEnchantment(Enchant.getEnchant(Enchant.POWER), 1 + rand.nextInt(3));
		item.addEnchantment(Enchant.getEnchant(Enchant.UNBREAKING), 1 + rand.nextInt(3));
		Loot.setItemName(item, "Laminated Bow");
		Loot.setItemLore(item, "Highly polished", TextFormat.DARKGREEN);
		return item;
	case GOLD:
		item.addEnchantment(Enchant.getEnchant(Enchant.POWER), 3 + rand.nextInt(3));
		if(rand.nextBoolean()){
			item.addEnchantment(Enchant.getEnchant(Enchant.INFINITY), 1);
		}
		item.addEnchantment(Enchant.getEnchant(Enchant.UNBREAKING), 1 + rand.nextInt(3));
		Loot.setItemName(item, "Recurve Bow");
		Loot.setItemLore(item, "Beautifully crafted", TextFormat.DARKGREEN);
		return item;
	case DIAMOND:
		item.addEnchantment(Enchant.getEnchant(Enchant.POWER), 3 + rand.nextInt(3));
		item.addEnchantment(Enchant.getEnchant(Enchant.FLAME), 1);
		item.addEnchantment(Enchant.getEnchant(Enchant.INFINITY), 1);
		item.addEnchantment(Enchant.getEnchant(Enchant.UNBREAKING), getUnbreakingLevel(quality, rand));
		item.addEnchantment(Enchant.getEnchant(Enchant.MENDING), 1);
		Loot.setItemName(item, "Eldritch Bow");
		Loot.setItemLore(item, "Warm to the touch", TextFormat.DARKGREEN);
		return item;
	default:
		return null;
	}
}
 
Example #23
Source Project: ToroQuest   Author: ToroCraft   File: ShopkeeperTradesForMoon.java    License: GNU General Public License v3.0 5 votes vote down vote up
private static ItemStack level2Chestplate() {
	ItemStack stack = new ItemStack(Items.LEATHER_CHESTPLATE);
	stack.setStackDisplayName("Moon Chestplate II");
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(0), 1);
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(7), 4);
	return stack;
}
 
Example #24
Source Project: EmergingTechnology   Author: MoonManModding   File: ShredderRecipes.java    License: MIT License 5 votes vote down vote up
private static List<ItemStack> getShredderStarchItems() {
    List<ItemStack> itemInputs = new ArrayList<ItemStack>();

    itemInputs.add(new ItemStack(Items.BEETROOT));
    itemInputs.add(new ItemStack(Items.POTATO));
    itemInputs.add(new ItemStack(Items.POISONOUS_POTATO));

    List<String> oreInputs = new ArrayList<String>();
    oreInputs.add("cropCorn");
    oreInputs.add("corn");

    List<ItemStack> inputs = RecipeBuilder.buildRecipeList(itemInputs, oreInputs);

    return inputs;
}
 
Example #25
Source Project: Chisel-2   Author: Chisel-2   File: ItemChisel.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean getIsRepairable(ItemStack damagedItem, ItemStack repairMaterial)
{
	switch (type) {
		case DIAMOND:
			return repairMaterial.getItem().equals(Items.diamond);
		case IRON:
			return repairMaterial.getItem().equals(Items.iron_ingot);
		case OBSIDIAN:
			return repairMaterial.getItem().equals(Item.getItemFromBlock(Blocks.obsidian));
	}

	return false;
}
 
Example #26
Source Project: customstuff4   Author: cubex2   File: FuelTests.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testBurnTime()
{
    Fuel fuel = gson.fromJson("{ \"item\": \"minecraft:bow\", \"burnTime\":1337 }", Fuel.class);
    fuel.init(InitPhase.PRE_INIT, new TestContentHelper("{}", TestContent.class));

    assertTrue(fuel.appliesToStack(new ItemStack(Items.BOW)));
    assertFalse(fuel.appliesToStack(new ItemStack(Items.BOW, 64, 1)));
}
 
Example #27
Source Project: Translocators   Author: Chicken-Bones   File: TileTranslocator.java    License: MIT License 5 votes vote down vote up
public boolean activate(EntityPlayer player, int subPart)
{
    ItemStack held = player.inventory.getCurrentItem();
    if(held == null && player.isSneaking())
    {
        stripModifiers();
        markUpdate();
    }
    else if(held == null)
    {
        if(subPart == 1)
            invert_redstone = !invert_redstone;
        else
            openGui(player);
    }
    else if(held.getItem() == Items.redstone && !redstone)
    {
        redstone = true;
        if(!player.capabilities.isCreativeMode)
            held.stackSize--;
        
        if((gettingPowered() != invert_redstone) != a_eject)
            invert_redstone = !invert_redstone;
        markUpdate();
    }
    else if(held.getItem() == Items.glowstone_dust && !fast)
    {
        fast = true;
        if(!player.capabilities.isCreativeMode)
            held.stackSize--;
        markUpdate();
    }
    else
        openGui(player);
    
    return true;
}
 
Example #28
Source Project: Et-Futurum   Author: ganymedes01   File: ClientProxy.java    License: The Unlicense 5 votes vote down vote up
private void registerItemRenderers() {
	if (EtFuturum.enableBanners)
		MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.banner), new ItemBannerRenderer());
	if (EtFuturum.enableFancySkulls)
		MinecraftForgeClient.registerItemRenderer(Items.skull, new ItemSkullRenderer());
	if (EtFuturum.enableBowRendering)
		MinecraftForgeClient.registerItemRenderer(Items.bow, new ItemBowRenderer());
}
 
Example #29
Source Project: WirelessRedstone   Author: Chicken-Bones   File: WRLogicProxy.java    License: MIT License 5 votes vote down vote up
private static void addRecipies()
{
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemwireless, 1, 0),
            "t  ",
            "srr",
            "fff",
            't', WirelessRedstoneCore.wirelessTransceiver,
            's', "obsidianRod",
            'f', new ItemStack(Blocks.stone_slab, 1, 0),
            'r', Items.redstone));

    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemwireless, 1, 1),
            "d  ",
            "srr",
            "fff",
            'd', WirelessRedstoneCore.recieverDish,
            's', "obsidianRod",
            'f', new ItemStack(Blocks.stone_slab, 1, 0),
            'r', Items.redstone));
    
    GameRegistry.addRecipe(new ItemStack(itemwireless, 1, 2),
            "p  ",
            "srr",
            "fff",
            'p', WirelessRedstoneCore.blazeTransceiver,
            's', Items.blaze_rod,
            'f', new ItemStack(Blocks.stone_slab, 1, 0),
            'r', Items.redstone);
}
 
Example #30
Source Project: litematica   Author: maruohon   File: ItemUtils.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
public static ItemStack storeTEInStack(ItemStack stack, TileEntity te)
{
    NBTTagCompound nbt = te.writeToNBT(new NBTTagCompound());

    if (stack.getItem() == Items.SKULL && nbt.hasKey("Owner"))
    {
        NBTTagCompound tagOwner = nbt.getCompoundTag("Owner");
        NBTTagCompound tagSkull = new NBTTagCompound();

        tagSkull.setTag("SkullOwner", tagOwner);
        stack.setTagCompound(tagSkull);

        return stack;
    }
    else
    {
        NBTTagCompound tagLore = new NBTTagCompound();
        NBTTagList tagList = new NBTTagList();

        tagList.appendTag(new NBTTagString("(+NBT)"));
        tagLore.setTag("Lore", tagList);
        stack.setTagInfo("display", tagLore);
        stack.setTagInfo("BlockEntityTag", nbt);

        return stack;
    }
}