added node placer item

This commit is contained in:
makeo committed 2015-11-04 17:06:15 +01:00
1 parent 0396d6cfab
commit eb6e23b5b4
2 files changed
+82 -6

No files matched your search

@@ -0,0 +1,79 @@
package makeo.gadomancy.common.items;
import makeo.gadomancy.common.registration.RegisteredItems;
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 thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.nodes.NodeModifier;
import thaumcraft.api.nodes.NodeType;
import thaumcraft.common.config.ConfigBlocks;
import thaumcraft.common.tiles.TileNode;
import java.util.List;
/**
* This class is part of the Gadomancy Mod
* Gadomancy is Open Source and distributed under the
* GNU LESSER GENERAL PUBLIC LICENSE
* for more read the LICENSE file
* <p/>
* Created by makeo @ 04.11.2015 09:57
*/
public class ItemCreativeNode extends Item {
public ItemCreativeNode() {
setCreativeTab(RegisteredItems.creativeTab);
}
@Override
public String getUnlocalizedName(ItemStack stack) {
return super.getUnlocalizedName(stack) + "." + stack.getItemDamage();
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
ForgeDirection dir = ForgeDirection.getOrientation(side);
x += dir.offsetX;
y += dir.offsetY;
z += dir.offsetZ;
if(placeRandomNode(world, x, y, z)) {
int metadata = stack.getItemDamage();
TileNode node = (TileNode) world.getTileEntity(x, y, z);
if(metadata == 0) {
node.setNodeType(NodeType.NORMAL);
node.setNodeModifier(NodeModifier.BRIGHT);
AspectList aspects = new AspectList();
for(Aspect primal : Aspect.getPrimalAspects()) {
aspects.add(primal, 10000);
}
node.setAspects(aspects);
node.markDirty();
world.markBlockForUpdate(x, y, z);
}
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);
}
@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");
}
list.add("\u00a7oCreative Mode Only");
}
}
@@ -2,12 +2,7 @@ package makeo.gadomancy.common.registration;
import cpw.mods.fml.common.registry.GameRegistry;
import makeo.gadomancy.common.Gadomancy;
import makeo.gadomancy.common.items.ItemExtendedNodeJar;
import makeo.gadomancy.common.items.ItemFakeGolemPlacer;
import makeo.gadomancy.common.items.ItemFakeGolemShield;
import makeo.gadomancy.common.items.ItemFakeModIcon;
import makeo.gadomancy.common.items.ItemGolemCoreBreak;
import makeo.gadomancy.common.items.ItemTransformationFocus;
import makeo.gadomancy.common.items.*;
import makeo.gadomancy.common.items.baubles.ItemFamiliar;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumRarity;
@@ -46,6 +41,7 @@ public class RegisteredItems {
public static Item itemGolemCoreBreak;
public static Item itemExtendedNodeJar;
public static Item itemFamiliar;
public static Item itemCreativeNode;
public static void preInit() {
creativeTab = new CreativeTabs(Gadomancy.MODID) {
@@ -75,6 +71,7 @@ public class RegisteredItems {
itemGolemCoreBreak = registerItem(new ItemGolemCoreBreak());
itemExtendedNodeJar = registerItem(new ItemExtendedNodeJar());
itemFamiliar = registerItem(new ItemFamiliar());
itemCreativeNode = registerItem(new ItemCreativeNode());
}
private static <T extends Item> T registerItem(T item, String name) {