mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-20 12:09:39 +00:00
Remove mead as well.
This commit is contained in:
1 parent
4ec1381fbe
commit
2530a7fb15
7 files changed
-461
No files matched your search
@@ -1,103 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.food;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.food.IBeverageEffect;
|
||||
import forestry.core.utils.Translator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
public abstract class BeverageEffect implements IBeverageEffect {
|
||||
private final int id;
|
||||
private final String unlocalizedDescription;
|
||||
|
||||
protected BeverageEffect(int id, String unlocalizedDescription) {
|
||||
this.id = id;
|
||||
this.unlocalizedDescription = unlocalizedDescription;
|
||||
|
||||
/*
|
||||
if (BeverageManager.effectList[id] != null) {
|
||||
throw new RuntimeException("Beverage effect slot " + id + " was already occupied by " + BeverageManager.effectList[id] + " when trying to add " + this);
|
||||
} else {
|
||||
BeverageManager.effectList[id] = this;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected String getLevel() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
if (getLevel() != null) {
|
||||
return Translator.translateToLocal(unlocalizedDescription) + " " + getLevel();
|
||||
} else {
|
||||
return Translator.translateToLocal(unlocalizedDescription);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<IBeverageEffect> loadEffects(ItemStack stack) {
|
||||
List<IBeverageEffect> effectsList = new ArrayList<>();
|
||||
|
||||
NBTTagCompound nbttagcompound = stack.getTagCompound();
|
||||
if (nbttagcompound == null) {
|
||||
return effectsList;
|
||||
}
|
||||
|
||||
if (nbttagcompound.hasKey("E")) {
|
||||
int effectLength = nbttagcompound.getInteger("L");
|
||||
NBTTagList nbttaglist = nbttagcompound.getTagList("E", 10);
|
||||
IBeverageEffect[] effects = new IBeverageEffect[effectLength];
|
||||
for (int i = 0; i < nbttaglist.tagCount(); i++) {
|
||||
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
|
||||
byte byte0 = nbttagcompound1.getByte("S");
|
||||
if (byte0 >= 0 && byte0 < effects.length) {
|
||||
//effects[byte0] = BeverageManager.effectList[nbttagcompound1.getInteger("ID")];
|
||||
}
|
||||
}
|
||||
effectsList = Arrays.asList(effects);
|
||||
}
|
||||
|
||||
return effectsList;
|
||||
}
|
||||
|
||||
public static void saveEffects(ItemStack stack, List<IBeverageEffect> effects) {
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
nbttagcompound.setInteger("L", effects.size());
|
||||
for (int i = 0; i < effects.size(); i++) {
|
||||
IBeverageEffect effect = effects.get(i);
|
||||
if (effect != null) {
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
nbttagcompound1.setByte("S", (byte) i);
|
||||
nbttagcompound1.setInteger("ID", effect.getId());
|
||||
nbttaglist.appendTag(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
nbttagcompound.setTag("E", nbttaglist);
|
||||
|
||||
stack.setTagCompound(nbttagcompound);
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.food;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BeverageEffectAntidote extends BeverageEffect {
|
||||
|
||||
private float chance = 0.2f;
|
||||
|
||||
public BeverageEffectAntidote(int id, float chance) {
|
||||
super(id, "for.beverage.effect.antidote");
|
||||
this.chance = chance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doEffect(World world, EntityPlayer player) {
|
||||
if (world.rand.nextFloat() < chance) {
|
||||
player.removePotionEffect(MobEffects.POISON);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLevel() {
|
||||
if (chance > 0.5f) {
|
||||
return "III";
|
||||
} else if (chance > 0.2f) {
|
||||
return "II";
|
||||
} else {
|
||||
return "I";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.food;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BeverageEffectDrunk extends BeverageEffect {
|
||||
|
||||
private final PotionEffect drunkEffect;
|
||||
private final float chance;
|
||||
|
||||
public BeverageEffectDrunk(int id, float chance) {
|
||||
super(id, "for.beverage.effect.alcoholic");
|
||||
this.chance = chance;
|
||||
this.drunkEffect = new PotionEffect(MobEffects.NAUSEA, 25 * 20, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doEffect(World world, EntityPlayer player) {
|
||||
if (world.rand.nextFloat() < chance) {
|
||||
player.addPotionEffect(drunkEffect);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package forestry.food;
|
||||
|
||||
import forestry.api.food.IBeverageEffect;
|
||||
|
||||
public class BeverageEffects {
|
||||
public static final IBeverageEffect weakAlcoholic = new BeverageEffectDrunk(10, 0.2f);
|
||||
public static final IBeverageEffect weakAntidote = new BeverageEffectAntidote(20, 0.5f);
|
||||
public static final IBeverageEffect strongAntidote = new BeverageEffectAntidote(21, 1.0f);
|
||||
|
||||
private BeverageEffects() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.food.items;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import forestry.api.core.IModelManager;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public enum EnumBeverage implements ItemBeverage.IBeverageInfo {
|
||||
MEAD_SHORT("meadShort", "glass", new Color(0xec9a19), new Color(0xffffff), 1, 0.2f, true),
|
||||
MEAD_CURATIVE("meadCurative", "glass", new Color(0xc5feff), new Color(0xffffff), 1, 0.2f, true);
|
||||
|
||||
public static final EnumBeverage[] VALUES = values();
|
||||
|
||||
private final String name;
|
||||
private final String iconType;
|
||||
private final int primaryColor;
|
||||
private final int secondaryColor;
|
||||
|
||||
private final int heal;
|
||||
private final float saturation;
|
||||
private final boolean isAlwaysEdible;
|
||||
|
||||
EnumBeverage(String name, String iconType, Color primaryColor, Color secondaryColor, int heal, float saturation, boolean isAlwaysEdible) {
|
||||
this.name = name;
|
||||
this.iconType = iconType;
|
||||
this.primaryColor = primaryColor.getRGB();
|
||||
this.secondaryColor = secondaryColor.getRGB();
|
||||
this.heal = heal;
|
||||
this.saturation = saturation;
|
||||
this.isAlwaysEdible = isAlwaysEdible;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModels(Item item, IModelManager manager) {
|
||||
manager.registerItemModel(item, ordinal(), "liquids/" + iconType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeal() {
|
||||
return heal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSaturation() {
|
||||
return saturation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlwaysEdible() {
|
||||
return isAlwaysEdible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUid() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPrimaryColor() {
|
||||
return primaryColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSecondaryColor() {
|
||||
return secondaryColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecret() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.food.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.food.IBeverageEffect;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.items.IColoredItem;
|
||||
import forestry.core.items.ItemForestryFood;
|
||||
import forestry.core.items.ItemOverlay;
|
||||
import forestry.food.BeverageEffect;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemBeverage extends ItemForestryFood implements IColoredItem {
|
||||
public interface IBeverageInfo extends ItemOverlay.IOverlayInfo {
|
||||
int getHeal();
|
||||
|
||||
float getSaturation();
|
||||
|
||||
boolean isAlwaysEdible();
|
||||
|
||||
void registerModels(Item item, IModelManager manager);
|
||||
}
|
||||
|
||||
public final IBeverageInfo[] beverages;
|
||||
|
||||
public ItemBeverage() {
|
||||
super(1, 0.2f);
|
||||
setMaxStackSize(1);
|
||||
this.beverages = EnumBeverage.VALUES;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the item's stackTagCompound needs to be synchronized over SMP.
|
||||
*/
|
||||
@Override
|
||||
public boolean getShareTag() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) {
|
||||
List<IBeverageEffect> effects = BeverageEffect.loadEffects(stack);
|
||||
|
||||
stack.shrink(1);
|
||||
|
||||
if (entityLiving instanceof EntityPlayer) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) entityLiving;
|
||||
entityplayer.getFoodStats().addStats(this, stack);
|
||||
worldIn.playSound(null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F);
|
||||
|
||||
if (worldIn.isRemote) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
for (IBeverageEffect effect : effects) {
|
||||
effect.doEffect(worldIn, entityplayer);
|
||||
}
|
||||
|
||||
entityplayer.addStat(StatList.getObjectUseStats(this));
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHealAmount(ItemStack itemstack) {
|
||||
int meta = itemstack.getItemDamage();
|
||||
IBeverageInfo beverage = beverages[meta];
|
||||
return beverage.getHeal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSaturationModifier(ItemStack itemstack) {
|
||||
int meta = itemstack.getItemDamage();
|
||||
IBeverageInfo beverage = beverages[meta];
|
||||
return beverage.getSaturation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxItemUseDuration(ItemStack itemstack) {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction(ItemStack itemstack) {
|
||||
return EnumAction.DRINK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
|
||||
ItemStack itemStack = playerIn.getHeldItem(hand);
|
||||
int meta = itemStack.getItemDamage();
|
||||
IBeverageInfo beverage = beverages[meta];
|
||||
if (playerIn.canEat(beverage.isAlwaysEdible())) {
|
||||
playerIn.setActiveHand(hand);
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
|
||||
} else {
|
||||
return new ActionResult<>(EnumActionResult.FAIL, itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs tab, NonNullList<ItemStack> subItems) {
|
||||
for (int i = 0; i < beverages.length; i++) {
|
||||
if (Config.isDebug || !beverages[i].isSecret()) {
|
||||
subItems.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack itemstack, EntityPlayer player, List<String> list, boolean flag) {
|
||||
List<IBeverageEffect> effects = BeverageEffect.loadEffects(itemstack);
|
||||
|
||||
for (IBeverageEffect effect : effects) {
|
||||
list.add(effect.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + "." + beverages[stack.getItemDamage()].getUid();
|
||||
}
|
||||
|
||||
/* MODELS */
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
for (IBeverageInfo info : beverages) {
|
||||
info.registerModels(item, manager);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack itemstack, int j) {
|
||||
if (j == 1 || beverages[itemstack.getItemDamage()].getSecondaryColor() == 0) {
|
||||
return beverages[itemstack.getItemDamage()].getPrimaryColor();
|
||||
} else {
|
||||
return beverages[itemstack.getItemDamage()].getSecondaryColor();
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack get(EnumBeverage beverage, int amount) {
|
||||
return new ItemStack(this, amount, beverage.ordinal());
|
||||
}
|
||||
}
|
||||
@@ -14,24 +14,17 @@ import java.util.Collections;
|
||||
|
||||
import forestry.core.items.ItemForestryFood;
|
||||
import forestry.core.items.ItemRegistry;
|
||||
import forestry.food.BeverageEffect;
|
||||
import forestry.food.BeverageEffects;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemRegistryFood extends ItemRegistry {
|
||||
public final ItemForestryFood honeyedSlice;
|
||||
public final ItemBeverage beverage;
|
||||
public final ItemForestryFood ambrosia;
|
||||
public final ItemForestryFood honeyPot;
|
||||
|
||||
public ItemRegistryFood() {
|
||||
// / FOOD ITEMS
|
||||
honeyedSlice = registerItem(new ItemForestryFood(8, 0.6f), "honeyed_slice");
|
||||
beverage = registerItem(new ItemBeverage(), "beverage");
|
||||
ambrosia = registerItem(new ItemAmbrosia().setIsDrink(), "ambrosia");
|
||||
honeyPot = registerItem(new ItemForestryFood(2, 0.2f).setIsDrink(), "honey_pot");
|
||||
|
||||
// Mead
|
||||
BeverageEffect.saveEffects(new ItemStack(beverage), Collections.singletonList(BeverageEffects.weakAlcoholic));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user