Add dark steel anvil

This commit is contained in:
tterrag1098 committed 2014-10-27 01:29:27 -04:00
1 parent 73f9ab553f
commit c81d974e52
14 files changed
+252 -30

No files matched your search

@@ -41,6 +41,7 @@ import cpw.mods.fml.common.event.FMLServerStoppedEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.relauncher.Side;
import crazypants.enderio.block.BlockDarkSteelAnvil;
import crazypants.enderio.block.BlockDarkSteelPressurePlate;
import crazypants.enderio.block.BlockReinforcedObsidian;
import crazypants.enderio.conduit.BlockConduitBundle;
@@ -243,6 +244,7 @@ public class EnderIO {
//Blocks
public static BlockDarkSteelPressurePlate blockDarkSteelPressurePlate;
public static BlockDarkSteelAnvil blockDarkSteelAnvil;
public static BlockEndermanSkull blockEndermanSkull;
public static BlockReinforcedObsidian blockReinforcedObsidian;
@@ -346,6 +348,7 @@ public class EnderIO {
blockEnchanter = BlockEnchanter.create();
blockDarkSteelPressurePlate = BlockDarkSteelPressurePlate.create();
blockDarkSteelAnvil = BlockDarkSteelAnvil.create();
blockElectricLight = BlockElectricLight.create();
blockLightNode = BlockLightNode.create();
@@ -49,6 +49,7 @@ public class GuiHandler implements IGuiHandler {
public static final int GUI_ID_SPAWN_GUARD = 96;
public static final int GUI_ID_TRANSCEIVER = 97;
public static final int GUI_ID_XP_OBELISK = 98;
public static final int GUI_ID_ANVIL = 99;
protected final Map<Integer, IGuiHandler> guiHandlers = new HashMap<Integer, IGuiHandler>();
@@ -69,6 +69,7 @@ public enum ModObject {
//Blocks
blockDarkSteelPressurePlate,
blockDarkSteelAnvil,
blockReinforcedObsidian,
blockIngotStorage,
@@ -0,0 +1,103 @@
package crazypants.enderio.block;
import net.minecraft.block.BlockAnvil;
import net.minecraft.client.gui.GuiRepair;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemAnvilBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIO;
import crazypants.enderio.EnderIOTab;
import crazypants.enderio.GuiHandler;
import crazypants.enderio.ModObject;
import crazypants.enderio.gui.IResourceTooltipProvider;
public class BlockDarkSteelAnvil extends BlockAnvil implements IResourceTooltipProvider {
private static final String[] anvilIconNames = new String[] { "anvil_0", "anvil_1", "anvil_2" };
@SideOnly(Side.CLIENT)
private IIcon[] anvilIcons;
public static BlockDarkSteelAnvil create() {
BlockDarkSteelAnvil res = new BlockDarkSteelAnvil();
res.init();
return res;
}
private BlockDarkSteelAnvil() {
super();
setHardness(5.0F);
setStepSound(soundTypeAnvil);
setResistance(2000.0F);
setBlockName(ModObject.blockDarkSteelAnvil.unlocalisedName);
setCreativeTab(EnderIOTab.tabEnderIO);
}
protected void init() {
GameRegistry.registerBlock(this, ItemAnvilBlock.class, ModObject.blockDarkSteelAnvil.unlocalisedName);
EnderIO.guiHandler.registerGuiHandler(GuiHandler.GUI_ID_ANVIL, new IGuiHandler() {
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new ContainerDarkSteelAnvil(player.inventory, world, x, y, z, player);
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new GuiRepair(player.inventory, world, x, y, z);
}
});
}
@Override
public String getUnlocalizedNameForTooltip(ItemStack itemStack) {
return this.getUnlocalizedName();
}
@Override
public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ) {
p.openGui(EnderIO.instance, GuiHandler.GUI_ID_ANVIL, w, x, y, z);
return true;
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int p_149691_1_, int p_149691_2_)
{
if(this.anvilRenderSide == 3 && p_149691_1_ == 1)
{
int k = (p_149691_2_ >> 2) % this.anvilIcons.length;
return this.anvilIcons[k];
}
else
{
return this.blockIcon;
}
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register)
{
this.blockIcon = register.registerIcon(EnderIO.MODID + ":anvil_base");
this.anvilIcons = new IIcon[anvilIconNames.length];
for (int i = 0; i < this.anvilIcons.length; ++i)
{
this.anvilIcons[i] = register.registerIcon(EnderIO.MODID + ":" + anvilIconNames[i]);
}
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
return new ItemStack(this, 1, world.getBlockMetadata(x, y, z) >> 2);
}
}
@@ -0,0 +1,83 @@
package crazypants.enderio.block;
import crazypants.enderio.EnderIO;
import crazypants.enderio.config.Config;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.ContainerRepair;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ContainerDarkSteelAnvil extends ContainerRepair {
private int x, y, z;
@SuppressWarnings("unchecked")
public ContainerDarkSteelAnvil(InventoryPlayer playerInv, final World world, final int x, final int y, final int z, EntityPlayer player) {
super(playerInv, world, x, y, z, player);
this.x = x;
this.y = y;
this.z = z;
this.inventorySlots.set(2, new Slot(this.outputSlot, 2, 134, 47) {
public boolean isItemValid(ItemStack stack) {
return false;
}
public boolean canTakeStack(EntityPlayer stack) {
return (stack.capabilities.isCreativeMode || stack.experienceLevel >= ContainerDarkSteelAnvil.this.maximumCost)
&& ContainerDarkSteelAnvil.this.maximumCost > 0 && this.getHasStack();
}
public void onPickupFromSlot(EntityPlayer player, ItemStack stack) {
if(!player.capabilities.isCreativeMode) {
player.addExperienceLevel(-ContainerDarkSteelAnvil.this.maximumCost);
}
ContainerDarkSteelAnvil.this.inputSlots.setInventorySlotContents(0, (ItemStack) null);
if(ContainerDarkSteelAnvil.this.stackSizeToBeUsedInRepair > 0) {
ItemStack itemstack1 = ContainerDarkSteelAnvil.this.inputSlots.getStackInSlot(1);
if(itemstack1 != null && itemstack1.stackSize > ContainerDarkSteelAnvil.this.stackSizeToBeUsedInRepair) {
itemstack1.stackSize -= ContainerDarkSteelAnvil.this.stackSizeToBeUsedInRepair;
ContainerDarkSteelAnvil.this.inputSlots.setInventorySlotContents(1, itemstack1);
} else {
ContainerDarkSteelAnvil.this.inputSlots.setInventorySlotContents(1, (ItemStack) null);
}
} else {
ContainerDarkSteelAnvil.this.inputSlots.setInventorySlotContents(1, (ItemStack) null);
}
ContainerDarkSteelAnvil.this.maximumCost = 0;
if(!player.capabilities.isCreativeMode && !world.isRemote && world.getBlock(x, y, z) == Blocks.anvil
&& player.getRNG().nextFloat() < Config.darkSteelAnvilDamageChance) {
int i1 = world.getBlockMetadata(x, y, z);
int k = i1 & 3;
int l = i1 >> 2;
++l;
if(l > 2) {
world.setBlockToAir(x, y, z);
world.playAuxSFX(1020, x, y, z, 0);
} else {
world.setBlockMetadataWithNotify(x, y, z, k | l << 2, 2);
world.playAuxSFX(1021, x, y, z, 0);
}
} else if(!world.isRemote) {
world.playAuxSFX(1021, x, y, z, 0);
}
}
});
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return player.worldObj.getBlock(this.x, this.y, this.z) == EnderIO.blockDarkSteelAnvil;
}
}
@@ -208,6 +208,8 @@ public final class Config {
public static int darkSteelTravelCost = 30;
public static int darkSteelSpoonCost = 10;
public static float darkSteelAnvilDamageChance = 0.024f;
public static int hootchPowerPerCycle = 6;
public static int hootchPowerTotalBurnTime = 6000;
public static int rocketFuelPowerPerCycle = 16;
@@ -750,6 +752,8 @@ public final class Config {
darkSteelAxeEffeciencyBoostWhenPowered = (float) config.get(sectionDarkSteel.name, "darkSteelAxeEffeciencyBoostWhenPowered",
darkSteelAxeEffeciencyBoostWhenPowered, "The increase in effciency when powered.").getDouble(darkSteelAxeEffeciencyBoostWhenPowered);
darkSteelAnvilDamageChance = (float) config.get(sectionDarkSteel.name, "darkSteelAnvilDamageChance", darkSteelAnvilDamageChance, "Chance that the dark steel anvil will take damage after repairing something.").getDouble();
hootchPowerPerCycle = config.get(sectionPower.name, "hootchPowerPerCycle", hootchPowerPerCycle,
"The amount of power generated per BC engine cycle. Examples: BC Oil = 3, BC Fuel = 6").getInt(hootchPowerPerCycle);
hootchPowerTotalBurnTime = config.get(sectionPower.name, "hootchPowerTotalBurnTime", hootchPowerTotalBurnTime,
@@ -162,6 +162,15 @@ public class MaterialRecipes {
}
GameRegistry.addShapedRecipe(reinfObs , "dbd", "bob", "dbd", 'd', corners, 'b', EnderIO.blockDarkIronBars, 'o', Blocks.obsidian);
}
GameRegistry.addRecipe(new ShapedOreRecipe(EnderIO.blockDarkSteelAnvil,
"bbb",
" i ",
"iii",
'b', "blockDarkSteel",
'i', "ingotDarkSteel"
));
for (Alloy alloy : Alloy.values()) {
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(EnderIO.blockIngotStorage, 1, alloy.ordinal()), "iii", "iii", "iii", 'i', alloy.oredictIngotName));
@@ -21,6 +21,7 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import crazypants.enderio.EnderIO;
import crazypants.enderio.block.BlockDarkSteelAnvil;
import crazypants.enderio.conduit.BlockConduitBundle;
import crazypants.enderio.conduit.ConduitUtil;
import crazypants.enderio.conduit.IConduit;
@@ -41,15 +42,17 @@ public class WailaCompat implements IWailaDataProvider {
public static final WailaCompat INSTANCE = new WailaCompat();
public static void load(IWailaRegistrar registrar) {
registrar.registerStackProvider(INSTANCE, BlockConduitBundle.class); // CHANGE BLOCK TYPE IF MORE ARE ADDED
registrar.registerStackProvider(INSTANCE, BlockConduitBundle.class);
registrar.registerStackProvider(INSTANCE, BlockDarkSteelAnvil.class);
registrar.registerHeadProvider(INSTANCE, Block.class);
registrar.registerBodyProvider(INSTANCE, Block.class);
registrar.registerTailProvider(INSTANCE, Block.class);
registrar.registerSyncedNBTKey("controllerStoredEnergyRF", TileCapacitorBank.class);
// registrar.registerHeadProvider(INSTANCE, IInternalPowerReceptor.class);
// registrar.registerSyncedNBTKey("*", IInternalPowerReceptor.class);
// registrar.registerHeadProvider(INSTANCE, IInternalPowerReceptor.class);
// registrar.registerSyncedNBTKey("*", IInternalPowerReceptor.class);
ConfigHandler.instance().addConfig(EnderIO.MOD_NAME, "facades.hidden", "Sneaky Facades");
}
@@ -61,6 +64,9 @@ public class WailaCompat implements IWailaDataProvider {
if(bundle.hasFacade()) {
return new ItemStack(bundle.getFacadeId(), 1, bundle.getFacadeMetadata());
}
} else if(accessor.getBlock() instanceof BlockDarkSteelAnvil) {
return accessor.getBlock().getPickBlock(accessor.getPosition(), accessor.getWorld(), accessor.getPosition().blockX, accessor.getPosition().blockY,
accessor.getPosition().blockZ);
}
return null;
}
@@ -73,21 +79,22 @@ public class WailaCompat implements IWailaDataProvider {
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
Block block = accessor.getBlock();
TileEntity te = accessor.getTileEntity();
Item item = Item.getItemFromBlock(block);
EntityPlayer player = accessor.getPlayer();
World world = player.worldObj;
MovingObjectPosition pos = accessor.getPosition();
Block block = accessor.getBlock();
TileEntity te = accessor.getTileEntity();
Item item = Item.getItemFromBlock(block);
EntityPlayer player = accessor.getPlayer();
World world = player.worldObj;
MovingObjectPosition pos = accessor.getPosition();
int x = pos.blockX, y = pos.blockY, z = pos.blockZ;
if(block instanceof AbstractMachineBlock<?>) {
if (te != null && te instanceof AbstractMachineEntity) {
if(te != null && te instanceof AbstractMachineEntity) {
AbstractMachineEntity machine = (AbstractMachineEntity) te;
ForgeDirection side = accessor.getSide();
IoMode mode = machine.getIoMode(side);
currenttip.add(EnumChatFormatting.YELLOW + String.format(Lang.localize("gui.machine.side"), EnumChatFormatting.WHITE + Lang.localize("gui.machine.side." + side.name().toLowerCase())));
currenttip.add(EnumChatFormatting.YELLOW
+ String.format(Lang.localize("gui.machine.side"), EnumChatFormatting.WHITE + Lang.localize("gui.machine.side." + side.name().toLowerCase())));
currenttip.add(EnumChatFormatting.YELLOW + String.format(Lang.localize("gui.machine.ioMode"), mode.colorLocalisedName()));
}
}
@@ -119,8 +126,8 @@ public class WailaCompat implements IWailaDataProvider {
} else if(block instanceof IResourceTooltipProvider) {
TooltipAddera.addInformation((IResourceTooltipProvider) block, itemStack, player, currenttip);
}
if (currenttip.size() > 0) {
if(currenttip.size() > 0) {
currenttip.add("");
}
@@ -137,35 +144,37 @@ public class WailaCompat implements IWailaDataProvider {
TooltipAddera.addInformation((IResourceTooltipProvider) block, itemStack, player, currenttip);
}
}
if (te instanceof IInternalPowerReceptor && accessor.getNBTData().hasKey("storedEnergyRF")) {
if (currenttip.size() > 4) {
if(te instanceof IInternalPowerReceptor && accessor.getNBTData().hasKey("storedEnergyRF")) {
if(currenttip.size() > 4) {
currenttip.add("");
}
IInternalPowerReceptor power = (IInternalPowerReceptor) te;
int stored = accessor.getTileEntity() instanceof TileCapacitorBank ? power.getEnergyStored() : accessor.getNBTData().getInteger("storedEnergyRF");
int max = power.getMaxEnergyStored();
currenttip.add(String.format("%s%d%s / %s%d%s RF", EnumChatFormatting.WHITE, stored, EnumChatFormatting.RESET, EnumChatFormatting.WHITE, max, EnumChatFormatting.RESET));
} else if (te instanceof IConduitBundle) {
int stored = accessor.getTileEntity() instanceof TileCapacitorBank ? power.getEnergyStored() : accessor.getNBTData().getInteger("storedEnergyRF");
int max = power.getMaxEnergyStored();
currenttip.add(String.format("%s%d%s / %s%d%s RF", EnumChatFormatting.WHITE, stored, EnumChatFormatting.RESET, EnumChatFormatting.WHITE, max,
EnumChatFormatting.RESET));
} else if(te instanceof IConduitBundle) {
NBTTagCompound nbtRoot = accessor.getNBTData();
short nbtVersion = nbtRoot.getShort("nbtVersion");
NBTTagList conduitTags = (NBTTagList) nbtRoot.getTag("conduits");
if(conduitTags != null) {
for (int i = 0; i < conduitTags.tagCount(); i++) {
NBTTagCompound conduitTag = conduitTags.getCompoundTagAt(i);
IConduit conduit = ConduitUtil.readConduitFromNBT(conduitTag, nbtVersion);
if(conduit != null && conduit instanceof IPowerConduit) {
currenttip.add(String.format("%s%d%s / %s%d%s RF", EnumChatFormatting.WHITE, ((IPowerConduit)conduit).getEnergyStored(), EnumChatFormatting.RESET, EnumChatFormatting.WHITE, ((IConduitBundle)te).getMaxEnergyStored(), EnumChatFormatting.RESET));
currenttip.add(String.format("%s%d%s / %s%d%s RF", EnumChatFormatting.WHITE, ((IPowerConduit) conduit).getEnergyStored(), EnumChatFormatting.RESET,
EnumChatFormatting.WHITE, ((IConduitBundle) te).getMaxEnergyStored(), EnumChatFormatting.RESET));
}
}
}
}
return currenttip;
}