mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-03-11 12:15:35 +00:00
added keys, locks, locksmith table and cloud residue item
This commit is contained in:
parent
5dec1e9cbb
commit
60294bf682
@ -251,6 +251,12 @@ item.turret_control.name=Geschützsteuerung
|
||||
item.turret_chip.name=Geschütz-KI-Chip
|
||||
item.turret_biometry.name=Geschütz-Telemetriekarte
|
||||
|
||||
item.key.name=Schlüssel
|
||||
item.key_red.name=Roter Schlüssel
|
||||
item.padlock.name=Vorhängeschloss
|
||||
tile.machine_keyforge.name=Schlossertisch
|
||||
container.keyForge=Schlossertisch
|
||||
|
||||
tile.mine_ap.name=Antipersonenmine
|
||||
tile.mine_he.name=Antipanzermine
|
||||
tile.mine_shrap.name=Schrapnellmine
|
||||
@ -1732,6 +1738,7 @@ tile.crystal_pulsar.name=Pulsating Crystal
|
||||
|
||||
tile.taint.name=Korrupter Schmutz
|
||||
tile.residue.name=Wolkenrückstände
|
||||
item.powder_cloud.name=Wolkenrückstände
|
||||
|
||||
tile.cheater_virus.name=Geliertes Euphemium
|
||||
tile.cheater_virus_seed.name=Instabiler Euphemiumschrabid-Block
|
||||
|
||||
@ -264,6 +264,12 @@ item.turret_control.name=Turret Controller
|
||||
item.turret_chip.name=Turret AI-Chip
|
||||
item.turret_biometry.name=Turret Telemetry Card
|
||||
|
||||
item.key.name=Key
|
||||
item.key_red.name=Red Key
|
||||
item.padlock.name=Padlock
|
||||
tile.machine_keyforge.name=Locksmith Table
|
||||
container.keyForge=Locksmith Table
|
||||
|
||||
tile.mine_ap.name=Anti-Personell Mine
|
||||
tile.mine_he.name=Anti-Tank Mine
|
||||
tile.mine_shrap.name=Shrapnel Mine
|
||||
@ -1732,6 +1738,7 @@ tile.crystal_pulsar.name=Pulsating Crystal
|
||||
|
||||
tile.taint.name=Taint
|
||||
tile.residue.name=Cloud Residue
|
||||
item.powder_cloud.name=Cloud Residue
|
||||
|
||||
tile.cheater_virus.name=Gelid Euphemium
|
||||
tile.cheater_virus_seed.name=Unstable Euphemium Schrabide Block
|
||||
|
||||
@ -23,6 +23,8 @@
|
||||
"block.vaultThud": {"category": "block", "sounds": [{"name": "block/vaultThud", "stream": false}]},
|
||||
"block.vaultScrapeNew": {"category": "block", "sounds": [{"name": "block/vaultScrapeNew", "stream": false}]},
|
||||
"block.vaultThudNew": {"category": "block", "sounds": [{"name": "block/vaultThudNew", "stream": false}]},
|
||||
"block.lockOpen": {"category": "block", "sounds": [{"name": "block/lockOpen", "stream": false}]},
|
||||
"block.lockHang": {"category": "block", "sounds": [{"name": "block/lockHang", "stream": false}]},
|
||||
|
||||
"item.techBleep": {"category": "player", "sounds": [{"name": "tool/techBleep", "stream": false}]},
|
||||
"item.techBoop": {"category": "player", "sounds": [{"name": "tool/techBoop", "stream": false}]},
|
||||
|
||||
BIN
assets/hbm/sounds/block/lockHang.ogg
Normal file
BIN
assets/hbm/sounds/block/lockHang.ogg
Normal file
Binary file not shown.
BIN
assets/hbm/sounds/block/lockOpen.ogg
Normal file
BIN
assets/hbm/sounds/block/lockOpen.ogg
Normal file
Binary file not shown.
BIN
assets/hbm/textures/blocks/machine_keyforge_side.png
Normal file
BIN
assets/hbm/textures/blocks/machine_keyforge_side.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 605 B |
BIN
assets/hbm/textures/blocks/machine_keyforge_top.png
Normal file
BIN
assets/hbm/textures/blocks/machine_keyforge_top.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 552 B |
BIN
assets/hbm/textures/gui/gui_keyforge.png
Normal file
BIN
assets/hbm/textures/gui/gui_keyforge.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
BIN
assets/hbm/textures/items/key_blue.png
Normal file
BIN
assets/hbm/textures/items/key_blue.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 238 B |
BIN
assets/hbm/textures/items/key_red.png
Normal file
BIN
assets/hbm/textures/items/key_red.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 231 B |
BIN
assets/hbm/textures/items/powder_cloud.png
Normal file
BIN
assets/hbm/textures/items/powder_cloud.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 277 B |
@ -460,6 +460,9 @@ public class ModBlocks {
|
||||
public static Block machine_telelinker;
|
||||
public static final int guiID_telelinker = 68;
|
||||
|
||||
public static Block machine_keyforge;
|
||||
public static final int guiID_keyforge = 67;
|
||||
|
||||
public static Block machine_reactor_small;
|
||||
public static final int guiID_reactor_small = 65;
|
||||
|
||||
@ -793,6 +796,7 @@ public class ModBlocks {
|
||||
|
||||
machine_satlinker = new MachineSatLinker(Material.iron).setBlockName("machine_satlinker").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.missileTab).setBlockTextureName(RefStrings.MODID + ":machine_satlinker_side");
|
||||
machine_telelinker = new MachineTeleLinker(Material.iron).setBlockName("machine_telelinker").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.nukeTab).setBlockTextureName(RefStrings.MODID + ":machine_telelinker_side");
|
||||
machine_keyforge = new MachineKeyForge(Material.iron).setBlockName("machine_keyforge").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.nukeTab).setBlockTextureName(RefStrings.MODID + ":machine_keyforge_side");
|
||||
|
||||
factory_titanium_hull = new BlockGeneric(Material.iron).setBlockName("factory_titanium_hull").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":factory_titanium_hull");
|
||||
factory_titanium_furnace = new FactoryHatch(Material.iron).setBlockName("factory_titanium_furnace").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":factory_titanium_furnace");
|
||||
@ -917,7 +921,7 @@ public class ModBlocks {
|
||||
crystal_hardened = new BlockGeneric(Material.iron).setBlockName("crystal_hardened").setHardness(15.0F).setResistance(Float.POSITIVE_INFINITY).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":crystal_hardened");
|
||||
crystal_pulsar = new CrystalPulsar(Material.iron).setBlockName("crystal_pulsar").setHardness(15.0F).setResistance(Float.POSITIVE_INFINITY).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":crystal_pulsar");
|
||||
taint = new BlockTaint(Material.iron).setBlockName("taint").setHardness(15.0F).setResistance(10.0F).setCreativeTab(null);
|
||||
residue = new BlockCloudResidue(Material.iron).setBlockName("residue").setHardness(15.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":residue");
|
||||
residue = new BlockCloudResidue(Material.iron).setBlockName("residue").setHardness(0.5F).setResistance(0.5F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":residue");
|
||||
|
||||
vent_chlorine = new BlockVent(Material.iron).setBlockName("vent_chlorine").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":vent_chlorine");
|
||||
vent_cloud = new BlockVent(Material.iron).setBlockName("vent_cloud").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":vent_cloud");
|
||||
@ -1259,6 +1263,7 @@ public class ModBlocks {
|
||||
GameRegistry.registerBlock(machine_teleporter, machine_teleporter.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(machine_satlinker, machine_satlinker.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(machine_telelinker, machine_telelinker.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(machine_keyforge, machine_keyforge.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(radiorec, radiorec.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(radiobox, radiobox.getUnlocalizedName());
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.items.ModItems;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@ -47,7 +48,7 @@ public class BlockCloudResidue extends Block {
|
||||
@Override
|
||||
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
|
||||
{
|
||||
return null;
|
||||
return p_149650_2_.nextInt(25) == 0 ? ModItems.powder_cloud : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -5,6 +5,7 @@ import java.util.Random;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.interfaces.IBomb;
|
||||
import com.hbm.interfaces.IDummy;
|
||||
import com.hbm.items.tool.ItemLock;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.machine.TileEntityDummy;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineRadGen;
|
||||
@ -84,9 +85,24 @@ public class DummyBlockVault extends BlockContainer implements IDummy, IBomb {
|
||||
if(world.isRemote)
|
||||
{
|
||||
return true;
|
||||
} else if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemLock) {
|
||||
return false;
|
||||
|
||||
} else if(!player.isSneaking())
|
||||
{
|
||||
explode(world, x, y, z);
|
||||
TileEntity til = world.getTileEntity(x, y, z);
|
||||
if(til != null && til instanceof TileEntityDummy) {
|
||||
int a = ((TileEntityDummy)til).targetX;
|
||||
int b = ((TileEntityDummy)til).targetY;
|
||||
int c = ((TileEntityDummy)til).targetZ;
|
||||
|
||||
TileEntityVaultDoor entity = (TileEntityVaultDoor) world.getTileEntity(a, b, c);
|
||||
if(entity != null)
|
||||
{
|
||||
if(entity.canAccess(player))
|
||||
entity.tryToggle();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
@ -119,7 +135,7 @@ public class DummyBlockVault extends BlockContainer implements IDummy, IBomb {
|
||||
int c = ((TileEntityDummy)te).targetZ;
|
||||
|
||||
TileEntityVaultDoor entity = (TileEntityVaultDoor) world.getTileEntity(a, b, c);
|
||||
if(entity != null)
|
||||
if(entity != null && !entity.isLocked())
|
||||
{
|
||||
entity.tryToggle();
|
||||
}
|
||||
|
||||
128
com/hbm/blocks/machine/MachineKeyForge.java
Normal file
128
com/hbm/blocks/machine/MachineKeyForge.java
Normal file
@ -0,0 +1,128 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineKeyForge;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineTeleLinker;
|
||||
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class MachineKeyForge extends BlockContainer {
|
||||
|
||||
private final Random field_149933_a = new Random();
|
||||
private Random rand;
|
||||
private static boolean keepInventory;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconTop;
|
||||
|
||||
public MachineKeyForge(Material p_i45386_1_) {
|
||||
super(p_i45386_1_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
|
||||
return new TileEntityMachineKeyForge();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
|
||||
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":machine_keyforge_top");
|
||||
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":machine_keyforge_side");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return side == 1 ? this.iconTop : (side == 0 ? this.iconTop : this.blockIcon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
if(world.isRemote)
|
||||
{
|
||||
return true;
|
||||
} else if(!player.isSneaking())
|
||||
{
|
||||
TileEntityMachineKeyForge entity = (TileEntityMachineKeyForge) world.getTileEntity(x, y, z);
|
||||
if(entity != null)
|
||||
{
|
||||
FMLNetworkHandler.openGui(player, MainRegistry.instance, ModBlocks.guiID_keyforge, world, x, y, z);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_)
|
||||
{
|
||||
if (!keepInventory)
|
||||
{
|
||||
ISidedInventory tileentityfurnace = (ISidedInventory)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);
|
||||
|
||||
if (tileentityfurnace != null)
|
||||
{
|
||||
for (int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1)
|
||||
{
|
||||
ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
float f = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
|
||||
float f1 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
|
||||
float f2 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
|
||||
|
||||
while (itemstack.stackSize > 0)
|
||||
{
|
||||
int j1 = this.field_149933_a.nextInt(21) + 10;
|
||||
|
||||
if (j1 > itemstack.stackSize)
|
||||
{
|
||||
j1 = itemstack.stackSize;
|
||||
}
|
||||
|
||||
itemstack.stackSize -= j1;
|
||||
EntityItem entityitem = new EntityItem(p_149749_1_, p_149749_2_ + f, p_149749_3_ + f1, p_149749_4_ + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
|
||||
|
||||
if (itemstack.hasTagCompound())
|
||||
{
|
||||
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
|
||||
}
|
||||
|
||||
float f3 = 0.05F;
|
||||
entityitem.motionX = (float)this.field_149933_a.nextGaussian() * f3;
|
||||
entityitem.motionY = (float)this.field_149933_a.nextGaussian() * f3 + 0.2F;
|
||||
entityitem.motionZ = (float)this.field_149933_a.nextGaussian() * f3;
|
||||
p_149749_1_.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,7 @@ package com.hbm.blocks.machine;
|
||||
|
||||
import com.hbm.interfaces.IBomb;
|
||||
import com.hbm.interfaces.IMultiblock;
|
||||
import com.hbm.items.tool.ItemLock;
|
||||
import com.hbm.tileentity.machine.TileEntityVaultDoor;
|
||||
|
||||
import net.minecraft.block.BlockContainer;
|
||||
@ -43,7 +44,8 @@ public class VaultDoor extends BlockContainer implements IBomb, IMultiblock {
|
||||
public void explode(World world, int x, int y, int z) {
|
||||
TileEntityVaultDoor te = (TileEntityVaultDoor) world.getTileEntity(x, y, z);
|
||||
|
||||
te.tryToggle();
|
||||
if(!te.isLocked())
|
||||
te.tryToggle();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -220,13 +222,20 @@ public class VaultDoor extends BlockContainer implements IBomb, IMultiblock {
|
||||
if(world.isRemote)
|
||||
{
|
||||
return true;
|
||||
} else if(!player.isSneaking())
|
||||
{
|
||||
} else if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemLock) {
|
||||
return false;
|
||||
|
||||
} if(!player.isSneaking()) {
|
||||
|
||||
TileEntityVaultDoor entity = (TileEntityVaultDoor) world.getTileEntity(x, y, z);
|
||||
if(entity != null)
|
||||
{
|
||||
entity.tryToggle();
|
||||
if(entity.isLocked()) {
|
||||
if(entity.canAccess(player))
|
||||
entity.tryToggle();
|
||||
} else {
|
||||
entity.tryToggle();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -46,6 +46,7 @@ import com.hbm.tileentity.machine.TileEntityMachineGasFlare;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineGenerator;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineIGenerator;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineInserter;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineKeyForge;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineMiningDrill;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineOilWell;
|
||||
import com.hbm.tileentity.machine.TileEntityMachinePress;
|
||||
@ -678,6 +679,15 @@ public class GUIHandler implements IGuiHandler {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
case ModBlocks.guiID_keyforge:
|
||||
{
|
||||
if(entity instanceof TileEntityMachineKeyForge)
|
||||
{
|
||||
return new ContainerMachineKeyForge(player.inventory, (TileEntityMachineKeyForge) entity);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1282,6 +1292,15 @@ public class GUIHandler implements IGuiHandler {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
case ModBlocks.guiID_keyforge:
|
||||
{
|
||||
if(entity instanceof TileEntityMachineKeyForge)
|
||||
{
|
||||
return new GUIMachineKeyForge(player.inventory, (TileEntityMachineKeyForge) entity);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//CLIENTONLY GUIS
|
||||
|
||||
@ -174,6 +174,9 @@ public class MachineRecipes {
|
||||
ItemStack[] schrabidium3 = new ItemStack[] { new ItemStack(ModItems.nugget_schrabidium_fuel, 4),
|
||||
new ItemStack(ModItems.nugget_lead, 19), new ItemStack(ModItems.nugget_neptunium, 1),
|
||||
new ItemStack(ModItems.rod_quad_euphemium, 1) };
|
||||
ItemStack[] cloud = new ItemStack[] { new ItemStack(ModItems.powder_copper, 1),
|
||||
new ItemStack(ModItems.sulfur, 1), new ItemStack(ModItems.dust, 1),
|
||||
new ItemStack(ModItems.dust, 1) };
|
||||
|
||||
if (item == ModItems.cell_uf6) {
|
||||
return uranium;
|
||||
@ -241,6 +244,10 @@ public class MachineRecipes {
|
||||
return schrabidium3;
|
||||
}
|
||||
|
||||
if (item == ModItems.powder_cloud) {
|
||||
return cloud;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -864,6 +871,8 @@ public class MachineRecipes {
|
||||
getCentrifugeOutput(ModItems.rod_dual_schrabidium_fuel_depleted));
|
||||
recipes.put(new ItemStack(ModItems.rod_quad_schrabidium_fuel_depleted),
|
||||
getCentrifugeOutput(ModItems.rod_quad_schrabidium_fuel_depleted));
|
||||
recipes.put(new ItemStack(ModItems.powder_cloud),
|
||||
getCentrifugeOutput(ModItems.powder_cloud));
|
||||
return recipes;
|
||||
}
|
||||
|
||||
|
||||
82
com/hbm/inventory/container/ContainerMachineKeyForge.java
Normal file
82
com/hbm/inventory/container/ContainerMachineKeyForge.java
Normal file
@ -0,0 +1,82 @@
|
||||
package com.hbm.inventory.container;
|
||||
|
||||
import com.hbm.tileentity.machine.TileEntityMachineKeyForge;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerMachineKeyForge extends Container {
|
||||
|
||||
private TileEntityMachineKeyForge diFurnace;
|
||||
|
||||
public ContainerMachineKeyForge(InventoryPlayer invPlayer, TileEntityMachineKeyForge tedf) {
|
||||
|
||||
diFurnace = tedf;
|
||||
|
||||
this.addSlotToContainer(new Slot(tedf, 0, 44, 35));
|
||||
this.addSlotToContainer(new Slot(tedf, 1, 80, 35));
|
||||
this.addSlotToContainer(new Slot(tedf, 2, 116, 35));
|
||||
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
for(int j = 0; j < 9; j++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters(ICrafting crafting) {
|
||||
super.addCraftingToCrafters(crafting);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2)
|
||||
{
|
||||
ItemStack var3 = null;
|
||||
Slot var4 = (Slot) this.inventorySlots.get(par2);
|
||||
|
||||
if (var4 != null && var4.getHasStack())
|
||||
{
|
||||
ItemStack var5 = var4.getStack();
|
||||
var3 = var5.copy();
|
||||
|
||||
if (par2 <= 0) {
|
||||
if (!this.mergeItemStack(var5, 1, this.inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(var5, 0, 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (var5.stackSize == 0)
|
||||
{
|
||||
var4.putStack((ItemStack) null);
|
||||
}
|
||||
else
|
||||
{
|
||||
var4.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return diFurnace.isUseableByPlayer(player);
|
||||
}
|
||||
}
|
||||
56
com/hbm/inventory/gui/GUIMachineKeyForge.java
Normal file
56
com/hbm/inventory/gui/GUIMachineKeyForge.java
Normal file
@ -0,0 +1,56 @@
|
||||
package com.hbm.inventory.gui;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.inventory.container.ContainerMachineKeyForge;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineKeyForge;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GUIMachineKeyForge extends GuiInfoContainer {
|
||||
|
||||
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/gui_keyforge.png");
|
||||
private TileEntityMachineKeyForge siren;
|
||||
|
||||
public GUIMachineKeyForge(InventoryPlayer invPlayer, TileEntityMachineKeyForge tedf) {
|
||||
super(new ContainerMachineKeyForge(invPlayer, tedf));
|
||||
siren = tedf;
|
||||
|
||||
this.xSize = 176;
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float f) {
|
||||
super.drawScreen(mouseX, mouseY, f);
|
||||
|
||||
String[] text = new String[] { "The first slot will copy the key/lock's",
|
||||
"pin configuration and paste it to the second slot." };
|
||||
this.drawCustomInfoStat(mouseX, mouseY, guiLeft - 16, guiTop + 36, 16, 16, guiLeft - 8, guiTop + 36 + 16, text);
|
||||
|
||||
String[] text1 = new String[] { "The third slot will randomize the",
|
||||
"key/lock's pin configuration."};
|
||||
this.drawCustomInfoStat(mouseX, mouseY, guiLeft - 16, guiTop + 36 + 16, 16, 16, guiLeft - 8, guiTop + 36 + 16, text1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int i, int j) {
|
||||
String name = this.siren.hasCustomInventoryName() ? this.siren.getInventoryName() : I18n.format(this.siren.getInventoryName());
|
||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
this.drawInfoPanel(guiLeft - 16, guiTop + 36, 16, 16, 2);
|
||||
this.drawInfoPanel(guiLeft - 16, guiTop + 36 + 16, 16, 16, 3);
|
||||
}
|
||||
}
|
||||
@ -227,6 +227,7 @@ public class ModItems {
|
||||
public static Item powder_spark_mix;
|
||||
public static Item powder_yellowcake;
|
||||
public static Item powder_magic;
|
||||
public static Item powder_cloud;
|
||||
|
||||
public static Item fragment_neodymium;
|
||||
public static Item fragment_cobalt;
|
||||
@ -1179,6 +1180,10 @@ public class ModItems {
|
||||
public static Item turret_biometry;
|
||||
public static Item chopper;
|
||||
|
||||
public static Item key;
|
||||
public static Item key_red;
|
||||
public static Item padlock;
|
||||
|
||||
public static Item turret_light_ammo;
|
||||
public static Item turret_heavy_ammo;
|
||||
public static Item turret_rocket_ammo;
|
||||
@ -1514,6 +1519,7 @@ public class ModItems {
|
||||
powder_meteorite_tiny = new Item().setUnlocalizedName("powder_meteorite_tiny").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":powder_meteorite_tiny");
|
||||
powder_yellowcake = new ItemRadioactive().setUnlocalizedName("powder_yellowcake").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":powder_yellowcake");
|
||||
powder_magic = new Item().setUnlocalizedName("powder_magic").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":powder_magic");
|
||||
powder_cloud = new Item().setUnlocalizedName("powder_cloud").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":powder_cloud");
|
||||
|
||||
fragment_neodymium = new Item().setUnlocalizedName("fragment_neodymium").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":fragment_neodymium");
|
||||
fragment_cobalt = new Item().setUnlocalizedName("fragment_cobalt").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":fragment_cobalt");
|
||||
@ -2286,6 +2292,10 @@ public class ModItems {
|
||||
geiger_counter = new ItemGeigerCounter().setUnlocalizedName("geiger_counter").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":geiger_counter");
|
||||
survey_scanner = new ItemSurveyScanner().setUnlocalizedName("survey_scanner").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":survey_scanner");
|
||||
|
||||
key = new ItemKey().setUnlocalizedName("key").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":key");
|
||||
key_red = new Item().setUnlocalizedName("key_red").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":key_red");
|
||||
padlock = new ItemLock().setUnlocalizedName("padlock").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":padlock");
|
||||
|
||||
turret_light_ammo = new ItemTurretAmmo(ModBlocks.turret_light, 100).setUnlocalizedName("turret_light_ammo").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":turret_light_ammo");
|
||||
turret_heavy_ammo = new ItemTurretAmmo(ModBlocks.turret_heavy, 25).setUnlocalizedName("turret_heavy_ammo").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":turret_heavy_ammo");
|
||||
turret_rocket_ammo = new ItemTurretAmmo(ModBlocks.turret_rocket, 8).setUnlocalizedName("turret_rocket_ammo").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":turret_rocket_ammo");
|
||||
@ -2702,6 +2712,7 @@ public class ModItems {
|
||||
GameRegistry.registerItem(powder_lanthanium, powder_lanthanium.getUnlocalizedName());
|
||||
GameRegistry.registerItem(powder_actinium, powder_actinium.getUnlocalizedName());
|
||||
GameRegistry.registerItem(powder_magic, powder_magic.getUnlocalizedName());
|
||||
GameRegistry.registerItem(powder_cloud, powder_cloud.getUnlocalizedName());
|
||||
GameRegistry.registerItem(powder_desh_mix, powder_desh_mix.getUnlocalizedName());
|
||||
GameRegistry.registerItem(powder_desh, powder_desh.getUnlocalizedName());
|
||||
GameRegistry.registerItem(powder_nitan_mix, powder_nitan_mix.getUnlocalizedName());
|
||||
@ -3335,6 +3346,11 @@ public class ModItems {
|
||||
GameRegistry.registerItem(survey_scanner, survey_scanner.getUnlocalizedName());
|
||||
GameRegistry.registerItem(geiger_counter, geiger_counter.getUnlocalizedName());
|
||||
|
||||
//Keys and Locks
|
||||
GameRegistry.registerItem(key, key.getUnlocalizedName());
|
||||
GameRegistry.registerItem(key_red, key_red.getUnlocalizedName());
|
||||
GameRegistry.registerItem(padlock, padlock.getUnlocalizedName());
|
||||
|
||||
//Missiles
|
||||
GameRegistry.registerItem(missile_generic, missile_generic.getUnlocalizedName());
|
||||
GameRegistry.registerItem(missile_anti_ballistic, missile_anti_ballistic.getUnlocalizedName());
|
||||
|
||||
5
com/hbm/items/tool/ItemKey.java
Normal file
5
com/hbm/items/tool/ItemKey.java
Normal file
@ -0,0 +1,5 @@
|
||||
package com.hbm.items.tool;
|
||||
|
||||
public class ItemKey extends ItemKeyPin {
|
||||
|
||||
}
|
||||
35
com/hbm/items/tool/ItemKeyPin.java
Normal file
35
com/hbm/items/tool/ItemKeyPin.java
Normal file
@ -0,0 +1,35 @@
|
||||
package com.hbm.items.tool;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ItemKeyPin extends Item {
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool)
|
||||
{
|
||||
if(getPins(itemstack) != 0)
|
||||
list.add("Pin configuration: " + getPins(itemstack));
|
||||
else
|
||||
list.add("Pins not set!");
|
||||
}
|
||||
|
||||
public static int getPins(ItemStack stack) {
|
||||
if(stack.stackTagCompound == null) {
|
||||
stack.stackTagCompound = new NBTTagCompound();
|
||||
return 0;
|
||||
}
|
||||
return stack.stackTagCompound.getInteger("pins");
|
||||
}
|
||||
|
||||
public static void setPins(ItemStack stack, int i) {
|
||||
if(stack.stackTagCompound == null) {
|
||||
stack.stackTagCompound = new NBTTagCompound();
|
||||
}
|
||||
stack.stackTagCompound.setInteger("pins", i);
|
||||
}
|
||||
}
|
||||
62
com/hbm/items/tool/ItemLock.java
Normal file
62
com/hbm/items/tool/ItemLock.java
Normal file
@ -0,0 +1,62 @@
|
||||
package com.hbm.items.tool;
|
||||
|
||||
import com.hbm.blocks.bomb.TurretBase;
|
||||
import com.hbm.tileentity.machine.TileEntityDummy;
|
||||
import com.hbm.tileentity.machine.TileEntityLockableBase;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemLock extends ItemKeyPin {
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int i, float f0, float f1, float f2)
|
||||
{
|
||||
if(this.getPins(stack) != 0) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(te != null && te instanceof TileEntityLockableBase) {
|
||||
TileEntityLockableBase tile = (TileEntityLockableBase)te;
|
||||
|
||||
if(tile.isLocked())
|
||||
return false;
|
||||
|
||||
tile.lock();
|
||||
tile.setPins(this.getPins(stack));
|
||||
|
||||
world.playSoundAtEntity(player, "hbm:block.lockHang", 1.0F, 1.0F);
|
||||
stack.stackSize--;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if(te != null && te instanceof TileEntityDummy) {
|
||||
|
||||
TileEntityDummy dummy = (TileEntityDummy)te;
|
||||
TileEntity target = world.getTileEntity(dummy.targetX, dummy.targetY, dummy.targetZ);
|
||||
|
||||
if(target != null && target instanceof TileEntityLockableBase) {
|
||||
TileEntityLockableBase tile = (TileEntityLockableBase)target;
|
||||
|
||||
if(tile.isLocked())
|
||||
return false;
|
||||
|
||||
tile.lock();
|
||||
tile.setPins(this.getPins(stack));
|
||||
|
||||
world.playSoundAtEntity(player, "hbm:block.lockHang", 1.0F, 1.0F);
|
||||
stack.stackSize--;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@ -3,7 +3,7 @@ package com.hbm.lib;
|
||||
public class RefStrings {
|
||||
public static final String MODID = "hbm";
|
||||
public static final String NAME = "Hbm's Nuclear Tech Mod";
|
||||
public static final String VERSION = "1.0.27 BETA (2891)";
|
||||
public static final String VERSION = "1.0.27 BETA (2893)";
|
||||
//HBM's Beta Naming Convention:
|
||||
//V T (X-Y-Z)
|
||||
//V -> next release version
|
||||
|
||||
@ -1108,6 +1108,10 @@ public class CraftingManager {
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.survey_scanner, 1), new Object[] { "SWS", " G ", "PCP", 'W', ModItems.wire_gold, 'P', ModItems.ingot_polymer, 'C', ModItems.circuit_gold, 'S', "plateSteel", 'G', "ingotGold" }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.geiger_counter, 1), new Object[] { "GPP", "WCS", "WBB", 'W', ModItems.wire_gold, 'P', ModItems.ingot_polymer, 'C', ModItems.circuit_copper, 'G', "ingotGold", 'S', "plateSteel", 'B', ModItems.ingot_beryllium }));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.key, 1), new Object[] { " B", " B ", "P ", 'P', "plateSteel", 'B', ModItems.bolt_tungsten }));
|
||||
GameRegistry.addRecipe(new ItemStack(ModItems.key_red, 1), new Object[] { " C", " M ", "K ", 'C', ModItems.circuit_targeting_tier4, 'M', ModItems.motor, 'K', ModItems.key });
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.padlock, 1), new Object[] { " P ", "PBP", "PPP", 'P', "plateSteel", 'B', ModItems.bolt_tungsten }));
|
||||
|
||||
//GameRegistry.addRecipe(new ItemStack(ModItems.schrabidium_hammer, 1), new Object[] { "BBB", "BBB", " S ", 'B', Item.getItemFromBlock(ModBlocks.block_schrabidium), 'S', Items.stick });
|
||||
GameRegistry.addRecipe(new ItemStack(ModItems.euphemium_stopper, 1), new Object[] { "I", "S", "S", 'I', ModItems.ingot_euphemium, 'S', Items.stick });
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.matchstick, 16), new Object[] { "I", "S", 'I', "sulfur", 'S', Items.stick }));
|
||||
@ -1217,6 +1221,7 @@ public class CraftingManager {
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.photo_panel), new Object[] { " G ", "IPI", " C ", 'G', "paneGlass", 'I', ModItems.plate_polymer, 'P', "dustNetherQuartz", 'C', ModItems.circuit_aluminium }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.machine_satlinker), new Object[] { "PSP", "SCS", "PSP", 'P', "plateSteel", 'S', ModItems.ingot_starmetal, 'C', ModItems.sat_chip }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.machine_telelinker), new Object[] { "PSP", "SCS", "PSP", 'P', "plateSteel", 'S', "ingotAdvanced", 'C', ModItems.turret_biometry }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.machine_keyforge), new Object[] { "PSP", "SCS", "PSP", 'P', "plateSteel", 'S', "ingotTungsten", 'C', ModItems.padlock }));
|
||||
GameRegistry.addRecipe(new ItemStack(ModItems.sat_chip), new Object[] { "WWW", "CIC", "WWW", 'W', ModItems.wire_red_copper, 'C', ModItems.circuit_red_copper, 'I', ModItems.ingot_polymer });
|
||||
GameRegistry.addRecipe(new ItemStack(ModItems.sat_mapper), new Object[] { "H", "B", 'H', ModItems.sat_head_mapper, 'B', ModItems.sat_base });
|
||||
GameRegistry.addRecipe(new ItemStack(ModItems.sat_scanner), new Object[] { "H", "B", 'H', ModItems.sat_head_scanner, 'B', ModItems.sat_base });
|
||||
|
||||
@ -270,6 +270,7 @@ import com.hbm.tileentity.machine.TileEntityMachineGasFlare;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineGenerator;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineIGenerator;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineInserter;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineKeyForge;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineMiningDrill;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineOilWell;
|
||||
import com.hbm.tileentity.machine.TileEntityMachinePress;
|
||||
@ -685,6 +686,7 @@ public class MainRegistry
|
||||
GameRegistry.registerTileEntity(TileEntityLandmine.class, "tileentity_landmine");
|
||||
GameRegistry.registerTileEntity(TileEntityBomber.class, "tileentity_bomber");
|
||||
GameRegistry.registerTileEntity(TileEntityMachineTeleLinker.class, "tileentity_telemetry_linker");
|
||||
GameRegistry.registerTileEntity(TileEntityMachineKeyForge.class, "tileentity_key_forge");
|
||||
|
||||
EntityRegistry.registerModEntity(EntityRocket.class, "entity_rocket", 0, this, 250, 1, true);
|
||||
EntityRegistry.registerModEntity(EntityNukeExplosion.class, "entity_nuke_explosion", 1, this, 250, 1, true);
|
||||
|
||||
67
com/hbm/tileentity/machine/TileEntityLockableBase.java
Normal file
67
com/hbm/tileentity/machine/TileEntityLockableBase.java
Normal file
@ -0,0 +1,67 @@
|
||||
package com.hbm.tileentity.machine;
|
||||
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.tool.ItemKey;
|
||||
|
||||
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;
|
||||
|
||||
public abstract class TileEntityLockableBase extends TileEntity {
|
||||
|
||||
private int lock;
|
||||
private boolean isLocked = false;
|
||||
|
||||
public boolean isLocked() {
|
||||
return isLocked;
|
||||
}
|
||||
|
||||
public void lock() {
|
||||
isLocked = true;
|
||||
}
|
||||
|
||||
public void setPins(int pins) {
|
||||
lock = pins;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
lock = nbt.getInteger("lock");
|
||||
isLocked = nbt.getBoolean("isLocked");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
nbt.setInteger("lock", lock);
|
||||
nbt.setBoolean("isLocked", isLocked);
|
||||
}
|
||||
|
||||
public boolean canAccess(EntityPlayer player) {
|
||||
|
||||
if(!isLocked) {
|
||||
return true;
|
||||
} else {
|
||||
ItemStack stack = player.getHeldItem();
|
||||
|
||||
if(stack != null && stack.getItem() instanceof ItemKey &&
|
||||
ItemKey.getPins(stack) == this.lock) {
|
||||
worldObj.playSoundAtEntity(player, "hbm:block.lockOpen", 1.0F, 1.0F);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(stack != null && stack.getItem() == ModItems.key_red) {
|
||||
worldObj.playSoundAtEntity(player, "hbm:block.lockOpen", 1.0F, 1.0F);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
214
com/hbm/tileentity/machine/TileEntityMachineKeyForge.java
Normal file
214
com/hbm/tileentity/machine/TileEntityMachineKeyForge.java
Normal file
@ -0,0 +1,214 @@
|
||||
package com.hbm.tileentity.machine;
|
||||
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.tool.ItemKeyPin;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TileEntityMachineKeyForge extends TileEntity implements ISidedInventory {
|
||||
|
||||
private ItemStack slots[];
|
||||
|
||||
private static final int[] slots_top = new int[] {0};
|
||||
private static final int[] slots_bottom = new int[] {1};
|
||||
private static final int[] slots_side = new int[] {2};
|
||||
|
||||
private String customName;
|
||||
|
||||
public TileEntityMachineKeyForge() {
|
||||
slots = new ItemStack[3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return slots.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return slots[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i) {
|
||||
if(slots[i] != null)
|
||||
{
|
||||
ItemStack itemStack = slots[i];
|
||||
slots[i] = null;
|
||||
return itemStack;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemStack) {
|
||||
slots[i] = itemStack;
|
||||
if(itemStack != null && itemStack.stackSize > getInventoryStackLimit())
|
||||
{
|
||||
itemStack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return this.hasCustomInventoryName() ? this.customName : "container.keyForge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return this.customName != null && this.customName.length() > 0;
|
||||
}
|
||||
|
||||
public void setCustomName(String name) {
|
||||
this.customName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
if(worldObj.getTileEntity(xCoord, yCoord, zCoord) != this)
|
||||
{
|
||||
return false;
|
||||
}else{
|
||||
return player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <=64;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {}
|
||||
@Override
|
||||
public void closeInventory() {}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
if(slots[i] != null)
|
||||
{
|
||||
if(slots[i].stackSize <= j)
|
||||
{
|
||||
ItemStack itemStack = slots[i];
|
||||
slots[i] = null;
|
||||
return itemStack;
|
||||
}
|
||||
ItemStack itemStack1 = slots[i].splitStack(j);
|
||||
if (slots[i].stackSize == 0)
|
||||
{
|
||||
slots[i] = null;
|
||||
}
|
||||
|
||||
return itemStack1;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
NBTTagList list = nbt.getTagList("items", 10);
|
||||
|
||||
slots = new ItemStack[getSizeInventory()];
|
||||
|
||||
for(int i = 0; i < list.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound nbt1 = list.getCompoundTagAt(i);
|
||||
byte b0 = nbt1.getByte("slot");
|
||||
if(b0 >= 0 && b0 < slots.length)
|
||||
{
|
||||
slots[b0] = ItemStack.loadItemStackFromNBT(nbt1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
for(int i = 0; i < slots.length; i++)
|
||||
{
|
||||
if(slots[i] != null)
|
||||
{
|
||||
NBTTagCompound nbt1 = new NBTTagCompound();
|
||||
nbt1.setByte("slot", (byte)i);
|
||||
slots[i].writeToNBT(nbt1);
|
||||
list.appendTag(nbt1);
|
||||
}
|
||||
}
|
||||
nbt.setTag("items", list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int p_94128_1_)
|
||||
{
|
||||
return p_94128_1_ == 0 ? slots_bottom : (p_94128_1_ == 1 ? slots_top : slots_side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int i, ItemStack itemStack, int j) {
|
||||
return this.isItemValidForSlot(i, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int i, ItemStack itemStack, int j) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
if(slots[0] != null && slots[1] != null && slots[0].getItem() instanceof ItemKeyPin && slots[1].getItem() instanceof ItemKeyPin) {
|
||||
|
||||
ItemKeyPin.setPins(slots[1], ItemKeyPin.getPins(slots[0]));
|
||||
}
|
||||
|
||||
if(slots[2] != null && slots[2].getItem() instanceof ItemKeyPin) {
|
||||
ItemKeyPin.setPins(slots[2], worldObj.rand.nextInt(900) + 100);
|
||||
}
|
||||
|
||||
//DEBUG, remove later
|
||||
if(slots[2] != null && slots[2].getItem() == Items.wheat_seeds) {
|
||||
slots[2] = new ItemStack(ModItems.nuke_starter_kit);
|
||||
}
|
||||
if(slots[2] != null && slots[2].getItem() == Items.bone) {
|
||||
slots[2] = new ItemStack(ModItems.nuke_advanced_kit);
|
||||
}
|
||||
if(slots[2] != null && slots[2].getItem() == Items.feather) {
|
||||
slots[2] = new ItemStack(ModItems.nuke_commercially_kit);
|
||||
}
|
||||
if(slots[2] != null && slots[2].getItem() == Items.apple) {
|
||||
slots[2] = new ItemStack(ModItems.nuke_electric_kit);
|
||||
}
|
||||
if(slots[2] != null && slots[2].getItem() == Items.clay_ball) {
|
||||
slots[2] = new ItemStack(ModItems.t45_kit);
|
||||
}
|
||||
if(slots[2] != null && slots[2].getItem() == Items.stick) {
|
||||
slots[2] = new ItemStack(ModItems.missile_kit);
|
||||
}
|
||||
if(slots[2] != null && slots[2].getItem() == Items.string) {
|
||||
slots[2] = new ItemStack(ModItems.grenade_kit);
|
||||
}
|
||||
if(slots[2] != null && slots[2].getItem() == Items.reeds) {
|
||||
slots[2] = new ItemStack(ModItems.man_kit);
|
||||
}
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -13,7 +13,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
||||
public class TileEntityVaultDoor extends TileEntity {
|
||||
public class TileEntityVaultDoor extends TileEntityLockableBase {
|
||||
|
||||
public boolean isOpening = false;
|
||||
//0: closed, 1: opening/closing, 2:open
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user