fixed redstone board writing, #1732
This commit is contained in:
parent
d8d57e822f
commit
ce55fe5eb1
7 changed files with 56 additions and 12 deletions
|
@ -8,16 +8,28 @@
|
|||
*/
|
||||
package buildcraft.api.boards;
|
||||
|
||||
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 cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public interface IRedstoneBoardNBT {
|
||||
|
||||
String getID();
|
||||
|
||||
String getName(NBTTagCompound nbt);
|
||||
void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced);
|
||||
|
||||
IRedstoneBoard create(NBTTagCompound nbt);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void registerIcons(IIconRegister iconRegister);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
IIcon getIcon(NBTTagCompound nbt);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
package buildcraft.api.boards;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public abstract class RedstoneBoardRegistry {
|
||||
|
@ -19,4 +20,6 @@ public abstract class RedstoneBoardRegistry {
|
|||
public abstract void createRandomBoard(NBTTagCompound nbt);
|
||||
|
||||
public abstract IRedstoneBoardNBT getRedstoneBoard(NBTTagCompound nbt);
|
||||
|
||||
public abstract void registerIcons(IIconRegister par1IconRegister);
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ public class BuildCraftSilicon extends BuildCraftMod {
|
|||
addGateRecipe(80000, GateMaterial.DIAMOND, Chipset.DIAMOND, PipeWire.RED, PipeWire.BLUE, PipeWire.GREEN, PipeWire.YELLOW);
|
||||
|
||||
// ROBOTS AND BOARDS
|
||||
BuildcraftRecipes.assemblyTable.addRecipe(100000, new ItemStack(redstoneCrystal), new ItemStack(
|
||||
BuildcraftRecipes.assemblyTable.addRecipe(1000000, new ItemStack(redstoneCrystal), new ItemStack(
|
||||
Blocks.redstone_block));
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(redstoneBoard),
|
||||
|
|
|
@ -8,12 +8,17 @@
|
|||
*/
|
||||
package buildcraft.core.robots.boards;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
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 buildcraft.api.boards.IRedstoneBoard;
|
||||
import buildcraft.api.boards.IRedstoneBoardNBT;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
||||
public class BoardRobotPickerNBT implements IRedstoneBoardNBT {
|
||||
|
||||
|
@ -25,8 +30,8 @@ public class BoardRobotPickerNBT implements IRedstoneBoardNBT {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getName(NBTTagCompound nbt) {
|
||||
return getID();
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) {
|
||||
list.add(StringUtils.localize("buildcraft.boardRobotPicker"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -36,11 +41,12 @@ public class BoardRobotPickerNBT implements IRedstoneBoardNBT {
|
|||
|
||||
@Override
|
||||
public IIcon getIcon(NBTTagCompound nbt) {
|
||||
if (icon == null) {
|
||||
icon = Minecraft.getMinecraft().getTextureMapBlocks().registerIcon("buildcraft:board_green");
|
||||
}
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
icon = iconRegister.registerIcon("buildcraft:board_green");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,10 @@
|
|||
*/
|
||||
package buildcraft.silicon;
|
||||
|
||||
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;
|
||||
|
@ -34,6 +37,16 @@ public class ItemRedstoneBoard extends ItemBuildCraft {
|
|||
return NBTUtils.getItemData(stack).hasKey("id") ? 1 : 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) {
|
||||
NBTTagCompound cpt = NBTUtils.getItemData(stack);
|
||||
|
||||
if (cpt.hasKey("id") && !cpt.getString("id").equals("<unknown>")) {
|
||||
RedstoneBoardRegistry.instance.getRedstoneBoard(cpt).addInformation(stack, player, list, advanced);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconIndex(ItemStack stack) {
|
||||
NBTTagCompound cpt = NBTUtils.getItemData(stack);
|
||||
|
@ -54,6 +67,8 @@ public class ItemRedstoneBoard extends ItemBuildCraft {
|
|||
public void registerIcons(IIconRegister par1IconRegister) {
|
||||
cleanBoard = par1IconRegister.registerIcon("buildcraft:board_clean");
|
||||
unknownBoard = par1IconRegister.registerIcon("buildcraft:board_unknown");
|
||||
|
||||
RedstoneBoardRegistry.instance.registerIcons(par1IconRegister);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class BoardRecipe implements IAssemblyRecipe {
|
|||
@Override
|
||||
public ItemStack makeOutput() {
|
||||
ItemStack stack = new ItemStack(BuildCraftSilicon.redstoneBoard);
|
||||
RedstoneBoardRegistry.instance.createRandomBoard(stack.stackTagCompound);
|
||||
RedstoneBoardRegistry.instance.createRandomBoard(NBTUtils.getItemData(stack));
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class BoardRecipe implements IAssemblyRecipe {
|
|||
|
||||
@Override
|
||||
public double getEnergyCost() {
|
||||
return 10;
|
||||
return 10000;
|
||||
}
|
||||
|
||||
// FIXME: canBeDone and useItems could use some improvements and
|
||||
|
|
|
@ -11,6 +11,7 @@ package buildcraft.silicon.boards;
|
|||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import buildcraft.api.boards.IRedstoneBoardNBT;
|
||||
|
@ -48,7 +49,7 @@ public class ImplRedstoneBoardRegistry extends RedstoneBoardRegistry {
|
|||
for (BoardFactory f : boards.values()) {
|
||||
accumulatedSearch += f.probability;
|
||||
|
||||
if (accumulatedSearch < value) {
|
||||
if (accumulatedSearch > value) {
|
||||
nbt.setString("id", f.boardNBT.getID());
|
||||
return;
|
||||
}
|
||||
|
@ -59,4 +60,11 @@ public class ImplRedstoneBoardRegistry extends RedstoneBoardRegistry {
|
|||
public IRedstoneBoardNBT getRedstoneBoard(NBTTagCompound nbt) {
|
||||
return boards.get(nbt.getString("id")).boardNBT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister par1IconRegister) {
|
||||
for (BoardFactory f : boards.values()) {
|
||||
f.boardNBT.registerIcons(par1IconRegister);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue