Added textures and translation keys for all the new items
|
@ -146,31 +146,38 @@ public class UItems {
|
|||
public static final Item daffodil_daisy_sandwich = new ItemEdible(Unicopia.MODID, "daffodil_daisy_sandwich", 3, 2, CookedToxicityDeterminent.instance);
|
||||
public static final Item hay_burger = new ItemEdible(Unicopia.MODID, "hay_burger", 3, 4, CookedToxicityDeterminent.instance);
|
||||
public static final Item hay_fries = new ItemEdible(Unicopia.MODID, "hay_fries", 1, 5, CookedToxicityDeterminent.instance);
|
||||
public static final Item salad = new ItemEdible(Unicopia.MODID, "salad", 4, 2, CookedToxicityDeterminent.instance);
|
||||
public static final Item salad = new ItemEdible(Unicopia.MODID, "salad", 4, 2, CookedToxicityDeterminent.instance)
|
||||
.setContainerItem(Items.BOWL);
|
||||
|
||||
public static final Item wheat_worms = new ItemEdible(Unicopia.MODID, "wheat_worms", 1, 0, stack -> Toxicity.SEVERE);
|
||||
|
||||
public static final Item apple_cider = new ItemEdible(Unicopia.MODID, "apple_cider", 4, 2, stack -> Toxicity.FAIR);
|
||||
public static final Item juice = new ItemEdible(Unicopia.MODID, "juice", 2, 2, stack -> Toxicity.SAFE);
|
||||
public static final Item burned_juice = new ItemEdible(Unicopia.MODID, "burned_juice", 3, 1, stack -> Toxicity.FAIR);
|
||||
public static final Item mug = new Item()
|
||||
.setTranslationKey("mug")
|
||||
.setRegistryName(Unicopia.MODID, "mug")
|
||||
.setCreativeTab(CreativeTabs.MATERIALS)
|
||||
.setFull3D();
|
||||
public static final Item apple_cider = new ItemEdible(Unicopia.MODID, "apple_cider", 4, 2, stack -> Toxicity.MILD)
|
||||
.setContainerItem(mug)
|
||||
.setFull3D();
|
||||
public static final Item juice = new ItemEdible(Unicopia.MODID, "juice", 2, 2, stack -> Toxicity.SAFE)
|
||||
.setContainerItem(Items.GLASS_BOTTLE);
|
||||
public static final Item burned_juice = new ItemEdible(Unicopia.MODID, "burned_juice", 3, 1, stack -> Toxicity.FAIR)
|
||||
.setContainerItem(Items.GLASS_BOTTLE);
|
||||
|
||||
static void registerItems(IForgeRegistry<Item> registry) {
|
||||
RegistryLockSpinner.unlock(Item.REGISTRY);
|
||||
|
||||
RegistryLockSpinner.commit(Item.REGISTRY, Items.APPLE, apple, Items.class);
|
||||
RegistryLockSpinner.commit(Item.REGISTRY, Items.STICK, stick, Items.class);
|
||||
RegistryLockSpinner.commit(Item.REGISTRY, Item.getItemFromBlock(Blocks.DOUBLE_PLANT), double_plant, Items.class);
|
||||
RegistryLockSpinner.commit(Item.REGISTRY, Item.getItemFromBlock(Blocks.YELLOW_FLOWER), yellow_flower, Items.class);
|
||||
RegistryLockSpinner.commit(Item.REGISTRY, Item.getItemFromBlock(Blocks.RED_FLOWER), red_flower, Items.class);
|
||||
|
||||
RegistryLockSpinner.lock(Item.REGISTRY);
|
||||
RegistryLockSpinner.open(Item.REGISTRY, Items.class, r -> r
|
||||
.replace(Items.APPLE, apple)
|
||||
.replace(Items.STICK, stick)
|
||||
.replace(Item.getItemFromBlock(Blocks.DOUBLE_PLANT), double_plant)
|
||||
.replace(Item.getItemFromBlock(Blocks.YELLOW_FLOWER), yellow_flower)
|
||||
.replace(Item.getItemFromBlock(Blocks.RED_FLOWER), red_flower));
|
||||
|
||||
registry.registerAll(
|
||||
cloud_spawner, dew_drop, cloud_matter, cloud_block,
|
||||
cloud_stairs, cloud_slab, cloud_farmland,
|
||||
mist_door, anvil,
|
||||
|
||||
bag_of_holding, spell, curse, spellbook,
|
||||
bag_of_holding, spell, curse, spellbook, mug,
|
||||
|
||||
alfalfa_seeds, alfalfa_leaves,
|
||||
cereal, sugar_cereal, sugar_block,
|
||||
|
@ -196,7 +203,7 @@ public class UItems {
|
|||
tomato, cloudsdale_tomato,
|
||||
|
||||
cloud_spawner, cloud_matter, cloud_stairs, cloud_farmland, mist_door, anvil,
|
||||
bag_of_holding, spell, curse, spellbook,
|
||||
bag_of_holding, spell, curse, spellbook, mug,
|
||||
|
||||
alfalfa_seeds, alfalfa_leaves,
|
||||
cereal, sugar_cereal, sugar_block,
|
||||
|
|
|
@ -57,6 +57,8 @@ public class ItemEdible extends ItemFood implements IEdible {
|
|||
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
|
||||
Toxicity toxicity = getToxicityLevel(stack);
|
||||
|
||||
setAlwaysEdible();
|
||||
|
||||
TextFormatting color = toxicity.toxicWhenCooked() ? TextFormatting.RED : toxicity.toxicWhenRaw() ? TextFormatting.DARK_PURPLE : TextFormatting.GRAY;
|
||||
|
||||
tooltip.add(color + I18n.format(toxicity.getTranslationKey()));
|
||||
|
@ -80,7 +82,14 @@ public class ItemEdible extends ItemFood implements IEdible {
|
|||
}
|
||||
}
|
||||
|
||||
ItemStack container = getContainerItem(stack);
|
||||
|
||||
if (!container.isEmpty()) {
|
||||
return container;
|
||||
}
|
||||
|
||||
stack.shrink(1);
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import net.minecraft.potion.PotionEffect;
|
|||
|
||||
public enum Toxicity {
|
||||
SAFE(0, 0),
|
||||
MILD(1, 160),
|
||||
FAIR(1, 30),
|
||||
SEVERE(5, 160),
|
||||
LETHAL(10, 900);
|
||||
|
@ -19,6 +20,10 @@ public enum Toxicity {
|
|||
this.duration = duration;
|
||||
}
|
||||
|
||||
public boolean isMild() {
|
||||
return this == MILD;
|
||||
}
|
||||
|
||||
public boolean toxicWhenRaw() {
|
||||
return isLethal() || this != SAFE;
|
||||
}
|
||||
|
@ -32,7 +37,7 @@ public enum Toxicity {
|
|||
}
|
||||
|
||||
public PotionEffect getPoisonEffect() {
|
||||
return new PotionEffect(MobEffects.POISON, duration, level);
|
||||
return new PotionEffect(isMild() ? MobEffects.NAUSEA : MobEffects.POISON, duration, level);
|
||||
}
|
||||
|
||||
public String getTranslationKey() {
|
||||
|
|
|
@ -44,7 +44,6 @@ public class UItemFoodDelegate extends ItemMultiTexture implements IEdible {
|
|||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
|
||||
foodItem.setAlwaysEdible();
|
||||
return foodItem.onItemRightClick(worldIn, playerIn, handIn);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.minelittlepony.unicopia.forgebullshit;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.util.registry.RegistryNamespaced;
|
||||
import net.minecraftforge.registries.ILockableRegistry;
|
||||
|
@ -9,7 +10,24 @@ import net.minecraftforge.registries.ILockableRegistry;
|
|||
@FUF(reason = "Forge locks the registries. We need a way to unlock them.")
|
||||
public final class RegistryLockSpinner {
|
||||
|
||||
public static void unlock(RegistryNamespaced<?, ?> registry) {
|
||||
public static <K, V> void open(RegistryNamespaced<K, V> registry, Class<?> containersClazz, Consumer<UnlockedRegistry<K, V>> action) {
|
||||
unlock(registry);
|
||||
|
||||
try {
|
||||
action.accept(new UnlockedRegistry<K, V>() {
|
||||
@Override
|
||||
public UnlockedRegistry<K, V> replace(V from, V to) {
|
||||
commit(registry, from, to, containersClazz);
|
||||
return this;
|
||||
}
|
||||
|
||||
});
|
||||
} finally {
|
||||
lock(registry);
|
||||
}
|
||||
}
|
||||
|
||||
private static void unlock(RegistryNamespaced<?, ?> registry) {
|
||||
if (registry instanceof ILockableRegistry) {
|
||||
try {
|
||||
Field f = registry.getClass().getDeclaredField("locked");
|
||||
|
@ -22,11 +40,9 @@ public final class RegistryLockSpinner {
|
|||
}
|
||||
}
|
||||
|
||||
public static <K, V> void commit(RegistryNamespaced<K, V> registry, V from, V to, Class<?> inClass) {
|
||||
private static <K, V> void commit(RegistryNamespaced<K, V> registry, V from, V to, Class<?> inClass) {
|
||||
registry.register(registry.getIDForObject(from), registry.getNameForObject(from), to);
|
||||
|
||||
|
||||
|
||||
for (Field i : inClass.getDeclaredFields()) {
|
||||
try {
|
||||
if (i.get(null) == from) {
|
||||
|
@ -42,7 +58,7 @@ public final class RegistryLockSpinner {
|
|||
private static boolean init = false;
|
||||
private static Field modifieres = null;
|
||||
|
||||
protected static void initModifiersField(Field f) {
|
||||
private static void initModifiersField() {
|
||||
if (!init) {
|
||||
init = true;
|
||||
try {
|
||||
|
@ -55,8 +71,8 @@ public final class RegistryLockSpinner {
|
|||
}
|
||||
|
||||
@FUF(reason = "Not exactly forge's fault, but it was would be nice of them to not leave these as final")
|
||||
protected static Field makeNonFinal(Field f) throws IllegalArgumentException, IllegalAccessException {
|
||||
initModifiersField(f);
|
||||
private static Field makeNonFinal(Field f) throws IllegalArgumentException, IllegalAccessException {
|
||||
initModifiersField();
|
||||
if (Modifier.isFinal(f.getModifiers()) && modifieres != null) {
|
||||
modifieres.setInt(f, f.getModifiers() & ~Modifier.FINAL);
|
||||
}
|
||||
|
@ -64,9 +80,14 @@ public final class RegistryLockSpinner {
|
|||
return f;
|
||||
}
|
||||
|
||||
public static void lock(RegistryNamespaced<?, ?> registry) {
|
||||
private static void lock(RegistryNamespaced<?, ?> registry) {
|
||||
if (registry instanceof ILockableRegistry) {
|
||||
((ILockableRegistry) registry).lock();
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface UnlockedRegistry<K, V> {
|
||||
UnlockedRegistry<K, V> replace(V from, V to);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,12 +19,13 @@ public class ItemCereal extends ItemFood {
|
|||
setTranslationKey(name);
|
||||
setRegistryName(domain, name);
|
||||
setMaxStackSize(1);
|
||||
setContainerItem(Items.BOWL);
|
||||
}
|
||||
|
||||
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) {
|
||||
super.onItemUseFinish(stack, worldIn, entityLiving);
|
||||
|
||||
return new ItemStack(Items.BOWL);
|
||||
return getContainerItem(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -83,6 +83,7 @@ item.hay_fries.name=Hay Fries
|
|||
item.salad.name=Salad
|
||||
item.wheat_worms.name=Wheat Worms
|
||||
item.apple_cider.name=Apple Cider
|
||||
item.mug.name=Mug
|
||||
|
||||
entity.racing_cloud.name=Bucking Bronco
|
||||
entity.construction_cloud.name=Construction Cloud
|
||||
|
@ -91,7 +92,8 @@ entity.spell.name=Magic
|
|||
entity.spellbook.name=Spellbook
|
||||
|
||||
toxicity.safe.name=Safe
|
||||
toxicity.fair.name=Fair
|
||||
toxicity.mild.name=Mildly Toxic
|
||||
toxicity.fair.name=Fairly Toxic
|
||||
toxicity.severe.name=Toxic
|
||||
toxicity.lethal.name=Lethal
|
||||
|
||||
|
|
6
src/main/resources/assets/unicopia/models/item/mug.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "unicopia:items/mug"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 3 KiB |
After Width: | Height: | Size: 197 B |
After Width: | Height: | Size: 3.2 KiB |
BIN
src/main/resources/assets/unicopia/textures/items/hay_burger.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
src/main/resources/assets/unicopia/textures/items/hay_fries.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
src/main/resources/assets/unicopia/textures/items/juice.png
Normal file
After Width: | Height: | Size: 271 B |
BIN
src/main/resources/assets/unicopia/textures/items/mug.png
Normal file
After Width: | Height: | Size: 3 KiB |
BIN
src/main/resources/assets/unicopia/textures/items/salad.png
Normal file
After Width: | Height: | Size: 314 B |
Before Width: | Height: | Size: 253 B After Width: | Height: | Size: 264 B |
After Width: | Height: | Size: 528 B |