mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 03:15:07 +00:00
'flatten' temeprance stone
This commit is contained in:
1 parent
b37764bd30
commit
53543d607a
5 files changed
+26
-18
No files matched your search
@@ -79,6 +79,8 @@ public class FlattenItems implements IFixableData {
|
||||
case 8: return ModItems.mutatedSeeds.getRegistryName().toString();
|
||||
}
|
||||
});
|
||||
// Just remove the meta (moved to NBT, defaults back to inactive)
|
||||
LOOKUP.put("botania:temperancestone", i -> ModItems.temperanceStone.getRegistryName().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,48 +19,46 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import vazkii.botania.client.core.handler.ModelHandler;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemTemperanceStone extends ItemMod {
|
||||
private static final String TAG_ACTIVE = "active";
|
||||
|
||||
public ItemTemperanceStone() {
|
||||
super(LibItemNames.TEMPERANCE_STONE);
|
||||
setMaxStackSize(1);
|
||||
setHasSubtypes(true);
|
||||
addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "active"),
|
||||
(stack, worldIn, entityIn) -> ItemNBTHelper.getBoolean(stack, TAG_ACTIVE, false) ? 1 : 0);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
int dmg = stack.getItemDamage();
|
||||
stack.setItemDamage(~dmg & 1);
|
||||
ItemNBTHelper.setBoolean(stack, TAG_ACTIVE, !ItemNBTHelper.getBoolean(stack, TAG_ACTIVE, false));
|
||||
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.NEUTRAL, 0.3F, 0.1F);
|
||||
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack par1ItemStack, World world, List<String> stacks, ITooltipFlag flags) {
|
||||
if(par1ItemStack.getItemDamage() == 1)
|
||||
public void addInformation(ItemStack stack, World world, List<String> stacks, ITooltipFlag flags) {
|
||||
if(ItemNBTHelper.getBoolean(stack, TAG_ACTIVE, false))
|
||||
addStringToTooltip(I18n.format("botaniamisc.active"), stacks);
|
||||
else addStringToTooltip(I18n.format("botaniamisc.inactive"), stacks);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModels() {
|
||||
ModelHandler.registerItemAppendMeta(this, 2, LibItemNames.TEMPERANCE_STONE);
|
||||
}
|
||||
|
||||
private void addStringToTooltip(String s, List<String> tooltip) {
|
||||
tooltip.add(s.replaceAll("&", "\u00a7"));
|
||||
}
|
||||
@@ -69,7 +67,7 @@ public class ItemTemperanceStone extends ItemMod {
|
||||
IInventory inv = player.inventory;
|
||||
for(int i = 0; i < inv.getSizeInventory(); i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
if(!stack.isEmpty() && stack.getItem() == ModItems.temperanceStone && stack.getItemDamage() == 1)
|
||||
if(!stack.isEmpty() && stack.getItem() == ModItems.temperanceStone && ItemNBTHelper.getBoolean(stack, TAG_ACTIVE, false))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "botania:items/stone_temperance"
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"predicate": {
|
||||
"botania:active": 1
|
||||
},
|
||||
"model": "botania:item/temperancestone_active"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "botania:items/stone_temperance"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user