lots more items

This commit is contained in:
Vincent Lee committed 2019-02-23 23:02:01 -06:00
1 parent cb2b082ef1
commit e7d0315ce3
69 files changed
+822 -950

No files matched your search

@@ -103,7 +103,6 @@ public final class BotaniaAPI {
public static final Set<Item> looniumBlacklist = new LinkedHashSet<>();
public static final Map<Block, EnumProperty<EnumDyeColor>> paintableBlocks = new LinkedHashMap<>();
public static final Set<String> magnetBlacklist = new LinkedHashSet<>();
public static final Set<Class<? extends Entity>> gravityRodBlacklist = new LinkedHashSet<>();
// TODO 1.13 move these to eliminate dependence on botania proper in Ingredients
@@ -538,65 +537,6 @@ public final class BotaniaAPI {
return gravityRodBlacklist.contains(entity);
}
/**
* Blacklists an item from being pulled by the Ring of Magnetization.
* Short.MAX_VALUE can be used as the stack's damage for a wildcard.
*/
public static void blacklistItemFromMagnet(ItemStack stack) {
String key = getMagnetKey(stack);
magnetBlacklist.add(key);
}
/**
* Blacklists a block from having items on top of it being pulled by the Ring of Magnetization.
* Short.MAX_VALUE can be used as meta for a wildcard.
*/
public static void blacklistBlockFromMagnet(Block block, int meta) {
String key = getMagnetKey(block, meta);
magnetBlacklist.add(key);
}
public static boolean isItemBlacklistedFromMagnet(ItemStack stack) {
return isItemBlacklistedFromMagnet(stack, 0);
}
public static boolean isItemBlacklistedFromMagnet(ItemStack stack, int recursion) {
if(recursion > 5)
return false;
if(stack.getItemDamage() != Short.MAX_VALUE) {
ItemStack copy = new ItemStack(stack.getItem(), 0, Short.MAX_VALUE);
boolean general = isItemBlacklistedFromMagnet(copy, recursion + 1);
if(general)
return true;
}
String key = getMagnetKey(stack);
return magnetBlacklist.contains(key);
}
public static boolean isBlockBlacklistedFromMagnet(IBlockState state) {
return isBlockBlacklistedFromMagnet(state.getBlock(), state.getBlock().getMetaFromState(state));
}
public static boolean isBlockBlacklistedFromMagnet(Block block, int meta) {
return isBlockBlacklistedFromMagnet(block, meta, 0);
}
public static boolean isBlockBlacklistedFromMagnet(Block block, int meta, int recursion) {
if(recursion >= 5)
return false;
if(meta != Short.MAX_VALUE) {
boolean general = isBlockBlacklistedFromMagnet(block, Short.MAX_VALUE, recursion + 1);
if(general)
return true;
}
String key = getMagnetKey(block, meta);
return magnetBlacklist.contains(key);
}
/**
* Registers a Petal Recipe.
* @param output The ItemStack to craft.
@@ -868,15 +808,4 @@ public final class BotaniaAPI {
return subTiles.getKeys();
}
private static String getMagnetKey(ItemStack stack) {
if(stack.isEmpty())
return "";
return "i_" + stack.getItem().getTranslationKey() + "@" + stack.getItemDamage();
}
private static String getMagnetKey(Block block, int meta) {
return "bm_" + block.getTranslationKey() + "@" + meta;
}
}
@@ -45,7 +45,7 @@ import javax.annotation.Nonnull;
import java.util.Random;
public class BlockModFlower extends BlockFlower implements ILexiconable, IGrowable {
protected final EnumDyeColor color;
public final EnumDyeColor color;
protected BlockModFlower(EnumDyeColor color, Properties builder) {
super(builder);
this.color = color;
@@ -13,6 +13,8 @@ package vazkii.botania.common.item;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -25,20 +27,15 @@ import java.util.Locale;
public class ItemAncientWill extends ItemMod {
public final IAncientWillContainer.AncientWillType type;
public ItemAncientWill(IAncientWillContainer.AncientWillType variant) {
super(LibItemNames.ANCIENT_WILL + "_" + variant.name().toLowerCase(Locale.ROOT));
public ItemAncientWill(IAncientWillContainer.AncientWillType variant, Properties props) {
super(props);
this.type = variant;
setMaxStackSize(1);
}
@OnlyIn(Dist.CLIENT)
@Override
public void addInformation(ItemStack stack, World world, List<String> list, ITooltipFlag flag) {
addStringToTooltip(I18n.format("botaniamisc.craftToAddWill"), list);
addStringToTooltip(I18n.format("botania.armorset.will_" + type.name().toLowerCase(Locale.ROOT) + ".shortDesc"), list);
}
public void addStringToTooltip(String s, List<String> tooltip) {
tooltip.add(s.replaceAll("&", "\u00a7"));
public void addInformation(ItemStack stack, World world, List<ITextComponent> list, ITooltipFlag flag) {
list.add(new TextComponentTranslation("botaniamisc.craftToAddWill"));
list.add(new TextComponentTranslation("botania.armorset.will_" + type.name().toLowerCase(Locale.ROOT) + ".shortDesc"));
}
}
@@ -20,13 +20,19 @@ import net.minecraft.init.Items;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.ResourceLocationException;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.IRegistry;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
@@ -34,6 +40,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemHandlerHelper;
import net.minecraftforge.registries.ForgeRegistries;
import vazkii.botania.api.item.IBlockProvider;
import vazkii.botania.client.core.handler.ItemsRemainingRenderHandler;
import vazkii.botania.client.core.handler.ModelHandler;
@@ -48,12 +55,10 @@ import java.util.List;
public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
public static final String TAG_ACTIVE = "active";
private static final String TAG_BLOCK_NAME = "blockName";
private static final String TAG_BLOCK_META = "blockMeta";
private static final String TAG_BLOCK_COUNT = "blockCount";
public ItemBlackHoleTalisman() {
super(LibItemNames.BLACK_HOLE_TALISMAN);
setMaxStackSize(1);
public ItemBlackHoleTalisman(Properties props) {
super(props);
addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "active"),
(stack, worldIn, entityIn) -> ItemNBTHelper.getBoolean(stack, TAG_ACTIVE, false) ? 1 : 0);
}
@@ -73,40 +78,41 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
public EnumActionResult onItemUse(ItemUseContext ctx) {
World world = ctx.getWorld();
BlockPos pos = ctx.getPos();
EnumFacing side = ctx.getFace();
EntityPlayer player = ctx.getPlayer();
IBlockState state = world.getBlockState(pos);
ItemStack stack = player.getHeldItem(hand);
ItemStack stack = ctx.getItem();
if (Item.getItemFromBlock(state.getBlock()) != Items.AIR
&& setBlock(stack, state.getBlock(), state.getBlock().getMetaFromState(state))) {
if (!state.isAir(world, pos) && setBlock(stack, state.getBlock())) {
return EnumActionResult.SUCCESS;
} else {
Block bBlock = getBlock(stack);
int bmeta = getBlockMeta(stack);
if(bBlock == null)
return EnumActionResult.PASS;
TileEntity tile = world.getTileEntity(pos);
if(tile != null && tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) {
if(tile != null && tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side).isPresent()) {
if(!world.isRemote) {
IItemHandler inv = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side);
ItemStack toAdd = new ItemStack(bBlock, 1, bmeta);
int maxSize = toAdd.getMaxStackSize();
toAdd.setCount(remove(stack, maxSize));
ItemStack remainder = ItemHandlerHelper.insertItemStacked(inv, toAdd, false);
if(!remainder.isEmpty())
add(stack, remainder.getCount());
tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side).ifPresent(inv -> {
ItemStack toAdd = new ItemStack(bBlock);
int maxSize = toAdd.getMaxStackSize();
toAdd.setCount(remove(stack, maxSize));
ItemStack remainder = ItemHandlerHelper.insertItemStacked(inv, toAdd, false);
if(!remainder.isEmpty())
add(stack, remainder.getCount());
});
}
return EnumActionResult.SUCCESS;
} else {
if(player.capabilities.isCreativeMode || getBlockCount(stack) > 0) {
ItemStack toUse = new ItemStack(bBlock, 1, bmeta);
ItemStack saveHeldItem = player.getHeldItem(hand);
player.setHeldItem(hand, toUse);
EnumActionResult result = Item.getItemFromBlock(bBlock).onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ);
player.setHeldItem(hand, saveHeldItem);
if(player == null || player.abilities.isCreativeMode || getBlockCount(stack) > 0) {
ItemStack toUse = new ItemStack(bBlock);
// todo 1.13 need the protected constructor probably
ItemUseContext newCtx = new ItemUseContext(ctx.getPlayer(), stack, pos, side, ctx.getHitX(), ctx.getHitY(), ctx.getHitZ());
EnumActionResult result = toUse.getItem().onItemUse(newCtx);
if (result == EnumActionResult.SUCCESS) {
remove(stack, 1);
@@ -121,11 +127,10 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
}
@Override
public void onUpdate(ItemStack itemstack, World world, Entity entity, int slot, boolean selected) {
public void inventoryTick(ItemStack itemstack, World world, Entity entity, int slot, boolean selected) {
Block block = getBlock(itemstack);
if(!entity.world.isRemote && ItemNBTHelper.getBoolean(itemstack, TAG_ACTIVE, false) && block != null && entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
int meta = getBlockMeta(itemstack);
int highest = -1;
int[] counts = new int[player.inventory.getSizeInventory() - player.inventory.armorInventory.size()];
@@ -136,7 +141,7 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
continue;
}
if(Item.getItemFromBlock(block) == stack.getItem() && stack.getItemDamage() == meta) {
if(block.asItem() == stack.getItem()) {
counts[i] = stack.getCount();
if(highest == -1)
highest = i;
@@ -178,12 +183,18 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
@Nonnull
@Override
public String getItemStackDisplayName(@Nonnull ItemStack par1ItemStack) {
Block block = getBlock(par1ItemStack);
int meta = getBlockMeta(par1ItemStack);
ItemStack stack = new ItemStack(block, 1, meta);
public ITextComponent getDisplayName(@Nonnull ItemStack stack) {
Block block = getBlock(stack);
ItemStack bstack = new ItemStack(block);
ITextComponent cand = super.getDisplayName(stack);
return super.getItemStackDisplayName(par1ItemStack) + (stack.isEmpty() ? "" : " (" + TextFormatting.GREEN + stack.getDisplayName() + TextFormatting.RESET + ")");
if(!bstack.isEmpty()) {
cand.appendText(" (");
cand.appendSibling(bstack.getDisplayName().applyTextStyle(TextFormatting.GREEN));
cand.appendText(")");
}
return cand;
}
@Nonnull
@@ -206,10 +217,9 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
return !getContainerItem(stack).isEmpty();
}
private boolean setBlock(ItemStack stack, Block block, int meta) {
if(Item.getItemFromBlock(block) != Items.AIR && (getBlock(stack) == null || getBlockCount(stack) == 0)) {
private boolean setBlock(ItemStack stack, Block block) {
if(block.asItem() != Items.AIR && (getBlock(stack) == null || getBlockCount(stack) == 0)) {
ItemNBTHelper.setString(stack, TAG_BLOCK_NAME, block.getRegistryName().toString());
ItemNBTHelper.setInt(stack, TAG_BLOCK_META, meta);
return true;
}
return false;
@@ -222,20 +232,16 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
@Override
@OnlyIn(Dist.CLIENT)
public void addInformation(ItemStack stack, World world, List<String> stacks, ITooltipFlag flags) {
public void addInformation(ItemStack stack, World world, List<ITextComponent> stacks, ITooltipFlag flags) {
Block block = getBlock(stack);
if(block != null) {
int count = getBlockCount(stack);
stacks.add(count + " " + I18n.format(new ItemStack(block, 1, getBlockMeta(stack)).getTranslationKey() + ".name"));
stacks.add(new TextComponentString(Integer.toString(count) + " ").appendSibling(new ItemStack(block).getDisplayName()));
}
if(ItemNBTHelper.getBoolean(stack, TAG_ACTIVE, false))
addStringToTooltip(I18n.format("botaniamisc.active"), stacks);
else addStringToTooltip(I18n.format("botaniamisc.inactive"), stacks);
}
void addStringToTooltip(String s, List<String> tooltip) {
tooltip.add(s.replaceAll("&", "\u00a7"));
stacks.add(new TextComponentTranslation("botaniamisc.active"));
else stacks.add(new TextComponentTranslation("botaniamisc.inactive"));
}
private static void setCount(ItemStack stack, int count) {
@@ -249,17 +255,17 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
return Math.min(current, count);
}
public static String getBlockName(ItemStack stack) {
private static String getBlockName(ItemStack stack) {
return ItemNBTHelper.getString(stack, TAG_BLOCK_NAME, "");
}
@Nullable
public static Block getBlock(ItemStack stack) {
return Block.getBlockFromName(getBlockName(stack));
}
public static int getBlockMeta(ItemStack stack) {
return ItemNBTHelper.getInt(stack, TAG_BLOCK_META, 0);
try {
return IRegistry.BLOCK.get(new ResourceLocation(getBlockName(stack)));
} catch (ResourceLocationException ex) {
return null;
}
}
public static int getBlockCount(ItemStack stack) {
@@ -267,10 +273,9 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
}
@Override
public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) {
public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, boolean doit) {
Block stored = getBlock(stack);
int storedMeta = getBlockMeta(stack);
if(stored == block && storedMeta == meta) {
if(stored == block) {
int count = getBlockCount(stack);
if(count > 0) {
if(doit)
@@ -283,10 +288,9 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
}
@Override
public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) {
public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block) {
Block stored = getBlock(stack);
int storedMeta = getBlockMeta(stack);
if(stored == block && storedMeta == meta)
if(stored == block)
return getBlockCount(stack);
return 0;
}
@@ -32,10 +32,12 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.server.ServerLifecycleHooks;
import vazkii.botania.client.core.handler.ModelHandler;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.entity.EntityPixie;
@@ -52,9 +54,8 @@ public class ItemBottledMana extends ItemMod {
public static final String TAG_SWIGS_LEFT = "swigsLeft";
private static final String TAG_SEED = "randomSeed";
public ItemBottledMana() {
super(LibItemNames.MANA_BOTTLE);
setMaxStackSize(1);
public ItemBottledMana(Properties props) {
super(props);
addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "swigs_taken"), (stack, world, entity) -> SWIGS - getSwigsLeft(stack));
}
@@ -66,8 +67,8 @@ public class ItemBottledMana extends ItemMod {
break;
}
case 1 : { // Water
if(!living.world.isRemote && !living.world.provider.doesWaterVaporize())
living.world.setBlockState(new BlockPos(living), Blocks.FLOWING_WATER.getDefaultState());
if(!living.world.isRemote && !living.world.getDimension().doesWaterVaporize())
living.world.setBlockState(new BlockPos(living), Blocks.WATER.getDefaultState());
break;
}
case 2 : { // Set on Fire
@@ -81,7 +82,7 @@ public class ItemBottledMana extends ItemMod {
break;
}
case 4 : { // Mega Jump
if(!living.world.provider.doesWaterVaporize()) {
if(!living.world.getDimension().isNether()) {
if(!living.world.isRemote)
living.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 300, 5));
living.motionY = 6;
@@ -159,7 +160,7 @@ public class ItemBottledMana extends ItemMod {
int range = 5;
List<EntityLivingBase> entities = living.world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(living.posX - range, living.posY - range, living.posZ - range, living.posX + range, living.posY + range, living.posZ + range));
for(EntityLivingBase entity : entities)
if(entity != living && (!(entity instanceof EntityPlayer) || FMLCommonHandler.instance().getMinecraftServerInstance() == null || FMLCommonHandler.instance().getMinecraftServerInstance().isPVPEnabled()))
if(entity != living && (!(entity instanceof EntityPlayer) || ServerLifecycleHooks.getCurrentServer() == null || ServerLifecycleHooks.getCurrentServer().isPVPEnabled()))
entity.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 50, 5));
}
@@ -184,8 +185,8 @@ public class ItemBottledMana extends ItemMod {
case 15 : { // Drop own Head
if(!living.world.isRemote && living instanceof EntityPlayer) {
living.attackEntityFrom(DamageSource.MAGIC, living.getHealth() - 1);
ItemStack skull = new ItemStack(Items.SKULL, 1, 3);
ItemNBTHelper.setString(skull, "SkullOwner", living.getName());
ItemStack skull = new ItemStack(Items.PLAYER_HEAD);
ItemNBTHelper.setString(skull, "SkullOwner", ((EntityPlayer) living).getGameProfile().getName());
living.entityDropItem(skull, 0);
}
break;
@@ -193,9 +194,6 @@ public class ItemBottledMana extends ItemMod {
}
}
@Override
public void onUpdate(ItemStack par1ItemStack, World world, Entity par3Entity, int par4, boolean par5) {}
private void randomEffect(EntityLivingBase player, ItemStack stack) {
effect(stack, player, new Random(getSeed(stack)).nextInt(16));
}
@@ -208,15 +206,15 @@ public class ItemBottledMana extends ItemMod {
}
private long randomSeed(ItemStack stack) {
long seed = Math.abs(itemRand.nextLong());
long seed = Math.abs(random.nextLong());
ItemNBTHelper.setLong(stack, TAG_SEED, seed);
return seed;
}
@OnlyIn(Dist.CLIENT)
@Override
public void addInformation(ItemStack par1ItemStack, World world, List<String> stacks, ITooltipFlag flags) {
stacks.add(I18n.format("botaniamisc.bottleTooltip"));
public void addInformation(ItemStack par1ItemStack, World world, List<ITextComponent> stacks, ITooltipFlag flags) {
stacks.add(new TextComponentTranslation("botaniamisc.bottleTooltip"));
}
@Nonnull
@@ -241,13 +239,13 @@ public class ItemBottledMana extends ItemMod {
}
@Override
public int getMaxItemUseDuration(ItemStack par1ItemStack) {
public int getUseDuration(ItemStack par1ItemStack) {
return 20;
}
@Nonnull
@Override
public EnumAction getItemUseAction(ItemStack par1ItemStack) {
public EnumAction getUseAction(ItemStack par1ItemStack) {
return EnumAction.DRINK;
}
@@ -28,9 +28,13 @@ import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.ResourceLocationException;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.IRegistry;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import net.minecraftforge.api.distmarker.Dist;
@@ -53,9 +57,8 @@ public class ItemCacophonium extends ItemMod {
private static final String TAG_SOUND = "sound";
private static final String TAG_SOUND_NAME = "soundName";
public ItemCacophonium() {
super(LibItemNames.CACOPHONIUM);
setMaxStackSize(1);
public ItemCacophonium(Properties props) {
super(props);
}
@Override
@@ -114,21 +117,21 @@ public class ItemCacophonium extends ItemMod {
@OnlyIn(Dist.CLIENT)
@Override
public void addInformation(ItemStack stack, World world, List<String> list, ITooltipFlag flags) {
public void addInformation(ItemStack stack, World world, List<ITextComponent> list, ITooltipFlag flags) {
if(isDOIT(stack))
list.add(I18n.format("botaniamisc.justDoIt"));
list.add(new TextComponentTranslation("botaniamisc.justDoIt"));
else if(getSound(stack) != null)
list.add(I18n.format(ItemNBTHelper.getString(stack, TAG_SOUND_NAME, "")));
}
@Nonnull
@Override
public EnumAction getItemUseAction(ItemStack par1ItemStack) {
public EnumAction getUseAction(ItemStack par1ItemStack) {
return EnumAction.BLOCK;
}
@Override
public int getMaxItemUseDuration(ItemStack par1ItemStack) {
public int getUseDuration(ItemStack par1ItemStack) {
return 72000;
}
@@ -161,10 +164,16 @@ public class ItemCacophonium extends ItemMod {
private static SoundEvent getSound(ItemStack stack) {
if(isDOIT(stack))
return ModSounds.doit;
else return SoundEvent.REGISTRY.getObject(new ResourceLocation(ItemNBTHelper.getString(stack, TAG_SOUND, "")));
else {
try {
return IRegistry.SOUND_EVENT.get(new ResourceLocation(ItemNBTHelper.getString(stack, TAG_SOUND, "")));
} catch (ResourceLocationException ex) {
return null;
}
}
}
private static boolean isDOIT(ItemStack stack) {
return !stack.isEmpty() && stack.getDisplayName().equalsIgnoreCase("shia labeouf");
return !stack.isEmpty() && stack.getDisplayName().getString().equalsIgnoreCase("shia labeouf");
}
}
@@ -1,22 +0,0 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [Jan 24, 2015, 7:56:38 PM (GMT)]
*/
package vazkii.botania.common.item;
import vazkii.botania.common.lib.LibItemNames;
public class ItemClip extends ItemMod {
public ItemClip() {
super(LibItemNames.CLIP);
setMaxStackSize(1);
}
}
@@ -12,6 +12,7 @@ package vazkii.botania.common.item;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
@@ -26,18 +27,22 @@ import javax.annotation.Nonnull;
public class ItemCorporeaSpark extends ItemMod {
public ItemCorporeaSpark(String name) {
super(name);
public ItemCorporeaSpark(Properties props) {
super(props);
}
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xv, float yv, float zv) {
public EnumActionResult onItemUse(ItemUseContext ctx) {
World world = ctx.getWorld();
BlockPos pos = ctx.getPos();
TileEntity tile = world.getTileEntity(pos);
if(tile != null && (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP) || tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null))
if(tile != null
&& (tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP).isPresent()
|| tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).isPresent())
&& !CorporeaHelper.doesBlockHaveSpark(world, pos)) {
ItemStack stack = player.getHeldItem(hand);
stack.shrink(1);
ctx.getItem().shrink(1);
if(!world.isRemote) {
EntityCorporeaSpark spark = new EntityCorporeaSpark(world);
if(this == ModItems.corporeaSparkMaster)
@@ -26,7 +26,7 @@ public class ItemCraftPattern extends ItemMod {
public final CratePattern pattern;
public ItemCraftPattern(CratePattern pattern, Properties props) {
super(LibItemNames.CRAFT_PATTERN_PREFIX + "_" + pattern.name().toLowerCase(Locale.ROOT));
super(props);
this.pattern = pattern;
}
@@ -35,9 +35,8 @@ public class ItemEnderHand extends ItemMod implements IManaUsingItem, IBlockProv
private static final int COST_SELF = 250;
private static final int COST_OTHER = 5000;
public ItemEnderHand() {
super(LibItemNames.ENDER_HAND);
setMaxStackSize(1);
public ItemEnderHand(Properties props) {
super(props);
}
@Nonnull
@@ -73,17 +72,17 @@ public class ItemEnderHand extends ItemMod implements IManaUsingItem, IBlockProv
}
@Override
public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) {
if(requestor != null && requestor.getItem() == this)
public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, boolean doit) {
if(!requestor.isEmpty() && requestor.getItem() == this)
return false;
ItemStack istack = ItemExchangeRod.removeFromInventory(player, new InvWrapper(player.getInventoryEnderChest()), stack, block, meta, false);
ItemStack istack = ItemExchangeRod.removeFromInventory(player, new InvWrapper(player.getInventoryEnderChest()), stack, block, false);
if(!istack.isEmpty()) {
boolean mana = ManaItemHandler.requestManaExact(stack, player, COST_PROVIDE, false);
if(mana) {
if(doit) {
ManaItemHandler.requestManaExact(stack, player, COST_PROVIDE, true);
ItemExchangeRod.removeFromInventory(player, new InvWrapper(player.getInventoryEnderChest()), stack, block, meta, true);
ItemExchangeRod.removeFromInventory(player, new InvWrapper(player.getInventoryEnderChest()), stack, block, true);
}
return true;
@@ -94,11 +93,11 @@ public class ItemEnderHand extends ItemMod implements IManaUsingItem, IBlockProv
}
@Override
public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) {
if(requestor != null && requestor.getItem() == this)
public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block) {
if(!requestor.isEmpty() && requestor.getItem() == this)
return 0;
return ItemExchangeRod.getInventoryItemCount(player, new InvWrapper(player.getInventoryEnderChest()), stack, block, meta);
return ItemExchangeRod.getInventoryItemCount(player, new InvWrapper(player.getInventoryEnderChest()), stack, block);
}
}
@@ -10,6 +10,7 @@
*/
package vazkii.botania.common.item;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -17,7 +18,8 @@ import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.item.ItemUseContext;
import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.play.server.SPacketCollectItem;
@@ -34,8 +36,8 @@ import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
@@ -43,6 +45,7 @@ import net.minecraftforge.items.ItemHandlerHelper;
import net.minecraftforge.items.ItemStackHandler;
import net.minecraftforge.items.wrapper.InvWrapper;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.BlockModFlower;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.lib.LibGuiIDs;
import vazkii.botania.common.lib.LibItemNames;
@@ -51,13 +54,9 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ItemFlowerBag extends ItemMod {
private static final String TAG_ITEMS = "InvItems";
public ItemFlowerBag() {
super(LibItemNames.FLOWER_BAG);
setMaxStackSize(1);
MinecraftForge.EVENT_BUS.register(this);
public ItemFlowerBag(Properties props) {
super(props);
MinecraftForge.EVENT_BUS.addListener(this::onPickupItem);
}
@Nonnull
@@ -66,65 +65,43 @@ public class ItemFlowerBag extends ItemMod {
return new InvProvider();
}
private static class InvProvider implements ICapabilitySerializable<NBTBase> {
private static class InvProvider implements ICapabilitySerializable<INBTBase> {
private final IItemHandler inv = new ItemStackHandler(16) {
@Nonnull
@Override
public ItemStack insertItem(int slot, @Nonnull ItemStack toInsert, boolean simulate) {
Block blk = Block.getBlockFromItem(toInsert.getItem());
if(!toInsert.isEmpty()
&& toInsert.getItem() == Item.getItemFromBlock(ModBlocks.flower)
&& toInsert.getItemDamage() == slot)
&& blk instanceof BlockModFlower
&& slot == ((BlockModFlower) blk).color.getId())
return super.insertItem(slot, toInsert, simulate);
else return toInsert;
}
};
private final LazyOptional<IItemHandler> opt = LazyOptional.of(() -> inv);
@Nonnull
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY;
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.orEmpty(capability, opt);
}
@Override
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(inv);
else return null;
}
@Override
public NBTBase serializeNBT() {
public INBTBase serializeNBT() {
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.writeNBT(inv, null);
}
@Override
public void deserializeNBT(NBTBase nbt) {
public void deserializeNBT(INBTBase nbt) {
CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.readNBT(inv, null, nbt);
}
}
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
if(stack.getTagCompound() != null && stack.getTagCompound().hasKey(TAG_ITEMS)) {
NBTTagList oldData = stack.getTagCompound().getTagList(TAG_ITEMS, Constants.NBT.TAG_COMPOUND);
IItemHandler newInv = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.readNBT(newInv, null, oldData);
stack.getTagCompound().removeTag(TAG_ITEMS);
if(stack.getTagCompound().getSize() == 0)
stack.setTagCompound(null);
}
}
@SubscribeEvent
public void onPickupItem(EntityItemPickupEvent event) {
private void onPickupItem(EntityItemPickupEvent event) {
ItemStack entityStack = event.getItem().getItem();
if(entityStack.getItem() == Item.getItemFromBlock(ModBlocks.flower) && entityStack.getCount() > 0) {
int color = entityStack.getItemDamage();
if(color > 15)
return;
if(Block.getBlockFromItem(entityStack.getItem()) instanceof BlockModFlower && entityStack.getCount() > 0) {
int color = ((BlockModFlower) Block.getBlockFromItem(entityStack.getItem())).color.getId();
for(int i = 0; i < event.getEntityPlayer().inventory.getSizeInventory(); i++) {
if(i == event.getEntityPlayer().inventory.currentItem)
@@ -132,7 +109,7 @@ public class ItemFlowerBag extends ItemMod {
ItemStack bag = event.getEntityPlayer().inventory.getStackInSlot(i);
if(!bag.isEmpty() && bag.getItem() == this) {
IItemHandler bagInv = bag.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
IItemHandler bagInv = bag.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElseThrow(NullPointerException::new);
ItemStack result = bagInv.insertItem(color, entityStack, false);
int numPickedUp = entityStack.getCount() - result.getCount();
@@ -165,25 +142,28 @@ public class ItemFlowerBag extends ItemMod {
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xs, float ys, float zs) {
public EnumActionResult onItemUse(ItemUseContext ctx) {
World world = ctx.getWorld();
BlockPos pos = ctx.getPos();
EnumFacing side = ctx.getFace();
TileEntity tile = world.getTileEntity(pos);
if(tile != null) {
if(!world.isRemote) {
IItemHandler tileInv = null;
if(tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side))
tileInv = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side);
IItemHandler tileInv;
if(tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side).isPresent())
tileInv = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side).orElseThrow(NullPointerException::new);
else if(tile instanceof IInventory)
tileInv = new InvWrapper((IInventory) tile);
else return EnumActionResult.FAIL;
if(tileInv == null)
return EnumActionResult.FAIL;
ctx.getItem().getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(bagInv -> {
for(int i = 0; i < bagInv.getSlots(); i++) {
ItemStack flower = bagInv.getStackInSlot(i);
((IItemHandlerModifiable) bagInv).setStackInSlot(i, ItemHandlerHelper.insertItemStacked(tileInv, flower, false));
}
});
IItemHandlerModifiable bagInv = (IItemHandlerModifiable) player.getHeldItem(hand).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
for(int i = 0; i < bagInv.getSlots(); i++) {
ItemStack flower = bagInv.getStackInSlot(i);
bagInv.setStackInSlot(i, ItemHandlerHelper.insertItemStacked(tileInv, flower, false));
}
}
return EnumActionResult.SUCCESS;
@@ -16,14 +16,17 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.lib.LibItemNames;
import vazkii.botania.common.lib.LibMisc;
import java.util.ArrayList;
import java.util.List;
@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID)
public class ItemKeepIvy extends ItemMod {
public static final String TAG_KEEP = "Botania_keepIvy";
@@ -32,9 +35,8 @@ public class ItemKeepIvy extends ItemMod {
private static final String TAG_DROP_COUNT = "dropCount";
private static final String TAG_DROP_PREFIX = "dropPrefix";
public ItemKeepIvy() {
super(LibItemNames.KEEP_IVY);
MinecraftForge.EVENT_BUS.register(ItemKeepIvy.class);
public ItemKeepIvy(Properties props) {
super(props);
}
@SubscribeEvent
@@ -42,7 +44,7 @@ public class ItemKeepIvy extends ItemMod {
List<EntityItem> keeps = new ArrayList<>();
for(EntityItem item : event.getDrops()) {
ItemStack stack = item.getItem();
if(!stack.isEmpty() && stack.hasTagCompound() && ItemNBTHelper.getBoolean(stack, TAG_KEEP, false))
if(!stack.isEmpty() && stack.hasTag() && ItemNBTHelper.getBoolean(stack, TAG_KEEP, false))
keeps.add(item);
}
@@ -50,44 +52,44 @@ public class ItemKeepIvy extends ItemMod {
event.getDrops().removeAll(keeps);
NBTTagCompound cmp = new NBTTagCompound();
cmp.setInteger(TAG_DROP_COUNT, keeps.size());
cmp.putInt(TAG_DROP_COUNT, keeps.size());
int i = 0;
for(EntityItem keep : keeps) {
ItemStack stack = keep.getItem();
NBTTagCompound cmp1 = stack.writeToNBT(new NBTTagCompound());
cmp.setTag(TAG_DROP_PREFIX + i, cmp1);
NBTTagCompound cmp1 = stack.write(new NBTTagCompound());
cmp.put(TAG_DROP_PREFIX + i, cmp1);
i++;
}
NBTTagCompound data = event.getEntityPlayer().getEntityData();
if(!data.hasKey(EntityPlayer.PERSISTED_NBT_TAG))
data.setTag(EntityPlayer.PERSISTED_NBT_TAG, new NBTTagCompound());
if(!data.contains(EntityPlayer.PERSISTED_NBT_TAG))
data.put(EntityPlayer.PERSISTED_NBT_TAG, new NBTTagCompound());
NBTTagCompound persist = data.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG);
persist.setTag(TAG_PLAYER_KEPT_DROPS, cmp);
NBTTagCompound persist = data.getCompound(EntityPlayer.PERSISTED_NBT_TAG);
persist.put(TAG_PLAYER_KEPT_DROPS, cmp);
}
}
@SubscribeEvent
public static void onPlayerRespawn(PlayerRespawnEvent event) {
NBTTagCompound data = event.player.getEntityData();
if(data.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) {
NBTTagCompound cmp = data.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG);
NBTTagCompound cmp1 = cmp.getCompoundTag(TAG_PLAYER_KEPT_DROPS);
NBTTagCompound data = event.getPlayer().getEntityData();
if(data.contains(EntityPlayer.PERSISTED_NBT_TAG)) {
NBTTagCompound cmp = data.getCompound(EntityPlayer.PERSISTED_NBT_TAG);
NBTTagCompound cmp1 = cmp.getCompound(TAG_PLAYER_KEPT_DROPS);
int count = cmp1.getInteger(TAG_DROP_COUNT);
int count = cmp1.getInt(TAG_DROP_COUNT);
for(int i = 0; i < count; i++) {
NBTTagCompound cmp2 = cmp1.getCompoundTag(TAG_DROP_PREFIX + i);
ItemStack stack = new ItemStack(cmp2);
NBTTagCompound cmp2 = cmp1.getCompound(TAG_DROP_PREFIX + i);
ItemStack stack = ItemStack.read(cmp2);
if(!stack.isEmpty()) {
ItemStack copy = stack.copy();
ItemNBTHelper.setBoolean(copy, TAG_KEEP, false);
event.player.inventory.addItemStackToInventory(copy);
event.getPlayer().inventory.addItemStackToInventory(copy);
}
}
cmp.setTag(TAG_PLAYER_KEPT_DROPS, new NBTTagCompound());
cmp.put(TAG_PLAYER_KEPT_DROPS, new NBTTagCompound());
}
}
@@ -20,8 +20,13 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.init.Blocks;
import net.minecraft.init.Particles;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.particles.BlockParticleData;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
@@ -32,6 +37,8 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.api.distmarker.Dist;
@@ -56,9 +63,7 @@ import java.util.List;
public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanetExcempt {
private static final String TAG_BLOCK = "_block";
private static final String TAG_BLOCK_NAME = "_blockname";
private static final String TAG_META = "_meta";
private static final String TAG_STATE = "_state";
private static final String TAG_TILE = "_tile";
private static final String TAG_X = "_x";
private static final String TAG_Y = "_y";
@@ -69,49 +74,58 @@ public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanet
private static final String TAG_ITERATION_I = "iterationI";
private static final String TAG_ITERATION_J = "iterationJ";
private static final String TAG_ITERATION_K = "iterationK";
private static final String TAG_LEVEL = "level";
private static final int BASE_RANGE = 14;
private static final int BASE_OFFSET = 42;
public ItemLaputaShard() {
super(LibItemNames.LAPUTA_SHARD);
setHasSubtypes(true);
public ItemLaputaShard(Properties props) {
super(props);
}
@Override
public void getSubItems(@Nonnull CreativeTabs tab, @Nonnull NonNullList<ItemStack> list) {
super.getSubItems(tab, list);
if(isInCreativeTab(tab)) {
for(int i = 0; i < 4; i++)
list.add(new ItemStack(this, 1, (i + 1) * 5 - 1));
public void fillItemGroup(@Nonnull ItemGroup tab, @Nonnull NonNullList<ItemStack> list) {
super.fillItemGroup(tab, list);
if(isInGroup(tab)) {
for(int i = 0; i < 4; i++) {
ItemStack s = new ItemStack(this);
s.getOrCreateTag().putInt(TAG_LEVEL, (i + 1) * 5 - 1);
list.add(s);
}
}
}
@OnlyIn(Dist.CLIENT)
@Override
public void addInformation(ItemStack stack, World world, List<String> list, ITooltipFlag flags) {
list.add(I18n.format("botaniamisc.shardLevel", I18n.format("botania.roman" + (stack.getItemDamage() + 1))));
public void addInformation(ItemStack stack, World world, List<ITextComponent> list, ITooltipFlag flags) {
int level = stack.getOrCreateTag().getInt(TAG_LEVEL);
ITextComponent levelLoc = new TextComponentTranslation("botania.roman" + (level + 1));
list.add(new TextComponentTranslation("botaniamisc.shardLevel", levelLoc));
}
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
if(!world.isRemote && pos.getY() < 160 && !world.provider.doesWaterVaporize()) {
public EnumActionResult onItemUse(ItemUseContext ctx) {
World world = ctx.getWorld();
BlockPos pos = ctx.getPos();
if(!world.isRemote && pos.getY() < 160 && !world.getDimension().isNether()) {
world.playSound(null, pos, ModSounds.laputaStart, SoundCategory.BLOCKS, 1.0F + world.rand.nextFloat(), world.rand.nextFloat() * 0.7F + 1.3F);
ItemStack stack = player.getHeldItem(hand);
ItemStack stack = ctx.getItem();
spawnBurstFirst(world, pos, stack);
UseItemSuccessTrigger.INSTANCE.trigger((EntityPlayerMP) player, stack, (WorldServer) world, pos.getX(), pos.getY(), pos.getZ());
if(ctx.getPlayer() != null) {
UseItemSuccessTrigger.INSTANCE.trigger((EntityPlayerMP) ctx.getPlayer(), stack, (WorldServer) world, pos.getX(), pos.getY(), pos.getZ());
}
stack.shrink(1);
}
return EnumActionResult.SUCCESS;
}
public void spawnBurstFirst(World world, BlockPos pos, ItemStack lens) {
int range = BASE_RANGE + lens.getItemDamage();
public void spawnBurstFirst(World world, BlockPos pos, ItemStack shard) {
int range = BASE_RANGE + shard.getOrCreateTag().getInt(TAG_LEVEL);
boolean pointy = world.rand.nextDouble() < 0.25;
double heightscale = (world.rand.nextDouble() + 0.5) * ((double)BASE_RANGE / (double)range);
spawnBurst(world, pos, lens, pointy, heightscale);
spawnBurst(world, pos, shard, pointy, heightscale);
}
public void spawnBurst(World world, BlockPos pos, ItemStack lens) {
@@ -121,12 +135,12 @@ public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanet
spawnBurst(world, pos, lens, pointy, heightscale);
}
public void spawnBurst(World world, BlockPos pos, ItemStack lens, boolean pointy, double heightscale) {
int range = BASE_RANGE + lens.getItemDamage();
public void spawnBurst(World world, BlockPos pos, ItemStack shard, boolean pointy, double heightscale) {
int range = BASE_RANGE + shard.getOrCreateTag().getInt(TAG_LEVEL);
int i = ItemNBTHelper.getInt(lens, TAG_ITERATION_I, 0);
int j = ItemNBTHelper.getInt(lens, TAG_ITERATION_J, BASE_OFFSET - BASE_RANGE / 2);
int k = ItemNBTHelper.getInt(lens, TAG_ITERATION_K, 0);
int i = ItemNBTHelper.getInt(shard, TAG_ITERATION_I, 0);
int j = ItemNBTHelper.getInt(shard, TAG_ITERATION_J, BASE_OFFSET - BASE_RANGE / 2);
int k = ItemNBTHelper.getInt(shard, TAG_ITERATION_K, 0);
if(j <= -BASE_RANGE * 2)
j = BASE_OFFSET - BASE_RANGE / 2;
@@ -146,18 +160,18 @@ public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanet
TileEntity tile = world.getTileEntity(pos_);
if(tile != null) {
TileEntity newTile = block.createTileEntity(world, state);
// Reset the TE so e.g. chests don't spawn their drops
TileEntity newTile = block.createTileEntity(state, world);
world.setTileEntity(pos_, newTile);
}
world.setBlockToAir(pos_);
world.playEvent(2001, pos_, Block.getStateId(state));
world.destroyBlock(pos_, false);
ItemStack copyLens = new ItemStack(this, 1, lens.getItemDamage());
ItemNBTHelper.setString(copyLens, TAG_BLOCK_NAME, Block.REGISTRY.getNameForObject(block).toString());
ItemNBTHelper.setInt(copyLens, TAG_META, block.getMetaFromState(state));
ItemStack copyLens = new ItemStack(this);
copyLens.getOrCreateTag().putInt(TAG_LEVEL, shard.getOrCreateTag().getInt(TAG_LEVEL));
copyLens.getTag().put(TAG_STATE, NBTUtil.writeBlockState(state));
NBTTagCompound cmp = new NBTTagCompound();
if(tile != null)
tile.writeToNBT(cmp);
cmp = tile.write(cmp);
ItemNBTHelper.setCompound(copyLens, TAG_TILE, cmp);
ItemNBTHelper.setInt(copyLens, TAG_X, pos.getX());
ItemNBTHelper.setInt(copyLens, TAG_Y, pos.getY());
@@ -245,31 +259,25 @@ public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanet
BlockPos pos = new BlockPos(x, y, z);
if(entity.world.isAirBlock(pos)) {
Block block = Blocks.AIR;
if (lens.hasTagCompound()) {
if (lens.getTagCompound().hasKey(TAG_BLOCK_NAME)) {
block = Block.getBlockFromName(ItemNBTHelper.getString(lens, TAG_BLOCK_NAME, ""));
} else if (lens.getTagCompound().hasKey(TAG_BLOCK)) {
// Attempt to read legacy tag (integer ID) if string block ID is absent
block = Block.getBlockById(ItemNBTHelper.getInt(lens, TAG_BLOCK, 0));
}
IBlockState state = Blocks.AIR.getDefaultState();
if (lens.hasTag() && lens.getTag().contains(TAG_STATE)) {
state = NBTUtil.readBlockState(lens.getTag().getCompound(TAG_STATE));
}
int meta = ItemNBTHelper.getInt(lens, TAG_META, 0);
TileEntity tile = null;
NBTTagCompound tilecmp = ItemNBTHelper.getCompound(lens, TAG_TILE, false);
if(tilecmp.hasKey("id"))
tile = TileEntity.create(entity.world, tilecmp);
if(tilecmp.contains("id"))
tile = TileEntity.create(tilecmp);
entity.world.setBlockState(pos, block.getStateFromMeta(meta), 1 | 2);
entity.world.playEvent(2001, pos, Block.getStateId(block.getStateFromMeta(meta)));
entity.world.setBlockState(pos, state);
entity.world.playEvent(2001, pos, Block.getStateId(state));
if(tile != null) {
tile.setPos(pos);
entity.world.setTileEntity(pos, tile);
}
}
entity.setDead();
entity.remove();
}
}
}
@@ -278,10 +286,8 @@ public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanet
public boolean doParticles(IManaBurst burst, ItemStack stack) {
EntityThrowable entity = (EntityThrowable) burst;
ItemStack lens = burst.getSourceLens();
String id = ItemNBTHelper.getString(lens, TAG_BLOCK_NAME, "minecraft:air");
Block b = Block.getBlockFromName(id);
int meta = ItemNBTHelper.getInt(lens, TAG_META, 0);
entity.world.spawnParticle(EnumParticleTypes.BLOCK_CRACK, entity.posX, entity.posY, entity.posZ, entity.motionX, entity.motionY, entity.motionZ, Block.getStateId(b.getStateFromMeta(meta)));
IBlockState state = NBTUtil.readBlockState(lens.getOrCreateTag().getCompound(TAG_STATE));
entity.world.addParticle(new BlockParticleData(Particles.BLOCK, state), entity.posX, entity.posY, entity.posZ, entity.motionX, entity.motionY, entity.motionZ);
return true;
}
@@ -291,10 +297,4 @@ public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanet
return false;
}
@OnlyIn(Dist.CLIENT)
@Override
public void registerModels() {
ModelHandler.registerItemAllMeta(this, 20);
}
}
@@ -11,6 +11,7 @@
package vazkii.botania.common.item;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemUseContext;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
@@ -27,21 +28,24 @@ import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.lib.LibItemNames;
import javax.annotation.Nonnull;
import java.util.function.BiFunction;
public class ItemObedienceStick extends ItemMod {
public ItemObedienceStick() {
super(LibItemNames.OBEDIENCE_STICK);
setMaxStackSize(1);
public ItemObedienceStick(Properties props) {
super(props);
}
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xs, float ys, float zs) {
public EnumActionResult onItemUse(ItemUseContext ctx) {
World world = ctx.getWorld();
BlockPos pos = ctx.getPos();
TileEntity tileAt = world.getTileEntity(pos);
if(tileAt != null && (tileAt instanceof IManaPool || tileAt instanceof IManaCollector)) {
if(tileAt instanceof IManaPool || tileAt instanceof IManaCollector) {
boolean pool = tileAt instanceof IManaPool;
Actuator act = pool ? Actuator.functionalActuator : Actuator.generatingActuator;
BiFunction<SubTileEntity, TileEntity, Boolean> act = pool ? functionalActuator : generatingActuator;
int range = pool ? SubTileFunctional.LINK_RANGE : SubTileGenerating.LINK_RANGE;
for(BlockPos pos_ : BlockPos.getAllInBox(pos.add(-range, -range, -range), pos.add(range, range, range))) {
@@ -51,7 +55,7 @@ public class ItemObedienceStick extends ItemMod {
TileEntity tile = world.getTileEntity(pos_);
if(tile instanceof ISubTileContainer) {
SubTileEntity subtile = ((ISubTileContainer) tile).getSubTile();
if(act.actuate(subtile, tileAt)) {
if(act.apply(subtile, tileAt)) {
Vector3 orig = new Vector3(pos_.getX() + 0.5, pos_.getY() + 0.5, pos_.getZ() + 0.5);
Vector3 end = new Vector3(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
ItemTwigWand.doParticleBeam(world, orig, end);
@@ -59,43 +63,26 @@ public class ItemObedienceStick extends ItemMod {
}
}
if(player.world.isRemote)
player.swingArm(hand);
return EnumActionResult.SUCCESS;
}
return EnumActionResult.PASS;
}
public static abstract class Actuator {
public static final Actuator generatingActuator = new Actuator() {
private static final BiFunction<SubTileEntity, TileEntity, Boolean> generatingActuator = (flower, tile) -> {
if(flower instanceof SubTileGenerating) {
((SubTileGenerating) flower).linkToForcefully(tile);
return true;
}
return false;
};
@Override
public boolean actuate(SubTileEntity flower, TileEntity tile) {
if(flower instanceof SubTileGenerating) {
((SubTileGenerating) flower).linkToForcefully(tile);
return true;
}
return false;
}
};
public static final Actuator functionalActuator = new Actuator() {
@Override
public boolean actuate(SubTileEntity flower, TileEntity tile) {
if(flower instanceof SubTileFunctional) {
((SubTileFunctional) flower).linkToForcefully(tile);
return true;
}
return false;
}
};
public abstract boolean actuate(SubTileEntity flower, TileEntity tile);
}
private static final BiFunction<SubTileEntity, TileEntity, Boolean> functionalActuator = (flower, tile) -> {
if(flower instanceof SubTileFunctional) {
((SubTileFunctional) flower).linkToForcefully(tile);
return true;
}
return false;
};
}
@@ -31,9 +31,8 @@ import javax.annotation.Nonnull;
public class ItemOpenBucket extends ItemMod {
public ItemOpenBucket() {
super(LibItemNames.OPEN_BUCKET);
setMaxStackSize(1);
public ItemOpenBucket(Properties props) {
super(props);
}
@Nonnull
@@ -13,9 +13,11 @@ package vazkii.botania.common.item;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
@@ -29,27 +31,25 @@ import javax.annotation.Nonnull;
public class ItemOvergrowthSeed extends ItemMod {
public ItemOvergrowthSeed() {
super(LibItemNames.OVERGROWTH_SEED);
public ItemOvergrowthSeed(Properties props) {
super(props);
}
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xs, float ys, float zs) {
public EnumActionResult onItemUse(ItemUseContext ctx) {
World world = ctx.getWorld();
BlockPos pos = ctx.getPos();
// todo 1.13 grass tag
IBlockState state = world.getBlockState(pos);
if(Item.getItemFromBlock(state.getBlock()) == Items.AIR)
return EnumActionResult.PASS;
ItemStack blockStack = new ItemStack(state.getBlock());
int[] ids = OreDictionary.getOreIDs(blockStack);
for(int i : ids) {
String name = OreDictionary.getOreName(i);
if(name.equals("grass")) {
if(state.getBlock() == Blocks.GRASS_BLOCK) {
if(!world.isRemote) {
world.playEvent(2001, pos, Block.getStateId(state));
world.setBlockState(pos, ModBlocks.enchantedSoil.getDefaultState());
player.getHeldItem(hand).shrink(1);
return EnumActionResult.SUCCESS;
ctx.getItem().shrink(1);
}
return EnumActionResult.SUCCESS;
}
return EnumActionResult.PASS;
}
@@ -16,6 +16,7 @@ import net.minecraft.item.IItemPropertyGetter;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import vazkii.botania.client.core.handler.ModelHandler;
@@ -37,9 +38,7 @@ public class ItemSlimeBottle extends ItemMod {
@Override
public void inventoryTick(ItemStack stack, World world, Entity entity, int something, boolean somethingelse) {
if(!world.isRemote) {
int x = MathHelper.floor(entity.posX);
int z = MathHelper.floor(entity.posZ);
boolean slime = SubTileNarslimmus.isSlimeChunk(world, x, z);
boolean slime = SubTileNarslimmus.isSlimeChunk(world, new BlockPos(entity));
ItemNBTHelper.setBoolean(stack, TAG_ACTIVE, slime);
}
}
@@ -15,6 +15,7 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
@@ -28,10 +29,12 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.registries.ForgeRegistries;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
import vazkii.botania.common.Botania;
import vazkii.botania.common.advancements.UseItemSuccessTrigger;
@@ -46,27 +49,26 @@ public class ItemSpawnerMover extends ItemMod {
private static final String TAG_SPAWN_DATA = "SpawnData";
private static final String TAG_ID = "id";
public ItemSpawnerMover() {
super(LibItemNames.SPAWNER_MOVER);
setMaxStackSize(1);
public ItemSpawnerMover(Properties props) {
super(props);
addPropertyOverride(new ResourceLocation("botania", "full"), (stack, worldIn, entityIn) -> hasData(stack) ? 1 : 0);
}
public static NBTTagCompound getSpawnerTag(ItemStack stack) {
NBTTagCompound tag = stack.getTagCompound();
if(tag != null && tag.hasKey(TAG_SPAWNER)) {
return tag.getCompoundTag(TAG_SPAWNER);
NBTTagCompound tag = stack.getTag();
if(tag != null && tag.contains(TAG_SPAWNER)) {
return tag.getCompound(TAG_SPAWNER);
}
return null;
}
private static String getEntityId(ItemStack stack) {
private static ResourceLocation getEntityId(ItemStack stack) {
NBTTagCompound tag = getSpawnerTag(stack);
if(tag != null && tag.hasKey(TAG_SPAWN_DATA)) {
tag = tag.getCompoundTag(TAG_SPAWN_DATA);
if(tag.hasKey(TAG_ID)) {
return EntityList.getTranslationName(new ResourceLocation(tag.getString(TAG_ID)));
if(tag != null && tag.contains(TAG_SPAWN_DATA)) {
tag = tag.getCompound(TAG_SPAWN_DATA);
if(tag.contains(TAG_ID)) {
return ResourceLocation.makeResourceLocation(tag.getString(TAG_ID));
}
}
@@ -79,10 +81,14 @@ public class ItemSpawnerMover extends ItemMod {
@OnlyIn(Dist.CLIENT)
@Override
public void addInformation(ItemStack stack, World world, List<String> infoList, ITooltipFlag flags) {
String id = getEntityId(stack);
if (id != null)
infoList.add(I18n.format("entity." + id + ".name"));
public void addInformation(ItemStack stack, World world, List<ITextComponent> infoList, ITooltipFlag flags) {
ResourceLocation id = getEntityId(stack);
if (id != null) {
EntityType<?> type = ForgeRegistries.ENTITIES.getValue();
if (type != null) {
infoList.add(type.func_212546_e());
}
}
}
@Nonnull
@@ -90,15 +96,14 @@ public class ItemSpawnerMover extends ItemMod {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xOffset, float yOffset, float zOffset) {
ItemStack itemstack = player.getHeldItem(hand);
if(getEntityId(itemstack) == null) {
if(world.getBlockState(pos).getBlock() == Blocks.MOB_SPAWNER) {
if(world.getBlockState(pos).getBlock() == Blocks.SPAWNER) {
if(!world.isRemote) {
TileEntity te = world.getTileEntity(pos);
NBTTagCompound tag = new NBTTagCompound();
tag.setTag(TAG_SPAWNER, new NBTTagCompound());
te.writeToNBT(tag.getCompoundTag(TAG_SPAWNER));
tag.put(TAG_SPAWNER, te.write(new NBTTagCompound()));
player.getCooldownTracker().setCooldown(this, 20);
itemstack.setTagCompound(tag);
world.setBlockToAir(pos);
itemstack.setTag(tag);
world.destroyBlock(pos, false);
UseItemSuccessTrigger.INSTANCE.trigger((EntityPlayerMP) player, itemstack, (WorldServer) world, pos.getX(), pos.getY(), pos.getZ());
player.renderBrokenItemStack(itemstack);
} else {
@@ -153,15 +158,15 @@ public class ItemSpawnerMover extends ItemMod {
return false;
Block block = world.getBlockState(pos).getBlock();
if(block == Blocks.MOB_SPAWNER) {
if(block == Blocks.SPAWNER) {
TileEntity te = world.getTileEntity(pos);
NBTTagCompound tag = stack.getTagCompound();
if (te instanceof TileEntityMobSpawner && tag.hasKey(TAG_SPAWNER)) {
tag = tag.getCompoundTag(TAG_SPAWNER);
tag.setInteger("x", pos.getX());
tag.setInteger("y", pos.getY());
tag.setInteger("z", pos.getZ());
te.readFromNBT(tag);
NBTTagCompound tag = stack.getTag();
if (te instanceof TileEntityMobSpawner && tag.contains(TAG_SPAWNER)) {
tag = tag.getCompound(TAG_SPAWNER);
tag.putInt("x", pos.getX());
tag.putInt("y", pos.getY());
tag.putInt("z", pos.getZ());
te.read(tag);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
}
}
@@ -225,32 +225,32 @@ public final class ModItems {
public static final Item terrasteelLegs = new ItemTerrasteelArmor(EntityEquipmentSlot.LEGS, unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.TERRASTEEL_LEGS);
public static final Item terrasteelBoots = new ItemTerrasteelArmor(EntityEquipmentSlot.FEET, unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.TERRASTEEL_BOOTS);
public static final Item terraSword = new ItemTerraSword(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.TERRA_SWORD);
public static final Item tinyPlanet = new ItemTinyPlanet();
public static final Item manaRing = new ItemManaRing();
public static final Item auraRing = new ItemAuraRing();
public static final Item manaRingGreater = new ItemGreaterManaRing();
public static final Item auraRingGreater = new ItemGreaterAuraRing();
public static final Item travelBelt = new ItemTravelBelt();
public static final Item knockbackBelt = new ItemKnockbackBelt();
public static final Item icePendant = new ItemIcePendant();
public static final Item lavaPendant = new ItemLavaPendant();
public static final Item magnetRing = new ItemMagnetRing();
public static final Item waterRing = new ItemWaterRing();
public static final Item miningRing = new ItemMiningRing();
public static final Item tinyPlanet = new ItemTinyPlanet(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.TINY_PLANET);
public static final Item manaRing = new ItemManaRing(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RING);
public static final Item auraRing = new ItemAuraRing(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.AURA_RING);
public static final Item manaRingGreater = new ItemGreaterManaRing(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RING_GREATER);
public static final Item auraRingGreater = new ItemGreaterAuraRing(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.AURA_RING_GREATER);
public static final Item travelBelt = new ItemTravelBelt(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.TRAVEL_BELT);
public static final Item knockbackBelt = new ItemKnockbackBelt(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.KNOCKBACK_BELT);
public static final Item icePendant = new ItemIcePendant(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ICE_PENDANT);
public static final Item lavaPendant = new ItemLavaPendant(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.LAVA_PENDANT);
public static final Item magnetRing = new ItemMagnetRing(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MAGNET_RING);
public static final Item waterRing = new ItemWaterRing(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.WATER_RING);
public static final Item miningRing = new ItemMiningRing(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MINING_RING);
public static final Item terraPick = new ItemTerraPick(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.TERRA_PICK);
public static final Item divaCharm = new ItemDivaCharm();
public static final Item divaCharm = new ItemDivaCharm(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.DIVA_CHARM);
public static final Item flightTiara = new ItemFlightTiara();
public static final Item enderDagger = new ItemEnderDagger(unstackable().defaultMaxDamage(69).setNoRepair()); // What you looking at?
public static final Item darkQuartz = new ItemMod(LibItemNames.QUARTZ_NAMES[0]);
public static final Item manaQuartz = new ItemMod(LibItemNames.QUARTZ_NAMES[1]);
public static final Item blazeQuartz = new ItemMod(LibItemNames.QUARTZ_NAMES[2]);
public static final Item lavenderQuartz = new ItemMod(LibItemNames.QUARTZ_NAMES[3]);
public static final Item redQuartz = new ItemMod(LibItemNames.QUARTZ_NAMES[4]);
public static final Item elfQuartz = new ItemElven(LibItemNames.QUARTZ_NAMES[5]);
public static final Item sunnyQuartz = new ItemMod(LibItemNames.QUARTZ_NAMES[6]);
public static final Item waterRod = new ItemWaterRod();
public static final Item darkQuartz = new ItemMod(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.QUARTZ_NAMES[0]);
public static final Item manaQuartz = new ItemMod(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.QUARTZ_NAMES[1]);
public static final Item blazeQuartz = new ItemMod(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.QUARTZ_NAMES[2]);
public static final Item lavenderQuartz = new ItemMod(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.QUARTZ_NAMES[3]);
public static final Item redQuartz = new ItemMod(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.QUARTZ_NAMES[4]);
public static final Item elfQuartz = new ItemMod(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.QUARTZ_NAMES[5]);
public static final Item sunnyQuartz = new ItemMod(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.QUARTZ_NAMES[6]);
public static final Item waterRod = new ItemWaterRod(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.WATER_ROD);
public static final Item elementiumHelm = new ItemElementiumHelm(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ELEMENTIUM_HELM);
public static final Item elementiumHelmRevealing = new ItemElementiumHelmRevealing();
public static final Item elementiumHelmRevealing = new ItemElementiumHelmRevealing(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ELEMENTIUM_HELM_R);
public static final Item elementiumChest = new ItemElementiumChest(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ELEMENTIUM_CHEST);
public static final Item elementiumLegs = new ItemElementiumLegs(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ELEMENTIUM_LEGS);
public static final Item elementiumBoots = new ItemElementiumBoots(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ELEMENTIUM_BOOTS);
@@ -259,54 +259,54 @@ public final class ModItems {
public static final Item elementiumAxe = new ItemElementiumAxe(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ELEMENTIUM_AXE);
public static final Item elementiumSword = new ItemElementiumSword(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ELEMENTIUM_SWORD);
public static final Item elementiumShears = new ItemElementiumShears(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ELEMENTIUM_SHEARS);
public static final Item openBucket = new ItemOpenBucket();
public static final Item spawnerMover = new ItemSpawnerMover();
public static final Item pixieRing = new ItemPixieRing();
public static final Item openBucket = new ItemOpenBucket(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.OPEN_BUCKET);
public static final Item spawnerMover = new ItemSpawnerMover(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.SPAWNER_MOVER);
public static final Item pixieRing = new ItemPixieRing(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.PIXIE_RING);
public static final Item superTravelBelt = new ItemSuperTravelBelt(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.SUPER_TRAVEL_BELT);
public static final Item rainbowRod = new ItemRainbowRod();
public static final Item tornadoRod = new ItemTornadoRod();
public static final Item fireRod = new ItemFireRod();
public static final Item rainbowRod = new ItemRainbowRod(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.RAINBOW_ROD);
public static final Item tornadoRod = new ItemTornadoRod(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.TORNADO_ROD);
public static final Item fireRod = new ItemFireRod(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.FIRE_ROD);
public static final Item vineBall = new ItemVineBall(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.VINE_BALL);
public static final Item slingshot = new ItemSlingshot(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.SLINGSHOT);
public static final Item manaBottle = new ItemBottledMana();
public static final Item laputaShard = new ItemLaputaShard();
public static final Item manaBottle = new ItemBottledMana(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_BOTTLE);
public static final Item laputaShard = new ItemLaputaShard(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.LAPUTA_SHARD);
public static final Item necroVirus = new ItemVirus(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.NECRO_VIRUS);
public static final Item nullVirus = new ItemVirus(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.NULL_VIRUS);
public static final Item reachRing = new ItemReachRing();
public static final Item reachRing = new ItemReachRing(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.REACH_RING);
public static final Item skyDirtRod = new ItemSkyDirtRod(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.SKY_DIRT_ROD);
public static final Item itemFinder = new ItemItemFinder();
public static final Item superLavaPendant = new ItemSuperLavaPendant();
public static final Item enderHand = new ItemEnderHand();
public static final Item glassPick = new ItemGlassPick(unstackable());
public static final Item itemFinder = new ItemItemFinder(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ITEM_FINDER);
public static final Item superLavaPendant = new ItemSuperLavaPendant(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.SUPER_LAVA_PENDANT);
public static final Item enderHand = new ItemEnderHand(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ENDER_HAND);
public static final Item glassPick = new ItemGlassPick(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.GLASS_PICK);
public static final Item spark = new ItemSpark(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.SPARK);
public static final Item sparkUpgradeDispersive = new ItemSparkUpgrade(defaultBuilder(), SparkUpgradeType.DISPERSIVE).setRegistryName(LibMisc.MOD_ID, LibItemNames.SPARK_UPGRADE + "_" + SparkUpgradeType.DISPERSIVE.name().toLowerCase(Locale.ROOT));
public static final Item sparkUpgradeDominant = new ItemSparkUpgrade(defaultBuilder(), SparkUpgradeType.DOMINANT).setRegistryName(LibMisc.MOD_ID, LibItemNames.SPARK_UPGRADE + "_" + SparkUpgradeType.DOMINANT.name().toLowerCase(Locale.ROOT));
public static final Item sparkUpgradeRecessive = new ItemSparkUpgrade(defaultBuilder(), SparkUpgradeType.RECESSIVE).setRegistryName(LibMisc.MOD_ID, LibItemNames.SPARK_UPGRADE + "_" + SparkUpgradeType.RECESSIVE.name().toLowerCase(Locale.ROOT));
public static final Item sparkUpgradeIsolated = new ItemSparkUpgrade(defaultBuilder(), SparkUpgradeType.ISOLATED).setRegistryName(LibMisc.MOD_ID, LibItemNames.SPARK_UPGRADE + "_" + SparkUpgradeType.ISOLATED.name().toLowerCase(Locale.ROOT));
public static final Item diviningRod = new ItemDiviningRod();
public static final Item gravityRod = new ItemGravityRod();
public static final Item manaInkwell = new ItemManaInkwell();
public static final Item diviningRod = new ItemDiviningRod(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.DIVINING_ROD);
public static final Item gravityRod = new ItemGravityRod(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.GRAVITY_ROD);
public static final Item manaInkwell = new ItemManaInkwell(unstackable().setNoRepair()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_INKWELL);
public static final Item vial = new ItemVial(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.VIAL);
public static final Item flask = new ItemVial(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.FLASK);
public static final Item brewVial = new ItemBrewBase(unstackable(), 4, 32, new ItemStack(vial)).setRegistryName(LibMisc.MOD_ID, LibItemNames.BREW_VIAL);
public static final Item brewFlask = new ItemBrewBase(unstackable(), 6, 24, new ItemStack(flask)).setRegistryName(LibMisc.MOD_ID, LibItemNames.BREW_FLASK);
public static final Item bloodPendant = new ItemBloodPendant();
public static final Item missileRod = new ItemMissileRod();
public static final Item holyCloak = new ItemHolyCloak();
public static final Item unholyCloak = new ItemUnholyCloak();
public static final Item balanceCloak = new ItemBalanceCloak();
public static final Item bloodPendant = new ItemBloodPendant(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.BLOOD_PENDANT);
public static final Item missileRod = new ItemMissileRod(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MISSILE_ROD);
public static final Item holyCloak = new ItemHolyCloak(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.HOLY_CLOAK);
public static final Item unholyCloak = new ItemUnholyCloak(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.UNHOLY_CLOAK);
public static final Item balanceCloak = new ItemBalanceCloak(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.BALANCE_CLOAK);
public static final Item craftingHalo = new ItemCraftingHalo(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.CRAFTING_HALO);
public static final Item blackLotus = new ItemBlackLotus(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.BLACK_LOTUS);
public static final Item blackerLotus = new ItemBlackLotus(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.BLACKER_LOTUS);
public static final Item monocle = new ItemMonocle();
public static final Item clip = new ItemClip();
public static final Item cobbleRod = new ItemCobbleRod();
public static final Item smeltRod = new ItemSmeltRod();
public static final Item monocle = new ItemMonocle(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MONOCLE);
public static final Item clip = new ItemMod(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.CLIP);
public static final Item cobbleRod = new ItemCobbleRod(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.COBBLE_ROD);
public static final Item smeltRod = new ItemSmeltRod(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.SMELT_ROD);
public static final Item worldSeed = new ItemWorldSeed(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.WORLD_SEED);
public static final Item spellCloth = new ItemSpellCloth(unstackable().defaultMaxDamage(35).setNoRepair()).setRegistryName(LibMisc.MOD_ID, LibItemNames.SPELL_CLOTH);
public static final Item thornChakram = new ItemThornChakram(defaultBuilder().maxStackSize(6)).setRegistryName(LibMisc.MOD_ID, LibItemNames.THORN_CHAKRAM);
public static final Item flareChakram = new ItemThornChakram(defaultBuilder().maxStackSize(6)).setRegistryName(LibMisc.MOD_ID, LibItemNames.FLARE_CHAKRAM);
public static final Item overgrowthSeed = new ItemOvergrowthSeed();
public static final Item overgrowthSeed = new ItemOvergrowthSeed(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.OVERGROWTH_SEED);
public static final Item craftPattern1_1 = new ItemCraftPattern(CratePattern.CRAFTY_1_1, unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.CRAFT_PATTERN_PREFIX + "1_1");
public static final Item craftPattern2_2 = new ItemCraftPattern(CratePattern.CRAFTY_2_2, unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.CRAFT_PATTERN_PREFIX + "2_2");
public static final Item craftPattern1_2 = new ItemCraftPattern(CratePattern.CRAFTY_1_2, unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.CRAFT_PATTERN_PREFIX + "1_2");
@@ -316,48 +316,48 @@ public final class ModItems {
public static final Item craftPattern2_3 = new ItemCraftPattern(CratePattern.CRAFTY_2_3, unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.CRAFT_PATTERN_PREFIX + "2_3");
public static final Item craftPattern3_2 = new ItemCraftPattern(CratePattern.CRAFTY_3_2, unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.CRAFT_PATTERN_PREFIX + "3_2");
public static final Item craftPatternDonut = new ItemCraftPattern(CratePattern.CRAFTY_DONUT, unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.CRAFT_PATTERN_PREFIX + "donut");
public static final Item ancientWillAhrim = new ItemAncientWill(IAncientWillContainer.AncientWillType.AHRIM);
public static final Item ancientWillDharok = new ItemAncientWill(IAncientWillContainer.AncientWillType.DHAROK);
public static final Item ancientWillGuthan = new ItemAncientWill(IAncientWillContainer.AncientWillType.GUTHAN);
public static final Item ancientWillTorag = new ItemAncientWill(IAncientWillContainer.AncientWillType.TORAG);
public static final Item ancientWillVerac = new ItemAncientWill(IAncientWillContainer.AncientWillType.VERAC);
public static final Item ancientWillKaril = new ItemAncientWill(IAncientWillContainer.AncientWillType.KARIL);
public static final Item corporeaSpark = new ItemCorporeaSpark(LibItemNames.CORPOREA_SPARK);
public static final Item corporeaSparkMaster = new ItemCorporeaSpark(LibItemNames.CORPOREA_SPARK_MASTER);
public static final Item ancientWillAhrim = new ItemAncientWill(IAncientWillContainer.AncientWillType.AHRIM, unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ANCIENT_WILL_PREFIX + "ahrim");
public static final Item ancientWillDharok = new ItemAncientWill(IAncientWillContainer.AncientWillType.DHAROK, unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ANCIENT_WILL_PREFIX + "dharok");
public static final Item ancientWillGuthan = new ItemAncientWill(IAncientWillContainer.AncientWillType.GUTHAN, unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ANCIENT_WILL_PREFIX + "guthan");
public static final Item ancientWillTorag = new ItemAncientWill(IAncientWillContainer.AncientWillType.TORAG, unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ANCIENT_WILL_PREFIX + "torag");
public static final Item ancientWillVerac = new ItemAncientWill(IAncientWillContainer.AncientWillType.VERAC, unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ANCIENT_WILL_PREFIX + "verac");
public static final Item ancientWillKaril = new ItemAncientWill(IAncientWillContainer.AncientWillType.KARIL, unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ANCIENT_WILL_PREFIX + "karil");
public static final Item corporeaSpark = new ItemCorporeaSpark(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.CORPOREA_SPARK);
public static final Item corporeaSparkMaster = new ItemCorporeaSpark(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.CORPOREA_SPARK_MASTER);
public static final Item livingwoodBow = new ItemLivingwoodBow(defaultBuilder().defaultMaxDamage(500)).setRegistryName(LibMisc.MOD_ID, LibItemNames.LIVINGWOOD_BOW);
public static final Item crystalBow = new ItemCrystalBow(defaultBuilder().defaultMaxDamage(500)).setRegistryName(LibMisc.MOD_ID, LibItemNames.CRYSTAL_BOW);
public static final Map<ItemBaubleCosmetic.Variant, Item> cosmetics = new EnumMap<>(ItemBaubleCosmetic.Variant.class);
static {
for(ItemBaubleCosmetic.Variant v : ItemBaubleCosmetic.Variant.values()) {
cosmetics.put(v, new ItemBaubleCosmetic(v));
cosmetics.put(v, new ItemBaubleCosmetic(v, unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.COSMETIC_PREFIX + v.name().toLowerCase(Locale.ROOT)));
}
}
public static final Item swapRing = new ItemSwapRing();
public static final Item flowerBag = new ItemFlowerBag();
public static final Item swapRing = new ItemSwapRing(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.SWAP_RING);
public static final Item flowerBag = new ItemFlowerBag(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.FLOWER_BAG);
public static final Item phantomInk = new ItemMod(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.PHANTOM_INK);
public static final Item poolMinecart = new ItemPoolMinecart(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.POOL_MINECART);
public static final Item pinkinator = new ItemPinkinator(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.PINKINATOR);
public static final Item infiniteFruit = new ItemInfiniteFruit();
public static final Item kingKey = new ItemKingKey();
public static final Item flugelEye = new ItemFlugelEye();
public static final Item thorRing = new ItemThorRing();
public static final Item odinRing = new ItemOdinRing();
public static final Item lokiRing = new ItemLokiRing();
public static final Item dice = new ItemDice();
public static final Item keepIvy = new ItemKeepIvy();
public static final Item blackHoleTalisman = new ItemBlackHoleTalisman();
public static final Item infiniteFruit = new ItemInfiniteFruit(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.INFINITE_FRUIT);
public static final Item kingKey = new ItemKingKey(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.KING_KEY);
public static final Item flugelEye = new ItemFlugelEye(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.FLUGEL_EYE);
public static final Item thorRing = new ItemThorRing(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.THOR_RING);
public static final Item odinRing = new ItemOdinRing(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ODIN_RING);
public static final Item lokiRing = new ItemLokiRing(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.LOKI_RING);
public static final Item dice = new ItemDice(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.DICE);
public static final Item keepIvy = new ItemKeepIvy(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.KEEP_IVY);
public static final Item blackHoleTalisman = new ItemBlackHoleTalisman(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.BLACK_HOLE_TALISMAN);
public static final Item recordGaia1 = new ItemModRecord(1, ModSounds.gaiaMusic1, unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.RECORD_GAIA1);
public static final Item recordGaia2 = new ItemModRecord(1, ModSounds.gaiaMusic2, unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.RECORD_GAIA2);
public static final Item temperanceStone = new ItemTemperanceStone(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.TEMPERANCE_STONE);
public static final Item incenseStick = new ItemIncenseStick(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.INCENSE_STICK);
public static final Item terraAxe = new ItemTerraAxe(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.TERRA_AXE);
public static final Item waterBowl = new ItemWaterBowl(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.WATER_BOWL);
public static final Item obedienceStick = new ItemObedienceStick();
public static final Item cacophonium = new ItemCacophonium();
public static final Item obedienceStick = new ItemObedienceStick(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.OBEDIENCE_STICK);
public static final Item cacophonium = new ItemCacophonium(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.CACOPHONIUM);
public static final Item slimeBottle = new ItemSlimeBottle(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.SLIME_BOTTLE);
public static final Item starSword = new ItemStarSword(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.STAR_SWORD);
public static final Item exchangeRod = new ItemExchangeRod(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.EXCHANGE_ROD);
public static final Item magnetRingGreater = new ItemGreaterMagnetRing();
public static final Item magnetRingGreater = new ItemGreaterMagnetRing(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MAGNET_RING_GREATER);
public static final Item thunderSword = new ItemThunderSword(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.THUNDER_SWORD);
public static final Item manaweaveHelm = new ItemManaweaveHelm(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANAWEAVE_HELM);
public static final Item manaweaveChest = new ItemManaweaveArmor(EntityEquipmentSlot.CHEST, unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANAWEAVE_CHEST);
@@ -20,12 +20,8 @@ import vazkii.botania.common.lib.LibItemNames;
public class ItemAuraRing extends ItemBauble implements IManaGivingItem {
public ItemAuraRing(String name) {
super(name);
}
public ItemAuraRing() {
this(LibItemNames.AURA_RING);
public ItemAuraRing(Properties props) {
super(props);
}
@Override
@@ -28,8 +28,8 @@ public class ItemBalanceCloak extends ItemHolyCloak {
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_BALANCE_CLOAK);
private static final ResourceLocation textureGlow = new ResourceLocation(LibResources.MODEL_BALANCE_CLOAK_GLOW);
public ItemBalanceCloak() {
super(LibItemNames.BALANCE_CLOAK);
public ItemBalanceCloak(Properties props) {
super(props);
}
public boolean effectOnDamage(LivingHurtEvent event, EntityPlayer player, ItemStack stack) {
@@ -26,6 +26,8 @@ import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
@@ -131,29 +133,25 @@ public abstract class ItemBauble extends ItemMod implements IBauble, ICosmeticAt
@Override
@OnlyIn(Dist.CLIENT)
public void addInformation(ItemStack par1ItemStack, World world, List<String> stacks, ITooltipFlag flags) {
public void addInformation(ItemStack par1ItemStack, World world, List<ITextComponent> stacks, ITooltipFlag flags) {
if(GuiScreen.isShiftKeyDown())
addHiddenTooltip(par1ItemStack, world, stacks, flags);
else addStringToTooltip(I18n.format("botaniamisc.shiftinfo"), stacks);
else stacks.add(new TextComponentTranslation("botaniamisc.shiftinfo"));
}
@OnlyIn(Dist.CLIENT)
public void addHiddenTooltip(ItemStack par1ItemStack, World world, List<String> stacks, ITooltipFlag flags) {
public void addHiddenTooltip(ItemStack par1ItemStack, World world, List<ITextComponent> stacks, ITooltipFlag flags) {
String key = vazkii.botania.client.core.helper.RenderHelper.getKeyDisplayString("Baubles Inventory");
if(key != null)
addStringToTooltip(I18n.format("botania.baubletooltip", key), stacks);
stacks.add(new TextComponentTranslation("botania.baubletooltip", key));
ItemStack cosmetic = getCosmeticItem(par1ItemStack);
if(!cosmetic.isEmpty())
addStringToTooltip(I18n.format("botaniamisc.hasCosmetic", cosmetic.getDisplayName()), stacks);
stacks.add(new TextComponentTranslation("botaniamisc.hasCosmetic", cosmetic.getDisplayName()));
if(hasPhantomInk(par1ItemStack))
addStringToTooltip(I18n.format("botaniamisc.hasPhantomInk"), stacks);
}
void addStringToTooltip(String s, List<String> tooltip) {
tooltip.add(s.replaceAll("&", "\u00a7"));
stacks.add(new TextComponentTranslation("botaniamisc.hasPhantomInk"));
}
@Override
@@ -197,14 +195,14 @@ public abstract class ItemBauble extends ItemMod implements IBauble, ICosmeticAt
NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_COSMETIC_ITEM, true);
if(cmp == null)
return ItemStack.EMPTY;
return new ItemStack(cmp);
return ItemStack.read(cmp);
}
@Override
public void setCosmeticItem(ItemStack stack, ItemStack cosmetic) {
NBTTagCompound cmp = new NBTTagCompound();
if(!cosmetic.isEmpty())
cmp = cosmetic.writeToNBT(cmp);
cmp = cosmetic.write(cmp);
ItemNBTHelper.setCompound(stack, TAG_COSMETIC_ITEM, cmp);
}
@@ -13,28 +13,29 @@ package vazkii.botania.common.item.equipment.bauble;
import baubles.api.BaubleType;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.model.BakedQuad;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.NonNullList;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.lwjgl.opengl.GL11;
import vazkii.botania.api.item.ICosmeticBauble;
import vazkii.botania.client.core.handler.ModelHandler;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lib.LibItemNames;
import javax.annotation.Nonnull;
@@ -58,15 +59,19 @@ public class ItemBaubleCosmetic extends ItemBauble implements ICosmeticBauble {
private final Variant variant;
public static final int SUBTYPES = Variant.values().length;
public ItemBaubleCosmetic(Variant variant) {
super(LibItemNames.COSMETIC + "_" + variant.name().toLowerCase(Locale.ROOT));
public ItemBaubleCosmetic(Variant variant, Properties props) {
super(props);
this.variant = variant;
}
@OnlyIn(Dist.CLIENT)
@Override
public void addHiddenTooltip(ItemStack stack, World world, List<String> stacks, ITooltipFlag flags) {
addStringToTooltip(I18n.format(stack.getItemDamage() == 32 ? "botaniamisc.cosmeticThinking" : "botaniamisc.cosmeticBauble"), stacks);
public void addHiddenTooltip(ItemStack stack, World world, List<ITextComponent> stacks, ITooltipFlag flags) {
if(this == ModItems.cosmetics.get(Variant.THINKING_HAND)) {
stacks.add(new TextComponentTranslation("botaniamisc.cosmeticThinking"));
} else {
stacks.add(new TextComponentTranslation("botaniamisc.cosmeticBauble"));
}
super.addHiddenTooltip(stack, world, stacks, flags);
}
@@ -77,7 +82,7 @@ public class ItemBaubleCosmetic extends ItemBauble implements ICosmeticBauble {
@Override
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
if (type == RenderType.HEAD) {
Helper.translateToHeadLevel(player);
@@ -85,89 +90,89 @@ public class ItemBaubleCosmetic extends ItemBauble implements ICosmeticBauble {
Helper.defaultTransforms();
switch (variant) {
case RED_GLASSES:
GlStateManager.scale(1.25, 1.25, 1.25);
GlStateManager.translate(0F, -0.085F, 0.045F);
scale(1.25F);
GlStateManager.translatef(0F, -0.085F, 0.045F);
renderItem(stack);
break;
case ENGINEER_GOGGLES:
GlStateManager.scale(1.25, 1.25, 1.25);
GlStateManager.translate(0F, -0.085F, 0.045F);
scale(1.25F);
GlStateManager.translatef(0F, -0.085F, 0.045F);
renderItem(stack);
break;
case EYEPATCH:
scale(0.55F);
GlStateManager.translate(-0.45F, -0.25F, 0F);
GlStateManager.translatef(-0.45F, -0.25F, 0F);
renderItem(stack);
break;
case WICKED_EYEPATCH:
scale(0.55F);
GlStateManager.translate(0.45F, -0.25F, 0F);
GlStateManager.translatef(0.45F, -0.25F, 0F);
renderItem(stack);
break;
case RED_RIBBONS:
scale(0.9F);
GlStateManager.translate(0F, 0.75F, 1F);
GlStateManager.translatef(0F, 0.75F, 1F);
renderItem(stack);
break;
case PINK_FLOWER_BUD:
GlStateManager.rotate(-90F, 0F, 1F, 0F);
GlStateManager.translate(0.4F, 0.6F, 0.45F);
GlStateManager.rotatef(-90F, 0F, 1F, 0F);
GlStateManager.translatef(0.4F, 0.6F, 0.45F);
renderItem(stack);
break;
case POLKA_DOTTED_BOWS:
GlStateManager.rotate(-90F, 0F, 1F, 0F);
GlStateManager.translate(0.65F, 0.3F, 0.5F);
GlStateManager.rotatef(-90F, 0F, 1F, 0F);
GlStateManager.translatef(0.65F, 0.3F, 0.5F);
renderItem(stack);
GlStateManager.translate(0F, 0F, -1F);
GlStateManager.translatef(0F, 0F, -1F);
renderItem(stack);
break;
case BLUE_BUTTERFLY:
GlStateManager.translate(-0.75F, 0.1F, 1F);
GlStateManager.translatef(-0.75F, 0.1F, 1F);
GlStateManager.pushMatrix();
GlStateManager.rotate(45F, 0F, 1F, 0F);
GlStateManager.rotatef(45F, 0F, 1F, 0F);
renderItem(stack);
GlStateManager.popMatrix();
GlStateManager.translate(0F, 0F, -0.75F);
GlStateManager.rotate(-45F, 0F, 1F, 0F);
GlStateManager.translatef(0F, 0F, -0.75F);
GlStateManager.rotatef(-45F, 0F, 1F, 0F);
renderItem(stack);
break;
case CAT_EARS:
GlStateManager.translate(0F, 0.25F, 0.25F);
GlStateManager.translatef(0F, 0.25F, 0.25F);
renderItem(stack);
break;
case GOOGLY_EYES:
GlStateManager.rotate(180F, 0F, 1F, 0F);
GlStateManager.scale(1.5F, 1.5F, 1F);
GlStateManager.translate(0F, -0.05F, 0F);
GlStateManager.rotatef(180F, 0F, 1F, 0F);
GlStateManager.scalef(1.5F, 1.5F, 1F);
GlStateManager.translatef(0F, -0.05F, 0F);
renderItem(stack);
break;
case CLOCK_EYE:
scale(0.75F);
GlStateManager.translate(-0.25F, -0.1F, 0F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.translatef(-0.25F, -0.1F, 0F);
GlStateManager.rotatef(180F, 0F, 0F, 1F);
renderItem(stack);
break;
case UNICORN_HORN:
scale(1.25F);
GlStateManager.rotate(-90F, 0F, 1F, 0F);
GlStateManager.translate(0F, 0.4F, 0F);
GlStateManager.rotatef(-90F, 0F, 1F, 0F);
GlStateManager.translatef(0F, 0.4F, 0F);
renderItem(stack);
break;
case DEVIL_HORNS:
GlStateManager.translate(0F, 0.2F, 0.25F);
GlStateManager.translatef(0F, 0.2F, 0.25F);
renderItem(stack);
break;
case HYPER_PLUS:
scale(0.35F);
GlStateManager.translate(-0.7F, 1F, -0.5F);
GlStateManager.translatef(-0.7F, 1F, -0.5F);
renderItem(stack);
GlStateManager.translate(1.45F, 0F, 0F);
GlStateManager.translatef(1.45F, 0F, 0F);
renderItem(stack);
break;
case ANCIENT_MASK:
scale(1.25F);
GlStateManager.translate(0F, 0.025F, 0.01F);
GlStateManager.translatef(0F, 0.025F, 0.01F);
renderItem(stack);
break;
case EERIE_MASK:
@@ -175,51 +180,51 @@ public class ItemBaubleCosmetic extends ItemBauble implements ICosmeticBauble {
break;
case ALIEN_ANTENNA:
scale(0.9F);
GlStateManager.rotate(180F, 0F, 1F, 0F);
GlStateManager.translate(0F, 0.75F, -1F);
GlStateManager.rotatef(180F, 0F, 1F, 0F);
GlStateManager.translatef(0F, 0.75F, -1F);
renderItem(stack);
break;
case ANAGLYPH_GLASSES:
scale(1.25F);
GlStateManager.translate(0F, -0.025F, 0F);
GlStateManager.translatef(0F, -0.025F, 0F);
renderItem(stack);
break;
case ORANGE_SHADES:
scale(1.25f);
GlStateManager.translate(0F, 0.04F, 0F);
GlStateManager.translatef(0F, 0.04F, 0F);
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.color(1F, 1F, 1F, 0.7F);
GlStateManager.color4f(1F, 1F, 1F, 0.7F);
renderItem(stack);
break;
case GROUCHO_GLASSES:
scale(1.5F);
GlStateManager.translate(0F, -0.2125F, 0F);
GlStateManager.translatef(0F, -0.2125F, 0F);
renderItem(stack);
break;
case THICK_EYEBROWS:
scale(0.5F);
GlStateManager.translate(-0.4F, 0.05F, 0F);
GlStateManager.translatef(-0.4F, 0.05F, 0F);
renderItem(stack);
GlStateManager.rotate(180F, 0F, 1F, 0F);
GlStateManager.translate(-0.775F, 0F, 0F);
GlStateManager.rotatef(180F, 0F, 1F, 0F);
GlStateManager.translatef(-0.775F, 0F, 0F);
renderItem(stack);
break;
case TINY_POTATO_MASK:
scale(1.25F);
GlStateManager.translate(0F, 0.025F, 0F);
GlStateManager.translatef(0F, 0.025F, 0F);
renderItem(stack);
break;
case QUESTGIVER_MARK:
scale(0.8F);
GlStateManager.translate(0F, 1F, 0.3F);
GlStateManager.translatef(0F, 1F, 0.3F);
renderItem(stack);
break;
case THINKING_HAND:
scale(0.9f);
GlStateManager.translate(0.2F, -0.5F, 0F);
GlStateManager.scale(-1, 1, 1);
GlStateManager.rotate(15F, 0F, 0F, 1F);
GlStateManager.translatef(0.2F, -0.5F, 0F);
GlStateManager.scalef(-1, 1, 1);
GlStateManager.rotatef(15F, 0F, 0F, 1F);
renderItem(stack);
break;
default: break;
@@ -230,50 +235,50 @@ public class ItemBaubleCosmetic extends ItemBauble implements ICosmeticBauble {
Helper.defaultTransforms();
switch (variant) {
case BLACK_BOWTIE:
GlStateManager.translate(0F, 0.15F, 0F);
GlStateManager.translatef(0F, 0.15F, 0F);
renderItem(stack);
break;
case BLACK_TIE:
GlStateManager.translate(0F, -0.15F, 0F);
GlStateManager.translatef(0F, -0.15F, 0F);
renderItem(stack);
break;
case PUFFY_SCARF:
GlStateManager.translate(0F, -0.15F, 0F);
GlStateManager.translatef(0F, -0.15F, 0F);
renderItem(stack);
break;
case WITCH_PIN:
scale(0.35F);
GlStateManager.translate(-0.35F, 0.35F, 0.15F);
GlStateManager.translatef(-0.35F, 0.35F, 0.15F);
renderItem(stack);
break;
case DEVIL_TAIL:
GlStateManager.rotate(90F, 0F, 1F, 0F);
GlStateManager.translate(0.5F, -0.75F, 0F);
GlStateManager.rotatef(90F, 0F, 1F, 0F);
GlStateManager.translatef(0.5F, -0.75F, 0F);
renderItem(stack);
break;
case KAMUI_EYE: // DON'T LOSE YOUR WAAAAAAAAY
scale(0.9F);
GlStateManager.translate(0.9F, 0.35F, 0F);
GlStateManager.translatef(0.9F, 0.35F, 0F);
renderItem(stack);
GlStateManager.translate(-1.3F, -0.5F, 0.5F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.translatef(-1.3F, -0.5F, 0.5F);
GlStateManager.rotatef(180F, 0F, 0F, 1F);
GlStateManager.rotatef(180F, 1F, 0F, 0F);
renderKamuiBlack(stack);
break;
case FOUR_LEAF_CLOVER:
scale(0.5F);
GlStateManager.translate(0.35F, 0.3F, -0.075F);
GlStateManager.translatef(0.35F, 0.3F, -0.075F);
renderItem(stack);
break;
case BOTANIST_EMBLEM:
scale(0.5F);
GlStateManager.translate(0F, -0.75F, 0F);
GlStateManager.translatef(0F, -0.75F, 0F);
renderItem(stack);
break;
case LUSITANIC_SHIELD:
GlStateManager.rotate(180F, 0F, 1F, 0F);
GlStateManager.translate(0.035F, -0.2F, 0.55F);
GlStateManager.rotate(8F, 0F, 0F, 1F);
GlStateManager.rotatef(180F, 0F, 1F, 0F);
GlStateManager.translatef(0.035F, -0.2F, 0.55F);
GlStateManager.rotatef(8F, 0F, 0F, 1F);
renderItem(stack);
break;
default: break;
@@ -282,27 +287,28 @@ public class ItemBaubleCosmetic extends ItemBauble implements ICosmeticBauble {
}
public void scale(float f) {
GlStateManager.scale(f, f, f);
GlStateManager.scalef(f, f, f);
}
public void renderItem(ItemStack stack) {
GlStateManager.pushMatrix();
Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.NONE);
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.NONE);
GlStateManager.popMatrix();
}
// todo 1.13 recheck vanilla copying
private void renderKamuiBlack(ItemStack stack) {
// Modified copy of RenderItem.renderItem(stack, transformtype)
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Minecraft.getMinecraft().renderEngine.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Minecraft.getInstance().textureManager.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(stack);
IBakedModel model = Minecraft.getInstance().getItemRenderer().getItemModelMesher().getItemModel(stack);
GlStateManager.enableRescaleNormal();
GlStateManager.alphaFunc(516, 0.1F);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.blendFuncSeparate(770, 771, 1, 0);
GlStateManager.pushMatrix();
model = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(model, ItemCameraTransforms.TransformType.NONE, false);
@@ -312,8 +318,8 @@ public class ItemBaubleCosmetic extends ItemBauble implements ICosmeticBauble {
GlStateManager.popMatrix();
GlStateManager.disableRescaleNormal();
GlStateManager.disableBlend();
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Minecraft.getMinecraft().renderEngine.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Minecraft.getInstance().textureManager.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
}
// Adapted from RenderItem.renderModel(model, stack), added extra color param
@@ -324,10 +330,10 @@ public class ItemBaubleCosmetic extends ItemBauble implements ICosmeticBauble {
for (EnumFacing enumfacing : EnumFacing.values())
{
renderQuads(worldrenderer, model.getQuads(null, enumfacing, 0), color, stack);
renderQuads(worldrenderer, model.getQuads(null, enumfacing, random), color, stack);
}
renderQuads(worldrenderer, model.getQuads(null, null, 0), color, stack);
renderQuads(worldrenderer, model.getQuads(null, null, random), color, stack);
tessellator.draw();
}
@@ -344,13 +350,7 @@ public class ItemBaubleCosmetic extends ItemBauble implements ICosmeticBauble {
if (flag && bakedquad.hasTintIndex())
{
k = Minecraft.getMinecraft().getItemColors().colorMultiplier(stack, bakedquad.getTintIndex());
if (EntityRenderer.anaglyphEnable)
{
k = TextureUtil.anaglyphColor(k);
}
k = Minecraft.getInstance().getItemColors().getColor(stack, bakedquad.getTintIndex());
k = k | -16777216;
}
@@ -17,8 +17,8 @@ import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.item.ItemStack;
public abstract class ItemBaubleModifier extends ItemBauble {
public ItemBaubleModifier(String name) {
super(name);
public ItemBaubleModifier(Properties props) {
super(props);
}
@Override
@@ -19,11 +19,11 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.NonNullList;
@@ -51,15 +51,14 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre
private static final String TAG_BREW_KEY = "brewKey";
public ItemBloodPendant() {
super(LibItemNames.BLOOD_PENDANT);
setMaxStackSize(1);
public ItemBloodPendant(Properties props) {
super(props);
}
@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> list) {
super.getSubItems(tab, list);
if(isInCreativeTab(tab)) {
public void fillItemGroup(ItemGroup tab, NonNullList<ItemStack> list) {
super.fillItemGroup(tab, list);
if(isInGroup(tab)) {
for(String s : BotaniaAPI.brewMap.keySet()) {
ItemStack brewStack = getItemForBrew(BotaniaAPI.brewMap.get(s), new ItemStack(this));
if(!brewStack.isEmpty())
@@ -151,26 +150,26 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre
@OnlyIn(Dist.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.BODY) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Helper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty();
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.translate(-0.26F, -0.4F, armor ? 0.2F : 0.15F);
GlStateManager.scale(0.5F, 0.5F, 0.5F);
GlStateManager.rotatef(180F, 1F, 0F, 0F);
GlStateManager.translatef(-0.26F, -0.4F, armor ? 0.2F : 0.15F);
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
for(TextureAtlasSprite icon : new TextureAtlasSprite[] { MiscellaneousIcons.INSTANCE.bloodPendantChain, MiscellaneousIcons.INSTANCE.bloodPendantGem }) {
float f = icon.getMinU();
float f1 = icon.getMaxU();
float f2 = icon.getMinV();
float f3 = icon.getMaxV();
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F);
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getWidth(), icon.getHeight(), 1F / 32F);
Color color = new Color(Minecraft.getMinecraft().getItemColors().colorMultiplier(stack, 1));
Color color = new Color(Minecraft.getInstance().getItemColors().getColor(stack, 1));
GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
int light = 15728880;
int lightmapX = light % 65536;
int lightmapY = light / 65536;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY);
OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lightmapX, lightmapY);
}
GL11.glColor3ub((byte) 255, (byte) 255, (byte) 255);
}
@@ -16,7 +16,7 @@ import com.google.common.base.Predicates;
import com.google.common.util.concurrent.ListenableFutureTask;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
@@ -29,11 +29,9 @@ import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.server.ServerLifecycleHooks;
import vazkii.botania.api.item.IBaubleRender;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
@@ -49,13 +47,12 @@ import java.util.List;
public class ItemDivaCharm extends ItemBauble implements IManaUsingItem, IBaubleRender {
public ItemDivaCharm() {
super(LibItemNames.DIVA_CHARM);
MinecraftForge.EVENT_BUS.register(this);
public ItemDivaCharm(Properties props) {
super(props);
MinecraftForge.EVENT_BUS.addListener(this::onEntityDamaged);
}
@SubscribeEvent
public void onEntityDamaged(LivingHurtEvent event) {
private void onEntityDamaged(LivingHurtEvent event) {
if (event.getSource().getImmediateSource() instanceof EntityPlayer && event.getEntityLiving() instanceof EntityLiving && !event.getEntityLiving().world.isRemote && Math.random() < 0.6F) {
Runnable lambda = () -> {
EntityLiving target = (EntityLiving) event.getEntityLiving();
@@ -71,7 +68,7 @@ public class ItemDivaCharm extends ItemBauble implements IManaUsingItem, IBauble
if(mobs.size() > 1) {
if(SubTileHeiseiDream.brainwashEntity(target, (List<IMob>) mobs)) {
target.heal(target.getMaxHealth());
target.isDead = false;
target.removed = false;
if(target instanceof EntityCreeper)
((EntityCreeper) event.getEntityLiving()).timeSinceIgnited = 2;
@@ -86,7 +83,7 @@ public class ItemDivaCharm extends ItemBauble implements IManaUsingItem, IBauble
// Have to delay a tick because setAttackTarget(player) is called *after* the event fires, and we want to get rid of that
// addScheduledTask runs the lambda immediately if on the main thread, hence this trickery
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
MinecraftServer server = ServerLifecycleHooks.getCurrentServer();
synchronized (server.futureTaskQueue) {
server.futureTaskQueue.add(ListenableFutureTask.create(lambda, null));
}
@@ -108,12 +105,12 @@ public class ItemDivaCharm extends ItemBauble implements IManaUsingItem, IBauble
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.HEAD) {
Helper.translateToHeadLevel(player);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
GlStateManager.scale(0.8, 0.8, 0.8);
GlStateManager.rotate(-90, 0, 1, 0);
GlStateManager.rotate(180, 1, 0, 0);
GlStateManager.translate(0.1625, -1.625, 0.40);
Minecraft.getMinecraft().getRenderItem().renderItem(new ItemStack(this, 1), ItemCameraTransforms.TransformType.GROUND);
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
GlStateManager.scaled(0.8, 0.8, 0.8);
GlStateManager.rotatef(-90, 0, 1, 0);
GlStateManager.rotatef(180, 1, 0, 0);
GlStateManager.translated(0.1625, -1.625, 0.40);
Minecraft.getInstance().getItemRenderer().renderItem(new ItemStack(this), ItemCameraTransforms.TransformType.GROUND);
}
}
@@ -14,8 +14,8 @@ import vazkii.botania.common.lib.LibItemNames;
public class ItemGreaterAuraRing extends ItemAuraRing {
public ItemGreaterAuraRing() {
super(LibItemNames.AURA_RING_GREATER);
public ItemGreaterAuraRing(Properties props) {
super(props);
}
@Override
@@ -14,8 +14,8 @@ import vazkii.botania.common.lib.LibItemNames;
public class ItemGreaterMagnetRing extends ItemMagnetRing {
public ItemGreaterMagnetRing() {
super(LibItemNames.MAGNET_RING_GREATER, 16);
public ItemGreaterMagnetRing(Properties props) {
super(props, 16);
}
}
@@ -17,8 +17,8 @@ public class ItemGreaterManaRing extends ItemManaRing {
private static final int MAX_MANA = ItemManaRing.MAX_MANA * 4;
public ItemGreaterManaRing() {
super(LibItemNames.MANA_RING_GREATER);
public ItemGreaterManaRing(Properties props) {
super(props);
}
@Override
@@ -23,7 +23,6 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.item.IBaubleRender;
@@ -45,17 +44,12 @@ public class ItemHolyCloak extends ItemBauble implements IBaubleRender {
private static final String TAG_COOLDOWN = "cooldown";
private static final String TAG_IN_EFFECT = "inEffect";
public ItemHolyCloak() {
this(LibItemNames.HOLY_CLOAK);
MinecraftForge.EVENT_BUS.register(this);
public ItemHolyCloak(Properties props) {
super(props);
MinecraftForge.EVENT_BUS.addListener(this::onPlayerDamage);
}
public ItemHolyCloak(String name) {
super(name);
}
@SubscribeEvent
public void onPlayerDamage(LivingHurtEvent event) {
private void onPlayerDamage(LivingHurtEvent event) {
if(event.getEntityLiving() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
ItemStack belt = BaublesApi.getBaublesHandler(player).getStackInSlot(5);
@@ -137,24 +131,24 @@ public class ItemHolyCloak extends ItemBauble implements IBaubleRender {
if(type == RenderType.BODY) {
Helper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty();
GlStateManager.translate(0F, armor ? -0.07F : -0.01F, 0F);
GlStateManager.translatef(0F, armor ? -0.07F : -0.01F, 0F);
float s = 1F / 16F;
GlStateManager.scale(s, s, s);
GlStateManager.scalef(s, s, s);
if(model == null)
model = new ModelCloak();
GlStateManager.enableLighting();
GlStateManager.enableRescaleNormal();
Minecraft.getMinecraft().renderEngine.bindTexture(getCloakTexture());
Minecraft.getInstance().textureManager.bindTexture(getCloakTexture());
model.render(1F);
int light = 15728880;
int lightmapX = light % 65536;
int lightmapY = light / 65536;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY);
Minecraft.getMinecraft().renderEngine.bindTexture(getCloakGlowTexture());
OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lightmapX, lightmapY);
Minecraft.getInstance().textureManager.bindTexture(getCloakGlowTexture());
model.render(1F);
}
}
@@ -31,8 +31,8 @@ import vazkii.botania.common.lib.LibItemNames;
public class ItemIcePendant extends ItemBauble implements IBaubleRender {
public ItemIcePendant() {
super(LibItemNames.ICE_PENDANT);
public ItemIcePendant(Properties props) {
super(props);
}
@Override
@@ -55,20 +55,20 @@ public class ItemIcePendant extends ItemBauble implements IBaubleRender {
@OnlyIn(Dist.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.BODY) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Helper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty();
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.translate(-0.36F, -0.3F, armor ? 0.2F : 0.15F);
GlStateManager.rotate(-45F, 0F, 0F, 1F);
GlStateManager.scale(0.5F, 0.5F, 0.5F);
GlStateManager.rotatef(180F, 1F, 0F, 0F);
GlStateManager.translatef(-0.36F, -0.3F, armor ? 0.2F : 0.15F);
GlStateManager.rotatef(-45F, 0F, 0F, 1F);
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.snowflakePendantGem;
float f = gemIcon.getMinU();
float f1 = gemIcon.getMaxU();
float f2 = gemIcon.getMinV();
float f3 = gemIcon.getMaxV();
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F);
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 32F);
}
}
@@ -12,7 +12,7 @@ package vazkii.botania.common.item.equipment.bauble;
import baubles.api.BaubleType;
import baubles.api.BaublesApi;
import gnu.trove.list.array.TIntArrayList;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
@@ -36,6 +36,7 @@ import net.minecraft.village.MerchantRecipe;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.InvWrapper;
@@ -54,10 +55,10 @@ import java.util.List;
public class ItemItemFinder extends ItemBauble implements IBaubleRender {
private static final String TAG_ENTITY_POSITIONS = "highlightPositionsEnt";
private static final String TAG_BLOCK_POSITIONS = "highlightPositionsBlock1";
private static final String TAG_BLOCK_POSITIONS = "highlightPositionsBlock";
public ItemItemFinder() {
super(LibItemNames.ITEM_FINDER);
public ItemItemFinder(Properties props) {
super(props);
}
@Override
@@ -79,7 +80,7 @@ public class ItemItemFinder extends ItemBauble implements IBaubleRender {
NBTTagList blocks = ItemNBTHelper.getList(stack, TAG_BLOCK_POSITIONS, Constants.NBT.TAG_LONG, false);
Botania.proxy.setWispFXDepthTest(false);
for(int i = 0; i < blocks.tagCount(); i++) {
for(int i = 0; i < blocks.size(); i++) {
BlockPos pos = BlockPos.fromLong(((NBTTagLong) blocks.get(i)).getLong());
float m = 0.02F;
Botania.proxy.wispFX(pos.getX() + (float) Math.random(), pos.getY() + (float) Math.random(), pos.getZ() + (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.15F + 0.05F * (float) Math.random(), m * (float) (Math.random() - 0.5), m * (float) (Math.random() - 0.5), m * (float) (Math.random() - 0.5));
@@ -98,13 +99,13 @@ public class ItemItemFinder extends ItemBauble implements IBaubleRender {
}
protected void tickServer(ItemStack stack, EntityPlayer player) {
TIntArrayList entPosBuilder = new TIntArrayList();
IntArrayList entPosBuilder = new IntArrayList();
NBTTagList blockPosBuilder = new NBTTagList();
scanForStack(player.getHeldItemMainhand(), player, entPosBuilder, blockPosBuilder);
scanForStack(player.getHeldItemOffhand(), player, entPosBuilder, blockPosBuilder);
int[] currentEnts = entPosBuilder.toArray();
int[] currentEnts = entPosBuilder.elements();
boolean entsEqual = Arrays.equals(currentEnts, ItemNBTHelper.getIntArray(stack, TAG_ENTITY_POSITIONS));
boolean blocksEqual = blockPosBuilder.equals(ItemNBTHelper.getList(stack, TAG_BLOCK_POSITIONS, Constants.NBT.TAG_LONG, false));
@@ -117,7 +118,7 @@ public class ItemItemFinder extends ItemBauble implements IBaubleRender {
BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, 4);
}
private void scanForStack(ItemStack pstack, EntityPlayer player, TIntArrayList entIdBuilder, NBTTagList blockPosBuilder) {
private void scanForStack(ItemStack pstack, EntityPlayer player, IntArrayList entIdBuilder, NBTTagList blockPosBuilder) {
if(!pstack.isEmpty() || player.isSneaking()) {
int range = 24;
@@ -125,8 +126,8 @@ public class ItemItemFinder extends ItemBauble implements IBaubleRender {
for(Entity e : entities) {
if(e == player)
continue;
if(e.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null) && !(e instanceof EntityPlayer)) {
if(scanInventory(e.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null), pstack))
if(e.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).isPresent() && !(e instanceof EntityPlayer)) {
if(scanInventory(e.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY), pstack))
entIdBuilder.add(e.getEntityId());
} else if(e instanceof EntityItem) {
@@ -137,12 +138,12 @@ public class ItemItemFinder extends ItemBauble implements IBaubleRender {
} else if(e instanceof IInventory) {
IInventory inv = (IInventory) e;
if(scanInventory(new InvWrapper(inv), pstack))
if(scanInventory(LazyOptional.of(() -> new InvWrapper(inv)), pstack))
entIdBuilder.add(e.getEntityId());
} else if(e instanceof EntityPlayer) {
EntityPlayer player_ = (EntityPlayer) e;
IItemHandler playerInv = player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
LazyOptional<IItemHandler> playerInv = player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY);
IItemHandler binv = BaublesApi.getBaublesHandler(player);
if(scanInventory(binv, pstack) || scanInventory(playerInv, pstack))
entIdBuilder.add(player_.getEntityId());
@@ -167,18 +168,17 @@ public class ItemItemFinder extends ItemBauble implements IBaubleRender {
TileEntity tile = player.world.getTileEntity(pos_);
if(tile != null) {
boolean foundCap = false;
for(EnumFacing e : EnumFacing.VALUES) {
if(tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, e)
&& scanInventory(tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, e), pstack)) {
blockPosBuilder.appendTag(new NBTTagLong(pos_.toLong()));
for(EnumFacing e : EnumFacing.BY_INDEX) {
if(scanInventory(tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, e), pstack)) {
blockPosBuilder.add(new NBTTagLong(pos_.toLong()));
foundCap = true;
break;
}
}
if(!foundCap && tile instanceof IInventory) {
IInventory inv = (IInventory) tile;
if(scanInventory(new InvWrapper(inv), pstack))
blockPosBuilder.appendTag(new NBTTagLong(pos_.toLong()));
if(scanInventory(LazyOptional.of(() -> new InvWrapper(inv)), pstack))
blockPosBuilder.add(new NBTTagLong(pos_.toLong()));
}
}
}
@@ -190,17 +190,18 @@ public class ItemItemFinder extends ItemBauble implements IBaubleRender {
return stack1.isItemEqual(stack2) && ItemStack.areItemStackTagsEqual(stack1, stack2);
}
private boolean scanInventory(IItemHandler inv, ItemStack pstack) {
private boolean scanInventory(LazyOptional<IItemHandler> optInv, ItemStack pstack) {
if(pstack.isEmpty())
return false;
for(int l = 0; l < inv.getSlots(); l++) {
ItemStack istack = inv.getStackInSlot(l);
if(!istack.isEmpty() && equalStacks(istack, pstack))
return true;
}
return false;
return optInv.map(inv -> {
for(int l = 0; l < inv.getSlots(); l++) {
ItemStack istack = inv.getStackInSlot(l);
if(!istack.isEmpty() && equalStacks(istack, pstack))
return true;
}
return false;
}).orElse(false);
}
@Override
@@ -219,12 +220,12 @@ public class ItemItemFinder extends ItemBauble implements IBaubleRender {
float f3 = gemIcon.getMaxV();
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty();
Helper.translateToHeadLevel(player);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
GlStateManager.rotate(90F, 0F, 1F, 0F);
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.translate(-0.4F, -1.4F, armor ? -0.3F : -0.25F);
GlStateManager.scale(0.75F, 0.75F, 0.75F);
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 16F);
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
GlStateManager.rotatef(90F, 0F, 1F, 0F);
GlStateManager.rotatef(180F, 1F, 0F, 0F);
GlStateManager.translatef(-0.4F, -1.4F, armor ? -0.3F : -0.25F);
GlStateManager.scalef(0.75F, 0.75F, 0.75F);
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 16F);
}
}
@@ -13,8 +13,8 @@ package vazkii.botania.common.item.equipment.bauble;
import baubles.api.BaubleType;
import com.google.common.collect.Multimap;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.model.ModelBiped;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
@@ -31,8 +31,8 @@ public class ItemKnockbackBelt extends ItemBaubleModifier implements IBaubleRend
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_KNOCKBACK_BELT);
private static ModelBiped model;
public ItemKnockbackBelt() {
super(LibItemNames.KNOCKBACK_BELT);
public ItemKnockbackBelt(Properties props) {
super(props);
}
@Override
@@ -52,13 +52,13 @@ public class ItemKnockbackBelt extends ItemBaubleModifier implements IBaubleRend
@OnlyIn(Dist.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.BODY) {
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
Minecraft.getInstance().textureManager.bindTexture(texture);
Helper.rotateIfSneaking(player);
GlStateManager.translate(0F, 0.2F, 0F);
GlStateManager.translatef(0F, 0.2F, 0F);
float s = 1.05F / 16F;
GlStateManager.scale(s, s, s);
GlStateManager.scalef(s, s, s);
if(model == null)
model = new ModelBiped();
@@ -29,8 +29,8 @@ import vazkii.botania.common.lib.LibItemNames;
public class ItemLavaPendant extends ItemBauble implements IBaubleRender {
public ItemLavaPendant() {
super(LibItemNames.LAVA_PENDANT);
public ItemLavaPendant(Properties props) {
super(props);
}
@Override
@@ -48,19 +48,19 @@ public class ItemLavaPendant extends ItemBauble implements IBaubleRender {
@OnlyIn(Dist.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.BODY) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Helper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty();
GlStateManager.scale(0.5, 0.5, 0.5);
GlStateManager.rotate(180, 0, 0, 1);
GlStateManager.translate(-0.5, -0.90, armor ? -0.4 : -0.25);
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
GlStateManager.rotatef(180, 0, 0, 1);
GlStateManager.translatef(-0.5, -0.90, armor ? -0.4 : -0.25);
TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.pyroclastGem;
float f = gemIcon.getMinU();
float f1 = gemIcon.getMaxU();
float f2 = gemIcon.getMinV();
float f3 = gemIcon.getMaxV();
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F);
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 32F);
}
}
@@ -13,16 +13,19 @@ package vazkii.botania.common.item.equipment.bauble;
import baubles.api.BaubleType;
import baubles.api.BaublesApi;
import com.google.common.collect.ImmutableList;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.Tag;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.item.ItemTossEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.items.IItemHandler;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.item.IRelic;
@@ -34,6 +37,7 @@ import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.core.helper.MathHelper;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.lib.LibItemNames;
import vazkii.botania.common.lib.LibMisc;
import java.util.List;
@@ -41,23 +45,23 @@ public class ItemMagnetRing extends ItemBauble {
private static final String TAG_COOLDOWN = "cooldown";
private static final List<ResourceLocation> BLACKLIST = ImmutableList.of(new ResourceLocation("appliedenergistics2", "item.ItemCrystalSeed"));
private static final Tag<Item> BLACKLIST = new ItemTags.Wrapper(new ResourceLocation(LibMisc.MOD_ID, "magnet_ring_blacklist"));
private static final Tag<Block> BLOCK_BLACKLIST = new BlockTags.Wrapper(new ResourceLocation(LibMisc.MOD_ID, "magnet_ring_blacklist"));
private final int range;
public ItemMagnetRing() {
this(LibItemNames.MAGNET_RING, 6);
MinecraftForge.EVENT_BUS.register(this);
public ItemMagnetRing(Properties props) {
this(props, 6);
MinecraftForge.EVENT_BUS.addListener(this::onTossItem);
}
public ItemMagnetRing(String name, int range) {
super(name);
public ItemMagnetRing(Properties props, int range) {
super(props);
this.range = range;
addPropertyOverride(new ResourceLocation("botania", "on"), (stack, worldIn, entityIn) -> ItemMagnetRing.getCooldown(stack) <= 0 ? 1 : 0);
}
@SubscribeEvent
public void onTossItem(ItemTossEvent event) {
private void onTossItem(ItemTossEvent event) {
IItemHandler inv = BaublesApi.getBaublesHandler(event.getPlayer());
for(int i = 0; i < inv.getSlots(); i++) {
ItemStack stack = inv.getStackInSlot(i);
@@ -105,19 +109,19 @@ public class ItemMagnetRing extends ItemBauble {
}
private boolean canPullItem(EntityItem item) {
if(item.isDead || SubTileSolegnolia.hasSolegnoliaAround(item))
if(!item.isAlive() || SubTileSolegnolia.hasSolegnoliaAround(item))
return false;
ItemStack stack = item.getItem();
if(stack.isEmpty() || stack.getItem() instanceof IManaItem || stack.getItem() instanceof IRelic || BLACKLIST.contains(Item.REGISTRY.getNameForObject(stack.getItem())) || BotaniaAPI.isItemBlacklistedFromMagnet(stack))
if(stack.isEmpty() || stack.getItem() instanceof IManaItem || stack.getItem() instanceof IRelic || BLACKLIST.contains(stack.getItem()))
return false;
BlockPos pos = new BlockPos(item);
if(BotaniaAPI.isBlockBlacklistedFromMagnet(item.world.getBlockState(pos)))
if(BLOCK_BLACKLIST.contains(item.world.getBlockState(pos).getBlock()))
return false;
if(BotaniaAPI.isBlockBlacklistedFromMagnet(item.world.getBlockState(pos.down())))
if(BLOCK_BLACKLIST.contains(item.world.getBlockState(pos.down()).getBlock()))
return false;
return true;
@@ -131,10 +135,6 @@ public class ItemMagnetRing extends ItemBauble {
ItemNBTHelper.setInt(stack, TAG_COOLDOWN, cooldown);
}
public static void addItemToBlackList(String item) {
BLACKLIST.add(new ResourceLocation(item));
}
@Override
public BaubleType getBaubleType(ItemStack arg0) {
return BaubleType.RING;
@@ -11,7 +11,7 @@
package vazkii.botania.common.item.equipment.bauble;
import baubles.api.BaubleType;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.NonNullList;
@@ -32,12 +32,8 @@ public class ItemManaRing extends ItemBauble implements IManaItem, IManaTooltipD
private static final String TAG_MANA = "mana";
public ItemManaRing() {
this(LibItemNames.MANA_RING);
}
public ItemManaRing(String name) {
super(name);
public ItemManaRing(Properties props) {
super(props);
}
@Override
@@ -46,8 +42,8 @@ public class ItemManaRing extends ItemBauble implements IManaItem, IManaTooltipD
}
@Override
public void getSubItems(@Nonnull CreativeTabs tab, @Nonnull NonNullList<ItemStack> stacks) {
if(isInCreativeTab(tab)) {
public void fillItemGroup(@Nonnull ItemGroup tab, @Nonnull NonNullList<ItemStack> stacks) {
if(isInGroup(tab)) {
stacks.add(new ItemStack(this));
ItemStack full = new ItemStack(this);
@@ -22,8 +22,8 @@ import vazkii.botania.common.lib.LibItemNames;
public class ItemMiningRing extends ItemBauble implements IManaUsingItem {
public ItemMiningRing() {
super(LibItemNames.MINING_RING);
public ItemMiningRing(Properties props) {
super(props);
}
@Override
@@ -18,9 +18,8 @@ import net.minecraft.block.BlockRedstoneRepeater;
import net.minecraft.block.BlockRedstoneWire;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
@@ -40,8 +39,8 @@ import vazkii.botania.common.lib.LibItemNames;
public class ItemMonocle extends ItemBauble implements IBurstViewerBauble, ICosmeticBauble {
public ItemMonocle() {
super(LibItemNames.MONOCLE);
public ItemMonocle(Properties props) {
super(props);
}
@Override
@@ -54,15 +53,15 @@ public class ItemMonocle extends ItemBauble implements IBurstViewerBauble, ICosm
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.HEAD) {
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty();
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Helper.translateToHeadLevel(player);
Helper.translateToFace();
Helper.defaultTransforms();
GlStateManager.rotate(180F, 0F, 1F, 0F);
GlStateManager.scale(0.5F, 0.5F, 0.5F);
GlStateManager.translate(0.5F, -0.2F, armor ? 0.12F : 0F);
Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.NONE);
GlStateManager.rotatef(180F, 0F, 1F, 0F);
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
GlStateManager.translatef(0.5F, -0.2F, armor ? 0.12F : 0F);
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.NONE);
}
}
@@ -17,8 +17,8 @@ import vazkii.botania.common.lib.LibItemNames;
public class ItemPixieRing extends ItemBauble implements IPixieSpawner {
public ItemPixieRing() {
super(LibItemNames.PIXIE_RING);
public ItemPixieRing(Properties props) {
super(props);
}
@Override
@@ -19,8 +19,8 @@ import vazkii.botania.common.lib.LibItemNames;
public class ItemReachRing extends ItemBaubleModifier {
public ItemReachRing() {
super(LibItemNames.REACH_RING);
public ItemReachRing(Properties props) {
super(props);
}
@Override
@@ -30,8 +30,8 @@ import vazkii.botania.common.lib.LibItemNames;
public class ItemSuperLavaPendant extends ItemBauble implements IBaubleRender {
public ItemSuperLavaPendant() {
super(LibItemNames.SUPER_LAVA_PENDANT);
public ItemSuperLavaPendant(Properties props) {
super(props);
}
@Override
@@ -53,19 +53,19 @@ public class ItemSuperLavaPendant extends ItemBauble implements IBaubleRender {
@OnlyIn(Dist.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.BODY) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Helper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty();
GlStateManager.scale(0.5, 0.5, 0.5);
GlStateManager.rotate(180, 0, 0, 1);
GlStateManager.translate(-0.5, -0.90, armor ? -0.4 : -0.25);
GlStateManager.scaled(0.5, 0.5, 0.5);
GlStateManager.rotatef(180, 0, 0, 1);
GlStateManager.translated(-0.5, -0.90, armor ? -0.4 : -0.25);
TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.crimsonGem;
float f = gemIcon.getMinU();
float f1 = gemIcon.getMaxU();
float f2 = gemIcon.getMinV();
float f3 = gemIcon.getMaxV();
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F);
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 32F);
}
}
}
@@ -25,8 +25,8 @@ import vazkii.botania.common.lib.LibItemNames;
public class ItemSwapRing extends ItemBauble {
public ItemSwapRing() {
super(LibItemNames.SWAP_RING);
public ItemSwapRing(Properties props) {
super(props);
}
@Override
@@ -38,8 +38,8 @@ public class ItemTinyPlanet extends ItemBauble implements IBaubleRender {
public static final String TAG_ORBIT = "orbit";
public ItemTinyPlanet() {
super(LibItemNames.TINY_PLANET);
public ItemTinyPlanet(Properties props) {
super(props);
}
@Override
@@ -92,25 +92,25 @@ public class ItemTinyPlanet extends ItemBauble implements IBaubleRender {
public static int getEntityOrbitTime(Entity entity) {
NBTTagCompound cmp = entity.getEntityData();
if(cmp.hasKey(TAG_ORBIT))
return cmp.getInteger(TAG_ORBIT);
if(cmp.contains(TAG_ORBIT))
return cmp.getInt(TAG_ORBIT);
else return 0;
}
public static void incrementOrbitTime(Entity entity) {
NBTTagCompound cmp = entity.getEntityData();
int time = getEntityOrbitTime(entity);
cmp.setInteger(TAG_ORBIT, time + 1);
cmp.putInt(TAG_ORBIT, time + 1);
}
@Override
@OnlyIn(Dist.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.HEAD) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
GlStateManager.scale(0.5F, 0.5F, 0.5F);
GlStateManager.translate(0, -1.5F, 0.5F);
Minecraft.getMinecraft().getBlockRendererDispatcher().renderBlockBrightness(ModBlocks.tinyPlanet.getDefaultState(), 1.0F);
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
GlStateManager.translatef(0, -1.5F, 0.5F);
Minecraft.getInstance().getBlockRendererDispatcher().renderBlockBrightness(ModBlocks.tinyPlanet.getDefaultState(), 1.0F);
}
}
@@ -35,8 +35,8 @@ public class ItemUnholyCloak extends ItemHolyCloak {
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_UNHOLY_CLOAK);
private static final ResourceLocation textureGlow = new ResourceLocation(LibResources.MODEL_UNHOLY_CLOAK_GLOW);
public ItemUnholyCloak() {
super(LibItemNames.UNHOLY_CLOAK);
public ItemUnholyCloak(Properties props) {
super(props);
}
@Override
@@ -27,15 +27,15 @@ public class ItemWaterRing extends ItemBauble implements IManaUsingItem {
private static final double SPEED_MULT = 1.2;
private static final double MAX_SPEED = 1.3;
public ItemWaterRing() {
super(LibItemNames.WATER_RING);
public ItemWaterRing(Properties props) {
super(props);
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
super.onWornTick(stack, player);
if(player.isInsideOfMaterial(Material.WATER)) {
if(player.isInWaterOrBubbleColumn()) {
if(player instanceof EntityPlayer) {
ItemStack firstRing = BaublesApi.getBaublesHandler((EntityPlayer) player).getStackInSlot(1);
if(!firstRing.isEmpty() && firstRing.getItem() instanceof ItemWaterRing && firstRing != stack) {
@@ -47,7 +47,7 @@ public class ItemWaterRing extends ItemBauble implements IManaUsingItem {
double motionY = player.motionY * SPEED_MULT;
double motionZ = player.motionZ * SPEED_MULT;
boolean flying = player instanceof EntityPlayer && ((EntityPlayer) player).capabilities.isFlying;
boolean flying = player instanceof EntityPlayer && ((EntityPlayer) player).abilities.isFlying;
if(Math.abs(motionX) < MAX_SPEED && !flying)
player.motionX = motionX;
@@ -26,6 +26,7 @@ import net.minecraft.item.ItemTool;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceFluidMode;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
@@ -154,7 +155,7 @@ public final class ToolCommons {
d3 = ((net.minecraft.entity.player.EntityPlayerMP)playerIn).interactionManager.getBlockReachDistance();
}*/
Vec3d vec3d1 = vec3d.add((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
return worldIn.rayTraceBlocks(vec3d, vec3d1, useLiquids, !useLiquids, false);
return worldIn.rayTraceBlocks(vec3d, vec3d1, useLiquids ? RayTraceFluidMode.SOURCE_ONLY : RayTraceFluidMode.NEVER, false, false);
}
}
@@ -26,8 +26,8 @@ import vazkii.botania.common.lib.LibItemNames;
@Optional.Interface(modid = "thaumcraft", iface = "thaumcraft.api.items.IRevealer", striprefs = true)})
public class ItemElementiumHelmRevealing extends ItemElementiumHelm implements IGoggles, IRevealer {
public ItemElementiumHelmRevealing() {
super(LibItemNames.ELEMENTIUM_HELM_R);
public ItemElementiumHelmRevealing(Properties props) {
super(props);
}
@Override
@@ -10,14 +10,11 @@
*/
package vazkii.botania.common.item.interaction.thaumcraft;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Optional;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import thaumcraft.api.items.IScribeTools;
import vazkii.botania.api.mana.IManaItem;
import vazkii.botania.common.core.helper.ItemNBTHelper;
@@ -35,17 +32,14 @@ public class ItemManaInkwell extends ItemMod implements IManaItem, IScribeTools
private static final String TAG_MANA = "mana";
public ItemManaInkwell() {
super(LibItemNames.MANA_INKWELL);
setMaxDamage(USES);
setMaxStackSize(1);
setNoRepair();
public ItemManaInkwell(Properties props) {
super(props.defaultMaxDamage(USES));
}
@Override
public void getSubItems(@Nonnull CreativeTabs tab, @Nonnull NonNullList<ItemStack> list) {
if(isInCreativeTab(tab)) {
list.add(new ItemStack(this, 1, USES));
public void fillItemGroup(@Nonnull ItemGroup tab, @Nonnull NonNullList<ItemStack> list) {
if(isInGroup(tab)) {
list.add(new ItemStack(this));
ItemStack full = new ItemStack(this);
setMana(full, MAX_MANA);
list.add(full);
@@ -60,7 +54,7 @@ public class ItemManaInkwell extends ItemMod implements IManaItem, IScribeTools
@Override
public void setDamage(ItemStack stack, int damage) {
int currentDamage = stack.getItemDamage();
int currentDamage = stack.getDamage();
if(damage > currentDamage) {
int cost = (damage - currentDamage) * COST_PER_USE;
int mana = getMana(stack);
@@ -94,7 +88,7 @@ public class ItemManaInkwell extends ItemMod implements IManaItem, IScribeTools
@Override
public void addMana(ItemStack stack, int mana) {
setMana(stack, Math.min(getMana(stack) + mana, getMaxMana(stack)));
stack.setItemDamage(getDamage(stack));
stack.setDamage(getDamage(stack));
}
@Override
@@ -25,6 +25,7 @@ import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.fml.server.ServerLifecycleHooks;
import vazkii.botania.api.item.IRelic;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lib.LibItemNames;
@@ -36,8 +37,8 @@ import java.util.List;
public class ItemDice extends ItemRelic {
public static ItemStack[] relicStacks;
public ItemDice() {
super(LibItemNames.DICE);
public ItemDice(Properties props) {
super(props);
relicStacks = new ItemStack[] {
new ItemStack(ModItems.infiniteFruit),
@@ -94,7 +95,7 @@ public class ItemDice extends ItemRelic {
ResourceLocation advId = ((IRelic) item).getAdvancement();
if(advId != null) {
Advancement adv = mpPlayer.getServerWorld().getAdvancementManager().getAdvancement(advId);
Advancement adv = ServerLifecycleHooks.getCurrentServer().getAdvancementManager().getAdvancement(advId);
return adv != null && mpPlayer.getAdvancements().getProgress(adv).isDone();
}
@@ -17,6 +17,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
@@ -40,8 +41,8 @@ import javax.annotation.Nonnull;
public class ItemFlugelEye extends ItemRelic implements ICoordBoundItem, IManaUsingItem {
public ItemFlugelEye() {
super(LibItemNames.FLUGEL_EYE);
public ItemFlugelEye(Properties props) {
super(props);
}
private static final String TAG_X = "x";
@@ -51,10 +52,13 @@ public class ItemFlugelEye extends ItemRelic implements ICoordBoundItem, IManaUs
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if(player.isSneaking()) {
public EnumActionResult onItemUse(ItemUseContext ctx) {
World world = ctx.getWorld();
BlockPos pos = ctx.getPos();
EntityPlayer player = ctx.getPlayer();
if(player != null && player.isSneaking()) {
if(world.isRemote) {
player.swingArm(hand);
for(int i = 0; i < 10; i++) {
float x1 = (float) (pos.getX() + Math.random());
float y1 = pos.getY() + 1;
@@ -62,12 +66,12 @@ public class ItemFlugelEye extends ItemRelic implements ICoordBoundItem, IManaUs
Botania.proxy.wispFX(x1, y1, z1, (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random() * 0.5F, -0.05F + (float) Math.random() * 0.05F);
}
} else {
ItemStack stack = player.getHeldItem(hand);
ItemStack stack = ctx.getItem();
ItemNBTHelper.setInt(stack, TAG_X, pos.getX());
ItemNBTHelper.setInt(stack, TAG_Y, pos.getY());
ItemNBTHelper.setInt(stack, TAG_Z, pos.getZ());
ItemNBTHelper.setInt(stack, TAG_DIMENSION, world.provider.getDimension());
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1F, 5F);
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1F, 5F);
}
return EnumActionResult.SUCCESS;
@@ -117,17 +121,17 @@ public class ItemFlugelEye extends ItemRelic implements ICoordBoundItem, IManaUs
private static void moveParticlesAndSound(Entity entity) {
PacketHandler.sendToNearby(entity.world, entity, new PacketBotaniaEffect(PacketBotaniaEffect.EffectType.FLUGEL_EFFECT, entity.posX, entity.posY, entity.posZ, entity.getEntityId()));
entity.world.playSound(null, entity.posX, entity.posY, entity.posZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1F, 1F);
entity.world.playSound(null, entity.posX, entity.posY, entity.posZ, SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1F, 1F);
}
@Override
public int getMaxItemUseDuration(ItemStack par1ItemStack) {
public int getUseDuration(ItemStack par1ItemStack) {
return 40;
}
@Nonnull
@Override
public EnumAction getItemUseAction(ItemStack par1ItemStack) {
public EnumAction getUseAction(ItemStack par1ItemStack) {
return EnumAction.BOW;
}
@@ -19,7 +19,6 @@ import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.common.lib.LibItemNames;
@@ -37,13 +36,13 @@ public class ItemInfiniteFruit extends ItemRelic implements IManaUsingItem {
}
@Override
public int getMaxItemUseDuration(ItemStack stack) {
public int getUseDuration(ItemStack stack) {
return 32;
}
@Nonnull
@Override
public EnumAction getItemUseAction(ItemStack stack) {
public EnumAction getUseAction(ItemStack stack) {
return isBoot(stack) ? EnumAction.DRINK : EnumAction.EAT;
}
@@ -75,7 +74,7 @@ public class ItemInfiniteFruit extends ItemRelic implements IManaUsingItem {
}
private static boolean isBoot(ItemStack par1ItemStack) {
String name = par1ItemStack.getDisplayName().toLowerCase(Locale.ROOT).trim();
String name = par1ItemStack.getDisplayName().getString().toLowerCase(Locale.ROOT).trim();
return name.equals("das boot");
}
@@ -39,8 +39,8 @@ public class ItemKingKey extends ItemRelic implements IManaUsingItem {
public static final int WEAPON_TYPES = 12;
public ItemKingKey() {
super(LibItemNames.KING_KEY);
public ItemKingKey(Properties props) {
super(props);
}
@Nonnull
@@ -65,7 +65,7 @@ public class ItemKingKey extends ItemRelic implements IManaUsingItem {
public void onUsingTick(ItemStack stack, EntityLivingBase living, int count) {
int spawned = getWeaponsSpawned(stack);
if(count != getMaxItemUseDuration(stack) && spawned < 20 && !living.world.isRemote && (!(living instanceof EntityPlayer) || ManaItemHandler.requestManaExact(stack, (EntityPlayer) living, 150, true))) {
if(count != getUseDuration(stack) && spawned < 20 && !living.world.isRemote && (!(living instanceof EntityPlayer) || ManaItemHandler.requestManaExact(stack, (EntityPlayer) living, 150, true))) {
Vector3 look = new Vector3(living.getLookVec()).multiply(1, 0, 1);
double playerRot = Math.toRadians(living.rotationYaw + 90);
@@ -107,12 +107,12 @@ public class ItemKingKey extends ItemRelic implements IManaUsingItem {
@Nonnull
@Override
public EnumAction getItemUseAction(ItemStack par1ItemStack) {
public EnumAction getUseAction(ItemStack par1ItemStack) {
return EnumAction.BOW;
}
@Override
public int getMaxItemUseDuration(ItemStack par1ItemStack) {
public int getUseDuration(ItemStack par1ItemStack) {
return 72000;
}
@@ -29,8 +29,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.items.IItemHandler;
@@ -62,8 +62,8 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
private static final String TAG_Y_ORIGIN = "yOrigin";
private static final String TAG_Z_ORIGIN = "zOrigin";
public ItemLokiRing() {
super(LibItemNames.LOKI_RING);
public ItemLokiRing(Properties props) {
super(props);
}
@SubscribeEvent
@@ -171,7 +171,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
if(getLokiRing(player) != stack)
return ImmutableList.of();
RayTraceResult lookPos = Minecraft.getMinecraft().objectMouseOver;
RayTraceResult lookPos = Minecraft.getInstance().objectMouseOver;
if(lookPos != null && lookPos.getBlockPos() != null && !player.world.isAirBlock(lookPos.getBlockPos()) && lookPos.entityHit == null) {
List<BlockPos> list = getCursorList(stack);
@@ -224,12 +224,12 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_CURSOR_LIST, false);
List<BlockPos> cursors = new ArrayList<>();
int count = cmp.getInteger(TAG_CURSOR_COUNT);
int count = cmp.getInt(TAG_CURSOR_COUNT);
for(int i = 0; i < count; i++) {
NBTTagCompound cursorCmp = cmp.getCompoundTag(TAG_CURSOR_PREFIX + i);
int x = cursorCmp.getInteger(TAG_X_OFFSET);
int y = cursorCmp.getInteger(TAG_Y_OFFSET);
int z = cursorCmp.getInteger(TAG_Z_OFFSET);
NBTTagCompound cursorCmp = cmp.getCompound(TAG_CURSOR_PREFIX + i);
int x = cursorCmp.getInt(TAG_X_OFFSET);
int y = cursorCmp.getInt(TAG_Y_OFFSET);
int z = cursorCmp.getInt(TAG_Z_OFFSET);
cursors.add(new BlockPos(x, y, z));
}
@@ -245,10 +245,10 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
int i = 0;
for(BlockPos cursor : cursors) {
NBTTagCompound cursorCmp = cursorToCmp(cursor);
cmp.setTag(TAG_CURSOR_PREFIX + i, cursorCmp);
cmp.put(TAG_CURSOR_PREFIX + i, cursorCmp);
i++;
}
cmp.setInteger(TAG_CURSOR_COUNT, i);
cmp.putInt(TAG_CURSOR_COUNT, i);
}
ItemNBTHelper.setCompound(stack, TAG_CURSOR_LIST, cmp);
@@ -256,17 +256,17 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
private static NBTTagCompound cursorToCmp(BlockPos pos) {
NBTTagCompound cmp = new NBTTagCompound();
cmp.setInteger(TAG_X_OFFSET, pos.getX());
cmp.setInteger(TAG_Y_OFFSET, pos.getY());
cmp.setInteger(TAG_Z_OFFSET, pos.getZ());
cmp.putInt(TAG_X_OFFSET, pos.getX());
cmp.putInt(TAG_Y_OFFSET, pos.getY());
cmp.putInt(TAG_Z_OFFSET, pos.getZ());
return cmp;
}
private static void addCursor(ItemStack stack, BlockPos pos) {
NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_CURSOR_LIST, false);
int count = cmp.getInteger(TAG_CURSOR_COUNT);
cmp.setTag(TAG_CURSOR_PREFIX + count, cursorToCmp(pos));
cmp.setInteger(TAG_CURSOR_COUNT, count + 1);
int count = cmp.getInt(TAG_CURSOR_COUNT);
cmp.put(TAG_CURSOR_PREFIX + count, cursorToCmp(pos));
cmp.putInt(TAG_CURSOR_COUNT, count + 1);
ItemNBTHelper.setCompound(stack, TAG_CURSOR_LIST, cmp);
}
@@ -23,8 +23,8 @@ import net.minecraft.util.DamageSource;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.items.IItemHandler;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.item.ModItems;
@@ -39,8 +39,8 @@ public class ItemOdinRing extends ItemRelicBauble {
private static final List<String> damageNegations = new ArrayList<>();
public ItemOdinRing() {
super(LibItemNames.ODIN_RING);
public ItemOdinRing(Properties props) {
super(props);
damageNegations.add(DamageSource.DROWN.damageType);
damageNegations.add(DamageSource.FALL.damageType);
@@ -20,6 +20,9 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
@@ -39,41 +42,40 @@ public class ItemRelic extends ItemMod implements IRelic {
private static final String TAG_SOULBIND_UUID = "soulbindUUID";
public ItemRelic(String name) {
super(name);
setMaxStackSize(1);
public ItemRelic(Properties props) {
super(props);
}
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
if(!world.isRemote && entity instanceof EntityPlayer)
updateRelic(stack, (EntityPlayer) entity);
}
@OnlyIn(Dist.CLIENT)
@Override
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flags) {
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flags) {
addBindInfo(tooltip, stack);
}
@OnlyIn(Dist.CLIENT)
public void addBindInfo(List<String> list, ItemStack stack) {
public void addBindInfo(List<ITextComponent> list, ItemStack stack) {
if(GuiScreen.isShiftKeyDown()) {
if(!hasUUID(stack)) {
addStringToTooltip(I18n.format("botaniamisc.relicUnbound"), list);
list.add(new TextComponentTranslation("botaniamisc.relicUnbound"));
} else {
if(!getSoulbindUUID(stack).equals(Minecraft.getMinecraft().player.getUniqueID()))
addStringToTooltip(I18n.format("botaniamisc.notYourSagittarius"), list);
else addStringToTooltip(I18n.format("botaniamisc.relicSoulbound", Minecraft.getMinecraft().player.getName()), list);
if(!getSoulbindUUID(stack).equals(Minecraft.getInstance().player.getUniqueID()))
list.add(new TextComponentTranslation("botaniamisc.notYourSagittarius"));
else list.add(new TextComponentTranslation("botaniamisc.relicSoulbound", Minecraft.getInstance().player.getName()));
}
if(stack.getItem() == ModItems.dice) {
addStringToTooltip("", list);
list.add(new TextComponentString(""));
String name = stack.getTranslationKey() + ".poem";
for(int i = 0; i < 4; i++)
addStringToTooltip(TextFormatting.ITALIC + I18n.format(name + i), list);
list.add(new TextComponentTranslation(name + i).applyTextStyle(TextFormatting.ITALIC));
}
} else addStringToTooltip(I18n.format("botaniamisc.shiftinfo"), list);
} else list.add(new TextComponentTranslation("botaniamisc.shiftinfo"));
}
public boolean shouldDamageWrongPlayer() {
@@ -85,10 +87,6 @@ public class ItemRelic extends ItemMod implements IRelic {
return Integer.MAX_VALUE;
}
private static void addStringToTooltip(String s, List<String> tooltip) {
tooltip.add(s.replaceAll("&", "\u00a7"));
}
public void updateRelic(ItemStack stack, EntityPlayer player) {
if(stack.isEmpty() || !(stack.getItem() instanceof IRelic))
return;
@@ -16,6 +16,7 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -29,14 +30,14 @@ import java.util.UUID;
public abstract class ItemRelicBauble extends ItemBauble implements IRelic {
private final ItemRelic dummy = new ItemRelic("dummy"); // Delegate for relic stuff
private final ItemRelic dummy = new ItemRelic(new Properties()); // Delegate for relic stuff
public ItemRelicBauble(String name) {
super(name);
public ItemRelicBauble(Properties props) {
super(props);
}
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean held) {
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean held) {
if(entity instanceof EntityPlayer)
dummy.updateRelic(stack, (EntityPlayer) entity);
}
@@ -54,7 +55,7 @@ public abstract class ItemRelicBauble extends ItemBauble implements IRelic {
@OnlyIn(Dist.CLIENT)
@Override
public void addHiddenTooltip(ItemStack par1ItemStack, World world, List<String> stacks, ITooltipFlag flags) {
public void addHiddenTooltip(ItemStack par1ItemStack, World world, List<ITextComponent> stacks, ITooltipFlag flags) {
super.addHiddenTooltip(par1ItemStack, world, stacks, flags);
dummy.addBindInfo(stacks, par1ItemStack);
}
@@ -22,8 +22,8 @@ import vazkii.botania.common.lib.LibMisc;
public class ItemThorRing extends ItemRelicBauble {
public ItemThorRing() {
super(LibItemNames.THOR_RING);
public ItemThorRing(Properties props) {
super(props);
}
@Override
@@ -14,6 +14,7 @@ import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
@@ -31,15 +32,14 @@ public class ItemCobbleRod extends ItemMod implements IManaUsingItem, IBlockProv
static final int COST = 150;
public ItemCobbleRod() {
super(LibItemNames.COBBLE_ROD);
setMaxStackSize(1);
public ItemCobbleRod(Properties props) {
super(props);
}
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
return ItemDirtRod.place(player, world, pos, hand, side, par8, par9, par10, Blocks.COBBLESTONE, COST, 0.3F, 0.3F, 0.3F);
public EnumActionResult onItemUse(ItemUseContext ctx) {
return ItemDirtRod.place(ctx, Blocks.COBBLESTONE, COST, 0.3F, 0.3F, 0.3F);
}
@Override
@@ -48,15 +48,15 @@ public class ItemCobbleRod extends ItemMod implements IManaUsingItem, IBlockProv
}
@Override
public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta, boolean doit) {
if(block == Blocks.COBBLESTONE && meta == 0)
public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, boolean doit) {
if(block == Blocks.COBBLESTONE)
return !doit || ManaItemHandler.requestManaExactForTool(requestor, player, COST, true);
return false;
}
@Override
public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta) {
if(block == Blocks.COBBLESTONE && meta == 0)
public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block) {
if(block == Blocks.COBBLESTONE)
return -1;
return 0;
}
@@ -23,6 +23,7 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.Tags;
import net.minecraftforge.oredict.OreDictionary;
import vazkii.botania.api.item.IAvatarTile;
import vazkii.botania.api.item.IAvatarWieldable;
@@ -44,9 +45,8 @@ public class ItemDiviningRod extends ItemMod implements IManaUsingItem, IAvatarW
static final int COST = 3000;
public ItemDiviningRod() {
super(LibItemNames.DIVINING_ROD);
setMaxStackSize(1);
public ItemDiviningRod(Properties props) {
super(props);
}
@Nonnull
@@ -66,20 +66,14 @@ public class ItemDiviningRod extends ItemMod implements IManaUsingItem, IAvatarW
return ActionResult.newResult(EnumActionResult.PASS, stack);
}
public void doHighlight(World world, BlockPos pos, int range, long seedxor) {
private void doHighlight(World world, BlockPos pos, int range, long seedxor) {
Botania.proxy.setWispFXDepthTest(false);
for(BlockPos pos_ : BlockPos.getAllInBox(pos.add(-range, -range, -range), pos.add(range, range, range))) {
IBlockState state = world.getBlockState(pos_);
if(Item.getItemFromBlock(state.getBlock()) == Items.AIR)
continue;
ItemStack orestack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state));
for(int id : OreDictionary.getOreIDs(orestack)) {
String s = OreDictionary.getOreName(id);
if(s.matches("^ore[A-Z].+")) {
Random rand = new Random(s.hashCode() ^ seedxor);
Botania.proxy.wispFX(pos_.getX() + world.rand.nextFloat(), pos_.getY() + world.rand.nextFloat(), pos_.getZ() + world.rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), 0.25F, 0F, 8);
break;
}
if(Tags.Blocks.ORES.contains(state.getBlock())) {
Random rand = new Random(state.hashCode() ^ seedxor);
Botania.proxy.wispFX(pos_.getX() + world.rand.nextFloat(), pos_.getY() + world.rand.nextFloat(), pos_.getZ() + world.rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), 0.25F, 0F, 8);
}
}
Botania.proxy.setWispFXDepthTest(true);
@@ -13,6 +13,7 @@ package vazkii.botania.common.item.rod;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
@@ -40,28 +41,27 @@ public class ItemFireRod extends ItemMod implements IManaUsingItem, IAvatarWield
private static final int COST = 900;
private static final int COOLDOWN = 1200;
public ItemFireRod() {
super(LibItemNames.FIRE_ROD);
setMaxStackSize(1);
public ItemFireRod(Properties props) {
super(props);
}
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
ItemStack stack = player.getHeldItem(hand);
if(!world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST, false)) {
EntityFlameRing entity = new EntityFlameRing(player.world);
public EnumActionResult onItemUse(ItemUseContext ctx) {
World world = ctx.getWorld();
EntityPlayer player = ctx.getPlayer();
ItemStack stack = ctx.getItem();
BlockPos pos = ctx.getPos();
if(!world.isRemote && player != null && ManaItemHandler.requestManaExactForTool(stack, player, COST, false)) {
EntityFlameRing entity = new EntityFlameRing(world);
entity.setPosition(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5);
player.world.spawnEntity(entity);
world.spawnEntity(entity);
player.getCooldownTracker().setCooldown(this, IManaProficiencyArmor.Helper.hasProficiency(player, stack) ? COOLDOWN / 2 : COOLDOWN);
ManaItemHandler.requestManaExactForTool(stack, player, COST, true);
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_BLAZE_AMBIENT, SoundCategory.PLAYERS, 1F, 1F);
// Fix up rods from old versions which used meta instead of cooldown tracker
if (stack.getItemDamage() > 0)
stack.setItemDamage(0);
ctx.getWorld().playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENTITY_BLAZE_AMBIENT, player != null ? SoundCategory.PLAYERS : SoundCategory.BLOCKS, 1F, 1F);
}
return EnumActionResult.SUCCESS;
@@ -49,9 +49,8 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem {
private static final String TAG_TARGET = "target";
private static final String TAG_DIST = "dist";
public ItemGravityRod() {
super(LibItemNames.GRAVITY_ROD);
setMaxStackSize(1);
public ItemGravityRod(Properties props) {
super(props);
}
@Override
@@ -60,8 +59,8 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem {
}
@Override
public void onUpdate(ItemStack stack, World world, Entity par3Entity, int slot, boolean held) {
if(!(par3Entity instanceof EntityPlayer))
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean held) {
if(!(entity instanceof EntityPlayer))
return;
int ticksTillExpire = ItemNBTHelper.getInt(stack, TAG_TICKS_TILL_EXPIRE, 0);
@@ -79,7 +78,7 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem {
ItemNBTHelper.setInt(stack, TAG_TICKS_TILL_EXPIRE, ticksTillExpire);
ItemNBTHelper.setInt(stack, TAG_TICKS_COOLDOWN, ticksCooldown);
EntityPlayer player = (EntityPlayer) par3Entity;
EntityPlayer player = (EntityPlayer) entity;
PotionEffect haste = player.getActivePotionEffect(MobEffects.HASTE);
float check = haste == null ? 0.16666667F : haste.getAmplifier() == 1 ? 0.5F : 0.4F;
if(player.getHeldItemMainhand() == stack && player.swingProgress == check && !world.isRemote)
@@ -182,7 +181,7 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem {
return true;
}
public static void leftClick(EntityPlayer player) {
private static void leftClick(EntityPlayer player) {
ItemStack stack = player.getHeldItemMainhand();
if(!stack.isEmpty() && stack.getItem() == ModItems.gravityRod) {
int targetID = ItemNBTHelper.getInt(stack, TAG_TARGET, -1);
@@ -205,7 +204,7 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem {
}
if(found) {
item = player.world.getEntityByID(targetID);
item = taritem;
ItemNBTHelper.setInt(stack, TAG_TARGET, -1);
ItemNBTHelper.setDouble(stack, TAG_DIST, -1);
Vector3 moveVector = new Vector3(player.getLookVec().normalize());
@@ -219,7 +218,7 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem {
EntityThrownItem thrown = new EntityThrownItem(item.world, item.posX, item.posY, item.posZ, (EntityItem) item);
item.world.spawnEntity(thrown);
}
item.setDead();
item.remove();
} else {
item.motionX = moveVector.x * 3.0F;
item.motionY = moveVector.y * 1.5F;
@@ -41,19 +41,18 @@ public class ItemMissileRod extends ItemMod implements IManaUsingItem, IAvatarWi
private static final int COST_PER = 120;
private static final int COST_AVATAR = 40;
public ItemMissileRod() {
super(LibItemNames.MISSILE_ROD);
setMaxStackSize(1);
public ItemMissileRod(Properties props) {
super(props);
}
@Nonnull
@Override
public EnumAction getItemUseAction(ItemStack par1ItemStack) {
public EnumAction getUseAction(ItemStack par1ItemStack) {
return EnumAction.BOW;
}
@Override
public int getMaxItemUseDuration(ItemStack par1ItemStack) {
public int getUseDuration(ItemStack par1ItemStack) {
return 72000;
}
@@ -62,7 +61,7 @@ public class ItemMissileRod extends ItemMod implements IManaUsingItem, IAvatarWi
if(!(living instanceof EntityPlayer)) return;
EntityPlayer player = (EntityPlayer) living;
if(count != getMaxItemUseDuration(stack) && count % (IManaProficiencyArmor.Helper.hasProficiency(player, stack) ? 1 : 2) == 0 && !player.world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST_PER, false)) {
if(count != getUseDuration(stack) && count % (IManaProficiencyArmor.Helper.hasProficiency(player, stack) ? 1 : 2) == 0 && !player.world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST_PER, false)) {
if(spawnMissile(player.world, player, player.posX + (Math.random() - 0.5 * 0.1), player.posY + 2.4 + (Math.random() - 0.5 * 0.1), player.posZ + (Math.random() - 0.5 * 0.1)))
ManaItemHandler.requestManaExactForTool(stack, player, COST_PER, true);
@@ -49,9 +49,8 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWi
private static final int MANA_COST_AVATAR = 10;
private static final int TIME = 600;
public ItemRainbowRod() {
super(LibItemNames.RAINBOW_ROD);
setMaxStackSize(1);
public ItemRainbowRod(Properties props) {
super(props);
}
@Nonnull
@@ -117,10 +116,6 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWi
world.playSound(null, player.posX, player.posY, player.posZ, ModSounds.bifrostRod, SoundCategory.PLAYERS, 0.5F, 0.25F);
ManaItemHandler.requestManaExactForTool(stack, player, MANA_COST, false);
player.getCooldownTracker().setCooldown(this, TIME);
// Fix up rods from old versions which used meta instead of cooldown tracker
if (stack.getItemDamage() > 0)
stack.setItemDamage(0);
}
}
@@ -157,7 +152,7 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWi
int l = 20;
AxisAlignedBB axis = null;
switch(world.getBlockState(tePos).getValue(BotaniaStateProps.CARDINALS)) {
switch(world.getBlockState(tePos).get(BotaniaStateProps.CARDINALS)) {
case NORTH :
axis = new AxisAlignedBB(tePos.add(-w, -h, -l), tePos.add(w + 1, h, 0));
break;
@@ -15,6 +15,8 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryBasic;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
@@ -25,6 +27,7 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.common.crafting.VanillaRecipeTypes;
import vazkii.botania.api.item.IManaProficiencyArmor;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
@@ -45,19 +48,18 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
public static final Map<EntityPlayer, SmeltData> playerData = new WeakHashMap<>();
public ItemSmeltRod() {
super(LibItemNames.SMELT_ROD);
setMaxStackSize(1);
public ItemSmeltRod(Properties props) {
super(props);
}
@Nonnull
@Override
public EnumAction getItemUseAction(ItemStack par1ItemStack) {
public EnumAction getUseAction(ItemStack par1ItemStack) {
return EnumAction.BOW;
}
@Override
public int getMaxItemUseDuration(ItemStack par1ItemStack) {
public int getUseDuration(ItemStack par1ItemStack) {
return 72000;
}
@@ -72,6 +74,7 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
public void onUsingTick(ItemStack stack, EntityLivingBase living, int time) {
if(!(living instanceof EntityPlayer)) return;
EntityPlayer p = (EntityPlayer) living;
IInventory dummyInv = new InventoryBasic(null, 1);
if(!ManaItemHandler.requestManaExactForTool(stack, p, COST_PER_TICK, false))
return;
@@ -81,8 +84,8 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
if(pos != null && pos.getBlockPos() != null) {
IBlockState state = p.world.getBlockState(pos.getBlockPos());
ItemStack blockStack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state));
ItemStack result = FurnaceRecipes.instance().getSmeltingResult(blockStack);
dummyInv.setInventorySlotContents(0, new ItemStack(state.getBlock()));
ItemStack result = p.world.getRecipeManager().getResult(dummyInv, p.world, VanillaRecipeTypes.SMELTING);
if(!result.isEmpty() && result.getItem() instanceof ItemBlock) {
boolean decremented = false;
@@ -95,7 +98,7 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
decremented = true;
if(data.progress <= 0) {
if(!p.world.isRemote) {
p.world.setBlockState(pos.getBlockPos(), Block.getBlockFromItem(result.getItem()).getStateFromMeta(result.getItemDamage()), 1 | 2);
p.world.setBlockState(pos.getBlockPos(), Block.getBlockFromItem(result.getItem()).getDefaultState());
p.world.playSound(null, p.posX, p.posY, p.posZ, SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.PLAYERS, 0.6F, 1F);
p.world.playSound(null, p.posX, p.posY, p.posZ, SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.PLAYERS, 1F, 1F);
@@ -45,44 +45,43 @@ public class ItemTornadoRod extends ItemMod implements IManaUsingItem, IAvatarWi
private static final int FLY_TIME = 20;
private static final int FALL_MULTIPLIER = 3;
private static final int MAX_DAMAGE = FLY_TIME * FALL_MULTIPLIER;
private static final int MAX_COUNTER = FLY_TIME * FALL_MULTIPLIER;
private static final int COST = 350;
private static final String TAG_FLYING = "flying";
private static final String TAG_FLYCOUNTER = "flyCounter";
public ItemTornadoRod() {
super(LibItemNames.TORNADO_ROD);
setMaxDamage(MAX_DAMAGE);
setMaxStackSize(1);
public ItemTornadoRod(Properties props) {
super(props);
addPropertyOverride(new ResourceLocation("botania", "flying"), (stack, world, living) -> isFlying(stack) ? 1 : 0);
}
@Override
public void onUpdate(ItemStack par1ItemStack, World world, Entity par3Entity, int par4, boolean holding) {
if(par3Entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) par3Entity;
boolean damaged = par1ItemStack.getItemDamage() > 0;
public void inventoryTick(ItemStack stack, World world, Entity ent, int par4, boolean holding) {
if(ent instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) ent;
boolean damaged = stack.getOrCreateTag().getInt(TAG_FLYCOUNTER) > 0;
if(damaged && !isFlying(par1ItemStack))
par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - 1);
if(damaged && !isFlying(stack))
stack.getTag().putInt(TAG_FLYCOUNTER, stack.getTag().getInt(TAG_FLYCOUNTER) - 1);
int max = FALL_MULTIPLIER * FLY_TIME;
if(par1ItemStack.getItemDamage() >= max) {
setFlying(par1ItemStack, false);
if(stack.getTag().getInt(TAG_FLYCOUNTER) >= max) {
setFlying(stack, false);
player.resetActiveHand();
} else if(isFlying(par1ItemStack)) {
} else if(isFlying(stack)) {
if(holding) {
player.fallDistance = 0F;
player.motionY = IManaProficiencyArmor.Helper.hasProficiency(player, par1ItemStack) ? 1.6 : 1.25;
player.motionY = IManaProficiencyArmor.Helper.hasProficiency(player, stack) ? 1.6 : 1.25;
player.world.playSound(null, player.posX, player.posY, player.posZ, ModSounds.airRod, SoundCategory.PLAYERS, 0.1F, 0.25F);
for(int i = 0; i < 5; i++)
Botania.proxy.wispFX(player.posX, player.posY, player.posZ, 0.25F, 0.25F, 0.25F, 0.35F + (float) Math.random() * 0.1F, 0.2F * (float) (Math.random() - 0.5), -0.01F * (float) Math.random(), 0.2F * (float) (Math.random() - 0.5));
}
par1ItemStack.setItemDamage(Math.min(max, par1ItemStack.getItemDamage() + FALL_MULTIPLIER));
if(par1ItemStack.getItemDamage() == MAX_DAMAGE)
setFlying(par1ItemStack, false);
stack.getTag().putInt(TAG_FLYCOUNTER, Math.min(max, stack.getTag().getInt(TAG_FLYCOUNTER) + FALL_MULTIPLIER));
if(stack.getTag().getInt(TAG_FLYCOUNTER) == MAX_COUNTER)
setFlying(stack, false);
}
if(damaged)
@@ -94,10 +93,10 @@ public class ItemTornadoRod extends ItemMod implements IManaUsingItem, IAvatarWi
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
int meta = stack.getItemDamage();
if(meta != 0 || ManaItemHandler.requestManaExactForTool(stack, player, COST, false)) {
int dmg = stack.getDamage();
if(dmg != 0 || ManaItemHandler.requestManaExactForTool(stack, player, COST, false)) {
player.setActiveHand(hand);
if(meta == 0) {
if(dmg == 0) {
ManaItemHandler.requestManaExactForTool(stack, player, COST, true);
setFlying(stack, true);
}
@@ -109,12 +108,12 @@ public class ItemTornadoRod extends ItemMod implements IManaUsingItem, IAvatarWi
@Nonnull
@Override
public EnumAction getItemUseAction(ItemStack par1ItemStack) {
public EnumAction getUseAction(ItemStack par1ItemStack) {
return EnumAction.BOW;
}
@Override
public int getMaxItemUseDuration(ItemStack par1ItemStack) {
public int getUseDuration(ItemStack par1ItemStack) {
return 720000;
}
@@ -4,6 +4,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemBucket;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
@@ -22,27 +23,26 @@ public class ItemWaterRod extends ItemMod implements IManaUsingItem {
public static final int COST = 75;
public ItemWaterRod() {
super(LibItemNames.WATER_ROD);
setMaxStackSize(1);
public ItemWaterRod(Properties props) {
super(props);
}
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
public EnumActionResult onItemUse(ItemUseContext ctx) {
ItemStack stack = player.getHeldItem(hand);
if(ManaItemHandler.requestManaExactForTool(stack, player, COST, false) && !world.provider.doesWaterVaporize()) {
// Adapted from bucket code
RayTraceResult mop = rayTrace(world, player, false);
if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) {
if (mop != null && mop.type == RayTraceResult.Type.BLOCK) {
BlockPos hitPos = mop.getBlockPos();
if(!world.isBlockModifiable(player, hitPos))
return EnumActionResult.FAIL;
BlockPos placePos = hitPos.offset(mop.sideHit);
if(player.canPlayerEdit(placePos, mop.sideHit, stack)) {
if (ManaItemHandler.requestManaExactForTool(stack, player, COST, true)
&& ((ItemBucket) Items.WATER_BUCKET).tryPlaceContainedLiquid(player, world, placePos)) {
&& ((ItemBucket) Items.WATER_BUCKET).tryPlaceContainedLiquid(player, world, placePos, mop)) {
for(int i = 0; i < 6; i++)
Botania.proxy.sparkleFX(pos.getX() + side.getXOffset() + Math.random(), pos.getY() + side.getYOffset() + Math.random(), pos.getZ() + side.getZOffset() + Math.random(), 0.2F, 0.2F, 1F, 1F, 5);
return EnumActionResult.SUCCESS;
@@ -134,12 +134,12 @@ public final class LibItemNames {
public static final String FLARE_CHAKRAM = "flare_chakram";
public static final String OVERGROWTH_SEED = "overgrowthseed";
public static final String CRAFT_PATTERN_PREFIX = "pattern_";
public static final String ANCIENT_WILL = "ancient_will";
public static final String ANCIENT_WILL_PREFIX = "ancient_will_";
public static final String CORPOREA_SPARK = "corporea_spark";
public static final String CORPOREA_SPARK_MASTER = "corporea_spark_master";
public static final String LIVINGWOOD_BOW = "livingwood_bow";
public static final String CRYSTAL_BOW = "crystal_bow";
public static final String COSMETIC = "cosmetic";
public static final String COSMETIC_PREFIX = "cosmetic_";
public static final String SWAP_RING = "swapring";
public static final String FLOWER_BAG = "flowerbag";
public static final String PHANTOM_INK = "phantomink";