Allows to mark areas and path on top of specific locations.

Generalization of #1882
This commit is contained in:
SpaceToad 2014-06-15 03:28:35 +02:00
parent 44d4e4e3b9
commit 254a533060
12 changed files with 192 additions and 194 deletions

View file

@ -150,7 +150,7 @@ item.blueprint.blank=Blank
item.blueprint.creative_only=Creative Only
item.blueprint.no_build=No Building
item.blueprint.incomplete=Incomplete
item.mapSpot.name=Map Spot
item.mapLocation.name=Map Location
item.PipeItemsWood.name=Wooden Transport Pipe
item.PipeItemsCobblestone.name=Cobblestone Transport Pipe
item.PipeItemsStone.name=Stone Transport Pipe

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 253 B

View file

@ -74,7 +74,7 @@ import buildcraft.core.CoreIconProvider;
import buildcraft.core.DefaultProps;
import buildcraft.core.InterModComms;
import buildcraft.core.ItemBuildCraft;
import buildcraft.core.ItemMapSpot;
import buildcraft.core.ItemMapLocation;
import buildcraft.core.ItemSpring;
import buildcraft.core.ItemWrench;
import buildcraft.core.SpringPopulate;
@ -137,7 +137,7 @@ public class BuildCraftCore extends BuildCraftMod {
public static Item goldGearItem;
public static Item diamondGearItem;
public static Item wrenchItem;
public static Item mapSpotItem;
public static Item mapLocationItem;
@SideOnly(Side.CLIENT)
public static IIcon redLaserTexture;
@SideOnly(Side.CLIENT)
@ -258,8 +258,8 @@ public class BuildCraftCore extends BuildCraftMod {
wrenchItem = (new ItemWrench()).setUnlocalizedName("wrenchItem");
CoreProxy.proxy.registerItem(wrenchItem);
mapSpotItem = (new ItemMapSpot()).setUnlocalizedName("mapSpot");
CoreProxy.proxy.registerItem(mapSpotItem);
mapLocationItem = (new ItemMapLocation()).setUnlocalizedName("mapLocation");
CoreProxy.proxy.registerItem(mapLocationItem);
Property modifyWorldProp = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "modifyWorld", true);
modifyWorldProp.comment = "set to false if BuildCraft should not generate custom blocks (e.g. oil)";
@ -394,7 +394,7 @@ public class BuildCraftCore extends BuildCraftMod {
CoreProxy.proxy.addCraftingRecipe(new ItemStack(ironGearItem), " I ", "IGI", " I ", 'I', Items.iron_ingot, 'G', stoneGearItem);
CoreProxy.proxy.addCraftingRecipe(new ItemStack(goldGearItem), " I ", "IGI", " I ", 'I', Items.gold_ingot, 'G', ironGearItem);
CoreProxy.proxy.addCraftingRecipe(new ItemStack(diamondGearItem), " I ", "IGI", " I ", 'I', Items.diamond, 'G', goldGearItem);
CoreProxy.proxy.addCraftingRecipe(new ItemStack(mapSpotItem), "ppp", "pYp", "ppp", 'p', Items.paper, 'Y', new ItemStack(Items.dye, 1, 11));
CoreProxy.proxy.addCraftingRecipe(new ItemStack(mapLocationItem), "ppp", "pYp", "ppp", 'p', Items.paper, 'Y', new ItemStack(Items.dye, 1, 11));
}
@Mod.EventHandler

View file

@ -25,6 +25,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.BuildCraftCore;
import buildcraft.core.CreativeTabBuildCraft;
import buildcraft.core.ItemMapLocation;
import buildcraft.core.utils.Utils;
public class BlockMarker extends BlockContainer {
@ -88,6 +89,11 @@ public class BlockMarker extends BlockContainer {
@Override
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) {
if (entityplayer.inventory.getCurrentItem() != null
&& entityplayer.inventory.getCurrentItem().getItem() instanceof ItemMapLocation) {
return false;
}
TileEntity tile = world.getTileEntity(i, j, k);
if (tile instanceof TileMarker) {
((TileMarker) tile).tryConnection();

View file

@ -1,93 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.boards.RedstoneBoardRegistry;
import buildcraft.core.utils.NBTUtils;
import buildcraft.core.utils.StringUtils;
public class ItemLocation extends ItemBuildCraft {
public IIcon cleanLocation;
public IIcon usedLocation;
public ItemLocation() {
super(CreativeTabBuildCraft.ITEMS);
}
@Override
public int getItemStackLimit(ItemStack stack) {
return NBTUtils.getItemData(stack).hasKey("x") ? 1 : 16;
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) {
NBTTagCompound cpt = NBTUtils.getItemData(stack);
if (cpt.hasKey("x")) {
int x = cpt.getInteger("x");
int y = cpt.getInteger("y");
int z = cpt.getInteger("z");
ForgeDirection side = ForgeDirection.values()[cpt.getByte("side")];
list.add(StringUtils.localize("{" + x + ", " + y + ", " + z + ", " + side + "}"));
}
}
@Override
public IIcon getIconIndex(ItemStack stack) {
NBTTagCompound cpt = NBTUtils.getItemData(stack);
if (!cpt.hasKey("x")) {
itemIcon = cleanLocation;
} else {
itemIcon = usedLocation;
}
return itemIcon;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister par1IconRegister) {
cleanLocation = par1IconRegister.registerIcon("buildcraft:location_clean");
usedLocation = par1IconRegister.registerIcon("buildcraft:location_used");
RedstoneBoardRegistry.instance.registerIcons(par1IconRegister);
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer par2EntityPlayer, World par3World, int x,
int y, int z, int side, float par8, float par9, float par10) {
NBTTagCompound cpt = NBTUtils.getItemData(stack);
cpt.setInteger("x", x);
cpt.setInteger("y", y);
cpt.setInteger("z", z);
cpt.setByte("side", (byte) side);
return true;
}
}

View file

@ -0,0 +1,178 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.boards.RedstoneBoardRegistry;
import buildcraft.api.core.BlockIndex;
import buildcraft.builders.TileMarker;
import buildcraft.builders.TilePathMarker;
import buildcraft.core.utils.NBTUtils;
import buildcraft.core.utils.StringUtils;
public class ItemMapLocation extends ItemBuildCraft {
public IIcon clean;
public IIcon spot;
public IIcon area;
public IIcon path;
public ItemMapLocation() {
super(CreativeTabBuildCraft.ITEMS);
}
@Override
public int getItemStackLimit(ItemStack stack) {
return NBTUtils.getItemData(stack).hasKey("kind") ? 1 : 16;
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) {
NBTTagCompound cpt = NBTUtils.getItemData(stack);
if (!cpt.hasKey("kind")) {
} else {
switch (cpt.getByte("kind")) {
case 0: {
int x = cpt.getInteger("x");
int y = cpt.getInteger("y");
int z = cpt.getInteger("z");
ForgeDirection side = ForgeDirection.values()[cpt.getByte("side")];
list.add(StringUtils.localize("{" + x + ", " + y + ", " + z + ", " + side + "}"));
break;
}
case 1: {
int x = cpt.getInteger("xMin");
int y = cpt.getInteger("yMin");
int z = cpt.getInteger("zMin");
int xLength = cpt.getInteger("xMax") - x + 1;
int yLength = cpt.getInteger("yMax") - y + 1;
int zLength = cpt.getInteger("zMax") - z + 1;
list.add(StringUtils.localize("{" + x + ", " + y + ", " + z + "} + {" + xLength + " x " + yLength + " x " + zLength + "}"));
break;
}
case 2: {
NBTTagList pathNBT = cpt.getTagList("path", Constants.NBT.TAG_COMPOUND);
BlockIndex first = new BlockIndex(pathNBT.getCompoundTagAt(0));
int x = first.x;
int y = first.y;
int z = first.z;
list.add(StringUtils.localize("{" + x + ", " + y + ", " + z + "} + " + pathNBT.tagCount() + " elements"));
break;
}
}
}
if (cpt.hasKey("kind")) {
}
}
@Override
public IIcon getIconIndex(ItemStack stack) {
NBTTagCompound cpt = NBTUtils.getItemData(stack);
if (!cpt.hasKey("kind")) {
itemIcon = clean;
} else {
switch (cpt.getByte("kind")) {
case 0:
itemIcon = spot;
break;
case 1:
itemIcon = area;
break;
case 2:
itemIcon = path;
break;
}
}
return itemIcon;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister par1IconRegister) {
clean = par1IconRegister.registerIcon("buildcraft:map_clean");
spot = par1IconRegister.registerIcon("buildcraft:map_spot");
area = par1IconRegister.registerIcon("buildcraft:map_area");
path = par1IconRegister.registerIcon("buildcraft:map_path");
RedstoneBoardRegistry.instance.registerIcons(par1IconRegister);
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer par2EntityPlayer, World world, int x,
int y, int z, int side, float par8, float par9, float par10) {
TileEntity tile = world.getTileEntity(x, y, z);
NBTTagCompound cpt = NBTUtils.getItemData(stack);
if (tile instanceof TilePathMarker) {
cpt.setByte("kind", (byte) 2);
TilePathMarker pathTile = (TilePathMarker) tile;
NBTTagList pathNBT = new NBTTagList();
for (BlockIndex index : pathTile.getPath()) {
NBTTagCompound nbt = new NBTTagCompound();
index.writeTo(nbt);
pathNBT.appendTag(nbt);
}
cpt.setTag("path", pathNBT);
} else if (tile instanceof TileMarker) {
cpt.setByte("kind", (byte) 1);
TileMarker areaTile = (TileMarker) tile;
cpt.setInteger("xMin", areaTile.xMin());
cpt.setInteger("yMin", areaTile.yMin());
cpt.setInteger("zMin", areaTile.zMin());
cpt.setInteger("xMax", areaTile.xMax());
cpt.setInteger("yMax", areaTile.yMax());
cpt.setInteger("zMax", areaTile.zMax());
} else {
cpt.setByte("kind", (byte) 0);
cpt.setByte("side", (byte) side);
cpt.setInteger("x", x);
cpt.setInteger("y", y);
cpt.setInteger("z", z);
}
return true;
}
}

View file

@ -1,93 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.boards.RedstoneBoardRegistry;
import buildcraft.core.utils.NBTUtils;
import buildcraft.core.utils.StringUtils;
public class ItemMapSpot extends ItemBuildCraft {
public IIcon cleanSpot;
public IIcon usedSpot;
public ItemMapSpot() {
super(CreativeTabBuildCraft.ITEMS);
}
@Override
public int getItemStackLimit(ItemStack stack) {
return NBTUtils.getItemData(stack).hasKey("x") ? 1 : 16;
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) {
NBTTagCompound cpt = NBTUtils.getItemData(stack);
if (cpt.hasKey("x")) {
int x = cpt.getInteger("x");
int y = cpt.getInteger("y");
int z = cpt.getInteger("z");
ForgeDirection side = ForgeDirection.values()[cpt.getByte("side")];
list.add(StringUtils.localize("{" + x + ", " + y + ", " + z + ", " + side + "}"));
}
}
@Override
public IIcon getIconIndex(ItemStack stack) {
NBTTagCompound cpt = NBTUtils.getItemData(stack);
if (!cpt.hasKey("x")) {
itemIcon = cleanSpot;
} else {
itemIcon = usedSpot;
}
return itemIcon;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister par1IconRegister) {
cleanSpot = par1IconRegister.registerIcon("buildcraft:map_spot_clean");
usedSpot = par1IconRegister.registerIcon("buildcraft:map_spot_used");
RedstoneBoardRegistry.instance.registerIcons(par1IconRegister);
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer par2EntityPlayer, World par3World, int x,
int y, int z, int side, float par8, float par9, float par10) {
NBTTagCompound cpt = NBTUtils.getItemData(stack);
cpt.setInteger("x", x);
cpt.setInteger("y", y);
cpt.setInteger("z", z);
cpt.setByte("side", (byte) side);
return true;
}
}

View file

@ -53,7 +53,7 @@ import buildcraft.api.transport.PipeWire;
import buildcraft.core.BlockBuildCraft;
import buildcraft.core.CoreConstants;
import buildcraft.core.CreativeTabBuildCraft;
import buildcraft.core.ItemMapSpot;
import buildcraft.core.ItemMapLocation;
import buildcraft.core.ItemRobot;
import buildcraft.core.TileBuffer;
import buildcraft.core.robots.DockingStation;
@ -750,7 +750,7 @@ public class BlockGenericPipe extends BlockBuildCraft {
// Only check the instance at this point. Call the IToolWrench
// interface callbacks for the individual pipe/logic calls
return pipe.blockActivated(player);
} else if (currentItem.getItem() instanceof ItemMapSpot) {
} else if (currentItem.getItem() instanceof ItemMapLocation) {
// We want to be able to record pipe locations
return false;
} else if (PipeWire.RED.isPipeWire(currentItem)) {