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

The following examples show how to use net.minecraft.init.Items#REDSTONE . 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: GTTileIDSU.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void update() {
	if (owner != null && isSimulating() && wrapper.isDummy()) {
		wrapper = IC2.saveManager.getGlobalData(getWorld(), "IDSU_Storage", GTIDSUStorageManager.class).getWrapper(owner);
	}
	if (wrapper.isDummy()) {
		return;
	}
	if (open > 0) {
		getNetwork().updateTileGuiField(this, "wrapper");
	}
	handleRedstone();
	boolean isEmitting = isEmittingRedstone();
	if (wrapper.getStoredEnergy() > 0 && !inventory.get(0).isEmpty()) {
		wrapper.removeEnergy((int) ElectricItem.manager.charge(inventory.get(0), wrapper.getStoredEnergy(), tier, false, false));
	}
	if (maxEnergy > wrapper.getStoredEnergy() && !inventory.get(1).isEmpty()) {
		ItemStack fuel = inventory.get(1);
		Item item = fuel.getItem();
		boolean removeItem = false;
		if (item == Items.REDSTONE) {
			wrapper.addEnergy(500);
			removeItem = true;
		} else if (item == Item.getItemFromBlock(Blocks.REDSTONE_BLOCK)) {
			wrapper.addEnergy(5000);
			removeItem = true;
		} else if (item == Ic2Items.suBattery.getItem()) {
			wrapper.addEnergy(1000);
			removeItem = true;
		} else {
			wrapper.addEnergy((int) ElectricItem.manager.discharge(fuel, (maxEnergy
					- wrapper.getStoredEnergy()), tier, false, true, false));
		}
		if (wrapper.getStoredEnergy() > maxEnergy) {
			wrapper.setEnergy(maxEnergy);
		}
		if (removeItem) {
			fuel.shrink(1);
		}
	}
	int newState = getUpdatedState();
	if (newState != state) {
		state = newState;
		getNetwork().updateTileEntityField(this, "state");
	}
	boolean newEmitting = isEmittingRedstone();
	if (isEmitting != newEmitting || emit != newEmitting) {
		updateNeighbors(true);
		emit = newEmitting;
	}
	updateComparators();
}
 
Example 2
Source File: EntityBurnableItem.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static boolean isBurnable(ItemStack stack) {
	return !stack.isEmpty() &&
			(stack.getItem() != Items.REDSTONE || !Loader.isModLoaded("fluxnetworks")) &&
			FireRecipes.RECIPES.keySet().stream().anyMatch(item -> item.apply(stack));
}
 
Example 3
Source File: TileSlotDischarge.java    From Production-Line with MIT License 4 votes vote down vote up
/**
 * Whether the current item can be inputted.
 *
 * @param itemStack Input item.
 */
@SuppressWarnings("NumericOverflow")
@Override
public boolean canInput(ItemStack itemStack) {
    return itemStack != null && (!(itemStack.getItem() != Items.REDSTONE && !(itemStack.getItem() instanceof ItemBatterySU)) || ElectricItem.manager.discharge(itemStack, Double.POSITIVE_INFINITY, 1, true, true, true) > 0.0D);
}
 
Example 4
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);
	}
}