mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 02:45:13 +00:00
Grind through a bunch of items. This is going to take a while
This commit is contained in:
1 parent
9cda2d5e87
commit
56e12c7dfd
56 files changed
+479
-651
No files matched your search
@@ -29,6 +29,7 @@ sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = co
|
||||
|
||||
minecraft {
|
||||
mappings channel: 'snapshot', version: '20190214-1.13.1'
|
||||
accessTransformer = file('src/main/resources/META-INF/botania_at.cfg')
|
||||
runs {
|
||||
client = {
|
||||
properties 'forge.logging.markers': 'SCAN,REGISTRIES,REGISTRYDUMP'
|
||||
|
||||
@@ -27,7 +27,7 @@ public interface IBlockProvider {
|
||||
* If you need to use calls to ManaItemHandler.requestMana[Exact], use
|
||||
* the requestor as the ItemStack passed in.
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* Gets the amount of blocks of the type passed stored in this item. You must
|
||||
@@ -35,6 +35,6 @@ public interface IBlockProvider {
|
||||
* -1 states that the item can provide infinite of the item passed in (for example,
|
||||
* the Rod of the Lands would return -1 if the block is dirt).
|
||||
*/
|
||||
public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block, int meta);
|
||||
public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack stack, Block block);
|
||||
|
||||
}
|
||||
@@ -910,4 +910,18 @@ public final class ModBlocks {
|
||||
BotaniaAPI.registerMiniSubTile(new ResourceLocation(key.getNamespace(), key.getPath() + "Chibi"), innerClazz, key);
|
||||
}
|
||||
|
||||
// This is a method returning fresh arrays to account for registry replacements
|
||||
private static Block[] getOrderedFlowers() {
|
||||
return new Block[] {
|
||||
whiteFlower, orangeFlower, magentaFlower, lightBlueFlower,
|
||||
yellowFlower, limeFlower, pinkFlower, grayFlower,
|
||||
lightGrayFlower, cyanFlower, purpleFlower, blueFlower,
|
||||
brownFlower, greenFlower, redFlower, blackFlower
|
||||
};
|
||||
}
|
||||
|
||||
public static Block getFlower(EnumDyeColor color) {
|
||||
return getOrderedFlowers()[color.getId()];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,8 +15,8 @@ import net.minecraft.item.EnumDyeColor;
|
||||
public class Item16Colors extends ItemMod {
|
||||
public final EnumDyeColor color;
|
||||
|
||||
public Item16Colors(String name, EnumDyeColor color) {
|
||||
super(name + "_" + color.getName());
|
||||
public Item16Colors(EnumDyeColor color, Properties props) {
|
||||
super(props);
|
||||
this.color = color;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ 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.nbt.NBTUtil;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
@@ -29,6 +30,8 @@ import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -49,30 +52,26 @@ public class ItemAstrolabe extends ItemMod {
|
||||
private static final String TAG_BLOCKSTATE = "blockstate";
|
||||
private static final String TAG_SIZE = "size";
|
||||
|
||||
public ItemAstrolabe() {
|
||||
super(LibItemNames.ASTROLABE);
|
||||
setMaxStackSize(1);
|
||||
public ItemAstrolabe(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = playerIn.getHeldItem(hand);
|
||||
IBlockState state = worldIn.getBlockState(pos);
|
||||
Block block = state.getBlock();
|
||||
int meta = block.getMetaFromState(state);
|
||||
public EnumActionResult onItemUse(ItemUseContext ctx) {
|
||||
ItemStack stack = ctx.getItem();
|
||||
IBlockState state = ctx.getWorld().getBlockState(ctx.getPos());
|
||||
EntityPlayer player = ctx.getPlayer();
|
||||
|
||||
if(playerIn.isSneaking()) {
|
||||
if(setBlock(stack, block, meta)) {
|
||||
displayRemainderCounter(playerIn, stack);
|
||||
if(player != null && player.isSneaking()) {
|
||||
if(setBlock(stack, state)) {
|
||||
displayRemainderCounter(player, stack);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
} else {
|
||||
boolean did = placeAllBlocks(stack, playerIn);
|
||||
} else if(player != null) {
|
||||
boolean did = placeAllBlocks(stack, player);
|
||||
if(did) {
|
||||
displayRemainderCounter(playerIn, stack);
|
||||
if(!worldIn.isRemote)
|
||||
playerIn.swingArm(hand);
|
||||
displayRemainderCounter(player, stack);
|
||||
}
|
||||
|
||||
return did ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
|
||||
@@ -108,7 +107,7 @@ public class ItemAstrolabe extends ItemMod {
|
||||
if(!ManaItemHandler.requestManaExact(stack, player, cost, false))
|
||||
return false;
|
||||
|
||||
ItemStack stackToPlace = new ItemStack(getBlock(stack), 1, getBlockMeta(stack));
|
||||
ItemStack stackToPlace = new ItemStack(getBlock(stack));
|
||||
for(BlockPos coords : blocksToPlace)
|
||||
placeBlockAndConsume(player, stack, stackToPlace, coords);
|
||||
ManaItemHandler.requestManaExact(stack, player, cost, true);
|
||||
@@ -117,22 +116,21 @@ public class ItemAstrolabe extends ItemMod {
|
||||
}
|
||||
|
||||
private void placeBlockAndConsume(EntityPlayer player, ItemStack requestor, ItemStack blockToPlace, BlockPos coords) {
|
||||
if(blockToPlace.getItem() == null)
|
||||
if(blockToPlace.isEmpty())
|
||||
return;
|
||||
|
||||
Block block = Block.getBlockFromItem(blockToPlace.getItem());
|
||||
int meta = blockToPlace.getItemDamage();
|
||||
IBlockState state = block.getStateFromMeta(meta);
|
||||
player.world.setBlockState(coords, state, 1 | 2);
|
||||
IBlockState state = block.getDefaultState();
|
||||
player.world.setBlockState(coords, state);
|
||||
player.world.playEvent(2001, coords, Block.getStateId(state));
|
||||
|
||||
if(player.capabilities.isCreativeMode)
|
||||
if(player.abilities.isCreativeMode)
|
||||
return;
|
||||
|
||||
List<ItemStack> stacksToCheck = new ArrayList<>();
|
||||
for(int i = 0; i < player.inventory.getSizeInventory(); i++) {
|
||||
ItemStack stackInSlot = player.inventory.getStackInSlot(i);
|
||||
if(!stackInSlot.isEmpty() && stackInSlot.getItem() == blockToPlace.getItem() && stackInSlot.getItemDamage() == blockToPlace.getItemDamage()) {
|
||||
if(!stackInSlot.isEmpty() && stackInSlot.getItem() == blockToPlace.getItem()) {
|
||||
stackInSlot.shrink(1);
|
||||
return;
|
||||
}
|
||||
@@ -144,27 +142,26 @@ public class ItemAstrolabe extends ItemMod {
|
||||
for(ItemStack providerStack : stacksToCheck) {
|
||||
IBlockProvider prov = (IBlockProvider) providerStack.getItem();
|
||||
|
||||
if(prov.provideBlock(player, requestor, providerStack, block, meta, false)) {
|
||||
prov.provideBlock(player, requestor, providerStack, block, meta, true);
|
||||
if(prov.provideBlock(player, requestor, providerStack, block, false)) {
|
||||
prov.provideBlock(player, requestor, providerStack, block, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasBlocks(ItemStack stack, EntityPlayer player, List<BlockPos> blocks) {
|
||||
if (player.capabilities.isCreativeMode)
|
||||
if (player.abilities.isCreativeMode)
|
||||
return true;
|
||||
|
||||
Block block = getBlock(stack);
|
||||
int meta = getBlockMeta(stack);
|
||||
ItemStack reqStack = new ItemStack(block, 1, meta);
|
||||
ItemStack reqStack = new ItemStack(block);
|
||||
|
||||
int required = blocks.size();
|
||||
int current = 0;
|
||||
List<ItemStack> stacksToCheck = new ArrayList<>();
|
||||
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
|
||||
ItemStack stackInSlot = player.inventory.getStackInSlot(i);
|
||||
if (!stackInSlot.isEmpty() && stackInSlot.getItem() == reqStack.getItem() && stackInSlot.getItemDamage() == reqStack.getItemDamage()) {
|
||||
if (!stackInSlot.isEmpty() && stackInSlot.getItem() == reqStack.getItem()) {
|
||||
current += stackInSlot.getCount();
|
||||
if (current >= required)
|
||||
return true;
|
||||
@@ -175,7 +172,7 @@ public class ItemAstrolabe extends ItemMod {
|
||||
|
||||
for(ItemStack providerStack : stacksToCheck) {
|
||||
IBlockProvider prov = (IBlockProvider) providerStack.getItem();
|
||||
int count = prov.getBlockCount(player, stack, providerStack, block, meta);
|
||||
int count = prov.getBlockCount(player, stack, providerStack, block);
|
||||
if(count == -1)
|
||||
return true;
|
||||
|
||||
@@ -236,10 +233,9 @@ public class ItemAstrolabe extends ItemMod {
|
||||
|
||||
public void displayRemainderCounter(EntityPlayer player, ItemStack stack) {
|
||||
Block block = getBlock(stack);
|
||||
int meta = getBlockMeta(stack);
|
||||
int count = ItemExchangeRod.getInventoryItemCount(player, stack, block, meta);
|
||||
int count = ItemExchangeRod.getInventoryItemCount(player, stack, block);
|
||||
if(!player.world.isRemote)
|
||||
ItemsRemainingRenderHandler.set(new ItemStack(block, 1, meta), count);
|
||||
ItemsRemainingRenderHandler.set(new ItemStack(block), count);
|
||||
}
|
||||
|
||||
private boolean setBlock(ItemStack stack, IBlockState state) {
|
||||
@@ -263,18 +259,18 @@ public class ItemAstrolabe extends ItemMod {
|
||||
}
|
||||
|
||||
public static IBlockState getBlockState(ItemStack stack) {
|
||||
return NBTUtil.readBlockState(ItemNBTHelper.getCompound(stack, TAG_BLOCKSTATE, null));
|
||||
return NBTUtil.readBlockState(ItemNBTHelper.getCompound(stack, TAG_BLOCKSTATE, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack par1ItemStack, World world, List par3List, ITooltipFlag flags) {
|
||||
public void addInformation(ItemStack par1ItemStack, World world, List<ITextComponent> tip, ITooltipFlag flags) {
|
||||
Block block = getBlock(par1ItemStack);
|
||||
int size = getSize(par1ItemStack);
|
||||
|
||||
par3List.add(size + " x " + size);
|
||||
if (block != null && block != Blocks.AIR)
|
||||
par3List.add(new ItemStack(block, 1, getBlockMeta(par1ItemStack)).getDisplayName());
|
||||
tip.add(new TextComponentString(size + " x " + size));
|
||||
if (block != Blocks.AIR)
|
||||
tip.add(new ItemStack(block).getDisplayName());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@ package vazkii.botania.common.item;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
@@ -28,13 +29,15 @@ import java.util.List;
|
||||
|
||||
public class ItemFertilizer extends ItemMod {
|
||||
|
||||
public ItemFertilizer() {
|
||||
super(LibItemNames.FERTILIZER);
|
||||
public ItemFertilizer(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) {
|
||||
World world = ctx.getWorld();
|
||||
BlockPos pos = ctx.getPos();
|
||||
final int range = 3;
|
||||
if(!world.isRemote) {
|
||||
List<BlockPos> validCoords = new ArrayList<>();
|
||||
@@ -43,7 +46,8 @@ public class ItemFertilizer extends ItemMod {
|
||||
for(int j = -range - 1; j < range; j++) {
|
||||
for(int k = 2; k >= -2; k--) {
|
||||
BlockPos pos_ = pos.add(i + 1, k + 1, j + 1);
|
||||
if(world.isAirBlock(pos_) && (!world.provider.isNether() || pos_.getY() < 255) && ModBlocks.flower.canPlaceBlockAt(world, pos_))
|
||||
if(world.isAirBlock(pos_) && (!world.getDimension().isNether() || pos_.getY() < 255)
|
||||
&& ModBlocks.whiteFlower.isValidPosition(ModBlocks.whiteFlower.getDefaultState(), world, pos_))
|
||||
validCoords.add(pos_);
|
||||
}
|
||||
}
|
||||
@@ -52,9 +56,9 @@ public class ItemFertilizer extends ItemMod {
|
||||
for(int i = 0; i < flowerCount; i++) {
|
||||
BlockPos coords = validCoords.get(world.rand.nextInt(validCoords.size()));
|
||||
validCoords.remove(coords);
|
||||
world.setBlockState(coords, ModBlocks.flower.getDefaultState().with(BotaniaStateProps.COLOR, EnumDyeColor.byMetadata(world.rand.nextInt(16))), 1 | 2);
|
||||
world.setBlockState(coords, ModBlocks.getFlower(EnumDyeColor.byId(world.rand.nextInt(16))).getDefaultState());
|
||||
}
|
||||
player.getHeldItem(hand).shrink(1);
|
||||
ctx.getItem().shrink(1);
|
||||
} else {
|
||||
for(int i = 0; i < 15; i++) {
|
||||
double x = pos.getX() - range + world.rand.nextInt(range * 2 + 1) + Math.random();
|
||||
|
||||
@@ -11,14 +11,12 @@
|
||||
package vazkii.botania.common.item;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDirt;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
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;
|
||||
@@ -26,8 +24,8 @@ import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
@@ -42,6 +40,7 @@ import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -56,7 +55,7 @@ public class ItemGrassSeeds extends ItemMod implements IFloatingFlowerVariant {
|
||||
* Represents a map of dimension IDs to a set of all block swappers
|
||||
* active in that dimension.
|
||||
*/
|
||||
private static final TIntObjectHashMap<Set<BlockSwapper>> blockSwappers = new TIntObjectHashMap<>();
|
||||
private static final Map<Integer, Set<BlockSwapper>> blockSwappers = new HashMap<>();
|
||||
private static final Map<IslandType, float[]> COLORS = ImmutableMap.<IslandType, float[]>builder()
|
||||
.put(IslandType.GRASS, new float[] {0F, 0.4F, 0F})
|
||||
.put(IslandType.PODZOL, new float[] {0.5F, 0.37F, 0F})
|
||||
@@ -71,18 +70,20 @@ public class ItemGrassSeeds extends ItemMod implements IFloatingFlowerVariant {
|
||||
|
||||
private final IslandType type;
|
||||
|
||||
public ItemGrassSeeds(IslandType type) {
|
||||
super(LibItemNames.GRASS_SEEDS + "_" + type.toString().toLowerCase(Locale.ROOT));
|
||||
public ItemGrassSeeds(IslandType type, Properties props) {
|
||||
super(props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@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) {
|
||||
World world = ctx.getWorld();
|
||||
BlockPos pos = ctx.getPos();
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
ItemStack stack = ctx.getItem();
|
||||
|
||||
if(state.getBlock() == Blocks.DIRT && state.get(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT || state.getBlock() == Blocks.GRASS && type != IslandType.GRASS) {
|
||||
if(state.getBlock() == Blocks.DIRT || state.getBlock() == Blocks.GRASS && type != IslandType.GRASS) {
|
||||
if(!world.isRemote) {
|
||||
BlockSwapper swapper = addBlockSwapper(world, pos, type);
|
||||
world.setBlockState(pos, swapper.stateToSet);
|
||||
@@ -166,7 +167,7 @@ public class ItemGrassSeeds extends ItemMod implements IFloatingFlowerVariant {
|
||||
|
||||
private static IBlockState stateForType(IslandType type) {
|
||||
if(type == IslandType.PODZOL)
|
||||
return Blocks.DIRT.getDefaultState().with(BlockDirt.VARIANT, BlockDirt.DirtType.PODZOL);
|
||||
return Blocks.PODZOL.getDefaultState();
|
||||
else if(type == IslandType.MYCEL)
|
||||
return Blocks.MYCELIUM.getDefaultState();
|
||||
else if(type == IslandType.DRY)
|
||||
@@ -287,8 +288,7 @@ public class ItemGrassSeeds extends ItemMod implements IFloatingFlowerVariant {
|
||||
// levels by 2 or more blocks grass growth.
|
||||
|
||||
return (block == Blocks.DIRT || block == Blocks.GRASS)
|
||||
&& (block != Blocks.DIRT || state.get(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT)
|
||||
&& world.getBlockState(pos.up()).getLightOpacity(world, pos.up()) <= 1;
|
||||
&& world.getBlockState(pos.up()).getOpacity(world, pos.up()) <= 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ package vazkii.botania.common.item;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockBush;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -21,6 +20,7 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
@@ -47,21 +47,20 @@ import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
public class ItemHorn extends ItemMod {
|
||||
public ItemHorn(String name) {
|
||||
super(name);
|
||||
setMaxStackSize(1);
|
||||
public ItemHorn(Properties props) {
|
||||
super(props);
|
||||
addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "vuvuzela"),
|
||||
(stack, worldIn, entityIn) -> stack.getDisplayName().toLowerCase(Locale.ROOT).contains("vuvuzela") ? 1 : 0);
|
||||
(stack, worldIn, entityIn) -> stack.getDisplayName().getString().toLowerCase(Locale.ROOT).contains("vuvuzela") ? 1 : 0);
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@@ -75,9 +74,9 @@ public class ItemHorn extends ItemMod {
|
||||
@Override
|
||||
public void onUsingTick(ItemStack stack, EntityLivingBase player, int time) {
|
||||
if(!player.world.isRemote) {
|
||||
if(time != getMaxItemUseDuration(stack) && time % 5 == 0)
|
||||
if(time != getUseDuration(stack) && time % 5 == 0)
|
||||
breakGrass(player.world, stack, new BlockPos(player));
|
||||
player.world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_NOTE_BASS, SoundCategory.BLOCKS, 1F, 0.001F);
|
||||
player.world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_NOTE_BLOCK_BASS, SoundCategory.BLOCKS, 1F, 0.001F);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,8 +100,8 @@ public class ItemHorn extends ItemMod {
|
||||
if(block instanceof IHornHarvestable
|
||||
? ((IHornHarvestable) block).canHornHarvest(world, pos, stack, type)
|
||||
: type == EnumHornType.WILD && block instanceof BlockBush && !(block instanceof ISpecialFlower)
|
||||
|| type == EnumHornType.CANOPY && block.isLeaves(world.getBlockState(pos), world, pos)
|
||||
|| type == EnumHornType.COVERING && block == Blocks.SNOW_LAYER)
|
||||
|| type == EnumHornType.CANOPY && BlockTags.LEAVES.contains(block)
|
||||
|| type == EnumHornType.COVERING && block == Blocks.SNOW)
|
||||
coords.add(pos);
|
||||
}
|
||||
|
||||
@@ -117,10 +116,7 @@ public class ItemHorn extends ItemMod {
|
||||
if(block instanceof IHornHarvestable && ((IHornHarvestable) block).hasSpecialHornHarvest(world, currCoords, stack, type))
|
||||
((IHornHarvestable) block).harvestByHorn(world, currCoords, stack, type);
|
||||
else {
|
||||
block.dropBlockAsItem(world, currCoords, state, 0);
|
||||
world.setBlockToAir(currCoords);
|
||||
if(ConfigHandler.blockBreakParticles)
|
||||
world.playEvent(2001, currCoords, Block.getStateId(state));
|
||||
world.destroyBlock(currCoords, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,9 +69,8 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
|
||||
private static final String TAG_QUEUE_TICKS = "queueTicks";
|
||||
private boolean skipSound = false;
|
||||
|
||||
public ItemLexicon() {
|
||||
super(LibItemNames.LEXICON);
|
||||
setMaxStackSize(1);
|
||||
public ItemLexicon(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -28,27 +28,12 @@ import vazkii.botania.common.lib.LibMisc;
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ItemManaCookie extends ItemFood implements IModelRegister {
|
||||
public class ItemManaCookie extends ItemFood {
|
||||
|
||||
public ItemManaCookie() {
|
||||
super(0, 0.1F, false);
|
||||
public ItemManaCookie(Properties props) {
|
||||
super(0, 0.1F, false, props);
|
||||
setPotionEffect(new PotionEffect(MobEffects.SATURATION, 20, 0), 1F);
|
||||
setCreativeTab(BotaniaCreativeTab.INSTANCE);
|
||||
setRegistryName(new ResourceLocation(LibMisc.MOD_ID, LibItemNames.MANA_COOKIE));
|
||||
setTranslationKey(LibItemNames.MANA_COOKIE);
|
||||
addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "totalbiscuit"),
|
||||
(stack, worldIn, entityIn) -> stack.getDisplayName().toLowerCase(Locale.ROOT).contains("totalbiscuit") ? 1F : 0F);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUnlocalizedNameInefficiently(@Nonnull ItemStack par1ItemStack) {
|
||||
return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item.", "item." + LibResources.PREFIX_MOD);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void registerModels() {
|
||||
ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(getRegistryName(), "inventory"));
|
||||
(stack, worldIn, entityIn) -> stack.getDisplayName().getString().toLowerCase(Locale.ROOT).contains("totalbiscuit") ? 1F : 0F);
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,9 @@ import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
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.minecraft.world.WorldServer;
|
||||
@@ -58,11 +61,8 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
|
||||
private static final int CLIP_SLOTS = 6;
|
||||
private static final int COOLDOWN = 30;
|
||||
|
||||
public ItemManaGun() {
|
||||
super(LibItemNames.MANA_GUN);
|
||||
setMaxDamage(COOLDOWN);
|
||||
setMaxStackSize(1);
|
||||
setNoRepair();
|
||||
public ItemManaGun(Properties props) {
|
||||
super(props.defaultMaxDamage(COOLDOWN));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -81,9 +81,9 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
|
||||
player.swingArm(hand);
|
||||
ItemStack lens = getLens(stack);
|
||||
ItemsRemainingRenderHandler.set(lens, -2);
|
||||
stack.setItemDamage(effCd);
|
||||
stack.setDamage(effCd);
|
||||
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
|
||||
} else if(stack.getItemDamage() == 0) {
|
||||
} else if(stack.getDamage() == 0) {
|
||||
EntityManaBurst burst = getBurst(player, stack, true, hand);
|
||||
if(burst != null && ManaItemHandler.requestManaExact(stack, player, burst.getMana(), true)) {
|
||||
if(!world.isRemote) {
|
||||
@@ -96,7 +96,7 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
|
||||
player.motionY -= burst.motionY * 0.3;
|
||||
player.motionZ -= burst.motionZ * 0.1;
|
||||
}
|
||||
stack.setItemDamage(effCd);
|
||||
stack.setDamage(effCd);
|
||||
} else if(!world.isRemote)
|
||||
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_LEVER_CLICK, SoundCategory.PLAYERS, 0.6F, (1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F);
|
||||
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
|
||||
@@ -120,7 +120,7 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
|
||||
// ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN
|
||||
// ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN
|
||||
private boolean isSugoiKawaiiDesuNe(ItemStack stack) {
|
||||
return stack.getDisplayName().equalsIgnoreCase("desu gun");
|
||||
return stack.getDisplayName().getString().equalsIgnoreCase("desu gun");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -171,44 +171,51 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, World world, List<String> stacks, ITooltipFlag flags) {
|
||||
boolean clip = hasClip(par1ItemStack);
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> stacks, ITooltipFlag flags) {
|
||||
boolean clip = hasClip(stack);
|
||||
if(clip && !GuiScreen.isShiftKeyDown()) {
|
||||
addStringToTooltip(I18n.format("botaniamisc.shiftinfo"), stacks);
|
||||
stacks.add(new TextComponentTranslation("botaniamisc.shiftinfo"));
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack lens = getLens(par1ItemStack);
|
||||
ItemStack lens = getLens(stack);
|
||||
if(!lens.isEmpty()) {
|
||||
List<String> tooltip = lens.getTooltip(Minecraft.getMinecraft().player, ITooltipFlag.TooltipFlags.NORMAL);
|
||||
List<ITextComponent> tooltip = lens.getTooltip(Minecraft.getInstance().player, ITooltipFlag.TooltipFlags.NORMAL);
|
||||
if(tooltip.size() > 1)
|
||||
stacks.addAll(tooltip.subList(1, tooltip.size()));
|
||||
}
|
||||
|
||||
if(clip) {
|
||||
int pos = getClipPos(par1ItemStack);
|
||||
addStringToTooltip(I18n.format("botaniamisc.hasClip"), stacks);
|
||||
int pos = getClipPos(stack);
|
||||
stacks.add(new TextComponentTranslation("botaniamisc.hasClip"));
|
||||
for(int i = 0; i < CLIP_SLOTS; i++) {
|
||||
String name;
|
||||
TextFormatting formatting = i == pos ? TextFormatting.GREEN : TextFormatting.GRAY;
|
||||
ItemStack lensAt = getLensAtPos(par1ItemStack, i);
|
||||
ItemStack lensAt = getLensAtPos(stack, i);
|
||||
|
||||
ITextComponent name;
|
||||
if(lensAt.isEmpty())
|
||||
name = I18n.format("botaniamisc.clipEmpty");
|
||||
name = new TextComponentTranslation("botaniamisc.clipEmpty");
|
||||
else name = lensAt.getDisplayName();
|
||||
addStringToTooltip(formatting + " - " + name, stacks);
|
||||
|
||||
ITextComponent tip = new TextComponentString(" - ").appendSibling(name);
|
||||
tip.getStyle().setColor(i == pos ? TextFormatting.GREEN : TextFormatting.GRAY);
|
||||
stacks.add(tip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addStringToTooltip(String s, List<String> tooltip) {
|
||||
tooltip.add(s.replaceAll("&", "\u00a7"));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getItemStackDisplayName(@Nonnull ItemStack par1ItemStack) {
|
||||
ItemStack lens = getLens(par1ItemStack);
|
||||
return super.getItemStackDisplayName(par1ItemStack) + (lens.isEmpty() ? "" : " (" + TextFormatting.GREEN + lens.getDisplayName() + TextFormatting.RESET + ")");
|
||||
public ITextComponent getDisplayName(@Nonnull ItemStack stack) {
|
||||
ItemStack lens = getLens(stack);
|
||||
ITextComponent cmp = super.getDisplayName(stack);
|
||||
if (!lens.isEmpty()) {
|
||||
cmp.appendText(" (");
|
||||
ITextComponent lensName = lens.getDisplayName();
|
||||
lensName.getStyle().setColor(TextFormatting.GREEN);
|
||||
cmp.appendSibling(lensName);
|
||||
cmp.appendText(")");
|
||||
}
|
||||
return cmp;
|
||||
}
|
||||
|
||||
public static boolean hasClip(ItemStack stack) {
|
||||
@@ -250,7 +257,7 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
|
||||
public static ItemStack getLensAtPos(ItemStack stack, int pos) {
|
||||
NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_LENS + pos, true);
|
||||
if(cmp != null) {
|
||||
return new ItemStack(cmp);
|
||||
return ItemStack.read(cmp);
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
@@ -258,7 +265,7 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
|
||||
public static void setLensAtPos(ItemStack stack, ItemStack lens, int pos) {
|
||||
NBTTagCompound cmp = new NBTTagCompound();
|
||||
if(lens != null)
|
||||
cmp = lens.writeToNBT(cmp);
|
||||
cmp = lens.write(cmp);
|
||||
ItemNBTHelper.setCompound(stack, TAG_LENS + pos, cmp);
|
||||
}
|
||||
|
||||
@@ -268,7 +275,7 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
|
||||
|
||||
NBTTagCompound cmp = new NBTTagCompound();
|
||||
if(!lens.isEmpty())
|
||||
cmp = lens.writeToNBT(cmp);
|
||||
cmp = lens.write(cmp);
|
||||
ItemNBTHelper.setCompound(stack, TAG_LENS, cmp);
|
||||
}
|
||||
|
||||
@@ -278,7 +285,7 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
|
||||
|
||||
NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_LENS, true);
|
||||
if(cmp != null) {
|
||||
return new ItemStack(cmp);
|
||||
return ItemStack.read(cmp);
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
@@ -294,9 +301,9 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World world, Entity par3Entity, int par4, boolean par5) {
|
||||
if(par1ItemStack.isItemDamaged())
|
||||
par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - 1);
|
||||
public void inventoryTick(ItemStack par1ItemStack, World world, Entity par3Entity, int par4, boolean par5) {
|
||||
if(par1ItemStack.isDamaged())
|
||||
par1ItemStack.setDamage(par1ItemStack.getDamage() - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
@@ -22,7 +23,7 @@ import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||
import vazkii.botania.api.mana.IManaItem;
|
||||
import vazkii.botania.api.mana.IManaPool;
|
||||
import vazkii.botania.api.mana.IManaTooltipDisplay;
|
||||
@@ -46,11 +47,8 @@ public class ItemManaMirror extends ItemMod implements IManaItem, ICoordBoundIte
|
||||
|
||||
private static final DummyPool fallbackPool = new DummyPool();
|
||||
|
||||
public ItemManaMirror() {
|
||||
super(LibItemNames.MANA_MIRROR);
|
||||
setMaxStackSize(1);
|
||||
setMaxDamage(1000);
|
||||
setNoRepair();
|
||||
public ItemManaMirror(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,7 +58,7 @@ public class ItemManaMirror extends ItemMod implements IManaItem, ICoordBoundIte
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World world, Entity par3Entity, int par4, boolean par5) {
|
||||
public void inventoryTick(ItemStack par1ItemStack, World world, Entity par3Entity, int par4, boolean par5) {
|
||||
if(world.isRemote)
|
||||
return;
|
||||
|
||||
@@ -78,11 +76,14 @@ public class ItemManaMirror extends ItemMod implements IManaItem, ICoordBoundIte
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
|
||||
if(player.isSneaking() && !world.isRemote) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if(tile != null && tile instanceof IManaPool) {
|
||||
bindPool(player.getHeldItem(hand), tile);
|
||||
public EnumActionResult onItemUse(ItemUseContext ctx) {
|
||||
World world = ctx.getWorld();
|
||||
EntityPlayer player = ctx.getPlayer();
|
||||
|
||||
if(player != null && player.isSneaking() && !world.isRemote) {
|
||||
TileEntity tile = world.getTileEntity(ctx.getPos());
|
||||
if(tile instanceof IManaPool) {
|
||||
bindPool(ctx.getItem(), tile);
|
||||
world.playSound(null, player.posX, player.posY, player.posZ, ModSounds.ding, SoundCategory.PLAYERS, 1F, 1F);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
@@ -91,11 +92,6 @@ public class ItemManaMirror extends ItemMod implements IManaItem, ICoordBoundIte
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
/*public int getMana(ItemStack stack) {
|
||||
IManaPool pool = getManaPool(stack);
|
||||
return pool == null ? 0 : pool.getCurrentMana();
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public int getMana(ItemStack stack) {
|
||||
return ItemNBTHelper.getInt(stack, TAG_MANA, 0);
|
||||
@@ -124,20 +120,11 @@ public class ItemManaMirror extends ItemMod implements IManaItem, ICoordBoundIte
|
||||
setManaBacklog(stack, getManaBacklog(stack) + mana);
|
||||
}
|
||||
|
||||
/*public void addMana(ItemStack stack, int mana) {
|
||||
IManaPool pool = getManaPool(stack);
|
||||
if(pool != null) {
|
||||
pool.recieveMana(mana);
|
||||
TileEntity tile = (TileEntity) pool;
|
||||
tile.getWorld().func_147453_f(tile.x, tile.y, tile.z, tile.getWorld().getBlock(tile.x, tile.y, tile.z));
|
||||
}
|
||||
}*/
|
||||
|
||||
public void bindPool(ItemStack stack, TileEntity pool) {
|
||||
ItemNBTHelper.setInt(stack, TAG_POS_X, pool == null ? 0 : pool.getPos().getX());
|
||||
ItemNBTHelper.setInt(stack, TAG_POS_Y, pool == null ? -1 : pool.getPos().getY());
|
||||
ItemNBTHelper.setInt(stack, TAG_POS_Z, pool == null ? 0 : pool.getPos().getZ());
|
||||
ItemNBTHelper.setInt(stack, TAG_DIM, pool == null ? 0 : pool.getWorld().provider.getDimension());
|
||||
ItemNBTHelper.setString(stack, TAG_DIM, pool == null ? "" : pool.getWorld().getDimension().getType().getModType().getRegistryName().toString());
|
||||
}
|
||||
|
||||
public BlockPos getPoolCoords(ItemStack stack) {
|
||||
@@ -147,12 +134,12 @@ public class ItemManaMirror extends ItemMod implements IManaItem, ICoordBoundIte
|
||||
return new BlockPos(x, y, z);
|
||||
}
|
||||
|
||||
public int getDimension(ItemStack stack) {
|
||||
return ItemNBTHelper.getInt(stack, TAG_DIM, 0);
|
||||
public String getDimension(ItemStack stack) {
|
||||
return ItemNBTHelper.getString(stack, TAG_DIM, "");
|
||||
}
|
||||
|
||||
public IManaPool getManaPool(ItemStack stack) {
|
||||
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
|
||||
MinecraftServer server = ServerLifecycleHooks.getCurrentServer();
|
||||
if(server == null)
|
||||
return fallbackPool;
|
||||
|
||||
@@ -160,17 +147,17 @@ public class ItemManaMirror extends ItemMod implements IManaItem, ICoordBoundIte
|
||||
if(coords.getY() == -1)
|
||||
return null;
|
||||
|
||||
int dim = getDimension(stack);
|
||||
String dim = getDimension(stack);
|
||||
World world = null;
|
||||
for(World w : server.worlds)
|
||||
if(w.provider.getDimension() == dim) {
|
||||
for(World w : server.getWorlds())
|
||||
if(w.getDimension().getType().getModType().getRegistryName().toString().equals(dim)) {
|
||||
world = w;
|
||||
break;
|
||||
}
|
||||
|
||||
if(world != null) {
|
||||
TileEntity tile = world.getTileEntity(coords);
|
||||
if(tile != null && tile instanceof IManaPool)
|
||||
if(tile instanceof IManaPool)
|
||||
return (IManaPool) tile;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,11 +12,13 @@ package vazkii.botania.common.item;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
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.util.math.MathHelper;
|
||||
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;
|
||||
@@ -37,14 +39,13 @@ public class ItemManaTablet extends ItemMod implements IManaItem, ICreativeManaP
|
||||
private static final String TAG_CREATIVE = "creative";
|
||||
private static final String TAG_ONE_USE = "oneUse";
|
||||
|
||||
public ItemManaTablet() {
|
||||
super(LibItemNames.MANA_TABLET);
|
||||
setMaxStackSize(1);
|
||||
public ItemManaTablet(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@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 fullPower = new ItemStack(this);
|
||||
@@ -58,21 +59,11 @@ public class ItemManaTablet extends ItemMod implements IManaItem, ICreativeManaP
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDamage(ItemStack stack) {
|
||||
// Compatibility shim, so tablets from previous versions of botania
|
||||
// stack right in barrels and so forth
|
||||
if(super.getDamage(stack) != 0)
|
||||
super.setDamage(stack, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
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(isStackCreative(par1ItemStack))
|
||||
stacks.add(I18n.format("botaniamisc.creative"));
|
||||
stacks.add(new TextComponentTranslation("botaniamisc.creative"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,38 +10,11 @@
|
||||
*/
|
||||
package vazkii.botania.common.item;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.client.render.IModelRegister;
|
||||
import vazkii.botania.common.core.BotaniaCreativeTab;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ItemMod extends Item implements IModelRegister {
|
||||
|
||||
public ItemMod(Item.Builder builder) {
|
||||
super(builder);
|
||||
setCreativeTab(BotaniaCreativeTab.INSTANCE);
|
||||
setRegistryName(new ResourceLocation(LibMisc.MOD_ID, name));
|
||||
setTranslationKey(name);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUnlocalizedNameInefficiently(@Nonnull ItemStack par1ItemStack) {
|
||||
return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item\\.", "item." + LibResources.PREFIX_MOD);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void registerModels() {
|
||||
ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(getRegistryName(), "inventory"));
|
||||
// todo 1.13 reevaluate need for this
|
||||
public class ItemMod extends Item {
|
||||
public ItemMod(Item.Properties props) {
|
||||
super(props);
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ import java.util.List;
|
||||
|
||||
public class ItemPinkinator extends ItemMod {
|
||||
|
||||
public ItemPinkinator(Item.Builder builder) {
|
||||
public ItemPinkinator(Properties builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class ItemPoolMinecart extends ItemMod {
|
||||
|
||||
public ItemPoolMinecart(Item.Builder builder) {
|
||||
public ItemPoolMinecart(Properties builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public class ItemSextant extends ItemMod {
|
||||
private static final String TAG_SOURCE_Y = "sourceY";
|
||||
private static final String TAG_SOURCE_Z = "sourceZ";
|
||||
|
||||
public ItemSextant(Item.Builder builder) {
|
||||
public ItemSextant(Properties builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import javax.annotation.Nullable;
|
||||
public class ItemSlimeBottle extends ItemMod {
|
||||
private static final String TAG_ACTIVE = "active";
|
||||
|
||||
public ItemSlimeBottle(Item.Builder builder) {
|
||||
public ItemSlimeBottle(Properties builder) {
|
||||
super(builder);
|
||||
addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "active"), (stack, worldIn, entityIn) -> stack.hasTag() && stack.getTag().getBoolean(TAG_ACTIVE) ? 1.0F : 0.0F);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class ItemSlingshot extends ItemMod {
|
||||
|
||||
private static final Predicate<ItemStack> AMMO_FUNC = s -> s != null && s.getItem() == ModItems.vineBall;
|
||||
|
||||
public ItemSlingshot(Item.Builder builder) {
|
||||
public ItemSlingshot(Properties builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class ItemSpark extends ItemMod implements IManaGivingItem {
|
||||
|
||||
public ItemSpark(Item.Builder builder) {
|
||||
public ItemSpark(Properties builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.Locale;
|
||||
public class ItemSparkUpgrade extends ItemMod {
|
||||
public final SparkUpgradeType type;
|
||||
|
||||
public ItemSparkUpgrade(Item.Builder builder, SparkUpgradeType type) {
|
||||
public ItemSparkUpgrade(Properties builder, SparkUpgradeType type) {
|
||||
super(builder);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class ItemSpellCloth extends ItemMod {
|
||||
|
||||
public ItemSpellCloth(Item.Builder builder) {
|
||||
public ItemSpellCloth(Properties builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import java.util.List;
|
||||
public class ItemTemperanceStone extends ItemMod {
|
||||
public static final String TAG_ACTIVE = "active";
|
||||
|
||||
public ItemTemperanceStone(Item.Builder builder) {
|
||||
public ItemTemperanceStone(Properties builder) {
|
||||
super(builder);
|
||||
addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "active"),
|
||||
(stack, worldIn, entityIn) -> ItemNBTHelper.getBoolean(stack, TAG_ACTIVE, false) ? 1 : 0);
|
||||
|
||||
@@ -25,7 +25,7 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class ItemThornChakram extends ItemMod {
|
||||
|
||||
public ItemThornChakram(Item.Builder builder) {
|
||||
public ItemThornChakram(Properties builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,13 +13,14 @@ package vazkii.botania.common.item;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockCommandBlock;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
@@ -71,7 +72,7 @@ public class ItemTwigWand extends ItemMod implements ICoordBoundItem {
|
||||
private static final String TAG_BIND_MODE = "bindMode";
|
||||
private static final BlockPos UNBOUND_POS = new BlockPos(0, -1, 0);
|
||||
|
||||
public ItemTwigWand(Item.Builder builder) {
|
||||
public ItemTwigWand(Item.Properties builder) {
|
||||
super(builder);
|
||||
addPropertyOverride(new ResourceLocation("botania", "bindmode"), (stack, worldIn, entityIn) -> getBindMode(stack) ? 1 : 0);
|
||||
}
|
||||
@@ -218,7 +219,7 @@ public class ItemTwigWand extends ItemMod implements ICoordBoundItem {
|
||||
public void inventoryTick(ItemStack par1ItemStack, World world, Entity par3Entity, int par4, boolean par5) {
|
||||
BlockPos coords = getBoundTile(par1ItemStack);
|
||||
TileEntity tile = world.getTileEntity(coords);
|
||||
if(tile == null || !(tile instanceof IWandBindable))
|
||||
if(!(tile instanceof IWandBindable))
|
||||
setBoundTile(par1ItemStack, UNBOUND_POS);
|
||||
}
|
||||
|
||||
@@ -236,8 +237,8 @@ public class ItemTwigWand extends ItemMod implements ICoordBoundItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(@Nonnull CreativeTabs tab, @Nonnull NonNullList<ItemStack> stacks) {
|
||||
if(isInCreativeTab(tab)) {
|
||||
public void fillItemGroup(@Nonnull ItemGroup group, @Nonnull NonNullList<ItemStack> stacks) {
|
||||
if(isInGroup(group)) {
|
||||
for(int i = 0; i < 16; i++)
|
||||
stacks.add(forColors(i, i));
|
||||
}
|
||||
@@ -305,9 +306,8 @@ public class ItemTwigWand extends ItemMod implements ICoordBoundItem {
|
||||
RayTraceResult pos = Minecraft.getInstance().objectMouseOver;
|
||||
if(pos != null && pos.type == RayTraceResult.Type.BLOCK) {
|
||||
TileEntity tile = Minecraft.getInstance().world.getTileEntity(pos.getBlockPos());
|
||||
if(tile != null && tile instanceof ITileBound) {
|
||||
BlockPos coords = ((ITileBound) tile).getBinding();
|
||||
return coords;
|
||||
if(tile instanceof ITileBound) {
|
||||
return ((ITileBound) tile).getBinding();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class ItemVineBall extends ItemMod {
|
||||
|
||||
public ItemVineBall(Item.Builder builder) {
|
||||
public ItemVineBall(Properties builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID)
|
||||
public class ItemVirus extends ItemMod {
|
||||
public ItemVirus(Item.Builder builder) {
|
||||
public ItemVirus(Properties builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class ItemWaterBowl extends ItemMod {
|
||||
|
||||
public ItemWaterBowl(Item.Builder builder) {
|
||||
public ItemWaterBowl(Properties builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class ItemWorldSeed extends ItemMod {
|
||||
|
||||
public ItemWorldSeed(Item.Builder builder) {
|
||||
public ItemWorldSeed(Properties builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class ItemWorldSeed extends ItemMod {
|
||||
player.rotationYaw = 0F;
|
||||
player.setPositionAndUpdate(coords.getX() + 0.5, coords.getY() + 0.5, coords.getZ() + 0.5);
|
||||
|
||||
while(!world.getCollisionBoxes(player, player.getBoundingBox()).isEmpty())
|
||||
while(!world.isCollisionBoxesEmpty(player, player.getBoundingBox()))
|
||||
player.setPositionAndUpdate(player.posX, player.posY + 1, player.posZ);
|
||||
|
||||
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1F, 1F);
|
||||
|
||||
@@ -75,8 +75,6 @@ import vazkii.botania.common.item.material.ItemPestleAndMortar;
|
||||
import vazkii.botania.common.item.material.ItemPetal;
|
||||
import vazkii.botania.common.item.material.ItemRune;
|
||||
import vazkii.botania.common.item.record.ItemModRecord;
|
||||
import vazkii.botania.common.item.record.ItemRecordGaia1;
|
||||
import vazkii.botania.common.item.record.ItemRecordGaia2;
|
||||
import vazkii.botania.common.item.relic.ItemDice;
|
||||
import vazkii.botania.common.item.relic.ItemFlugelEye;
|
||||
import vazkii.botania.common.item.relic.ItemInfiniteFruit;
|
||||
@@ -111,37 +109,37 @@ public final class ModItems {
|
||||
public static final Map<EnumDyeColor, Item> dyes = new EnumMap<>(EnumDyeColor.class);
|
||||
static {
|
||||
for(EnumDyeColor color : EnumDyeColor.values()) {
|
||||
petals.put(color, new ItemPetal(color));
|
||||
dyes.put(color, new ItemDye(color));
|
||||
petals.put(color, new ItemPetal(, color, defaultBuilder()));
|
||||
dyes.put(color, new ItemDye(color, defaultBuilder()));
|
||||
}
|
||||
}
|
||||
|
||||
public static final Item pestleAndMortar = new ItemPestleAndMortar(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.PESTLE_AND_MORTAR);
|
||||
public static final Item twigWand = new ItemTwigWand(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.TWIG_WAND);
|
||||
|
||||
public static final Item manaSteel = new ItemManaResource(LibItemNames.MANA_RESOURCE_NAMES[0]);
|
||||
public static final Item manaPearl = new ItemManaResource(LibItemNames.MANA_RESOURCE_NAMES[1]);
|
||||
public static final Item manaDiamond = new ItemManaResource(LibItemNames.MANA_RESOURCE_NAMES[2]);
|
||||
public static final Item livingwoodTwig = new ItemManaResource(LibItemNames.MANA_RESOURCE_NAMES[3]);
|
||||
public static final Item terrasteel = new ItemManaResource(LibItemNames.MANA_RESOURCE_NAMES[4]);
|
||||
public static final Item lifeEssence = new ItemManaResource(LibItemNames.MANA_RESOURCE_NAMES[5]);
|
||||
public static final Item redstoneRoot = new ItemManaResource(LibItemNames.MANA_RESOURCE_NAMES[6]);
|
||||
public static final Item elementium = new ItemManaResource(LibItemNames.MANA_RESOURCE_NAMES[7]);
|
||||
public static final Item pixieDust = new ItemManaResource(LibItemNames.MANA_RESOURCE_NAMES[8]);
|
||||
public static final Item dragonstone = new ItemManaResource(LibItemNames.MANA_RESOURCE_NAMES[9]);
|
||||
public static final Item placeholder = new ItemManaResource(LibItemNames.MANA_RESOURCE_NAMES[11]);
|
||||
public static final Item redString = new ItemManaResource(LibItemNames.MANA_RESOURCE_NAMES[12]);
|
||||
public static final Item dreamwoodTwig = new ItemManaResource(LibItemNames.MANA_RESOURCE_NAMES[13]);
|
||||
public static final Item gaiaIngot = new ItemManaResource(LibItemNames.MANA_RESOURCE_NAMES[14]);
|
||||
public static final Item enderAirBottle = new ItemManaResource(LibItemNames.MANA_RESOURCE_NAMES[15]);
|
||||
public static final Item manaString = new ItemManaResource(LibItemNames.MANA_RESOURCE_NAMES[16]);
|
||||
public static final Item manasteelNugget = new ItemManaResource(LibItemNames.MANA_RESOURCE_NAMES[17]);
|
||||
public static final Item terrasteelNugget = new ItemManaResource(LibItemNames.MANA_RESOURCE_NAMES[18]);
|
||||
public static final Item elementiumNugget = new ItemManaResource(LibItemNames.MANA_RESOURCE_NAMES[19]);
|
||||
public static final Item livingroot = new ItemManaResource(LibItemNames.MANA_RESOURCE_NAMES[20]);
|
||||
public static final Item pebble = new ItemManaResource(LibItemNames.MANA_RESOURCE_NAMES[21]);
|
||||
public static final Item manaweaveCloth = new ItemManaResource(LibItemNames.MANA_RESOURCE_NAMES[22]);
|
||||
public static final Item manaPowder = new ItemManaResource(LibItemNames.MANA_RESOURCE_NAMES[23]);
|
||||
public static final Item manaSteel = new ItemManaResource(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RESOURCE_NAMES[0]);
|
||||
public static final Item manaPearl = new ItemManaResource(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RESOURCE_NAMES[1]);
|
||||
public static final Item manaDiamond = new ItemManaResource(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RESOURCE_NAMES[2]);
|
||||
public static final Item livingwoodTwig = new ItemManaResource(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RESOURCE_NAMES[3]);
|
||||
public static final Item terrasteel = new ItemManaResource(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RESOURCE_NAMES[4]);
|
||||
public static final Item lifeEssence = new ItemManaResource(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RESOURCE_NAMES[5]);
|
||||
public static final Item redstoneRoot = new ItemManaResource(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RESOURCE_NAMES[6]);
|
||||
public static final Item elementium = new ItemManaResource(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RESOURCE_NAMES[7]);
|
||||
public static final Item pixieDust = new ItemManaResource(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RESOURCE_NAMES[8]);
|
||||
public static final Item dragonstone = new ItemManaResource(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RESOURCE_NAMES[9]);
|
||||
public static final Item placeholder = new ItemManaResource(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RESOURCE_NAMES[11]);
|
||||
public static final Item redString = new ItemManaResource(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RESOURCE_NAMES[12]);
|
||||
public static final Item dreamwoodTwig = new ItemManaResource(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RESOURCE_NAMES[13]);
|
||||
public static final Item gaiaIngot = new ItemManaResource(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RESOURCE_NAMES[14]);
|
||||
public static final Item enderAirBottle = new ItemManaResource(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RESOURCE_NAMES[15]);
|
||||
public static final Item manaString = new ItemManaResource(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RESOURCE_NAMES[16]);
|
||||
public static final Item manasteelNugget = new ItemManaResource(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RESOURCE_NAMES[17]);
|
||||
public static final Item terrasteelNugget = new ItemManaResource(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RESOURCE_NAMES[18]);
|
||||
public static final Item elementiumNugget = new ItemManaResource(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RESOURCE_NAMES[19]);
|
||||
public static final Item livingroot = new ItemManaResource(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RESOURCE_NAMES[20]);
|
||||
public static final Item pebble = new ItemManaResource(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RESOURCE_NAMES[21]);
|
||||
public static final Item manaweaveCloth = new ItemManaResource(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RESOURCE_NAMES[22]);
|
||||
public static final Item manaPowder = new ItemManaResource(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_RESOURCE_NAMES[23]);
|
||||
|
||||
public static final Item lensNormal = new ItemLens(unstackable(), new Lens(), ItemLens.PROP_NONE).setRegistryName(LibMisc.MOD_ID, LibItemNames.LENS_NAMES[0]);
|
||||
public static final Item lensSpeed = new ItemLens(unstackable(), new LensSpeed(), ItemLens.PROP_NONE).setRegistryName(LibMisc.MOD_ID, LibItemNames.LENS_NAMES[1]);
|
||||
@@ -186,29 +184,29 @@ public final class ModItems {
|
||||
public static final Item runeEnvy = new ItemRune(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.RUNE_NAMES[14]);
|
||||
public static final Item runePride = new ItemRune(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.RUNE_NAMES[15]);
|
||||
|
||||
public static final Item manaTablet = new ItemManaTablet();
|
||||
public static final Item manaGun = new ItemManaGun();
|
||||
public static final Item manaCookie = new ItemManaCookie();
|
||||
public static final Item fertilizer = new ItemFertilizer();
|
||||
public static final Item manaTablet = new ItemManaTablet(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_TABLET);
|
||||
public static final Item manaGun = new ItemManaGun(unstackable().setNoRepair()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_GUN);
|
||||
public static final Item manaCookie = new ItemManaCookie(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_COOKIE);
|
||||
public static final Item fertilizer = new ItemFertilizer(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.FERTILIZER);
|
||||
|
||||
public static final Item grassSeeds = new ItemGrassSeeds(IFloatingFlower.IslandType.GRASS);
|
||||
public static final Item podzolSeeds = new ItemGrassSeeds(IFloatingFlower.IslandType.PODZOL);
|
||||
public static final Item mycelSeeds = new ItemGrassSeeds(IFloatingFlower.IslandType.MYCEL);
|
||||
public static final Item drySeeds = new ItemGrassSeeds(IFloatingFlower.IslandType.DRY);
|
||||
public static final Item goldenSeeds = new ItemGrassSeeds(IFloatingFlower.IslandType.GOLDEN);
|
||||
public static final Item vividSeeds = new ItemGrassSeeds(IFloatingFlower.IslandType.VIVID);
|
||||
public static final Item scorchedSeeds = new ItemGrassSeeds(IFloatingFlower.IslandType.SCORCHED);
|
||||
public static final Item infusedSeeds = new ItemGrassSeeds(IFloatingFlower.IslandType.INFUSED);
|
||||
public static final Item mutatedSeeds = new ItemGrassSeeds(IFloatingFlower.IslandType.MUTATED);
|
||||
public static final Item grassSeeds = new ItemGrassSeeds(IFloatingFlower.IslandType.GRASS, defaultBuilder());
|
||||
public static final Item podzolSeeds = new ItemGrassSeeds(IFloatingFlower.IslandType.PODZOL, defaultBuilder());
|
||||
public static final Item mycelSeeds = new ItemGrassSeeds(IFloatingFlower.IslandType.MYCEL, defaultBuilder());
|
||||
public static final Item drySeeds = new ItemGrassSeeds(IFloatingFlower.IslandType.DRY, defaultBuilder());
|
||||
public static final Item goldenSeeds = new ItemGrassSeeds(IFloatingFlower.IslandType.GOLDEN, defaultBuilder());
|
||||
public static final Item vividSeeds = new ItemGrassSeeds(IFloatingFlower.IslandType.VIVID, defaultBuilder());
|
||||
public static final Item scorchedSeeds = new ItemGrassSeeds(IFloatingFlower.IslandType.SCORCHED, defaultBuilder());
|
||||
public static final Item infusedSeeds = new ItemGrassSeeds(IFloatingFlower.IslandType.INFUSED, defaultBuilder());
|
||||
public static final Item mutatedSeeds = new ItemGrassSeeds(IFloatingFlower.IslandType.MUTATED, defaultBuilder());
|
||||
|
||||
public static final Item dirtRod = new ItemDirtRod();
|
||||
public static final Item terraformRod = new ItemTerraformRod();
|
||||
public static final Item grassHorn = new ItemHorn(LibItemNames.GRASS_HORN);
|
||||
public static final Item leavesHorn = new ItemHorn(LibItemNames.LEAVES_HORN);
|
||||
public static final Item snowHorn = new ItemHorn(LibItemNames.SNOW_HORN);
|
||||
public static final Item manaMirror = new ItemManaMirror();
|
||||
public static final Item manasteelHelm = new ItemManasteelHelm();
|
||||
public static final Item manasteelHelmRevealing = new ItemManasteelHelmRevealing();
|
||||
public static final Item dirtRod = new ItemDirtRod(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.DIRT_ROD);
|
||||
public static final Item terraformRod = new ItemTerraformRod(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.TERRAFORM_ROD);
|
||||
public static final Item grassHorn = new ItemHorn(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.GRASS_HORN);
|
||||
public static final Item leavesHorn = new ItemHorn(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.LEAVES_HORN);
|
||||
public static final Item snowHorn = new ItemHorn(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.SNOW_HORN);
|
||||
public static final Item manaMirror = new ItemManaMirror(unstackable().defaultMaxDamage(1000).setNoRepair()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_MIRROR);
|
||||
public static final Item manasteelHelm = new ItemManasteelHelm(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANASTEEL_HELM);
|
||||
public static final Item manasteelHelmRevealing = new ItemManasteelHelmRevealing(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANASTEEL_HELM_R);
|
||||
public static final Item manasteelChest = new ItemManasteelChest();
|
||||
public static final Item manasteelLegs = new ItemManasteelLegs();
|
||||
public static final Item manasteelBoots = new ItemManasteelBoots();
|
||||
@@ -271,7 +269,7 @@ public final class ModItems {
|
||||
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 skyDirtRod = new ItemSkyDirtRod();
|
||||
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();
|
||||
@@ -354,7 +352,7 @@ public final class ModItems {
|
||||
public static final Item cacophonium = new ItemCacophonium();
|
||||
public static final Item slimeBottle = new ItemSlimeBottle(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.SLIME_BOTTLE);
|
||||
public static final Item starSword = new ItemStarSword();
|
||||
public static final Item exchangeRod = new ItemExchangeRod();
|
||||
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 thunderSword = new ItemThunderSword();
|
||||
public static final Item manaweaveHelm = new ItemManaweaveHelm();
|
||||
@@ -370,15 +368,15 @@ public final class ModItems {
|
||||
public static final Item invisibilityCloak = new ItemInvisibilityCloak();
|
||||
public static final Item cloudPendant = new ItemCloudPendant();
|
||||
public static final Item superCloudPendant = new ItemSuperCloudPendant();
|
||||
public static final Item thirdEye = new ItemThirdEye();
|
||||
public static final Item astrolabe = new ItemAstrolabe();
|
||||
public static final Item goddessCharm = new ItemGoddessCharm();
|
||||
public static final Item thirdEye = new ItemThirdEye(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.THIRD_EYE);
|
||||
public static final Item astrolabe = new ItemAstrolabe(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.ASTROLABE);
|
||||
public static final Item goddessCharm = new ItemGoddessCharm(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.GODDESS_CHARM);
|
||||
|
||||
private static Item.Builder defaultBuilder() {
|
||||
return new Item.Builder().group(BotaniaCreativeTab.INSTANCE);
|
||||
private static Item.Properties defaultBuilder() {
|
||||
return new Item.Properties().group(BotaniaCreativeTab.INSTANCE);
|
||||
}
|
||||
|
||||
private static Item.Builder unstackable() {
|
||||
private static Item.Properties unstackable() {
|
||||
return defaultBuilder().maxStackSize(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,19 +17,10 @@ import vazkii.botania.client.lib.LibResources;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
// todo 1.13 reevaluate if necessary
|
||||
public class ItemBlockMod extends ItemBlock {
|
||||
|
||||
public ItemBlockMod(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUnlocalizedNameInefficiently(@Nonnull ItemStack par1ItemStack) {
|
||||
return getUnlocalizedNameInefficiently_(par1ItemStack).replaceAll("tile.", "tile." + LibResources.PREFIX_MOD);
|
||||
}
|
||||
|
||||
public String getUnlocalizedNameInefficiently_(ItemStack stack) {
|
||||
return super.getUnlocalizedNameInefficiently(stack);
|
||||
public ItemBlockMod(Block block, Properties props) {
|
||||
super(block, props);
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public class ItemBrewBase extends ItemMod implements IBrewItem {
|
||||
private final int drinkSpeed;
|
||||
private final ItemStack baseItem;
|
||||
|
||||
public ItemBrewBase(Item.Builder builder, int swigs, int drinkSpeed, ItemStack baseItem) {
|
||||
public ItemBrewBase(Properties builder, int swigs, int drinkSpeed, ItemStack baseItem) {
|
||||
super(builder);
|
||||
this.swigs = swigs;
|
||||
this.drinkSpeed = drinkSpeed;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class ItemIncenseStick extends ItemMod implements IBrewItem, IBrewContain
|
||||
private static final String TAG_BREW_KEY = "brewKey";
|
||||
public static final int TIME_MULTIPLIER = 60;
|
||||
|
||||
public ItemIncenseStick(Item.Builder builder) {
|
||||
public ItemIncenseStick(Properties builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import vazkii.botania.common.item.ModItems;
|
||||
|
||||
public class ItemVial extends ItemMod implements IBrewContainer {
|
||||
|
||||
public ItemVial(Item.Builder builder) {
|
||||
public ItemVial(Properties builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
|
||||
+9
-7
@@ -1,10 +1,12 @@
|
||||
package vazkii.botania.common.item.equipment.armor.elementium;
|
||||
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.client.renderer.entity.model.ModelBiped;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
@@ -20,8 +22,8 @@ import java.util.List;
|
||||
|
||||
public abstract class ItemElementiumArmor extends ItemManasteelArmor implements IPixieSpawner {
|
||||
|
||||
public ItemElementiumArmor(EntityEquipmentSlot type, String name) {
|
||||
super(type, name, BotaniaAPI.elementiumArmorMaterial);
|
||||
public ItemElementiumArmor(EntityEquipmentSlot type, Properties props) {
|
||||
super(type, BotaniaAPI.elementiumArmorMaterial, props);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,15 +79,15 @@ public abstract class ItemElementiumArmor extends ItemManasteelArmor implements
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public String getArmorSetName() {
|
||||
return I18n.format("botania.armorset.elementium.name");
|
||||
public ITextComponent getArmorSetName() {
|
||||
return new TextComponentTranslation("botania.armorset.elementium.name");
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void addArmorSetDescription(ItemStack stack, List<String> list) {
|
||||
public void addArmorSetDescription(ItemStack stack, List<ITextComponent> list) {
|
||||
super.addArmorSetDescription(stack, list);
|
||||
addStringToTooltip(I18n.format("botania.armorset.elementium.desc"), list);
|
||||
list.add(new TextComponentTranslation("botania.armorset.elementium.desc"));
|
||||
}
|
||||
|
||||
}
|
||||
+34
-65
@@ -13,8 +13,7 @@ package vazkii.botania.common.item.equipment.armor.manasteel;
|
||||
import com.google.common.collect.Multimap;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.entity.model.ModelBiped;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -23,14 +22,17 @@ import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.IArmorMaterial;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
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.client.model.ModelLoader;
|
||||
import net.minecraftforge.common.ISpecialArmor;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
@@ -52,7 +54,7 @@ import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ItemManasteelArmor extends ItemArmor implements ISpecialArmor, IManaUsingItem, IPhantomInkable, IModelRegister {
|
||||
public class ItemManasteelArmor extends ItemArmor implements IManaUsingItem, IPhantomInkable {
|
||||
|
||||
private static final int MANA_PER_DAMAGE = 70;
|
||||
|
||||
@@ -61,55 +63,25 @@ public class ItemManasteelArmor extends ItemArmor implements ISpecialArmor, IMan
|
||||
protected Map<EntityEquipmentSlot, ModelBiped> models = null;
|
||||
public final EntityEquipmentSlot type;
|
||||
|
||||
public ItemManasteelArmor(EntityEquipmentSlot type, String name) {
|
||||
this(type, name, BotaniaAPI.manasteelArmorMaterial);
|
||||
public ItemManasteelArmor(EntityEquipmentSlot type, Properties props) {
|
||||
this(type, BotaniaAPI.manasteelArmorMaterial, props);
|
||||
}
|
||||
|
||||
public ItemManasteelArmor(EntityEquipmentSlot type, String name, ArmorMaterial mat) {
|
||||
super(mat, 0, type);
|
||||
public ItemManasteelArmor(EntityEquipmentSlot type, IArmorMaterial mat, Properties props) {
|
||||
super(mat, type, props);
|
||||
this.type = type;
|
||||
setCreativeTab(BotaniaCreativeTab.INSTANCE);
|
||||
setRegistryName(new ResourceLocation(LibMisc.MOD_ID, name));
|
||||
setTranslationKey(name);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUnlocalizedNameInefficiently(@Nonnull ItemStack par1ItemStack) {
|
||||
return super.getUnlocalizedNameInefficiently(par1ItemStack).replaceAll("item.", "item." + LibResources.PREFIX_MOD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorProperties getProperties(EntityLivingBase player, @Nonnull ItemStack armor, DamageSource source, double damage, int slot) {
|
||||
if(source.isUnblockable())
|
||||
return new ArmorProperties(0, 0, 0);
|
||||
return new ArmorProperties(0, damageReduceAmount / 25D, armor.getMaxDamage() + 1 - armor.getItemDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getArmorDisplay(EntityPlayer player, @Nonnull ItemStack armor, int slot) {
|
||||
return damageReduceAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
|
||||
Multimap<String, AttributeModifier> attrib = super.getAttributeModifiers(slot, stack);
|
||||
// Remove these or else vanilla will double count it and ISpecialArmor
|
||||
attrib.removeAll(SharedMonsterAttributes.ARMOR.getName());
|
||||
attrib.removeAll(SharedMonsterAttributes.ARMOR_TOUGHNESS.getName());
|
||||
return attrib;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) {
|
||||
public void inventoryTick(ItemStack stack, World world, Entity player, int par4, boolean par5) {
|
||||
if(player instanceof EntityPlayer)
|
||||
onArmorTick(world, (EntityPlayer) player, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
|
||||
if(!world.isRemote && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExact(stack, player, MANA_PER_DAMAGE * 2, true))
|
||||
stack.setItemDamage(stack.getItemDamage() - 1);
|
||||
if(!world.isRemote && stack.getDamage() > 0 && ManaItemHandler.requestManaExact(stack, player, MANA_PER_DAMAGE * 2, true))
|
||||
stack.setDamage(stack.getDamage() - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -170,26 +142,26 @@ public class ItemManasteelArmor extends ItemArmor implements ISpecialArmor, IMan
|
||||
|
||||
@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(GuiScreen.isShiftKeyDown())
|
||||
addInformationAfterShift(stack, world, list, flags);
|
||||
else addStringToTooltip(I18n.format("botaniamisc.shiftinfo"), list);
|
||||
else list.add(new TextComponentTranslation("botaniamisc.shiftinfo"));
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformationAfterShift(ItemStack stack, World world, List<String> list, ITooltipFlag flags) {
|
||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
||||
addStringToTooltip(getArmorSetTitle(player), list);
|
||||
public void addInformationAfterShift(ItemStack stack, World world, List<ITextComponent> list, ITooltipFlag flags) {
|
||||
EntityPlayer player = Minecraft.getInstance().player;
|
||||
list.add(getArmorSetTitle(player));
|
||||
addArmorSetDescription(stack, list);
|
||||
ItemStack[] stacks = getArmorSetStacks();
|
||||
for(int i = 0; i < stacks.length; i++)
|
||||
addStringToTooltip((hasArmorSetItem(player, i) ? TextFormatting.GREEN : "") + " - " + stacks[i].getDisplayName(), list);
|
||||
for(int i = 0; i < stacks.length; i++) {
|
||||
ITextComponent cmp = new TextComponentString(" - ").appendSibling(stack.getDisplayName());
|
||||
if(hasArmorSetItem(player, i))
|
||||
cmp.getStyle().setColor(TextFormatting.GREEN);
|
||||
list.add(cmp);
|
||||
}
|
||||
if(hasPhantomInk(stack))
|
||||
addStringToTooltip(I18n.format("botaniamisc.hasPhantomInk"), list);
|
||||
}
|
||||
|
||||
public void addStringToTooltip(String s, List<String> tooltip) {
|
||||
tooltip.add(s.replaceAll("&", "\u00a7"));
|
||||
list.add(new TextComponentTranslation("botaniamisc.hasPhantomInk"));
|
||||
}
|
||||
|
||||
static ItemStack[] armorset;
|
||||
@@ -238,18 +210,21 @@ public class ItemManasteelArmor extends ItemArmor implements ISpecialArmor, IMan
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public String getArmorSetName() {
|
||||
return I18n.format("botania.armorset.manasteel.name");
|
||||
public ITextComponent getArmorSetName() {
|
||||
return new TextComponentTranslation("botania.armorset.manasteel.name");
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private String getArmorSetTitle(EntityPlayer player) {
|
||||
return I18n.format("botaniamisc.armorset") + " " + getArmorSetName() + " (" + getSetPiecesEquipped(player) + "/" + getArmorSetStacks().length + ")";
|
||||
private ITextComponent getArmorSetTitle(EntityPlayer player) {
|
||||
return new TextComponentTranslation("botaniamisc.armorset")
|
||||
.appendText(" ")
|
||||
.appendSibling(getArmorSetName())
|
||||
.appendText(" (" + getSetPiecesEquipped(player) + "/" + getArmorSetStacks().length + ")");
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addArmorSetDescription(ItemStack stack, List<String> list) {
|
||||
addStringToTooltip(I18n.format("botania.armorset.manasteel.desc"), list);
|
||||
public void addArmorSetDescription(ItemStack stack, List<ITextComponent> list) {
|
||||
list.add(new TextComponentTranslation("botania.armorset.manasteel.desc"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -261,10 +236,4 @@ public class ItemManasteelArmor extends ItemArmor implements ISpecialArmor, IMan
|
||||
public void setPhantomInk(ItemStack stack, boolean ink) {
|
||||
ItemNBTHelper.setBoolean(stack, TAG_PHANTOM_INK, ink);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void registerModels() {
|
||||
ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(getRegistryName(), "inventory"));
|
||||
}
|
||||
}
|
||||
+2
-6
@@ -20,12 +20,8 @@ import javax.annotation.Nullable;
|
||||
|
||||
public class ItemManasteelHelm extends ItemManasteelArmor implements IManaDiscountArmor {
|
||||
|
||||
public ItemManasteelHelm() {
|
||||
this(LibItemNames.MANASTEEL_HELM);
|
||||
}
|
||||
|
||||
public ItemManasteelHelm(String name) {
|
||||
super(EntityEquipmentSlot.HEAD, name);
|
||||
public ItemManasteelHelm(Properties props) {
|
||||
super(EntityEquipmentSlot.HEAD, props);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,8 +28,8 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
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;
|
||||
@@ -56,9 +56,8 @@ public abstract class ItemBauble extends ItemMod implements IBauble, ICosmeticAt
|
||||
private static final String TAG_COSMETIC_ITEM = "cosmeticItem";
|
||||
private static final String TAG_PHANTOM_INK = "phantomInk";
|
||||
|
||||
public ItemBauble(String name) {
|
||||
super(name);
|
||||
setMaxStackSize(1);
|
||||
public ItemBauble(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
// Apparently baubles doesn't unequip on death, which causes attribute modifiers to get weird/desync on respawn
|
||||
|
||||
@@ -14,7 +14,7 @@ import baubles.api.BaubleType;
|
||||
import baubles.api.BaublesApi;
|
||||
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.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
@@ -22,8 +22,8 @@ import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.ExplosionEvent;
|
||||
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 vazkii.botania.api.item.IBaubleRender;
|
||||
@@ -39,8 +39,8 @@ public class ItemGoddessCharm extends ItemBauble implements IManaUsingItem, IBau
|
||||
|
||||
public static final int COST = 1000;
|
||||
|
||||
public ItemGoddessCharm() {
|
||||
super(LibItemNames.GODDESS_CHARM);
|
||||
public ItemGoddessCharm(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -71,9 +71,9 @@ public class ItemGoddessCharm extends ItemBauble implements IManaUsingItem, IBau
|
||||
Helper.translateToHeadLevel(player);
|
||||
Helper.translateToFace();
|
||||
Helper.defaultTransforms();
|
||||
GlStateManager.rotate(-90F, 0F, 1F, 0F);
|
||||
GlStateManager.translate(0.5F, 0.2F, 0.45F);
|
||||
Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.NONE);
|
||||
GlStateManager.rotatef(-90F, 0F, 1F, 0F);
|
||||
GlStateManager.translatef(0.5F, 0.2F, 0.45F);
|
||||
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.NONE);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ public class ItemThirdEye extends ItemBauble implements IManaUsingItem, IBaubleR
|
||||
|
||||
private static final int COST = 2;
|
||||
|
||||
public ItemThirdEye() {
|
||||
super(LibItemNames.THIRD_EYE);
|
||||
public ItemThirdEye(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,13 +79,13 @@ public class ItemThirdEye extends ItemBauble implements IManaUsingItem, IBaubleR
|
||||
@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();
|
||||
double scale = 0.6;
|
||||
GlStateManager.rotate(180, 0, 0, 1);
|
||||
GlStateManager.translate(-0.3, -0.6, armor ? -0.18 : -0.12);
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
GlStateManager.rotatef(180, 0, 0, 1);
|
||||
GlStateManager.translated(-0.3, -0.6, armor ? -0.18 : -0.12);
|
||||
GlStateManager.scaled(scale, scale, scale);
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
GlStateManager.pushMatrix();
|
||||
@@ -96,15 +96,15 @@ public class ItemThirdEye extends ItemBauble implements IManaUsingItem, IBaubleR
|
||||
double scale1 = 0.75;
|
||||
width /= 2F;
|
||||
|
||||
GlStateManager.translate(0.15, 0.15, -0.05);
|
||||
GlStateManager.translated(0.15, 0.15, -0.05);
|
||||
double time = ClientTickHandler.total * 0.12;
|
||||
double dist = 0.05;
|
||||
GlStateManager.translate(Math.sin(time) * dist, Math.cos(time * 0.5) * dist, 0);
|
||||
GlStateManager.translated(Math.sin(time) * dist, Math.cos(time * 0.5) * dist, 0);
|
||||
|
||||
GlStateManager.scale(scale1, scale1, scale1);
|
||||
GlStateManager.scaled(scale1, scale1, scale1);
|
||||
break;
|
||||
case 2:
|
||||
GlStateManager.translate(0, 0, -0.05);
|
||||
GlStateManager.translated(0, 0, -0.05);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class ItemCrystalBow extends ItemLivingwoodBow {
|
||||
|
||||
private final int ARROW_COST = 200;
|
||||
|
||||
public ItemCrystalBow(Item.Builder builder) {
|
||||
public ItemCrystalBow(Properties builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public class ItemLivingwoodBow extends ItemBow implements IManaUsingItem {
|
||||
private static final Predicate<ItemStack> AMMO_FUNC = s -> !s.isEmpty() && s.getItem() instanceof ItemArrow;
|
||||
public static final int MANA_PER_DAMAGE = 40;
|
||||
|
||||
public ItemLivingwoodBow(Item.Builder builder) {
|
||||
public ItemLivingwoodBow(Properties builder) {
|
||||
super(builder);
|
||||
addPropertyOverride(new ResourceLocation("minecraft:pull"), (stack, worldIn, entityIn) -> {
|
||||
if (entityIn == null)
|
||||
|
||||
+2
-2
@@ -26,8 +26,8 @@ import vazkii.botania.common.lib.LibItemNames;
|
||||
@Optional.Interface(modid = "thaumcraft", iface = "thaumcraft.api.items.IRevealer", striprefs = true)})
|
||||
public class ItemManasteelHelmRevealing extends ItemManasteelHelm implements IGoggles, IRevealer {
|
||||
|
||||
public ItemManasteelHelmRevealing() {
|
||||
super(LibItemNames.MANASTEEL_HELM_R);
|
||||
public ItemManasteelHelmRevealing(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ItemLens extends ItemMod implements ILensControl, ICompositableLens
|
||||
private final Lens lens;
|
||||
private final int props;
|
||||
|
||||
public ItemLens(Item.Builder builder, Lens lens, int props) {
|
||||
public ItemLens(Item.Properties builder, Lens lens, int props) {
|
||||
super(builder);
|
||||
this.lens = lens;
|
||||
this.props = props;
|
||||
|
||||
@@ -38,8 +38,8 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class ItemDye extends Item16Colors {
|
||||
|
||||
public ItemDye(EnumDyeColor color) {
|
||||
super(LibItemNames.DYE, color);
|
||||
public ItemDye(EnumDyeColor color, Properties props) {
|
||||
super(color, props);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -83,10 +83,4 @@ public class ItemDye extends Item16Colors {
|
||||
return false;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void registerModels() {
|
||||
ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(LibMisc.MOD_ID + ":" + LibItemNames.DYE, "inventory"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -39,8 +39,8 @@ import javax.annotation.Nonnull;
|
||||
// todo 1.13 further break this up
|
||||
@Mod.EventBusSubscriber
|
||||
public class ItemManaResource extends ItemMod implements IFlowerComponent, IElvenItem {
|
||||
public ItemManaResource(String registryName) {
|
||||
super(registryName);
|
||||
public ItemManaResource(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -17,7 +17,7 @@ import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
public class ItemPestleAndMortar extends ItemMod {
|
||||
|
||||
public ItemPestleAndMortar(Item.Builder builder) {
|
||||
public ItemPestleAndMortar(Item.Properties builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ package vazkii.botania.common.item.material;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -31,77 +30,22 @@ import vazkii.botania.api.item.IPetalApothecary;
|
||||
import vazkii.botania.api.recipe.IFlowerComponent;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.item.Item16Colors;
|
||||
import vazkii.botania.common.item.block.ItemBlockMod;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ItemPetal extends Item16Colors implements IFlowerComponent {
|
||||
public class ItemPetal extends ItemBlockMod implements IFlowerComponent {
|
||||
public final EnumDyeColor color;
|
||||
|
||||
public ItemPetal(EnumDyeColor color) {
|
||||
super(LibItemNames.PETAL, color);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
// Copy of ItemBlock.onItemUse
|
||||
IBlockState iblockstate = world.getBlockState(pos);
|
||||
Block block = iblockstate.getBlock();
|
||||
|
||||
if (!block.isReplaceable(world, pos))
|
||||
{
|
||||
pos = pos.offset(facing);
|
||||
}
|
||||
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (!stack.isEmpty() && player.canPlayerEdit(pos, facing, stack) && world.mayPlace(ModBlocks.buriedPetals, pos, false, facing, null))
|
||||
{
|
||||
int i = this.getMetadata(stack.getMetadata());
|
||||
IBlockState iblockstate1 = ModBlocks.buriedPetals.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, i, player);
|
||||
|
||||
if (placeBlockAt(stack, player, world, pos, facing, hitX, hitY, hitZ, iblockstate1))
|
||||
{
|
||||
SoundType soundtype = ModBlocks.buriedPetals.getSoundType();
|
||||
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
|
||||
stack.shrink(1);
|
||||
}
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
// Direct copy of ItemBlock.placeBlockAt
|
||||
private boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) {
|
||||
if (!world.setBlockState(pos, newState, 3)) return false;
|
||||
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
if (state.getBlock() == ModBlocks.buriedPetals)
|
||||
{
|
||||
// setTileEntityNBT(world, player, pos, stack);
|
||||
ModBlocks.buriedPetals.onBlockPlacedBy(world, pos, state, player, stack);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int stackMeta) {
|
||||
return color.getMetadata();
|
||||
public ItemPetal(Block buriedPetals, EnumDyeColor color, Properties props) {
|
||||
super(buriedPetals, props);
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getParticleColor(ItemStack stack) {
|
||||
return color.colorValue;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void registerModels() {
|
||||
ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(LibMisc.MOD_ID + ":" + LibItemNames.PETAL, "inventory"));
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ import vazkii.botania.common.item.ItemMod;
|
||||
|
||||
public class ItemRune extends ItemMod implements IFlowerComponent {
|
||||
|
||||
public ItemRune(Item.Builder builder) {
|
||||
public ItemRune(Item.Properties builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import net.minecraft.item.ItemRecord;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
|
||||
public class ItemModRecord extends ItemRecord {
|
||||
public ItemModRecord(int comparator, SoundEvent sound, Item.Builder builder) {
|
||||
public ItemModRecord(int comparator, SoundEvent sound, Properties builder) {
|
||||
super(comparator, sound, builder);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
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;
|
||||
@@ -42,32 +43,29 @@ public class ItemDirtRod extends ItemMod implements IManaUsingItem, IBlockProvid
|
||||
|
||||
static final int COST = 75;
|
||||
|
||||
public ItemDirtRod() {
|
||||
this(LibItemNames.DIRT_ROD);
|
||||
}
|
||||
|
||||
public ItemDirtRod(String name) {
|
||||
super(name);
|
||||
setMaxStackSize(1);
|
||||
public ItemDirtRod(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 place(player, world, pos, hand, side, par8, par9, par10, Blocks.DIRT, COST, 0.35F, 0.2F, 0.05F);
|
||||
public EnumActionResult onItemUse(ItemUseContext ctx) {
|
||||
return place(ctx, Blocks.DIRT, COST, 0.35F, 0.2F, 0.05F);
|
||||
}
|
||||
|
||||
public static EnumActionResult place(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ, Block block, int cost, float r, float g, float b) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
public static EnumActionResult place(ItemUseContext ctx, Block block, int cost, float r, float g, float b) {
|
||||
EntityPlayer player = ctx.getPlayer();
|
||||
ItemStack stack = ctx.getItem();
|
||||
World world = ctx.getWorld();
|
||||
EnumFacing side = ctx.getFace();
|
||||
BlockPos pos = ctx.getPos();
|
||||
|
||||
if(ManaItemHandler.requestManaExactForTool(stack, player, cost, false)) {
|
||||
int entities = world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(pos.offset(side), pos.offset(side).add(1, 1, 1))).size();
|
||||
|
||||
if(entities == 0) {
|
||||
ItemStack stackToPlace = new ItemStack(block);
|
||||
|
||||
player.setHeldItem(hand, stackToPlace);
|
||||
stackToPlace.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ);
|
||||
player.setHeldItem(hand, stack);
|
||||
stackToPlace.onItemUse(new ItemUseContext(player, stackToPlace, pos, side, ctx.getHitX(), ctx.getHitY(), ctx.getHitZ()));
|
||||
|
||||
if(stackToPlace.isEmpty()) {
|
||||
ManaItemHandler.requestManaExactForTool(stack, player, cost, true);
|
||||
|
||||
@@ -12,6 +12,7 @@ package vazkii.botania.common.item.rod;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -21,6 +22,8 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -28,13 +31,14 @@ import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
@@ -59,69 +63,62 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
|
||||
private static final int COST = 40;
|
||||
|
||||
private static final String TAG_BLOCK_NAME = "blockName";
|
||||
private static final String TAG_BLOCK_META = "blockMeta";
|
||||
private static final String TAG_TARGET_BLOCK_NAME = "targetBlockName";
|
||||
private static final String TAG_TARGET_BLOCK_META = "targetBlockMeta";
|
||||
private static final String TAG_TARGET_BLOCK_NAME = "targetState";
|
||||
private static final String TAG_SWAPPING = "swapping";
|
||||
private static final String TAG_SELECT_X = "selectX";
|
||||
private static final String TAG_SELECT_Y = "selectY";
|
||||
private static final String TAG_SELECT_Z = "selectZ";
|
||||
private static final String TAG_EXTRA_RANGE = "extraRange";
|
||||
|
||||
public ItemExchangeRod() {
|
||||
super(LibItemNames.EXCHANGE_ROD);
|
||||
setMaxStackSize(1);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
public ItemExchangeRod(Properties props) {
|
||||
super(props);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::onLeftClick);
|
||||
}
|
||||
|
||||
@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);
|
||||
public EnumActionResult onItemUse(ItemUseContext ctx) {
|
||||
World world = ctx.getWorld();
|
||||
BlockPos pos = ctx.getPos();
|
||||
EntityPlayer player = ctx.getPlayer();
|
||||
ItemStack stack = ctx.getItem();
|
||||
IBlockState wstate = world.getBlockState(pos);
|
||||
|
||||
if(player.isSneaking()) {
|
||||
if(player != null && player.isSneaking()) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if(tile == null) {
|
||||
if(BlockCamo.isValidBlock(wstate)) {
|
||||
Item item = Item.getItemFromBlock(wstate.getBlock());
|
||||
|
||||
setBlock(stack, wstate.getBlock(), !item.getHasSubtypes() ? 0 : wstate.getBlock().getMetaFromState(wstate));
|
||||
player.setItemStackToSlot(hand == EnumHand.MAIN_HAND ? EntityEquipmentSlot.MAINHAND : EntityEquipmentSlot.OFFHAND, stack);
|
||||
if(BlockCamo.isValidBlock(wstate, world, pos)) {
|
||||
setBlock(stack, wstate);
|
||||
|
||||
displayRemainderCounter(player, stack);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
} else if(canExchange(stack) && !ItemNBTHelper.getBoolean(stack, TAG_SWAPPING, false)) {
|
||||
Block block = getBlock(stack);
|
||||
int meta = getBlockMeta(stack);
|
||||
List<BlockPos> swap = getBlocksToSwap(world, stack, block.getStateFromMeta(meta), pos, null);
|
||||
IBlockState state = getState(stack);
|
||||
List<BlockPos> swap = getBlocksToSwap(world, stack, state, pos, null);
|
||||
if(swap.size() > 0) {
|
||||
ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, true);
|
||||
ItemNBTHelper.setInt(stack, TAG_SELECT_X, pos.getX());
|
||||
ItemNBTHelper.setInt(stack, TAG_SELECT_Y, pos.getY());
|
||||
ItemNBTHelper.setInt(stack, TAG_SELECT_Z, pos.getZ());
|
||||
setTargetBlock(stack, wstate.getBlock(), wstate.getBlock().getMetaFromState(wstate));
|
||||
if(world.isRemote)
|
||||
player.swingArm(hand);
|
||||
setTarget(stack, wstate);
|
||||
}
|
||||
}
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLeftClick(PlayerInteractEvent.LeftClickBlock event) {
|
||||
private void onLeftClick(PlayerInteractEvent.LeftClickBlock event) {
|
||||
ItemStack stack = event.getItemStack();
|
||||
if(!stack.isEmpty() && stack.getItem() == this && canExchange(stack) && ManaItemHandler.requestManaExactForTool(stack, event.getEntityPlayer(), COST, false)) {
|
||||
if(exchange(event.getWorld(), event.getEntityPlayer(), event.getPos(), stack, getBlock(stack).getStateFromMeta(getBlockMeta(stack))))
|
||||
if(exchange(event.getWorld(), event.getEntityPlayer(), event.getPos(), stack, getState(stack)))
|
||||
ManaItemHandler.requestManaExactForTool(stack, event.getEntityPlayer(), COST, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int something, boolean somethingelse) {
|
||||
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean equipped) {
|
||||
if(!canExchange(stack) || !(entity instanceof EntityPlayer))
|
||||
return;
|
||||
|
||||
@@ -132,8 +129,7 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
|
||||
if(extraRange != extraRangeNew)
|
||||
ItemNBTHelper.setInt(stack, TAG_EXTRA_RANGE, extraRangeNew);
|
||||
|
||||
Block block = getBlock(stack);
|
||||
int meta = getBlockMeta(stack);
|
||||
IBlockState state = getState(stack);
|
||||
if(ItemNBTHelper.getBoolean(stack, TAG_SWAPPING, false)) {
|
||||
if(!ManaItemHandler.requestManaExactForTool(stack, player, COST, false)) {
|
||||
ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false);
|
||||
@@ -143,16 +139,15 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
|
||||
int x = ItemNBTHelper.getInt(stack, TAG_SELECT_X, 0);
|
||||
int y = ItemNBTHelper.getInt(stack, TAG_SELECT_Y, 0);
|
||||
int z = ItemNBTHelper.getInt(stack, TAG_SELECT_Z, 0);
|
||||
Block targetBlock = getTargetBlock(stack);
|
||||
int targetMeta = getTargetBlockMeta(stack);
|
||||
List<BlockPos> swap = getBlocksToSwap(world, stack, block.getStateFromMeta(meta), new BlockPos(x, y, z), targetBlock.getStateFromMeta(targetMeta));
|
||||
IBlockState target = getTargetState(stack);
|
||||
List<BlockPos> swap = getBlocksToSwap(world, stack, state, new BlockPos(x, y, z), target);
|
||||
if(swap.size() == 0) {
|
||||
ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false);
|
||||
return;
|
||||
}
|
||||
|
||||
BlockPos coords = swap.get(world.rand.nextInt(swap.size()));
|
||||
boolean exchange = exchange(world, player, coords, stack, block.getStateFromMeta(meta));
|
||||
boolean exchange = exchange(world, player, coords, stack, state);
|
||||
if(exchange)
|
||||
ManaItemHandler.requestManaExactForTool(stack, player, COST, true);
|
||||
else ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false);
|
||||
@@ -193,7 +188,7 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
|
||||
continue;
|
||||
|
||||
// Check to see if the block is visible on any side:
|
||||
for(EnumFacing dir : EnumFacing.VALUES) {
|
||||
for(EnumFacing dir : EnumFacing.BY_INDEX) {
|
||||
BlockPos adjPos = pos_.offset(dir);
|
||||
IBlockState adjState = world.getBlockState(adjPos);
|
||||
|
||||
@@ -203,7 +198,7 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
|
||||
|
||||
// If there is a rendering-specific way to check for this,
|
||||
// that should be placed in preference to this.
|
||||
if(!adjState.isSideSolid(world, adjPos, dir.getOpposite())) {
|
||||
if(adjState.getBlockFaceShape(world, adjPos, dir.getOpposite()) != BlockFaceShape.SOLID) {
|
||||
coordsList.add(pos_);
|
||||
break;
|
||||
}
|
||||
@@ -218,15 +213,15 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
|
||||
if(tile != null)
|
||||
return false;
|
||||
|
||||
ItemStack placeStack = removeFromInventory(player, stack, state.getBlock(), state.getBlock().getMetaFromState(state), false);
|
||||
ItemStack placeStack = removeFromInventory(player, stack, state.getBlock(), false);
|
||||
if(!placeStack.isEmpty()) {
|
||||
IBlockState stateAt = world.getBlockState(pos);
|
||||
Block blockAt = stateAt.getBlock();
|
||||
if(!blockAt.isAir(world.getBlockState(pos), world, pos) && stateAt.getPlayerRelativeBlockHardness(player, world, pos) > 0 && stateAt != state) {
|
||||
if(!world.isRemote) {
|
||||
world.destroyBlock(pos, !player.capabilities.isCreativeMode);
|
||||
if(!player.capabilities.isCreativeMode) {
|
||||
removeFromInventory(player, stack, state.getBlock(), state.getBlock().getMetaFromState(state), true);
|
||||
world.destroyBlock(pos, !player.abilities.isCreativeMode);
|
||||
if(!player.abilities.isCreativeMode) {
|
||||
removeFromInventory(player, stack, state.getBlock(), true);
|
||||
}
|
||||
world.setBlockState(pos, state, 1 | 2);
|
||||
state.getBlock().onBlockPlacedBy(world, pos, state, player, placeStack);
|
||||
@@ -240,11 +235,10 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
|
||||
}
|
||||
|
||||
public boolean canExchange(ItemStack stack) {
|
||||
Block block = getBlock(stack);
|
||||
return block != null && block != Blocks.AIR;
|
||||
return !getState(stack).isAir();
|
||||
}
|
||||
|
||||
public static ItemStack removeFromInventory(EntityPlayer player, IItemHandler inv, ItemStack stack, Block block, int meta, boolean doit) {
|
||||
public static ItemStack removeFromInventory(EntityPlayer player, IItemHandler inv, ItemStack stack, Block block, boolean doit) {
|
||||
List<ItemStack> providers = new ArrayList<>();
|
||||
for(int i = inv.getSlots() - 1; i >= 0; i--) {
|
||||
ItemStack invStack = inv.getStackInSlot(i);
|
||||
@@ -252,7 +246,7 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
|
||||
continue;
|
||||
|
||||
Item item = invStack.getItem();
|
||||
if(item == Item.getItemFromBlock(block) && invStack.getItemDamage() == meta) {
|
||||
if(item == block.asItem()) {
|
||||
return inv.extractItem(i, 1, !doit);
|
||||
}
|
||||
|
||||
@@ -262,38 +256,38 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
|
||||
|
||||
for(ItemStack provStack : providers) {
|
||||
IBlockProvider prov = (IBlockProvider) provStack.getItem();
|
||||
if(prov.provideBlock(player, stack, provStack, block, meta, doit))
|
||||
return new ItemStack(block, 1, meta);
|
||||
if(prov.provideBlock(player, stack, provStack, block, doit))
|
||||
return new ItemStack(block);
|
||||
}
|
||||
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public static ItemStack removeFromInventory(EntityPlayer player, ItemStack stack, Block block, int meta, boolean doit) {
|
||||
if(player.capabilities.isCreativeMode)
|
||||
return new ItemStack(block, 1, meta);
|
||||
public static ItemStack removeFromInventory(EntityPlayer player, ItemStack stack, Block block, boolean doit) {
|
||||
if(player.abilities.isCreativeMode)
|
||||
return new ItemStack(block);
|
||||
|
||||
ItemStack outStack = removeFromInventory(player, BotaniaAPI.internalHandler.getBaublesInventoryWrapped(player), stack, block, meta, doit);
|
||||
ItemStack outStack = removeFromInventory(player, BotaniaAPI.internalHandler.getBaublesInventoryWrapped(player), stack, block, doit);
|
||||
if (outStack.isEmpty())
|
||||
outStack = removeFromInventory(player, player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null), stack, block, meta, doit);
|
||||
outStack = removeFromInventory(player, player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY), stack, block, doit);
|
||||
return outStack;
|
||||
}
|
||||
|
||||
public static int getInventoryItemCount(EntityPlayer player, ItemStack stack, Block block, int meta) {
|
||||
if(player.capabilities.isCreativeMode)
|
||||
public static int getInventoryItemCount(EntityPlayer player, ItemStack stack, Block block) {
|
||||
if(player.abilities.isCreativeMode)
|
||||
return -1;
|
||||
|
||||
int baubleCount = getInventoryItemCount(player, BotaniaAPI.internalHandler.getBaublesInventoryWrapped(player), stack, block, meta);
|
||||
int baubleCount = getInventoryItemCount(player, BotaniaAPI.internalHandler.getBaublesInventoryWrapped(player), stack, block);
|
||||
if (baubleCount == -1) return -1;
|
||||
|
||||
int count = getInventoryItemCount(player, player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null), stack, block, meta);
|
||||
int count = getInventoryItemCount(player, player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY), stack, block);
|
||||
if (count == -1) return -1;
|
||||
|
||||
return count+baubleCount;
|
||||
}
|
||||
|
||||
public static int getInventoryItemCount(EntityPlayer player, IItemHandler inv, ItemStack stack, Block block, int meta) {
|
||||
if(player.capabilities.isCreativeMode)
|
||||
public static int getInventoryItemCount(EntityPlayer player, IItemHandler inv, ItemStack stack, Block block) {
|
||||
if(player.abilities.isCreativeMode)
|
||||
return -1;
|
||||
|
||||
int count = 0;
|
||||
@@ -303,12 +297,12 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
|
||||
continue;
|
||||
|
||||
Item item = invStack.getItem();
|
||||
if(item == Item.getItemFromBlock(block) && invStack.getItemDamage() == meta)
|
||||
if(item == block.asItem())
|
||||
count += invStack.getCount();
|
||||
|
||||
if(item instanceof IBlockProvider) {
|
||||
IBlockProvider prov = (IBlockProvider) item;
|
||||
int provCount = prov.getBlockCount(player, stack, invStack, block, meta);
|
||||
int provCount = prov.getBlockCount(player, stack, invStack, block);
|
||||
if(provCount == -1)
|
||||
return -1;
|
||||
count += provCount;
|
||||
@@ -319,11 +313,10 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
|
||||
}
|
||||
|
||||
public void displayRemainderCounter(EntityPlayer player, ItemStack stack) {
|
||||
Block block = getBlock(stack);
|
||||
int meta = getBlockMeta(stack);
|
||||
int count = getInventoryItemCount(player, stack, block, meta);
|
||||
Block block = getState(stack).getBlock();
|
||||
int count = getInventoryItemCount(player, stack, block);
|
||||
if(!player.world.isRemote)
|
||||
ItemsRemainingRenderHandler.set(new ItemStack(block, 1, meta), count);
|
||||
ItemsRemainingRenderHandler.set(new ItemStack(block), count);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -331,49 +324,35 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean setBlock(ItemStack stack, Block block, int meta) {
|
||||
ItemNBTHelper.setString(stack, TAG_BLOCK_NAME, Block.REGISTRY.getNameForObject(block).toString());
|
||||
ItemNBTHelper.setInt(stack, TAG_BLOCK_META, meta);
|
||||
return true;
|
||||
private void setBlock(ItemStack stack, IBlockState state) {
|
||||
ItemNBTHelper.setCompound(stack, TAG_BLOCK_NAME, NBTUtil.writeBlockState(state));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getItemStackDisplayName(@Nonnull ItemStack par1ItemStack) {
|
||||
Block block = getBlock(par1ItemStack);
|
||||
int meta = getBlockMeta(par1ItemStack);
|
||||
return super.getItemStackDisplayName(par1ItemStack) + (block == null ? "" : " (" + TextFormatting.GREEN + new ItemStack(block, 1, meta).getDisplayName() + TextFormatting.RESET + ")");
|
||||
public ITextComponent getDisplayName(@Nonnull ItemStack stack) {
|
||||
IBlockState state = getState(stack);
|
||||
ITextComponent cmp = super.getDisplayName(stack);
|
||||
if (!state.isAir()) {
|
||||
cmp.appendText(" (");
|
||||
ITextComponent sub = new ItemStack(state.getBlock()).getDisplayName();
|
||||
sub.getStyle().setColor(TextFormatting.GREEN);
|
||||
cmp.appendSibling(sub);
|
||||
cmp.appendText(")");
|
||||
}
|
||||
return cmp;
|
||||
}
|
||||
|
||||
public static String getBlockName(ItemStack stack) {
|
||||
return ItemNBTHelper.getString(stack, TAG_BLOCK_NAME, "");
|
||||
public static IBlockState getState(ItemStack stack) {
|
||||
return NBTUtil.readBlockState(ItemNBTHelper.getCompound(stack, TAG_BLOCK_NAME, false));
|
||||
}
|
||||
|
||||
public static Block getBlock(ItemStack stack) {
|
||||
Block block = Block.getBlockFromName(getBlockName(stack));
|
||||
return block;
|
||||
private void setTarget(ItemStack stack, IBlockState state) {
|
||||
ItemNBTHelper.setCompound(stack, TAG_TARGET_BLOCK_NAME, NBTUtil.writeBlockState(state));
|
||||
}
|
||||
|
||||
public static int getBlockMeta(ItemStack stack) {
|
||||
return ItemNBTHelper.getInt(stack, TAG_BLOCK_META, 0);
|
||||
}
|
||||
|
||||
private void setTargetBlock(ItemStack stack, Block block, int meta) {
|
||||
ItemNBTHelper.setString(stack, TAG_TARGET_BLOCK_NAME, Block.REGISTRY.getNameForObject(block).toString());
|
||||
ItemNBTHelper.setInt(stack, TAG_TARGET_BLOCK_META, meta);
|
||||
}
|
||||
|
||||
public static String getTargetBlockName(ItemStack stack) {
|
||||
return ItemNBTHelper.getString(stack, TAG_TARGET_BLOCK_NAME, "");
|
||||
}
|
||||
|
||||
public static Block getTargetBlock(ItemStack stack) {
|
||||
Block block = Block.getBlockFromName(getTargetBlockName(stack));
|
||||
return block;
|
||||
}
|
||||
|
||||
public static int getTargetBlockMeta(ItemStack stack) {
|
||||
return ItemNBTHelper.getInt(stack, TAG_TARGET_BLOCK_META, 0);
|
||||
public static IBlockState getTargetState(ItemStack stack) {
|
||||
return NBTUtil.readBlockState(ItemNBTHelper.getCompound(stack, TAG_TARGET_BLOCK_NAME, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -383,26 +362,23 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
|
||||
if(holding != stack || !canExchange(stack))
|
||||
return ImmutableList.of();
|
||||
|
||||
Block block = getBlock(stack);
|
||||
int meta = getBlockMeta(stack);
|
||||
IBlockState state = getState(stack);
|
||||
|
||||
RayTraceResult pos = Minecraft.getMinecraft().objectMouseOver;
|
||||
RayTraceResult pos = Minecraft.getInstance().objectMouseOver;
|
||||
if(pos != null && pos.getBlockPos() != null) {
|
||||
BlockPos bPos = pos.getBlockPos();
|
||||
Block targetBlock = null;
|
||||
int targetMeta = 0;
|
||||
IBlockState target = null;
|
||||
if(ItemNBTHelper.getBoolean(stack, TAG_SWAPPING, false)) {
|
||||
bPos = new BlockPos(
|
||||
ItemNBTHelper.getInt(stack, TAG_SELECT_X, 0),
|
||||
ItemNBTHelper.getInt(stack, TAG_SELECT_Y, 0),
|
||||
ItemNBTHelper.getInt(stack, TAG_SELECT_Z, 0)
|
||||
);
|
||||
targetBlock = getTargetBlock(stack);
|
||||
targetMeta = getTargetBlockMeta(stack);
|
||||
target = getTargetState(stack);
|
||||
}
|
||||
|
||||
if(!player.world.isAirBlock(bPos)) {
|
||||
List<BlockPos> coordsList = getBlocksToSwap(player.world, stack, block.getStateFromMeta(meta), bPos, targetBlock == null ? null : targetBlock.getStateFromMeta(targetMeta));
|
||||
List<BlockPos> coordsList = getBlocksToSwap(player.world, stack, state, bPos, target);
|
||||
for(BlockPos coords : coordsList)
|
||||
if(coords.equals(bPos)) {
|
||||
coordsList.remove(coords);
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
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.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -31,8 +32,8 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class ItemSkyDirtRod extends ItemDirtRod {
|
||||
|
||||
public ItemSkyDirtRod() {
|
||||
super(LibItemNames.SKY_DIRT_ROD);
|
||||
public ItemSkyDirtRod(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -53,7 +54,8 @@ public class ItemSkyDirtRod extends ItemDirtRod {
|
||||
if(entities == 0) {
|
||||
ItemStack stackToPlace = new ItemStack(Blocks.DIRT);
|
||||
player.setHeldItem(hand, stackToPlace);
|
||||
stackToPlace.onItemUse(player, world, new BlockPos(x, y, z), hand, EnumFacing.DOWN, 0F, 0F, 0F);
|
||||
ItemUseContext ctx = new ItemUseContext(player, stackToPlace, new BlockPos(x, y, z), EnumFacing.DOWN, 0, 0, 0);
|
||||
stackToPlace.onItemUse(ctx);
|
||||
player.setHeldItem(hand, stack);
|
||||
|
||||
if(stackToPlace.isEmpty()) {
|
||||
|
||||
@@ -22,10 +22,13 @@ import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.Tag;
|
||||
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.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -38,32 +41,22 @@ import vazkii.botania.api.subtile.ISpecialFlower;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.item.ItemMod;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemTerraformRod extends ItemMod implements IManaUsingItem, IBlockProvider {
|
||||
|
||||
private static final Tag<Block> TERRAFORMABLE = new BlockTags.Wrapper(new ResourceLocation(LibMisc.MOD_ID, "terraformable"));
|
||||
private static final int COST_PER = 55;
|
||||
|
||||
// todo 1.13 migrate rest of these
|
||||
private static final List<String> validBlocks = ImmutableList.of(
|
||||
"stone",
|
||||
"dirt",
|
||||
"grass",
|
||||
"sand",
|
||||
"gravel",
|
||||
"hardenedClay",
|
||||
"snowLayer",
|
||||
"mycelium",
|
||||
"podzol",
|
||||
"sandstone",
|
||||
"blockDiorite",
|
||||
"stoneDiorite",
|
||||
"blockGranite",
|
||||
"stoneGranite",
|
||||
"blockAndesite",
|
||||
"stoneAndesite",
|
||||
|
||||
// Mod support
|
||||
"marble",
|
||||
@@ -72,25 +65,24 @@ public class ItemTerraformRod extends ItemMod implements IManaUsingItem, IBlockP
|
||||
"blockLimestone"
|
||||
);
|
||||
|
||||
public ItemTerraformRod() {
|
||||
super(LibItemNames.TERRAFORM_ROD);
|
||||
setMaxStackSize(1);
|
||||
public ItemTerraformRod(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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUsingTick(ItemStack stack, EntityLivingBase living, int count) {
|
||||
if(count != getMaxItemUseDuration(stack) && count % 10 == 0 && living instanceof EntityPlayer)
|
||||
if(count != getUseDuration(stack) && count % 10 == 0 && living instanceof EntityPlayer)
|
||||
terraform(stack, living.world, (EntityPlayer) living);
|
||||
}
|
||||
|
||||
@@ -113,33 +105,33 @@ public class ItemTerraformRod extends ItemMod implements IManaUsingItem, IBlockP
|
||||
|
||||
for(BlockPos pos : BlockPos.getAllInBoxMutable(startCenter.add(-range, -range, -range), startCenter.add(range, range, range))) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
if(state.getBlock() == Blocks.AIR)
|
||||
if(state.isAir(world, pos))
|
||||
continue;
|
||||
else if(Item.getItemFromBlock(state.getBlock()) == Items.AIR)
|
||||
continue;
|
||||
int[] ids = OreDictionary.getOreIDs(new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)));
|
||||
for(int id : ids)
|
||||
if(validBlocks.contains(OreDictionary.getOreName(id))) {
|
||||
List<BlockPos> airBlocks = new ArrayList<>();
|
||||
|
||||
for(EnumFacing dir : EnumFacing.HORIZONTALS) {
|
||||
BlockPos pos_ = pos.offset(dir);
|
||||
Block block_ = world.getBlockState(pos_).getBlock();
|
||||
if(block_.isAir(world.getBlockState(pos_), world, pos_) || block_.isReplaceable(world, pos_) || block_ instanceof BlockFlower && !(block_ instanceof ISpecialFlower) || block_ == Blocks.DOUBLE_PLANT) {
|
||||
airBlocks.add(pos_);
|
||||
}
|
||||
}
|
||||
if(TERRAFORMABLE.contains(state.getBlock())) {
|
||||
List<BlockPos> airBlocks = new ArrayList<>();
|
||||
|
||||
if(!airBlocks.isEmpty()) {
|
||||
if(pos.getY() > startCenter.getY())
|
||||
blocks.add(new CoordsWithBlock(pos, Blocks.AIR));
|
||||
else for(BlockPos coords : airBlocks) {
|
||||
if(world.getBlockState(coords.down()).getBlock() != Blocks.AIR)
|
||||
blocks.add(new CoordsWithBlock(coords, Blocks.DIRT));
|
||||
}
|
||||
for(EnumFacing dir : EnumFacing.BY_HORIZONTAL_INDEX) {
|
||||
BlockPos pos_ = pos.offset(dir);
|
||||
IBlockState state_ = world.getBlockState(pos_);
|
||||
Block block_ = state_.getBlock();
|
||||
if(state_.isAir(world, pos_) || block_.isReplaceable(state_, world, pos_)
|
||||
|| block_ instanceof BlockFlower && !(block_ instanceof ISpecialFlower)
|
||||
|| block_ == Blocks.DOUBLE_PLANT) {
|
||||
airBlocks.add(pos_);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(!airBlocks.isEmpty()) {
|
||||
if(pos.getY() > startCenter.getY())
|
||||
blocks.add(new CoordsWithBlock(pos, Blocks.AIR));
|
||||
else for(BlockPos coords : airBlocks) {
|
||||
if(world.getBlockState(coords.down()).getBlock() != Blocks.AIR)
|
||||
blocks.add(new CoordsWithBlock(coords, Blocks.DIRT));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int cost = COST_PER * blocks.size();
|
||||
|
||||
@@ -14,7 +14,9 @@ public final class LibItemNames {
|
||||
|
||||
public static final String LEXICON = "lexicon";
|
||||
public static final String PETAL = "petal";
|
||||
public static final String PETAL_SUFFIX = "_" + PETAL;
|
||||
public static final String DYE = "dye";
|
||||
public static final String DYE_SUFFIX = "_" + DYE;
|
||||
public static final String PESTLE_AND_MORTAR = "pestleandmortar";
|
||||
public static final String TWIG_WAND = "twigwand";
|
||||
public static final String[] RUNE_NAMES = {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"#forge:stone",
|
||||
"#forge:dirt",
|
||||
"minecraft:grass_block",
|
||||
"#minecraft:sand",
|
||||
"minecraft:gravel",
|
||||
"minecraft:snow",
|
||||
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user