Added creative node creators for all node types

This commit is contained in:
makeo committed 2015-11-04 20:55:39 +01:00
1 parent d0eb1fd087
commit 33cdd7ef3d
5 files changed
+76 -17

No files matched your search

@@ -1,18 +1,22 @@
package makeo.gadomancy.common.items;
import makeo.gadomancy.common.blocks.tiles.TileExtendedNode;
import makeo.gadomancy.common.registration.RegisteredItems;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import org.apache.logging.log4j.LogManager;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.nodes.NodeModifier;
import thaumcraft.api.nodes.NodeType;
import thaumcraft.common.blocks.BlockAiry;
import thaumcraft.common.config.ConfigBlocks;
import thaumcraft.common.tiles.TileNode;
import thaumcraft.common.lib.world.ThaumcraftWorldGenerator;
import java.util.List;
@@ -27,11 +31,19 @@ import java.util.List;
public class ItemCreativeNode extends Item {
public ItemCreativeNode() {
setCreativeTab(RegisteredItems.creativeTab);
setUnlocalizedName("nodePlacer");
}
@Override
public String getUnlocalizedName(ItemStack stack) {
return super.getUnlocalizedName(stack) + "." + stack.getItemDamage();
public void getSubItems(Item item, CreativeTabs tab, List list) {
for(int i = 0; i < NodeType.values().length; i++) {
list.add(new ItemStack(item, 1, i));
}
}
@Override
public String getUnlocalizedNameInefficiently(ItemStack stack) {
return Item.getItemFromBlock(ConfigBlocks.blockAiry).getUnlocalizedName(new ItemStack(ConfigBlocks.blockAiry, 1, 0));
}
@Override
@@ -43,7 +55,7 @@ public class ItemCreativeNode extends Item {
if(placeRandomNode(world, x, y, z)) {
int metadata = stack.getItemDamage();
TileNode node = (TileNode) world.getTileEntity(x, y, z);
TileExtendedNode node = (TileExtendedNode) world.getTileEntity(x, y, z);
if(metadata == 0) {
node.setNodeType(NodeType.NORMAL);
@@ -51,29 +63,36 @@ public class ItemCreativeNode extends Item {
AspectList aspects = new AspectList();
for(Aspect primal : Aspect.getPrimalAspects()) {
aspects.add(primal, 10000);
aspects.add(primal, 500);
}
node.setAspects(aspects);
node.markDirty();
world.markBlockForUpdate(x, y, z);
} else {
node.setNodeType(NodeType.values()[metadata]);
}
return true;
}
return false;
}
private boolean placeRandomNode(World world, int x, int y, int z) {
return world.getBlock(x, y, z) == Blocks.air && world.setBlock(x, y, z, ConfigBlocks.blockAiry);
if(world.getBlock(x, y, z) == Blocks.air) {
ThaumcraftWorldGenerator.createRandomNodeAt(world, x, y, z, world.rand, false, false, false);
return world.getBlock(x, y, z) == ConfigBlocks.blockAiry;
}
return false;
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advancedItemTooltips) {
int metadata = stack.getItemDamage();
if(metadata == 0) {
list.add("\u00a75Place a huge and bright aura node");
} else {
list.add("\u00a75Place a node of type " + NodeType.values()[metadata].name().toLowerCase());
}
list.add("\u00a7oCreative Mode Only");
}
}