structure analysis wands

This commit is contained in:
Boblet 2022-09-15 14:09:47 +02:00
parent 48fc913ac2
commit 896b91d960
11 changed files with 276 additions and 2 deletions

View File

@ -56,6 +56,7 @@ public class ModBlocks {
public static Block test_rail;
public static Block test_bb_bork;
public static Block test_bb_inf;
public static Block structure_anchor;
public static Block ore_uranium;
public static Block ore_uranium_scorched;
@ -1310,6 +1311,7 @@ public class ModBlocks {
test_rail = new TestRail(Material.iron).setBlockName("test_rail").setCreativeTab(null).setHardness(2.5F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":test_rail");
test_bb_bork = new TestBB(Material.iron).setBlockName("test_bb_bork").setCreativeTab(null).setHardness(2.5F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":test_bb_bork");
test_bb_inf = new TestBB(Material.iron).setBlockName("test_bb_inf").setCreativeTab(null).setHardness(2.5F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":test_bb_inf");
structure_anchor = new BlockGeneric(Material.iron).setBlockName("structure_anchor").setCreativeTab(null).setHardness(2.5F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":structure_anchor");
ore_uranium = new BlockOutgas(Material.rock, true, 5, true).setBlockName("ore_uranium").setCreativeTab(MainRegistry.blockTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":ore_uranium");
ore_uranium_scorched = new BlockOutgas(Material.rock, true, 5, true).setBlockName("ore_uranium_scorched").setCreativeTab(MainRegistry.blockTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":ore_uranium_scorched");
@ -2383,6 +2385,7 @@ public class ModBlocks {
GameRegistry.registerBlock(test_rail, test_rail.getUnlocalizedName());
GameRegistry.registerBlock(test_bb_bork, test_bb_bork.getUnlocalizedName());
GameRegistry.registerBlock(test_bb_inf, test_bb_inf.getUnlocalizedName());
GameRegistry.registerBlock(structure_anchor, structure_anchor.getUnlocalizedName());
//Ores
GameRegistry.registerBlock(ore_uranium, ore_uranium.getUnlocalizedName());

View File

@ -2309,6 +2309,10 @@ public class ModItems {
public static Item wand_s;
public static Item wand_d;
public static Item structure_single;
public static Item structure_solid;
public static Item structure_pattern;
public static Item rod_of_discord;
public static Item cape_test;
@ -4732,6 +4736,10 @@ public class ModItems {
wand = new ItemWand().setUnlocalizedName("wand_k").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setFull3D().setTextureName(RefStrings.MODID + ":wand");
wand_s = new ItemWandS().setUnlocalizedName("wand_s").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setFull3D().setTextureName(RefStrings.MODID + ":wand_s");
wand_d = new ItemWandD().setUnlocalizedName("wand_d").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setFull3D().setTextureName(RefStrings.MODID + ":wand_d");
structure_single = new ItemStructureSingle().setUnlocalizedName("structure_single").setMaxStackSize(1).setCreativeTab(null).setFull3D().setTextureName(RefStrings.MODID + ":structure_single");
structure_solid = new ItemStructureSolid().setUnlocalizedName("structure_solid").setMaxStackSize(1).setCreativeTab(null).setFull3D().setTextureName(RefStrings.MODID + ":structure_solid");
structure_pattern = new ItemStructurePattern().setUnlocalizedName("structure_pattern").setMaxStackSize(1).setCreativeTab(null).setFull3D().setTextureName(RefStrings.MODID + ":structure_pattern");
rod_of_discord = new ItemDiscord().setUnlocalizedName("rod_of_discord").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setFull3D().setTextureName(RefStrings.MODID + ":rod_of_discord");
@ -8097,6 +8105,9 @@ public class ModItems {
GameRegistry.registerItem(wand, wand.getUnlocalizedName());
GameRegistry.registerItem(wand_s, wand_s.getUnlocalizedName());
GameRegistry.registerItem(wand_d, wand_d.getUnlocalizedName());
GameRegistry.registerItem(structure_single, structure_single.getUnlocalizedName());
GameRegistry.registerItem(structure_solid, structure_solid.getUnlocalizedName());
GameRegistry.registerItem(structure_pattern, structure_pattern.getUnlocalizedName());
GameRegistry.registerItem(rod_of_discord, rod_of_discord.getUnlocalizedName());
//GameRegistry.registerItem(analyzer, analyzer.getUnlocalizedName());
//GameRegistry.registerItem(remote, remote.getUnlocalizedName());

View File

@ -0,0 +1,56 @@
package com.hbm.items.tool;
import java.util.List;
import com.hbm.util.fauxpointtwelve.BlockPos;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
public class ItemStructurePattern extends ItemStructureTool {
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
super.addInformation(stack, player, list, ext);
list.add(EnumChatFormatting.YELLOW + "Click to print all <placeBlockAtCurrentPosition>");
list.add(EnumChatFormatting.YELLOW + "lines for the current selection with blocks and metadata.");
}
@Override
protected boolean dualUse() {
return true;
}
@Override
protected void doTheThing(ItemStack stack, World world, int x, int y, int z) {
BlockPos pos = this.getAnchor(stack);
if(pos == null) return;
int savedX = stack.stackTagCompound.getInteger("x");
int savedY = stack.stackTagCompound.getInteger("y");
int savedZ = stack.stackTagCompound.getInteger("z");
int minX = Math.min(savedX, x) - pos.getX();
int minY = Math.min(savedY, y) - pos.getY();
int minZ = Math.min(savedZ, z) - pos.getZ();
int maxX = Math.max(savedX, x) - pos.getX();
int maxY = Math.max(savedY, y) - pos.getY();
int maxZ = Math.max(savedZ, z) - pos.getZ();
for(int ix = minX; ix <= maxX; ix++) {
for(int iy = minX; iy <= maxY; iy++) {
for(int iz = minX; iz <= maxZ; iz++) {
Block b = world.getBlock(ix + pos.getX(), iy + pos.getY(), iz + pos.getZ());
int meta = world.getBlockMetadata(ix + pos.getX(), iy + pos.getY(), iz + pos.getZ());
System.out.println("this.placeBlockAtCurrentPosition(world, " + b.getUnlocalizedName() + ", " + meta + ", " + ix + ", " + iy + ", " + iz + ", box)");
}
}
}
}
}

View File

@ -0,0 +1,37 @@
package com.hbm.items.tool;
import java.util.List;
import com.hbm.util.fauxpointtwelve.BlockPos;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
public class ItemStructureSingle extends ItemStructureTool {
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
super.addInformation(stack, player, list, ext);
list.add(EnumChatFormatting.YELLOW + "Click to print exactly one <placeBlockAtCurrentPosition>");
list.add(EnumChatFormatting.YELLOW + "line with the targted block and metadata");
}
@Override
protected void doTheThing(ItemStack stack, World world, int x, int y, int z) {
BlockPos pos = this.getAnchor(stack);
if(pos == null) return;
int ix = x - pos.getX();
int iy = y - pos.getX();
int iz = z - pos.getX();
Block b = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
System.out.println("this.placeBlockAtCurrentPosition(world, " + b.getUnlocalizedName() + ", " + meta + ", " + x + ", " + y + ", " + z + ", box)");
}
}

View File

@ -0,0 +1,45 @@
package com.hbm.items.tool;
import java.util.List;
import com.hbm.util.fauxpointtwelve.BlockPos;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
public class ItemStructureSolid extends ItemStructureTool {
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
super.addInformation(stack, player, list, ext);
list.add(EnumChatFormatting.YELLOW + "Click to print a <fillWithMetadataBlocks>");
list.add(EnumChatFormatting.YELLOW + "line with wildcard block and metadata.");
}
@Override
protected boolean dualUse() {
return true;
}
@Override
protected void doTheThing(ItemStack stack, World world, int x, int y, int z) {
BlockPos pos = this.getAnchor(stack);
if(pos == null) return;
int savedX = stack.stackTagCompound.getInteger("x");
int savedY = stack.stackTagCompound.getInteger("y");
int savedZ = stack.stackTagCompound.getInteger("z");
int minX = Math.min(savedX, x) - pos.getX();
int minY = Math.min(savedY, y) - pos.getY();
int minZ = Math.min(savedZ, z) - pos.getZ();
int maxX = Math.max(savedX, x) - pos.getX();
int maxY = Math.max(savedY, y) - pos.getY();
int maxZ = Math.max(savedZ, z) - pos.getZ();
System.out.println("this.fillWithMetadataBlocks(world, box, " + minX + ", " + minY + ", " + minZ + ", " + maxX + ", " + maxY + ", " + maxZ + ", <block>, <meta>, Blocks.air, 0, false)");
}
}

View File

@ -0,0 +1,116 @@
package com.hbm.items.tool;
import java.util.ArrayList;
import java.util.List;
import com.hbm.blocks.ILookOverlay;
import com.hbm.blocks.ModBlocks;
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.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.Pre;
public abstract class ItemStructureTool extends Item implements ILookOverlay {
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
BlockPos anchor = this.getAnchor(stack);
if(anchor == null) {
list.add(EnumChatFormatting.RED + "No anchor set! Right click an anchor to get started.");
}
}
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);
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
Block b = world.getBlock(x, y, z);
if(b == ModBlocks.structure_anchor) {
this.setAnchor(stack, x, y, z);
return true;
}
if(this.getAnchor(stack) == null) {
return false;
}
if(!this.dualUse()) {
this.doTheThing(stack, world, x, y, z);
} else {
if(!stack.stackTagCompound.hasKey("x")) {
stack.stackTagCompound.setInteger("x", x);
stack.stackTagCompound.setInteger("y", y);
stack.stackTagCompound.setInteger("z", z);
} else {
this.doTheThing(stack, world, x, y, z);
stack.stackTagCompound.removeTag("x");
stack.stackTagCompound.removeTag("y");
stack.stackTagCompound.removeTag("z");
}
}
return true;
}
protected boolean dualUse() {
return false;
}
protected abstract void doTheThing(ItemStack stack, World world, int x, int y, int z);
@Override
public void printHook(Pre event, World world, int x, int y, int z) {
ItemStack stack = Minecraft.getMinecraft().thePlayer.getHeldItem();
List<String> text = new ArrayList();
BlockPos anchor = getAnchor(stack);
if(anchor == null) {
text.add(EnumChatFormatting.RED + "No Anchor");
} else {
int dX = x - anchor.getX();
int dY = y - anchor.getY();
int dZ = z - anchor.getZ();
text.add(EnumChatFormatting.YELLOW + "Position: " + dX + " / " + dY + " / " + dZ);
if(this.dualUse() && stack.stackTagCompound.hasKey("x")) {
int sX = Math.abs(x - stack.stackTagCompound.getInteger("x")) + 1;
int sY = Math.abs(y - stack.stackTagCompound.getInteger("y")) + 1;
int sZ = Math.abs(z - stack.stackTagCompound.getInteger("z")) + 1;
text.add(EnumChatFormatting.GOLD + "Selection: " + sX + " / " + sY + " / " + sZ);
}
}
ILookOverlay.printGeneric(event, this.getItemStackDisplayName(stack), 0xffff00, 0x404000, text);
}
}

View File

@ -155,8 +155,14 @@ public class ModEventHandlerClient {
World world = mc.theWorld;
MovingObjectPosition mop = mc.objectMouseOver;
if(mop != null && mop.typeOfHit == mop.typeOfHit.BLOCK && world.getBlock(mop.blockX, mop.blockY, mop.blockZ) instanceof ILookOverlay) {
((ILookOverlay) world.getBlock(mop.blockX, mop.blockY, mop.blockZ)).printHook(event, world, mop.blockX, mop.blockY, mop.blockZ);
if(mop != null && mop.typeOfHit == mop.typeOfHit.BLOCK ) {
if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ILookOverlay) {
((ILookOverlay) player.getHeldItem().getItem()).printHook(event, world, mop.blockX, mop.blockY, mop.blockZ);
} else if(world.getBlock(mop.blockX, mop.blockY, mop.blockZ) instanceof ILookOverlay) {
((ILookOverlay) world.getBlock(mop.blockX, mop.blockY, mop.blockZ)).printHook(event, world, mop.blockX, mop.blockY, mop.blockZ);
}
}
/*if(mop != null && mop.typeOfHit == mop.typeOfHit.BLOCK) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B