diff --git a/src/main/java/com/hbm/blocks/ModBlocks.java b/src/main/java/com/hbm/blocks/ModBlocks.java index 2e4a6cda9..75c4fd2ae 100644 --- a/src/main/java/com/hbm/blocks/ModBlocks.java +++ b/src/main/java/com/hbm/blocks/ModBlocks.java @@ -887,6 +887,7 @@ public class ModBlocks { public static Block cm_circuit; public static Block cm_port; public static Block custom_machine; + public static Block cm_anchor; public static Block pwr_fuel; public static Block pwr_control; @@ -2060,6 +2061,7 @@ public class ModBlocks { cm_circuit = new BlockCM(Material.iron, EnumCMCircuit.class, true, true).setBlockName("cm_circuit").setCreativeTab(MainRegistry.machineTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":cm_circuit"); cm_port = new BlockCMPort(Material.iron, EnumCMMaterials.class, true, true).setBlockName("cm_port").setCreativeTab(MainRegistry.machineTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":cm_port"); custom_machine = new BlockCustomMachine().setBlockName("custom_machine").setCreativeTab(MainRegistry.machineTab).setLightLevel(1F).setHardness(5.0F).setResistance(10.0F); + cm_anchor = new BlockCMAnchor().setBlockName("custom_machine_anchor").setCreativeTab(MainRegistry.machineTab).setHardness(5.0F).setResistance(10.0F); pwr_fuel = new BlockPillarPWR(Material.iron, RefStrings.MODID + ":pwr_fuel_top").setBlockName("pwr_fuel").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":pwr_fuel_side"); pwr_control = new BlockPillarPWR(Material.iron, RefStrings.MODID + ":pwr_control_top").setBlockName("pwr_control").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":pwr_control_side"); @@ -3418,6 +3420,7 @@ public class ModBlocks { register(cm_tank); register(cm_circuit); register(cm_port); + register(cm_anchor); //PWR register(pwr_fuel); diff --git a/src/main/java/com/hbm/blocks/machine/BlockCMAnchor.java b/src/main/java/com/hbm/blocks/machine/BlockCMAnchor.java new file mode 100644 index 000000000..bafa683a3 --- /dev/null +++ b/src/main/java/com/hbm/blocks/machine/BlockCMAnchor.java @@ -0,0 +1,43 @@ +package com.hbm.blocks.machine; + +import com.hbm.lib.RefStrings; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class BlockCMAnchor extends Block { + @SideOnly(Side.CLIENT) + private IIcon iconFront; + + public BlockCMAnchor() { + super(Material.iron); + } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + this.iconFront = iconRegister.registerIcon(RefStrings.MODID + ":cm_terminal_front"); + this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":cm_terminal_side"); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int metadata) { + return metadata == 0 && side == 3 ? this.iconFront : (side == metadata ? this.iconFront : this.blockIcon); + } + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) { + int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + + if(i == 0) world.setBlockMetadataWithNotify(x, y, z, 2, 2); + if(i == 1) world.setBlockMetadataWithNotify(x, y, z, 5, 2); + if(i == 2) world.setBlockMetadataWithNotify(x, y, z, 3, 2); + if(i == 3) world.setBlockMetadataWithNotify(x, y, z, 4, 2); + } +} diff --git a/src/main/java/com/hbm/items/ModItems.java b/src/main/java/com/hbm/items/ModItems.java index a080abd59..a0d8adc7b 100644 --- a/src/main/java/com/hbm/items/ModItems.java +++ b/src/main/java/com/hbm/items/ModItems.java @@ -2213,6 +2213,7 @@ public class ModItems { public static Item structure_pattern; public static Item structure_randomized; public static Item structure_randomly; + public static Item structure_custommachine; public static Item rod_of_discord; @@ -4482,7 +4483,8 @@ public class ModItems { structure_pattern = new ItemStructurePattern().setUnlocalizedName("structure_pattern").setMaxStackSize(1).setCreativeTab(null).setFull3D().setTextureName(RefStrings.MODID + ":structure_pattern"); structure_randomized = new ItemStructureRandomized().setUnlocalizedName("structure_randomized").setMaxStackSize(1).setCreativeTab(null).setFull3D().setTextureName(RefStrings.MODID + ":structure_randomized"); structure_randomly = new ItemStructureRandomly().setUnlocalizedName("structure_randomly").setMaxStackSize(1).setCreativeTab(null).setFull3D().setTextureName(RefStrings.MODID + ":structure_randomly"); - + structure_custommachine = new ItemCMStructure().setUnlocalizedName("structure_custommachine").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setFull3D().setTextureName(RefStrings.MODID + ":structure_custommachine"); + rod_of_discord = new ItemDiscord().setUnlocalizedName("rod_of_discord").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setFull3D().setTextureName(RefStrings.MODID + ":rod_of_discord"); nuke_starter_kit = new ItemStarterKit().setUnlocalizedName("nuke_starter_kit").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":nuke_starter_kit"); @@ -7942,6 +7944,7 @@ public class ModItems { GameRegistry.registerItem(structure_pattern, structure_pattern.getUnlocalizedName()); GameRegistry.registerItem(structure_randomized, structure_randomized.getUnlocalizedName()); GameRegistry.registerItem(structure_randomly, structure_randomly.getUnlocalizedName()); + GameRegistry.registerItem(structure_custommachine, structure_custommachine.getUnlocalizedName()); GameRegistry.registerItem(rod_of_discord, rod_of_discord.getUnlocalizedName()); //GameRegistry.registerItem(analyzer, analyzer.getUnlocalizedName()); //GameRegistry.registerItem(remote, remote.getUnlocalizedName()); diff --git a/src/main/java/com/hbm/items/tool/ItemCMStructure.java b/src/main/java/com/hbm/items/tool/ItemCMStructure.java new file mode 100644 index 000000000..cb72b7d3c --- /dev/null +++ b/src/main/java/com/hbm/items/tool/ItemCMStructure.java @@ -0,0 +1,172 @@ +package com.hbm.items.tool; + +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import com.google.gson.stream.JsonWriter; +import com.hbm.blocks.ILookOverlay; +import com.hbm.blocks.ModBlocks; +import com.hbm.main.MainRegistry; +import com.hbm.util.fauxpointtwelve.BlockPos; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.common.util.ForgeDirection; + +import java.io.File; +import java.io.FileWriter; +import java.util.ArrayList; +import java.util.List; + +public class ItemCMStructure extends Item implements ILookOverlay { + File file = new File(MainRegistry.configHbmDir, "CMstructureOutput.txt"); + public static BlockPos getAnchor(ItemStack stack) { + + if(!stack.hasTagCompound()) { + return null; + } + + return new BlockPos(stack.stackTagCompound.getInteger("anchorX"), stack.stackTagCompound.getInteger("anchorY"), stack.stackTagCompound.getInteger("anchorZ")); + } + public static void setAnchor(ItemStack stack, int x, int y, int z) { + + if(stack.stackTagCompound == null) { + stack.stackTagCompound = new NBTTagCompound(); + } + + stack.stackTagCompound.setInteger("anchorX", x); + stack.stackTagCompound.setInteger("anchorY", y); + stack.stackTagCompound.setInteger("anchorZ", z); + } + public static void writeToFile(File config,ItemStack stack,World world){ + int anchorX = stack.stackTagCompound.getInteger("anchorX"); + int anchorY = stack.stackTagCompound.getInteger("anchorY"); + int anchorZ = stack.stackTagCompound.getInteger("anchorZ"); + int x1=stack.stackTagCompound.getInteger("x1"); + int y1=stack.stackTagCompound.getInteger("y1"); + int z1=stack.stackTagCompound.getInteger("z1"); + int x2=stack.stackTagCompound.getInteger("x2"); + int y2=stack.stackTagCompound.getInteger("y2"); + int z2=stack.stackTagCompound.getInteger("z2"); + ForgeDirection dir = ForgeDirection.getOrientation(world.getBlockMetadata(anchorX,anchorY,anchorZ)); + //ForgeDirection rot = dir.getRotation(ForgeDirection.UP); + int z=z1;z1=z text = new ArrayList(); + + BlockPos anchor = getAnchor(stack); + + if(anchor == null) { + + text.add(EnumChatFormatting.RED + "No Anchor"); + } else { + int anchorX = stack.stackTagCompound.getInteger("anchorX"); + int anchorY = stack.stackTagCompound.getInteger("anchorY"); + int anchorZ = stack.stackTagCompound.getInteger("anchorZ"); + text.add(EnumChatFormatting.GOLD + "Anchor: " + anchorX + " / " + anchorY + " / " + anchorZ); + if(stack.stackTagCompound.hasKey("x1")){ + int x1=stack.stackTagCompound.getInteger("x1"); + int y1=stack.stackTagCompound.getInteger("y1"); + int z1=stack.stackTagCompound.getInteger("z1"); + + text.add(EnumChatFormatting.YELLOW + "Position1: " + x1 + " / " + y1 + " / " + z1); + } + if(stack.stackTagCompound.hasKey("x2")) { + int x2=stack.stackTagCompound.getInteger("x2"); + int y2=stack.stackTagCompound.getInteger("y2"); + int z2=stack.stackTagCompound.getInteger("z2"); + text.add(EnumChatFormatting.YELLOW + "Position2: " + x2 + " / " + y2 + " / " + z2); + } + } + + ILookOverlay.printGeneric(event, this.getItemStackDisplayName(stack), 0xffff00, 0x404000, text); + } +} diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index be8530bcf..c44050231 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -4236,6 +4236,7 @@ item.volcanic_pickaxe.name=Molten Pickaxe item.wand_d.name=Debug Wand item.wand_k.name=Construction Wand item.wand_s.name=Structure Wand +item.structure_custommachine.name=Custom Machine Structure Output Wand item.warhead_buster_large.name=Large Bunker Buster Warhead item.warhead_buster_medium.name=Medium Bunker Buster Warhead item.warhead_buster_small.name=Small Bunker Buster Warhead @@ -4638,6 +4639,7 @@ tile.cluster_depth_titanium.name=Depth Titanium Ore Cluster tile.cluster_depth_tungsten.name=Depth Tungsten Ore Cluster tile.cluster_iron.name=Iron Ore Cluster tile.cluster_titanium.name=Titanium Ore Cluster +tile.custom_machine_anchor.name=Custom Machine Structure Positioning Anchor tile.cm_block.alloy.name=Advanced Alloy Machine Casing tile.cm_block.desh.name=Desh Machine Casing tile.cm_block.steel.name=Steel Machine Casing diff --git a/src/main/resources/assets/hbm/textures/items/structure_custommachine.png b/src/main/resources/assets/hbm/textures/items/structure_custommachine.png new file mode 100644 index 000000000..3f95a0a78 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/items/structure_custommachine.png differ