Initial commit.
parent
e4dcb96666
commit
f8859ca5aa
|
@ -0,0 +1,79 @@
|
|||
package com.droog71.prospect;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import com.droog71.prospect.common.CommonProxy;
|
||||
import com.droog71.prospect.config.ConfigHandler;
|
||||
import com.droog71.prospect.event.FMLEventHandler;
|
||||
import com.droog71.prospect.gui.ProspectGuiHandler;
|
||||
import com.droog71.prospect.init.ProspectBlocks;
|
||||
import com.droog71.prospect.init.ProspectItems;
|
||||
import com.droog71.prospect.init.ProspectSounds;
|
||||
import com.droog71.prospect.worldgen.OreGen;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
import net.minecraftforge.fml.common.Mod.Instance;
|
||||
import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
@Mod(modid = Prospect.MODID, name = Prospect.NAME, version = Prospect.VERSION)
|
||||
public class Prospect
|
||||
{
|
||||
public static final String MODID = "prospect";
|
||||
public static final String NAME = "Prospect";
|
||||
public static final String VERSION = "1.0";
|
||||
private static Logger logger;
|
||||
|
||||
@Instance
|
||||
public static Prospect instance;
|
||||
|
||||
@SidedProxy(clientSide = "com.droog71.prospect.common.ClientProxy", serverSide = "com.droog71.prospect.common.CommonProxy")
|
||||
public static CommonProxy proxy;
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
ProspectBlocks.init();
|
||||
ProspectItems.init();
|
||||
ProspectSounds.init();
|
||||
ConfigHandler.createConfigFile();
|
||||
logger = event.getModLog();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent event)
|
||||
{
|
||||
GameRegistry.registerWorldGenerator(new OreGen(), 0);
|
||||
GameRegistry.addSmelting(ProspectBlocks.copper_ore, new ItemStack(ProspectItems.copper_ingot), 0.7f);
|
||||
GameRegistry.addSmelting(ProspectBlocks.tin_ore, new ItemStack(ProspectItems.tin_ingot), 0.7f);
|
||||
GameRegistry.addSmelting(ProspectBlocks.aluminum_ore, new ItemStack(ProspectItems.aluminum_ingot), 0.7f);
|
||||
GameRegistry.addSmelting(ProspectBlocks.silver_ore, new ItemStack(ProspectItems.silver_ingot), 0.7f);
|
||||
GameRegistry.addSmelting(ProspectBlocks.lead_ore, new ItemStack(ProspectItems.lead_ingot), 0.7f);
|
||||
GameRegistry.addSmelting(ProspectBlocks.silicon_ore, new ItemStack(ProspectItems.silicon), 0.7f);
|
||||
GameRegistry.addSmelting(ProspectItems.prepared_circuit, new ItemStack(ProspectItems.quantum_circuit), 0.7f);
|
||||
OreDictionary.registerOre("ingotCopper", ProspectItems.copper_ingot);
|
||||
OreDictionary.registerOre("ingotTin", ProspectItems.tin_ingot);
|
||||
OreDictionary.registerOre("ingotAluminum", ProspectItems.aluminum_ingot);
|
||||
OreDictionary.registerOre("ingotSilver", ProspectItems.silver_ingot);
|
||||
OreDictionary.registerOre("ingotLead", ProspectItems.lead_ingot);
|
||||
OreDictionary.registerOre("silicon", ProspectItems.silicon);
|
||||
FMLCommonHandler.instance().bus().register(FMLEventHandler.INSTANCE);
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new ProspectGuiHandler());
|
||||
}
|
||||
|
||||
public static final CreativeTabs tabProspect = new CreativeTabs("Prospect")
|
||||
{
|
||||
@Override
|
||||
public ItemStack getTabIconItem()
|
||||
{
|
||||
return new ItemStack(ProspectBlocks.purifier);
|
||||
}
|
||||
};
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package com.droog71.prospect.armor;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.EnumHelper;
|
||||
|
||||
public class ProspectArmor extends ItemArmor
|
||||
{
|
||||
public ProspectArmor(String name, CreativeTabs tab, ArmorMaterial materialIn, int renderIndexIn, EntityEquipmentSlot equipmentSlotIn)
|
||||
{
|
||||
super(materialIn, renderIndexIn, equipmentSlotIn);
|
||||
setUnlocalizedName(name);
|
||||
setRegistryName(name);
|
||||
setCreativeTab(tab);
|
||||
}
|
||||
public static final ArmorMaterial PROSPECTOR_ARMOR = EnumHelper.addArmorMaterial("prospector", "prospect:prospector", 5, new int[]{1, 2, 3, 1}, 15, SoundEvents.ITEM_ARMOR_EQUIP_LEATHER, 0.0F);
|
||||
|
||||
@Override
|
||||
public boolean onDroppedByPlayer(ItemStack item, EntityPlayer player)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemEnchantability()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBookEnchantable(ItemStack stack, ItemStack book)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.droog71.prospect.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
public class ProspectBlock extends Block
|
||||
{
|
||||
public ProspectBlock(String name, Material material)
|
||||
{
|
||||
super(material);
|
||||
setUnlocalizedName(name);
|
||||
setRegistryName(name);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.droog71.prospect.blocks;
|
||||
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ProspectBlockContainer extends BlockContainer
|
||||
{
|
||||
public ProspectBlockContainer(String name, Material material)
|
||||
{
|
||||
super(material);
|
||||
setUnlocalizedName(name);
|
||||
setRegistryName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.droog71.prospect.blocks.energy;
|
||||
|
||||
import com.droog71.prospect.blocks.ProspectBlock;
|
||||
import com.droog71.prospect.tilentity.CableTileEntity;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class Cable extends ProspectBlock
|
||||
{
|
||||
private int rating;
|
||||
private int capacity;
|
||||
|
||||
public Cable(String name, Material material, int rating, int capacity)
|
||||
{
|
||||
super(name, material);
|
||||
this.rating = rating;
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, IBlockState state)
|
||||
{
|
||||
return new CableTileEntity(this.rating,this.capacity);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
package com.droog71.prospect.blocks.energy;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.droog71.prospect.Prospect;
|
||||
import com.droog71.prospect.blocks.ProspectBlockContainer;
|
||||
import com.droog71.prospect.init.ProspectBlocks;
|
||||
import com.droog71.prospect.tilentity.ExtruderTileEntity;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class Extruder extends ProspectBlockContainer
|
||||
{
|
||||
public Extruder(String name, Material material)
|
||||
{
|
||||
super(name, material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumBlockRenderType getRenderType(IBlockState state)
|
||||
{
|
||||
return EnumBlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Item that this Block should drop when harvested.
|
||||
*/
|
||||
@Override
|
||||
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||
{
|
||||
return Item.getItemFromBlock(ProspectBlocks.extruder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is right clicked by a player.
|
||||
*/
|
||||
@Override
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (worldIn.isRemote)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
|
||||
if (tileentity instanceof ExtruderTileEntity)
|
||||
{
|
||||
playerIn.openGui(Prospect.instance, 4, worldIn, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||
*/
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||
{
|
||||
return new ExtruderTileEntity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated
|
||||
*/
|
||||
@Override
|
||||
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||
{
|
||||
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
|
||||
if (tileentity instanceof ExtruderTileEntity)
|
||||
{
|
||||
InventoryHelper.dropInventoryItems(worldIn, pos, (ExtruderTileEntity)tileentity);
|
||||
worldIn.updateComparatorOutputLevel(pos, this);
|
||||
}
|
||||
super.breakBlock(worldIn, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride(IBlockState state)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(IBlockState blockState, World worldIn, BlockPos pos)
|
||||
{
|
||||
return Container.calcRedstone(worldIn.getTileEntity(pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state)
|
||||
{
|
||||
return new ItemStack(Item.getItemFromBlock(ProspectBlocks.extruder));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
package com.droog71.prospect.blocks.energy;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.droog71.prospect.Prospect;
|
||||
import com.droog71.prospect.blocks.ProspectBlockContainer;
|
||||
import com.droog71.prospect.init.ProspectBlocks;
|
||||
import com.droog71.prospect.tilentity.LaunchPadTileEntity;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class LaunchPad extends ProspectBlockContainer
|
||||
{
|
||||
public LaunchPad(String name, Material material)
|
||||
{
|
||||
super(name, material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumBlockRenderType getRenderType(IBlockState state)
|
||||
{
|
||||
return EnumBlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Item that this Block should drop when harvested.
|
||||
*/
|
||||
@Override
|
||||
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||
{
|
||||
return Item.getItemFromBlock(ProspectBlocks.launch_pad);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is right clicked by a player.
|
||||
*/
|
||||
@Override
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (worldIn.isRemote)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
|
||||
if (tileentity instanceof LaunchPadTileEntity)
|
||||
{
|
||||
playerIn.openGui(Prospect.instance, 3, worldIn, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||
*/
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||
{
|
||||
return new LaunchPadTileEntity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated
|
||||
*/
|
||||
@Override
|
||||
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||
{
|
||||
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
|
||||
if (tileentity instanceof LaunchPadTileEntity)
|
||||
{
|
||||
InventoryHelper.dropInventoryItems(worldIn, pos, (LaunchPadTileEntity)tileentity);
|
||||
worldIn.updateComparatorOutputLevel(pos, this);
|
||||
int addToY = ((LaunchPadTileEntity)tileentity).capsuleYpos;
|
||||
worldIn.setBlockToAir(new BlockPos(pos.getX(),pos.getY()+addToY-1,pos.getZ()));
|
||||
}
|
||||
super.breakBlock(worldIn, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride(IBlockState state)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(IBlockState blockState, World worldIn, BlockPos pos)
|
||||
{
|
||||
return Container.calcRedstone(worldIn.getTileEntity(pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state)
|
||||
{
|
||||
return new ItemStack(Item.getItemFromBlock(ProspectBlocks.launch_pad));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
package com.droog71.prospect.blocks.energy;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.droog71.prospect.Prospect;
|
||||
import com.droog71.prospect.blocks.ProspectBlockContainer;
|
||||
import com.droog71.prospect.init.ProspectBlocks;
|
||||
import com.droog71.prospect.tilentity.PressTileEntity;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class Press extends ProspectBlockContainer
|
||||
{
|
||||
public Press(String name, Material material)
|
||||
{
|
||||
super(name, material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumBlockRenderType getRenderType(IBlockState state)
|
||||
{
|
||||
return EnumBlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Item that this Block should drop when harvested.
|
||||
*/
|
||||
@Override
|
||||
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||
{
|
||||
return Item.getItemFromBlock(ProspectBlocks.press);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is right clicked by a player.
|
||||
*/
|
||||
@Override
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (worldIn.isRemote)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
|
||||
if (tileentity instanceof PressTileEntity)
|
||||
{
|
||||
playerIn.openGui(Prospect.instance, 5, worldIn, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||
*/
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||
{
|
||||
return new PressTileEntity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated
|
||||
*/
|
||||
@Override
|
||||
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||
{
|
||||
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
|
||||
if (tileentity instanceof PressTileEntity)
|
||||
{
|
||||
InventoryHelper.dropInventoryItems(worldIn, pos, (PressTileEntity)tileentity);
|
||||
worldIn.updateComparatorOutputLevel(pos, this);
|
||||
}
|
||||
super.breakBlock(worldIn, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride(IBlockState state)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(IBlockState blockState, World worldIn, BlockPos pos)
|
||||
{
|
||||
return Container.calcRedstone(worldIn.getTileEntity(pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state)
|
||||
{
|
||||
return new ItemStack(Item.getItemFromBlock(ProspectBlocks.press));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
package com.droog71.prospect.blocks.energy;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.droog71.prospect.Prospect;
|
||||
import com.droog71.prospect.blocks.ProspectBlockContainer;
|
||||
import com.droog71.prospect.init.ProspectBlocks;
|
||||
import com.droog71.prospect.tilentity.PrinterTileEntity;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class Printer extends ProspectBlockContainer
|
||||
{
|
||||
public Printer(String name, Material material)
|
||||
{
|
||||
super(name, material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumBlockRenderType getRenderType(IBlockState state)
|
||||
{
|
||||
return EnumBlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Item that this Block should drop when harvested.
|
||||
*/
|
||||
@Override
|
||||
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||
{
|
||||
return Item.getItemFromBlock(ProspectBlocks.printer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is right clicked by a player.
|
||||
*/
|
||||
@Override
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (worldIn.isRemote)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
|
||||
if (tileentity instanceof PrinterTileEntity)
|
||||
{
|
||||
playerIn.openGui(Prospect.instance, 1, worldIn, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||
*/
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||
{
|
||||
return new PrinterTileEntity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated
|
||||
*/
|
||||
@Override
|
||||
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||
{
|
||||
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
|
||||
if (tileentity instanceof PrinterTileEntity)
|
||||
{
|
||||
InventoryHelper.dropInventoryItems(worldIn, pos, (PrinterTileEntity)tileentity);
|
||||
worldIn.updateComparatorOutputLevel(pos, this);
|
||||
}
|
||||
super.breakBlock(worldIn, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride(IBlockState state)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(IBlockState blockState, World worldIn, BlockPos pos)
|
||||
{
|
||||
return Container.calcRedstone(worldIn.getTileEntity(pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state)
|
||||
{
|
||||
return new ItemStack(Item.getItemFromBlock(ProspectBlocks.printer));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.droog71.prospect.blocks.energy;
|
||||
|
||||
import com.droog71.prospect.blocks.ProspectBlock;
|
||||
import com.droog71.prospect.tilentity.PurifierTileEntity;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class Purifier extends ProspectBlock
|
||||
{
|
||||
public boolean powered;
|
||||
|
||||
public Purifier(String name, Material material)
|
||||
{
|
||||
super(name, material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, IBlockState state)
|
||||
{
|
||||
return new PurifierTileEntity();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.droog71.prospect.blocks.energy;
|
||||
|
||||
import com.droog71.prospect.blocks.ProspectBlock;
|
||||
import com.droog71.prospect.tilentity.QuarryTileEntity;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class Quarry extends ProspectBlock
|
||||
{
|
||||
public Quarry(String name, Material material)
|
||||
{
|
||||
super(name, material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, IBlockState state)
|
||||
{
|
||||
return new QuarryTileEntity();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
package com.droog71.prospect.blocks.energy;
|
||||
|
||||
import java.util.Random;
|
||||
import com.droog71.prospect.Prospect;
|
||||
import com.droog71.prospect.blocks.ProspectBlockContainer;
|
||||
import com.droog71.prospect.init.ProspectBlocks;
|
||||
import com.droog71.prospect.tilentity.ReplicatorTileEntity;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class Replicator extends ProspectBlockContainer
|
||||
{
|
||||
public Replicator(String name, Material material)
|
||||
{
|
||||
super(name, material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumBlockRenderType getRenderType(IBlockState state)
|
||||
{
|
||||
return EnumBlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Item that this Block should drop when harvested.
|
||||
*/
|
||||
@Override
|
||||
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||
{
|
||||
return Item.getItemFromBlock(ProspectBlocks.replicator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is right clicked by a player.
|
||||
*/
|
||||
@Override
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (worldIn.isRemote)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
|
||||
if (tileentity instanceof ReplicatorTileEntity)
|
||||
{
|
||||
playerIn.openGui(Prospect.instance, 2, worldIn, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||
*/
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||
{
|
||||
return new ReplicatorTileEntity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated
|
||||
*/
|
||||
@Override
|
||||
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||
{
|
||||
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
|
||||
if (tileentity instanceof ReplicatorTileEntity)
|
||||
{
|
||||
InventoryHelper.dropInventoryItems(worldIn, pos, (ReplicatorTileEntity)tileentity);
|
||||
worldIn.updateComparatorOutputLevel(pos, this);
|
||||
}
|
||||
super.breakBlock(worldIn, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride(IBlockState state)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(IBlockState blockState, World worldIn, BlockPos pos)
|
||||
{
|
||||
return Container.calcRedstone(worldIn.getTileEntity(pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state)
|
||||
{
|
||||
return new ItemStack(Item.getItemFromBlock(ProspectBlocks.replicator));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.droog71.prospect.blocks.energy;
|
||||
|
||||
import com.droog71.prospect.blocks.ProspectBlock;
|
||||
import com.droog71.prospect.tilentity.SolarPanelTileEntity;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class SolarPanel extends ProspectBlock
|
||||
{
|
||||
private int rating;
|
||||
private int capacity;
|
||||
private int tier;
|
||||
|
||||
public SolarPanel(String name, Material material, int capacity, int rating, int tier)
|
||||
{
|
||||
super(name, material);
|
||||
this.capacity = capacity;
|
||||
this.rating = rating;
|
||||
this.tier = tier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, IBlockState state)
|
||||
{
|
||||
return new SolarPanelTileEntity(capacity, rating, tier);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.droog71.prospect.blocks.energy;
|
||||
|
||||
import com.droog71.prospect.blocks.ProspectBlock;
|
||||
import com.droog71.prospect.tilentity.TransformerTileEntity;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class Transformer extends ProspectBlock
|
||||
{
|
||||
private int maxReceive;
|
||||
private int rating;
|
||||
private int capacity;
|
||||
|
||||
public Transformer(String name, Material material,int maxReceive, int capacity, int rating)
|
||||
{
|
||||
super(name, material);
|
||||
this.maxReceive = maxReceive;
|
||||
this.capacity = capacity;
|
||||
this.rating = rating;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, IBlockState state)
|
||||
{
|
||||
return new TransformerTileEntity(maxReceive, capacity, rating);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package com.droog71.prospect.blocks.ore;
|
||||
|
||||
import java.util.Random;
|
||||
import com.droog71.prospect.blocks.ProspectBlock;
|
||||
import com.droog71.prospect.init.ProspectItems;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class LivingOre extends ProspectBlock
|
||||
{
|
||||
public LivingOre(String name, Material material)
|
||||
{
|
||||
super(name, material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(IBlockState state, Random random, int i)
|
||||
{
|
||||
return ProspectItems.gem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random random)
|
||||
{
|
||||
return 1 + random.nextInt(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDroppedWithBonus(int fortune, Random random)
|
||||
{
|
||||
if (fortune > 0)
|
||||
{
|
||||
return 1 + random.nextInt(5);
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.quantityDropped(random);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.droog71.prospect.common;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
|
||||
public class ClientProxy extends CommonProxy
|
||||
{
|
||||
@Override
|
||||
public void registerRenderInformation(Item item)
|
||||
{
|
||||
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation( item.getRegistryName(), "inventory"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.droog71.prospect.common;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class CommonProxy
|
||||
{
|
||||
public void registerRenderInformation(Item item)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package com.droog71.prospect.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class ConfigHandler
|
||||
{
|
||||
public static boolean getSporesEnabled()
|
||||
{
|
||||
File configFile = new File(System.getProperty("user.dir")+"/config/prospect.cfg");
|
||||
if (configFile.exists())
|
||||
{
|
||||
Scanner configFileScanner;
|
||||
try
|
||||
{
|
||||
configFileScanner = new Scanner(configFile);
|
||||
String configFileContents = configFileScanner.useDelimiter("\\Z").next();
|
||||
configFileScanner.close();
|
||||
String configValue = configFileContents.split(":")[1].toLowerCase();
|
||||
if (configValue.equals("true"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
System.out.println("Reactor turbines mod failed to find config file!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
createConfigFile();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void createConfigFile()
|
||||
{
|
||||
try
|
||||
{
|
||||
File configFile = new File(System.getProperty("user.dir")+"/config/prospect.cfg");
|
||||
if (!configFile.exists())
|
||||
{
|
||||
configFile.createNewFile();
|
||||
FileWriter f;
|
||||
try
|
||||
{
|
||||
f = new FileWriter(configFile,false);
|
||||
f.write("toxic_spores_enabled:true");
|
||||
f.close();
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
System.out.println("Prospect mod failed to write to config file!");
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
System.out.println("Prospect mod failed to create config file!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.droog71.prospect.event;
|
||||
|
||||
import com.droog71.prospect.init.ProspectItems;
|
||||
import com.droog71.prospect.init.ProspectPotions;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
|
||||
|
||||
public enum FMLEventHandler
|
||||
{
|
||||
INSTANCE;
|
||||
private static final String NBT_KEY = "prospect.firstjoin";
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent event)
|
||||
{
|
||||
NBTTagCompound data = event.player.getEntityData();
|
||||
NBTTagCompound persistent;
|
||||
if (!data.hasKey(EntityPlayer.PERSISTED_NBT_TAG))
|
||||
{
|
||||
data.setTag(EntityPlayer.PERSISTED_NBT_TAG, (persistent = new NBTTagCompound()));
|
||||
}
|
||||
else
|
||||
{
|
||||
persistent = data.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG);
|
||||
}
|
||||
if (!persistent.hasKey(NBT_KEY)) //If this is the first time onPlayerJoin is called for this player, equip armor and spore filter.
|
||||
{
|
||||
persistent.setBoolean(NBT_KEY, true);
|
||||
event.player.inventory.addItemStackToInventory(new ItemStack(ProspectItems.filter));
|
||||
event.player.inventory.setInventorySlotContents(36, new ItemStack(ProspectItems.boots));
|
||||
event.player.inventory.setInventorySlotContents(37, new ItemStack(ProspectItems.pants));
|
||||
event.player.inventory.setInventorySlotContents(38, new ItemStack(ProspectItems.suit));
|
||||
event.player.inventory.setInventorySlotContents(39, new ItemStack(ProspectItems.helmet));
|
||||
}
|
||||
event.player.addPotionEffect(new PotionEffect(ProspectPotions.spore, 1000000, 0, false, false)); //Enable toxic spore effects.
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerRespawn(PlayerEvent.PlayerRespawnEvent event)
|
||||
{
|
||||
event.player.addPotionEffect(new PotionEffect(ProspectPotions.spore, 1000000, 0, false, false)); //Enable toxic spore effects.
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package com.droog71.prospect.fe;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
public class ProspectEnergyStorage implements IEnergyStorage
|
||||
{
|
||||
protected int energy;
|
||||
public int capacity;
|
||||
public int maxReceive;
|
||||
public boolean overloaded;
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound)
|
||||
{
|
||||
energy = compound.getInteger("energy");
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound)
|
||||
{
|
||||
compound.setInteger("energy",energy);
|
||||
return compound;
|
||||
}
|
||||
|
||||
public int generateEnergy(int amount)
|
||||
{
|
||||
int energyAdded = Math.min(capacity - energy, amount);
|
||||
energy += energyAdded;
|
||||
return energyAdded;
|
||||
}
|
||||
|
||||
public int useEnergy(int energyToUse)
|
||||
{
|
||||
int energyUsed = Math.min(energy, energyToUse);
|
||||
energy -= energyUsed;
|
||||
return energyUsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(int amount, boolean simulate)
|
||||
{
|
||||
if (amount > maxReceive)
|
||||
{
|
||||
overloaded = true;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!canReceive())
|
||||
return 0;
|
||||
|
||||
int energyReceived = Math.min(capacity - energy, Math.min(maxReceive, amount));
|
||||
if (!simulate)
|
||||
energy += energyReceived;
|
||||
return energyReceived;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(int maxExtract, boolean simulate)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored()
|
||||
{
|
||||
return energy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored()
|
||||
{
|
||||
return capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtract()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceive()
|
||||
{
|
||||
return maxReceive > 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package com.droog71.prospect.gui;
|
||||
|
||||
import com.droog71.prospect.inventory.ExtruderContainer;
|
||||
import com.droog71.prospect.tilentity.ExtruderTileEntity;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ExtruderGUI extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation EXTRUDER_GUI_TEXTURES = new ResourceLocation("prospect:textures/gui/extruder.png");
|
||||
/** The player inventory bound to this GUI. */
|
||||
private final InventoryPlayer playerInventory;
|
||||
private final IInventory tileExtruder;
|
||||
|
||||
public ExtruderGUI(InventoryPlayer playerInv, IInventory extruderInv)
|
||||
{
|
||||
super(new ExtruderContainer(playerInv, extruderInv));
|
||||
this.playerInventory = playerInv;
|
||||
this.tileExtruder = extruderInv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the screen and all the components in it.
|
||||
*/
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.drawDefaultBackground();
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
this.renderHoveredToolTip(mouseX, mouseY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
String s = this.tileExtruder.getName();
|
||||
this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 6, 4210752);
|
||||
this.fontRenderer.drawString(this.playerInventory.getDisplayName().getUnformattedText(), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the background layer of this container (behind the items).
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
|
||||
{
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(EXTRUDER_GUI_TEXTURES);
|
||||
int i = (this.width - this.xSize) / 2;
|
||||
int j = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
if (ExtruderTileEntity.isEnergized(this.tileExtruder))
|
||||
{
|
||||
int k = this.getBurnLeftScaled(13);
|
||||
this.drawTexturedModalRect(i + 56, j + 36 + 12 - k, 176, 12 - k, 14, k + 1);
|
||||
}
|
||||
|
||||
int l = this.getCookProgressScaled(24);
|
||||
this.drawTexturedModalRect(i + 79, j + 34, 176, 14, l + 1, 16);
|
||||
}
|
||||
|
||||
private int getCookProgressScaled(int pixels)
|
||||
{
|
||||
int i = this.tileExtruder.getField(2);
|
||||
int j = this.tileExtruder.getField(3);
|
||||
return j != 0 && i != 0 ? i * pixels / j : 0;
|
||||
}
|
||||
|
||||
private int getBurnLeftScaled(int pixels)
|
||||
{
|
||||
int i = this.tileExtruder.getField(1);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
i = 200;
|
||||
}
|
||||
|
||||
return this.tileExtruder.getField(0) * pixels / i;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package com.droog71.prospect.gui;
|
||||
|
||||
import com.droog71.prospect.inventory.LaunchPadContainer;
|
||||
import com.droog71.prospect.tilentity.LaunchPadTileEntity;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class LaunchPadGUI extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation LAUNCHPAD_GUI_TEXTURES = new ResourceLocation("prospect:textures/gui/launch_pad.png");
|
||||
/** The player inventory bound to this GUI. */
|
||||
private final InventoryPlayer playerInventory;
|
||||
private final IInventory tileLaunchPad;
|
||||
|
||||
public LaunchPadGUI(InventoryPlayer playerInv, IInventory launchpadInv)
|
||||
{
|
||||
super(new LaunchPadContainer(playerInv, launchpadInv));
|
||||
this.playerInventory = playerInv;
|
||||
this.tileLaunchPad = launchpadInv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the screen and all the components in it.
|
||||
*/
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.drawDefaultBackground();
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
this.renderHoveredToolTip(mouseX, mouseY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
String s = this.tileLaunchPad.getName();
|
||||
this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 6, 4210752);
|
||||
this.fontRenderer.drawString(this.playerInventory.getDisplayName().getUnformattedText(), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the background layer of this container (behind the items).
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
|
||||
{
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(LAUNCHPAD_GUI_TEXTURES);
|
||||
int i = (this.width - this.xSize) / 2;
|
||||
int j = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
if (LaunchPadTileEntity.isEnergized(this.tileLaunchPad))
|
||||
{
|
||||
int k = this.getBurnLeftScaled(13);
|
||||
this.drawTexturedModalRect(i + 56, j + 36 + 12 - k, 176, 12 - k, 14, k + 1);
|
||||
}
|
||||
|
||||
int l = this.getCookProgressScaled(24);
|
||||
this.drawTexturedModalRect(i + 79, j + 34, 176, 14, l + 1, 16);
|
||||
}
|
||||
|
||||
private int getCookProgressScaled(int pixels)
|
||||
{
|
||||
int i = this.tileLaunchPad.getField(2);
|
||||
int j = this.tileLaunchPad.getField(3);
|
||||
return j != 0 && i != 0 ? i * pixels / j : 0;
|
||||
}
|
||||
|
||||
private int getBurnLeftScaled(int pixels)
|
||||
{
|
||||
int i = this.tileLaunchPad.getField(1);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
i = 200;
|
||||
}
|
||||
|
||||
return this.tileLaunchPad.getField(0) * pixels / i;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package com.droog71.prospect.gui;
|
||||
|
||||
import com.droog71.prospect.inventory.PressContainer;
|
||||
import com.droog71.prospect.tilentity.PressTileEntity;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class PressGUI extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation PRESS_GUI_TEXTURES = new ResourceLocation("prospect:textures/gui/press.png");
|
||||
/** The player inventory bound to this GUI. */
|
||||
private final InventoryPlayer playerInventory;
|
||||
private final IInventory tilePress;
|
||||
|
||||
public PressGUI(InventoryPlayer playerInv, IInventory pressInv)
|
||||
{
|
||||
super(new PressContainer(playerInv, pressInv));
|
||||
this.playerInventory = playerInv;
|
||||
this.tilePress = pressInv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the screen and all the components in it.
|
||||
*/
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.drawDefaultBackground();
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
this.renderHoveredToolTip(mouseX, mouseY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
String s = this.tilePress.getName();
|
||||
this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 6, 4210752);
|
||||
this.fontRenderer.drawString(this.playerInventory.getDisplayName().getUnformattedText(), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the background layer of this container (behind the items).
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
|
||||
{
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(PRESS_GUI_TEXTURES);
|
||||
int i = (this.width - this.xSize) / 2;
|
||||
int j = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
if (PressTileEntity.isEnergized(this.tilePress))
|
||||
{
|
||||
int k = this.getBurnLeftScaled(13);
|
||||
this.drawTexturedModalRect(i + 56, j + 36 + 12 - k, 176, 12 - k, 14, k + 1);
|
||||
}
|
||||
|
||||
int l = this.getCookProgressScaled(24);
|
||||
this.drawTexturedModalRect(i + 79, j + 34, 176, 14, l + 1, 16);
|
||||
}
|
||||
|
||||
private int getCookProgressScaled(int pixels)
|
||||
{
|
||||
int i = this.tilePress.getField(2);
|
||||
int j = this.tilePress.getField(3);
|
||||
return j != 0 && i != 0 ? i * pixels / j : 0;
|
||||
}
|
||||
|
||||
private int getBurnLeftScaled(int pixels)
|
||||
{
|
||||
int i = this.tilePress.getField(1);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
i = 200;
|
||||
}
|
||||
|
||||
return this.tilePress.getField(0) * pixels / i;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package com.droog71.prospect.gui;
|
||||
|
||||
import com.droog71.prospect.inventory.PrinterContainer;
|
||||
import com.droog71.prospect.tilentity.PrinterTileEntity;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class PrinterGUI extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation PRINTER_GUI_TEXTURES = new ResourceLocation("prospect:textures/gui/printer.png");
|
||||
/** The player inventory bound to this GUI. */
|
||||
private final InventoryPlayer playerInventory;
|
||||
private final IInventory tilePrinter;
|
||||
|
||||
public PrinterGUI(InventoryPlayer playerInv, IInventory printerInv)
|
||||
{
|
||||
super(new PrinterContainer(playerInv, printerInv));
|
||||
this.playerInventory = playerInv;
|
||||
this.tilePrinter = printerInv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the screen and all the components in it.
|
||||
*/
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.drawDefaultBackground();
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
this.renderHoveredToolTip(mouseX, mouseY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
String s = this.tilePrinter.getName();
|
||||
this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 6, 4210752);
|
||||
this.fontRenderer.drawString(this.playerInventory.getDisplayName().getUnformattedText(), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the background layer of this container (behind the items).
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
|
||||
{
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(PRINTER_GUI_TEXTURES);
|
||||
int i = (this.width - this.xSize) / 2;
|
||||
int j = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
if (PrinterTileEntity.isEnergized(this.tilePrinter))
|
||||
{
|
||||
int k = this.getBurnLeftScaled(13);
|
||||
this.drawTexturedModalRect(i + 56, j + 36 + 12 - k, 176, 12 - k, 14, k + 1);
|
||||
}
|
||||
|
||||
int l = this.getCookProgressScaled(24);
|
||||
this.drawTexturedModalRect(i + 79, j + 34, 176, 14, l + 1, 16);
|
||||
}
|
||||
|
||||
private int getCookProgressScaled(int pixels)
|
||||
{
|
||||
int i = this.tilePrinter.getField(2);
|
||||
int j = this.tilePrinter.getField(3);
|
||||
return j != 0 && i != 0 ? i * pixels / j : 0;
|
||||
}
|
||||
|
||||
private int getBurnLeftScaled(int pixels)
|
||||
{
|
||||
int i = this.tilePrinter.getField(1);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
i = 200;
|
||||
}
|
||||
|
||||
return this.tilePrinter.getField(0) * pixels / i;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package com.droog71.prospect.gui;
|
||||
|
||||
import com.droog71.prospect.inventory.ExtruderContainer;
|
||||
import com.droog71.prospect.inventory.LaunchPadContainer;
|
||||
import com.droog71.prospect.inventory.PressContainer;
|
||||
import com.droog71.prospect.inventory.PrinterContainer;
|
||||
import com.droog71.prospect.inventory.ReplicatorContainer;
|
||||
import com.droog71.prospect.tilentity.ExtruderTileEntity;
|
||||
import com.droog71.prospect.tilentity.LaunchPadTileEntity;
|
||||
import com.droog71.prospect.tilentity.PressTileEntity;
|
||||
import com.droog71.prospect.tilentity.PrinterTileEntity;
|
||||
import com.droog71.prospect.tilentity.ReplicatorTileEntity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||
|
||||
public class ProspectGuiHandler implements IGuiHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
if (ID == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (ID == 1)
|
||||
{
|
||||
return new PrinterContainer(player.inventory, (PrinterTileEntity)world.getTileEntity(new BlockPos(x,y,z)));
|
||||
}
|
||||
if (ID == 2)
|
||||
{
|
||||
return new ReplicatorContainer(player.inventory, (ReplicatorTileEntity)world.getTileEntity(new BlockPos(x,y,z)));
|
||||
}
|
||||
if (ID == 3)
|
||||
{
|
||||
return new LaunchPadContainer(player.inventory, (LaunchPadTileEntity)world.getTileEntity(new BlockPos(x,y,z)));
|
||||
}
|
||||
if (ID == 4)
|
||||
{
|
||||
return new ExtruderContainer(player.inventory, (ExtruderTileEntity)world.getTileEntity(new BlockPos(x,y,z)));
|
||||
}
|
||||
if (ID == 5)
|
||||
{
|
||||
return new PressContainer(player.inventory, (PressTileEntity)world.getTileEntity(new BlockPos(x,y,z)));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
if (ID == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (ID == 1)
|
||||
{
|
||||
return new PrinterGUI(player.inventory, (PrinterTileEntity)world.getTileEntity(new BlockPos(x,y,z)));
|
||||
}
|
||||
if (ID == 2)
|
||||
{
|
||||
return new ReplicatorGUI(player.inventory, (ReplicatorTileEntity)world.getTileEntity(new BlockPos(x,y,z)));
|
||||
}
|
||||
if (ID == 3)
|
||||
{
|
||||
return new LaunchPadGUI(player.inventory, (LaunchPadTileEntity)world.getTileEntity(new BlockPos(x,y,z)));
|
||||
}
|
||||
if (ID == 4)
|
||||
{
|
||||
return new ExtruderGUI(player.inventory, (ExtruderTileEntity)world.getTileEntity(new BlockPos(x,y,z)));
|
||||
}
|
||||
if (ID == 5)
|
||||
{
|
||||
return new PressGUI(player.inventory, (PressTileEntity)world.getTileEntity(new BlockPos(x,y,z)));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package com.droog71.prospect.gui;
|
||||
|
||||
import com.droog71.prospect.inventory.ReplicatorContainer;
|
||||
import com.droog71.prospect.tilentity.ReplicatorTileEntity;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ReplicatorGUI extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation REPLICATOR_GUI_TEXTURES = new ResourceLocation("prospect:textures/gui/replicator.png");
|
||||
/** The player inventory bound to this GUI. */
|
||||
private final InventoryPlayer playerInventory;
|
||||
private final IInventory tileReplicator;
|
||||
|
||||
public ReplicatorGUI(InventoryPlayer playerInv, IInventory replicatorInv)
|
||||
{
|
||||
super(new ReplicatorContainer(playerInv, replicatorInv));
|
||||
this.playerInventory = playerInv;
|
||||
this.tileReplicator = replicatorInv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the screen and all the components in it.
|
||||
*/
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.drawDefaultBackground();
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
this.renderHoveredToolTip(mouseX, mouseY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
String s = this.tileReplicator.getName();
|
||||
this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 6, 4210752);
|
||||
this.fontRenderer.drawString(this.playerInventory.getDisplayName().getUnformattedText(), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the background layer of this container (behind the items).
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
|
||||
{
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(REPLICATOR_GUI_TEXTURES);
|
||||
int i = (this.width - this.xSize) / 2;
|
||||
int j = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
if (ReplicatorTileEntity.isEnergized(this.tileReplicator))
|
||||
{
|
||||
int k = this.getBurnLeftScaled(13);
|
||||
this.drawTexturedModalRect(i + 56, j + 36 + 12 - k, 176, 12 - k, 14, k + 1);
|
||||
}
|
||||
|
||||
int l = this.getCookProgressScaled(24);
|
||||
this.drawTexturedModalRect(i + 79, j + 34, 176, 14, l + 1, 16);
|
||||
}
|
||||
|
||||
private int getCookProgressScaled(int pixels)
|
||||
{
|
||||
int i = this.tileReplicator.getField(2);
|
||||
int j = this.tileReplicator.getField(3);
|
||||
return j != 0 && i != 0 ? i * pixels / j : 0;
|
||||
}
|
||||
|
||||
private int getBurnLeftScaled(int pixels)
|
||||
{
|
||||
int i = this.tileReplicator.getField(4);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
i = 200;
|
||||
}
|
||||
|
||||
return this.tileReplicator.getField(5) * pixels / i;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,254 @@
|
|||
package com.droog71.prospect.init;
|
||||
|
||||
import com.droog71.prospect.Prospect;
|
||||
import com.droog71.prospect.blocks.ProspectBlock;
|
||||
import com.droog71.prospect.blocks.energy.Cable;
|
||||
import com.droog71.prospect.blocks.energy.Extruder;
|
||||
import com.droog71.prospect.blocks.energy.LaunchPad;
|
||||
import com.droog71.prospect.blocks.energy.Press;
|
||||
import com.droog71.prospect.blocks.energy.Printer;
|
||||
import com.droog71.prospect.blocks.energy.Purifier;
|
||||
import com.droog71.prospect.blocks.energy.Quarry;
|
||||
import com.droog71.prospect.blocks.energy.Replicator;
|
||||
import com.droog71.prospect.blocks.energy.SolarPanel;
|
||||
import com.droog71.prospect.blocks.energy.Transformer;
|
||||
import com.droog71.prospect.blocks.ore.LivingOre;
|
||||
import com.droog71.prospect.tilentity.CableTileEntity;
|
||||
import com.droog71.prospect.tilentity.ExtruderTileEntity;
|
||||
import com.droog71.prospect.tilentity.LaunchPadTileEntity;
|
||||
import com.droog71.prospect.tilentity.PressTileEntity;
|
||||
import com.droog71.prospect.tilentity.PrinterTileEntity;
|
||||
import com.droog71.prospect.tilentity.PurifierTileEntity;
|
||||
import com.droog71.prospect.tilentity.QuarryTileEntity;
|
||||
import com.droog71.prospect.tilentity.ReplicatorTileEntity;
|
||||
import com.droog71.prospect.tilentity.SolarPanelTileEntity;
|
||||
import com.droog71.prospect.tilentity.TransformerTileEntity;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = Prospect.MODID)
|
||||
public class ProspectBlocks
|
||||
{
|
||||
public static Block living_ore;
|
||||
public static Block copper_ore;
|
||||
public static Block tin_ore;
|
||||
public static Block silver_ore;
|
||||
public static Block lead_ore;
|
||||
public static Block aluminum_ore;
|
||||
public static Block silicon_ore;
|
||||
public static Block purifier;
|
||||
public static Block quarry;
|
||||
public static Block printer;
|
||||
public static Block replicator;
|
||||
public static Block quarry_frame;
|
||||
public static Block quarry_tube;
|
||||
public static Block quarry_drill;
|
||||
public static Block launch_pad;
|
||||
public static Block capsule;
|
||||
public static Block extruder;
|
||||
public static Block press;
|
||||
public static Block lv_cable;
|
||||
public static Block mv_cable;
|
||||
public static Block hv_cable;
|
||||
public static Block ev_cable;
|
||||
public static Block iv_cable;
|
||||
public static Block lv_transformer;
|
||||
public static Block mv_transformer;
|
||||
public static Block hv_transformer;
|
||||
public static Block ev_transformer;
|
||||
public static Block lv_solar_panel;
|
||||
public static Block mv_solar_panel;
|
||||
public static Block hv_solar_panel;
|
||||
public static Block ev_solar_panel;
|
||||
public static Block iv_solar_panel;
|
||||
static ExtruderTileEntity extruderTileEntity;
|
||||
static PressTileEntity pressTileEntity;
|
||||
static PurifierTileEntity purifierTileEntity;
|
||||
static PrinterTileEntity printerTileEntity;
|
||||
static QuarryTileEntity quarryTileEntity;
|
||||
static ReplicatorTileEntity replicatorTileEntity;
|
||||
static SolarPanelTileEntity solarPanelTileEntity;
|
||||
static LaunchPadTileEntity launchPadTileEntity;
|
||||
static CableTileEntity cableTileEntity;
|
||||
static TransformerTileEntity transformerTileEntity;
|
||||
|
||||
public static void init()
|
||||
{
|
||||
extruder = new Extruder("extruder",Material.IRON).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
press = new Press("press",Material.IRON).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
purifier = new Purifier("purifier",Material.IRON).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
quarry = new Quarry("quarry",Material.IRON).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
printer = new Printer("printer",Material.IRON).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
replicator = new Replicator("replicator",Material.IRON).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
quarry_frame = new ProspectBlock("quarry_frame",Material.IRON).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
quarry_tube = new ProspectBlock("quarry_tube",Material.IRON).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
quarry_drill = new ProspectBlock("quarry_drill",Material.IRON).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
launch_pad = new LaunchPad("launch_pad",Material.IRON).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
capsule = new ProspectBlock("capsule",Material.IRON).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
copper_ore = new ProspectBlock("copper_ore",Material.ROCK).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
tin_ore = new ProspectBlock("tin_ore",Material.ROCK).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
silver_ore = new ProspectBlock("silver_ore",Material.ROCK).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
lead_ore = new ProspectBlock("lead_ore",Material.ROCK).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
aluminum_ore = new ProspectBlock("aluminum_ore",Material.ROCK).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
silicon_ore = new ProspectBlock("silicon_ore",Material.ROCK).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
living_ore = new LivingOre("living_ore",Material.ROCK).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
lv_cable = new Cable("lv_cable",Material.IRON,1000,5000).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
mv_cable = new Cable("mv_cable",Material.IRON,4000,20000).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
hv_cable = new Cable("hv_cable",Material.IRON,9000,45000).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
ev_cable = new Cable("ev_cable",Material.IRON,16000,80000).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
iv_cable = new Cable("iv_cable",Material.IRON,25000,125000).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
lv_transformer = new Transformer("lv_transformer",Material.IRON,4000,20000,1000).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
mv_transformer = new Transformer("mv_transformer",Material.IRON,9000,45000,4000).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
hv_transformer = new Transformer("hv_transformer",Material.IRON,16000,80000,9000).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
ev_transformer = new Transformer("ev_transformer",Material.IRON,25000,125000,16000).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
lv_solar_panel = new SolarPanel("lv_solar_panel",Material.IRON,64,32,1).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
mv_solar_panel = new SolarPanel("mv_solar_panel",Material.IRON,256,128,2).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
hv_solar_panel = new SolarPanel("hv_solar_panel",Material.IRON,1024,512,3).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
ev_solar_panel = new SolarPanel("ev_solar_panel",Material.IRON,4096,2048,4).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
iv_solar_panel = new SolarPanel("iv_solar_panel",Material.IRON,16384,8192,5).setHardness(1.0f).setCreativeTab(Prospect.tabProspect);
|
||||
extruderTileEntity = new ExtruderTileEntity();
|
||||
pressTileEntity = new PressTileEntity();
|
||||
purifierTileEntity = new PurifierTileEntity();
|
||||
printerTileEntity = new PrinterTileEntity();
|
||||
quarryTileEntity = new QuarryTileEntity();
|
||||
replicatorTileEntity = new ReplicatorTileEntity();
|
||||
solarPanelTileEntity = new SolarPanelTileEntity();
|
||||
launchPadTileEntity = new LaunchPadTileEntity();
|
||||
cableTileEntity = new CableTileEntity(0,0);
|
||||
transformerTileEntity = new TransformerTileEntity(0,0,0);
|
||||
GameRegistry.registerTileEntity(pressTileEntity.getClass(),"prospect:pressTileEntity");
|
||||
GameRegistry.registerTileEntity(extruderTileEntity.getClass(),"prospect:extruderTileEntity");
|
||||
GameRegistry.registerTileEntity(purifierTileEntity.getClass(), "prospect:purifierTileEntity");
|
||||
GameRegistry.registerTileEntity(printerTileEntity.getClass(), "prospect:printerTileEntity");
|
||||
GameRegistry.registerTileEntity(quarryTileEntity.getClass(), "prospect:quarryTileEntity");
|
||||
GameRegistry.registerTileEntity(replicatorTileEntity.getClass(), "prospect:replicatorTileEntity");
|
||||
GameRegistry.registerTileEntity(solarPanelTileEntity.getClass(), "prospect:solarPanelTileEntity");
|
||||
GameRegistry.registerTileEntity(launchPadTileEntity.getClass(), "prospect:launchPadTileEntity");
|
||||
GameRegistry.registerTileEntity(cableTileEntity.getClass(), "prospect:cableTileEntity");
|
||||
GameRegistry.registerTileEntity(transformerTileEntity.getClass(), "prospect:transformerTileEntity");
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerBlocks(RegistryEvent.Register<Block> event)
|
||||
{
|
||||
event.getRegistry().registerAll(extruder);
|
||||
event.getRegistry().registerAll(press);
|
||||
event.getRegistry().registerAll(living_ore);
|
||||
event.getRegistry().registerAll(purifier);
|
||||
event.getRegistry().registerAll(quarry);
|
||||
event.getRegistry().registerAll(quarry_frame);
|
||||
event.getRegistry().registerAll(quarry_tube);
|
||||
event.getRegistry().registerAll(quarry_drill);
|
||||
event.getRegistry().registerAll(printer);
|
||||
event.getRegistry().registerAll(replicator);
|
||||
event.getRegistry().registerAll(launch_pad);
|
||||
event.getRegistry().registerAll(capsule);
|
||||
event.getRegistry().registerAll(copper_ore);
|
||||
event.getRegistry().registerAll(tin_ore);
|
||||
event.getRegistry().registerAll(silver_ore);
|
||||
event.getRegistry().registerAll(lead_ore);
|
||||
event.getRegistry().registerAll(aluminum_ore);
|
||||
event.getRegistry().registerAll(silicon_ore);
|
||||
event.getRegistry().registerAll(lv_cable);
|
||||
event.getRegistry().registerAll(mv_cable);
|
||||
event.getRegistry().registerAll(hv_cable);
|
||||
event.getRegistry().registerAll(ev_cable);
|
||||
event.getRegistry().registerAll(iv_cable);
|
||||
event.getRegistry().registerAll(lv_transformer);
|
||||
event.getRegistry().registerAll(mv_transformer);
|
||||
event.getRegistry().registerAll(hv_transformer);
|
||||
event.getRegistry().registerAll(ev_transformer);
|
||||
event.getRegistry().registerAll(lv_solar_panel);
|
||||
event.getRegistry().registerAll(mv_solar_panel);
|
||||
event.getRegistry().registerAll(hv_solar_panel);
|
||||
event.getRegistry().registerAll(ev_solar_panel);
|
||||
event.getRegistry().registerAll(iv_solar_panel);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItemBlocks(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
event.getRegistry().registerAll(new ItemBlock(extruder).setRegistryName(extruder.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(press).setRegistryName(press.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(living_ore).setRegistryName(living_ore.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(purifier).setRegistryName(purifier.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(printer).setRegistryName(printer.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(replicator).setRegistryName(replicator.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(quarry).setRegistryName(quarry.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(quarry_frame).setRegistryName(quarry_frame.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(quarry_tube).setRegistryName(quarry_tube.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(quarry_drill).setRegistryName(quarry_drill.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(launch_pad).setRegistryName(launch_pad.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(capsule).setRegistryName(capsule.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(copper_ore).setRegistryName(copper_ore.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(tin_ore).setRegistryName(tin_ore.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(silver_ore).setRegistryName(silver_ore.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(lead_ore).setRegistryName(lead_ore.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(aluminum_ore).setRegistryName(aluminum_ore.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(silicon_ore).setRegistryName(silicon_ore.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(lv_cable).setRegistryName(lv_cable.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(mv_cable).setRegistryName(mv_cable.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(hv_cable).setRegistryName(hv_cable.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(ev_cable).setRegistryName(ev_cable.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(iv_cable).setRegistryName(iv_cable.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(lv_transformer).setRegistryName(lv_transformer.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(mv_transformer).setRegistryName(mv_transformer.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(hv_transformer).setRegistryName(hv_transformer.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(ev_transformer).setRegistryName(ev_transformer.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(lv_solar_panel).setRegistryName(lv_solar_panel.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(mv_solar_panel).setRegistryName(mv_solar_panel.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(hv_solar_panel).setRegistryName(hv_solar_panel.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(ev_solar_panel).setRegistryName(ev_solar_panel.getRegistryName()));
|
||||
event.getRegistry().registerAll(new ItemBlock(iv_solar_panel).setRegistryName(iv_solar_panel.getRegistryName()));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerRenders(ModelRegistryEvent event)
|
||||
{
|
||||
registerRender(Item.getItemFromBlock(extruder));
|
||||
registerRender(Item.getItemFromBlock(press));
|
||||
registerRender(Item.getItemFromBlock(living_ore));
|
||||
registerRender(Item.getItemFromBlock(purifier));
|
||||
registerRender(Item.getItemFromBlock(quarry));
|
||||
registerRender(Item.getItemFromBlock(quarry_frame));
|
||||
registerRender(Item.getItemFromBlock(quarry_tube));
|
||||
registerRender(Item.getItemFromBlock(quarry_drill));
|
||||
registerRender(Item.getItemFromBlock(printer));
|
||||
registerRender(Item.getItemFromBlock(replicator));
|
||||
registerRender(Item.getItemFromBlock(launch_pad));
|
||||
registerRender(Item.getItemFromBlock(capsule));
|
||||
registerRender(Item.getItemFromBlock(copper_ore));
|
||||
registerRender(Item.getItemFromBlock(tin_ore));
|
||||
registerRender(Item.getItemFromBlock(silver_ore));
|
||||
registerRender(Item.getItemFromBlock(lead_ore));
|
||||
registerRender(Item.getItemFromBlock(aluminum_ore));
|
||||
registerRender(Item.getItemFromBlock(silicon_ore));
|
||||
registerRender(Item.getItemFromBlock(lv_cable));
|
||||
registerRender(Item.getItemFromBlock(mv_cable));
|
||||
registerRender(Item.getItemFromBlock(hv_cable));
|
||||
registerRender(Item.getItemFromBlock(ev_cable));
|
||||
registerRender(Item.getItemFromBlock(iv_cable));
|
||||
registerRender(Item.getItemFromBlock(lv_transformer));
|
||||
registerRender(Item.getItemFromBlock(mv_transformer));
|
||||
registerRender(Item.getItemFromBlock(hv_transformer));
|
||||
registerRender(Item.getItemFromBlock(ev_transformer));
|
||||
registerRender(Item.getItemFromBlock(lv_solar_panel));
|
||||
registerRender(Item.getItemFromBlock(mv_solar_panel));
|
||||
registerRender(Item.getItemFromBlock(hv_solar_panel));
|
||||
registerRender(Item.getItemFromBlock(ev_solar_panel));
|
||||
registerRender(Item.getItemFromBlock(iv_solar_panel));
|
||||
}
|
||||
|
||||
public static void registerRender(Item item)
|
||||
{
|
||||
Prospect.proxy.registerRenderInformation(item);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,373 @@
|
|||
package com.droog71.prospect.init;
|
||||
|
||||
import com.droog71.prospect.Prospect;
|
||||
import com.droog71.prospect.armor.ProspectArmor;
|
||||
import com.droog71.prospect.items.ProspectItem;
|
||||
import com.droog71.prospect.items.Schematic;
|
||||
import com.droog71.prospect.items.SporeFilter;
|
||||
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
@Mod.EventBusSubscriber(modid=Prospect.MODID)
|
||||
public class ProspectItems
|
||||
{
|
||||
public static Item helmet;
|
||||
public static Item suit;
|
||||
public static Item pants;
|
||||
public static Item boots;
|
||||
|
||||
public static Item filter;
|
||||
public static Item suit_material;
|
||||
public static Item gem;
|
||||
public static Item credit;
|
||||
public static Item copper_wire;
|
||||
public static Item mv_wire;
|
||||
public static Item hv_wire;
|
||||
public static Item ev_wire;
|
||||
public static Item iv_wire;
|
||||
public static Item in_lv_wire;
|
||||
public static Item in_mv_wire;
|
||||
public static Item in_hv_wire;
|
||||
public static Item in_ev_wire;
|
||||
public static Item in_iv_wire;
|
||||
public static Item lv_coil;
|
||||
public static Item mv_coil;
|
||||
public static Item hv_coil;
|
||||
public static Item ev_coil;
|
||||
public static Item iv_coil;
|
||||
public static Item circuit;
|
||||
public static Item prepared_circuit;
|
||||
public static Item quantum_circuit;
|
||||
public static Item copper_ingot;
|
||||
public static Item tin_ingot;
|
||||
public static Item silver_ingot;
|
||||
public static Item lead_ingot;
|
||||
public static Item aluminum_ingot;
|
||||
public static Item copper_plate;
|
||||
public static Item tin_plate;
|
||||
public static Item silver_plate;
|
||||
public static Item lead_plate;
|
||||
public static Item aluminum_plate;
|
||||
public static Item silicon;
|
||||
|
||||
public static Item mv_wire_schematic;
|
||||
public static Item hv_wire_schematic;
|
||||
public static Item ev_wire_schematic;
|
||||
public static Item iv_wire_schematic;
|
||||
public static Item in_lv_wire_schematic;
|
||||
public static Item in_mv_wire_schematic;
|
||||
public static Item in_hv_wire_schematic;
|
||||
public static Item in_ev_wire_schematic;
|
||||
public static Item in_iv_wire_schematic;
|
||||
public static Item lv_coil_schematic;
|
||||
public static Item mv_coil_schematic;
|
||||
public static Item hv_coil_schematic;
|
||||
public static Item ev_coil_schematic;
|
||||
public static Item iv_coil_schematic;
|
||||
public static Item circuit_schematic;
|
||||
public static Item prepared_circuit_schematic;
|
||||
public static Item filter_schematic;
|
||||
public static Item helmet_schematic;
|
||||
public static Item suit_schematic;
|
||||
public static Item pants_schematic;
|
||||
public static Item boots_schematic;
|
||||
public static Item printer_schematic;
|
||||
public static Item quarry_schematic;
|
||||
public static Item purifier_schematic;
|
||||
public static Item launch_pad_schematic;
|
||||
public static Item replicator_schematic;
|
||||
public static Item extruder_schematic;
|
||||
public static Item lv_cable_schematic;
|
||||
public static Item mv_cable_schematic;
|
||||
public static Item hv_cable_schematic;
|
||||
public static Item ev_cable_schematic;
|
||||
public static Item iv_cable_schematic;
|
||||
public static Item lv_transformer_schematic;
|
||||
public static Item mv_transformer_schematic;
|
||||
public static Item hv_transformer_schematic;
|
||||
public static Item ev_transformer_schematic;
|
||||
public static Item lv_solar_panel_schematic;
|
||||
public static Item mv_solar_panel_schematic;
|
||||
public static Item hv_solar_panel_schematic;
|
||||
public static Item ev_solar_panel_schematic;
|
||||
public static Item iv_solar_panel_schematic;
|
||||
|
||||
public static Item chest_schematic;
|
||||
public static Item hopper_schematic;
|
||||
public static Item piston_schematic;
|
||||
|
||||
public static void init()
|
||||
{
|
||||
helmet = new ProspectArmor("helmet",Prospect.tabProspect,ProspectArmor.PROSPECTOR_ARMOR, 0, EntityEquipmentSlot.HEAD);
|
||||
suit = new ProspectArmor("suit",Prospect.tabProspect,ProspectArmor.PROSPECTOR_ARMOR, 0, EntityEquipmentSlot.CHEST);
|
||||
pants = new ProspectArmor("pants",Prospect.tabProspect,ProspectArmor.PROSPECTOR_ARMOR, 1, EntityEquipmentSlot.LEGS);
|
||||
boots = new ProspectArmor("boots",Prospect.tabProspect,ProspectArmor.PROSPECTOR_ARMOR, 0, EntityEquipmentSlot.FEET);
|
||||
|
||||
filter = new SporeFilter("filter").setMaxDamage(100000).setCreativeTab(Prospect.tabProspect).setMaxStackSize(1);
|
||||
gem = new ProspectItem("gem").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
credit = new ProspectItem("credit").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
suit_material = new ProspectItem("suit_material").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
copper_wire = new ProspectItem("copper_wire").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
mv_wire = new ProspectItem("mv_wire").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
hv_wire = new ProspectItem("hv_wire").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
ev_wire = new ProspectItem("ev_wire").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
iv_wire = new ProspectItem("iv_wire").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
in_lv_wire = new ProspectItem("in_lv_wire").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
in_mv_wire = new ProspectItem("in_mv_wire").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
in_hv_wire = new ProspectItem("in_hv_wire").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
in_ev_wire = new ProspectItem("in_ev_wire").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
in_iv_wire = new ProspectItem("in_iv_wire").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
lv_coil = new ProspectItem("lv_coil").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
mv_coil = new ProspectItem("mv_coil").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
hv_coil = new ProspectItem("hv_coil").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
ev_coil = new ProspectItem("ev_coil").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
iv_coil = new ProspectItem("iv_coil").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
circuit = new ProspectItem("circuit").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
prepared_circuit = new ProspectItem("prepared_circuit").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
quantum_circuit = new ProspectItem("quantum_circuit").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
copper_ingot = new ProspectItem("copper_ingot").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
tin_ingot = new ProspectItem("tin_ingot").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
silver_ingot = new ProspectItem("silver_ingot").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
lead_ingot = new ProspectItem("lead_ingot").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
aluminum_ingot = new ProspectItem("aluminum_ingot").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
copper_plate = new ProspectItem("copper_plate").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
tin_plate = new ProspectItem("tin_plate").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
silver_plate = new ProspectItem("silver_plate").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
lead_plate = new ProspectItem("lead_plate").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
aluminum_plate = new ProspectItem("aluminum_plate").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
silicon = new ProspectItem("silicon").setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
|
||||
boots_schematic = new Schematic("boots_schematic",0).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
pants_schematic = new Schematic("pants_schematic",1).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
suit_schematic = new Schematic("suit_schematic",2).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
helmet_schematic = new Schematic("helmet_schematic",3).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
filter_schematic = new Schematic("filter_schematic",4).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
launch_pad_schematic = new Schematic("launch_pad_schematic",5).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
printer_schematic = new Schematic("printer_schematic",6).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
extruder_schematic = new Schematic("extruder_schematic",7).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
purifier_schematic = new Schematic("purifier_schematic",8).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
quarry_schematic = new Schematic("quarry_schematic",9).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
replicator_schematic = new Schematic("replicator_schematic",10).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
mv_wire_schematic = new Schematic("mv_wire_schematic",11).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
hv_wire_schematic = new Schematic("hv_wire_schematic",12).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
ev_wire_schematic = new Schematic("ev_wire_schematic",13).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
iv_wire_schematic = new Schematic("iv_wire_schematic",14).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
in_lv_wire_schematic = new Schematic("in_lv_wire_schematic",15).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
in_mv_wire_schematic = new Schematic("in_mv_wire_schematic",16).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
in_hv_wire_schematic = new Schematic("in_hv_wire_schematic",17).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
in_ev_wire_schematic = new Schematic("in_ev_wire_schematic",18).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
in_iv_wire_schematic = new Schematic("in_iv_wire_schematic",19).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
lv_coil_schematic = new Schematic("lv_coil_schematic",20).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
mv_coil_schematic = new Schematic("mv_coil_schematic",21).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
hv_coil_schematic = new Schematic("hv_coil_schematic",22).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
ev_coil_schematic = new Schematic("ev_coil_schematic",23).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
iv_coil_schematic = new Schematic("iv_coil_schematic",24).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
circuit_schematic = new Schematic("circuit_schematic",25).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
prepared_circuit_schematic = new Schematic("prepared_circuit_schematic",26).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
lv_cable_schematic = new Schematic("lv_cable_schematic",27).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
mv_cable_schematic = new Schematic("mv_cable_schematic",28).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
hv_cable_schematic = new Schematic("hv_cable_schematic",29).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
ev_cable_schematic = new Schematic("ev_cable_schematic",30).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
iv_cable_schematic = new Schematic("iv_cable_schematic",31).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
lv_transformer_schematic = new Schematic("lv_transformer_schematic",32).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
mv_transformer_schematic = new Schematic("mv_transformer_schematic",33).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
hv_transformer_schematic = new Schematic("hv_transformer_schematic",34).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
ev_transformer_schematic = new Schematic("ev_transformer_schematic",35).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
lv_solar_panel_schematic = new Schematic("lv_solar_panel_schematic",36).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
mv_solar_panel_schematic = new Schematic("mv_solar_panel_schematic",37).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
hv_solar_panel_schematic = new Schematic("hv_solar_panel_schematic",38).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
ev_solar_panel_schematic = new Schematic("ev_solar_panel_schematic",39).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
iv_solar_panel_schematic = new Schematic("iv_solar_panel_schematic",40).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
chest_schematic = new Schematic("chest_schematic",41).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
hopper_schematic = new Schematic("hopper_schematic",42).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
piston_schematic = new Schematic("piston_schematic",43).setCreativeTab(Prospect.tabProspect).setMaxStackSize(64);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
event.getRegistry().registerAll(helmet);
|
||||
event.getRegistry().registerAll(suit);
|
||||
event.getRegistry().registerAll(pants);
|
||||
event.getRegistry().registerAll(boots);
|
||||
|
||||
event.getRegistry().registerAll(filter);
|
||||
event.getRegistry().registerAll(gem);
|
||||
event.getRegistry().registerAll(credit);
|
||||
event.getRegistry().registerAll(suit_material);
|
||||
event.getRegistry().registerAll(copper_wire);
|
||||
event.getRegistry().registerAll(mv_wire);
|
||||
event.getRegistry().registerAll(hv_wire);
|
||||
event.getRegistry().registerAll(ev_wire);
|
||||
event.getRegistry().registerAll(iv_wire);
|
||||
event.getRegistry().registerAll(in_lv_wire);
|
||||
event.getRegistry().registerAll(in_mv_wire);
|
||||
event.getRegistry().registerAll(in_hv_wire);
|
||||
event.getRegistry().registerAll(in_ev_wire);
|
||||
event.getRegistry().registerAll(in_iv_wire);
|
||||
event.getRegistry().registerAll(lv_coil);
|
||||
event.getRegistry().registerAll(mv_coil);
|
||||
event.getRegistry().registerAll(hv_coil);
|
||||
event.getRegistry().registerAll(ev_coil);
|
||||
event.getRegistry().registerAll(iv_coil);
|
||||
event.getRegistry().registerAll(circuit);
|
||||
event.getRegistry().registerAll(prepared_circuit);
|
||||
event.getRegistry().registerAll(quantum_circuit);
|
||||
event.getRegistry().registerAll(copper_ingot);
|
||||
event.getRegistry().registerAll(tin_ingot);
|
||||
event.getRegistry().registerAll(silver_ingot);
|
||||
event.getRegistry().registerAll(lead_ingot);
|
||||
event.getRegistry().registerAll(aluminum_ingot);
|
||||
event.getRegistry().registerAll(copper_plate);
|
||||
event.getRegistry().registerAll(tin_plate);
|
||||
event.getRegistry().registerAll(silver_plate);
|
||||
event.getRegistry().registerAll(lead_plate);
|
||||
event.getRegistry().registerAll(aluminum_plate);
|
||||
event.getRegistry().registerAll(silicon);
|
||||
|
||||
event.getRegistry().registerAll(purifier_schematic);
|
||||
event.getRegistry().registerAll(launch_pad_schematic);
|
||||
event.getRegistry().registerAll(printer_schematic);
|
||||
event.getRegistry().registerAll(helmet_schematic);
|
||||
event.getRegistry().registerAll(suit_schematic);
|
||||
event.getRegistry().registerAll(pants_schematic);
|
||||
event.getRegistry().registerAll(boots_schematic);
|
||||
event.getRegistry().registerAll(filter_schematic);
|
||||
event.getRegistry().registerAll(quarry_schematic);
|
||||
event.getRegistry().registerAll(replicator_schematic);
|
||||
event.getRegistry().registerAll(extruder_schematic);
|
||||
event.getRegistry().registerAll(lv_cable_schematic);
|
||||
event.getRegistry().registerAll(mv_cable_schematic);
|
||||
event.getRegistry().registerAll(hv_cable_schematic);
|
||||
event.getRegistry().registerAll(ev_cable_schematic);
|
||||
event.getRegistry().registerAll(iv_cable_schematic);
|
||||
event.getRegistry().registerAll(lv_transformer_schematic);
|
||||
event.getRegistry().registerAll(mv_transformer_schematic);
|
||||
event.getRegistry().registerAll(hv_transformer_schematic);
|
||||
event.getRegistry().registerAll(ev_transformer_schematic);
|
||||
event.getRegistry().registerAll(lv_solar_panel_schematic);
|
||||
event.getRegistry().registerAll(mv_solar_panel_schematic);
|
||||
event.getRegistry().registerAll(hv_solar_panel_schematic);
|
||||
event.getRegistry().registerAll(ev_solar_panel_schematic);
|
||||
event.getRegistry().registerAll(iv_solar_panel_schematic);
|
||||
event.getRegistry().registerAll(mv_wire_schematic);
|
||||
event.getRegistry().registerAll(hv_wire_schematic);
|
||||
event.getRegistry().registerAll(ev_wire_schematic);
|
||||
event.getRegistry().registerAll(iv_wire_schematic);
|
||||
event.getRegistry().registerAll(in_lv_wire_schematic);
|
||||
event.getRegistry().registerAll(in_mv_wire_schematic);
|
||||
event.getRegistry().registerAll(in_hv_wire_schematic);
|
||||
event.getRegistry().registerAll(in_ev_wire_schematic);
|
||||
event.getRegistry().registerAll(in_iv_wire_schematic);
|
||||
event.getRegistry().registerAll(lv_coil_schematic);
|
||||
event.getRegistry().registerAll(mv_coil_schematic);
|
||||
event.getRegistry().registerAll(hv_coil_schematic);
|
||||
event.getRegistry().registerAll(ev_coil_schematic);
|
||||
event.getRegistry().registerAll(iv_coil_schematic);
|
||||
event.getRegistry().registerAll(circuit_schematic);
|
||||
event.getRegistry().registerAll(prepared_circuit_schematic);
|
||||
|
||||
event.getRegistry().registerAll(chest_schematic);
|
||||
event.getRegistry().registerAll(hopper_schematic);
|
||||
event.getRegistry().registerAll(piston_schematic);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerRenders(ModelRegistryEvent event)
|
||||
{
|
||||
registerRender(filter);
|
||||
registerRender(helmet);
|
||||
registerRender(suit);
|
||||
registerRender(pants);
|
||||
registerRender(boots);
|
||||
|
||||
registerRender(gem);
|
||||
registerRender(credit);
|
||||
registerRender(suit_material);
|
||||
registerRender(copper_wire);
|
||||
registerRender(mv_wire);
|
||||
registerRender(hv_wire);
|
||||
registerRender(ev_wire);
|
||||
registerRender(iv_wire);
|
||||
registerRender(in_lv_wire);
|
||||
registerRender(in_mv_wire);
|
||||
registerRender(in_hv_wire);
|
||||
registerRender(in_ev_wire);
|
||||
registerRender(in_iv_wire);
|
||||
registerRender(lv_coil);
|
||||
registerRender(mv_coil);
|
||||
registerRender(hv_coil);
|
||||
registerRender(ev_coil);
|
||||
registerRender(iv_coil);
|
||||
registerRender(circuit);
|
||||
registerRender(prepared_circuit);
|
||||
registerRender(quantum_circuit);
|
||||
registerRender(copper_ingot);
|
||||
registerRender(tin_ingot);
|
||||
registerRender(silver_ingot);
|
||||
registerRender(lead_ingot);
|
||||
registerRender(aluminum_ingot);
|
||||
registerRender(copper_plate);
|
||||
registerRender(tin_plate);
|
||||
registerRender(silver_plate);
|
||||
registerRender(lead_plate);
|
||||
registerRender(aluminum_plate);
|
||||
registerRender(silicon);
|
||||
|
||||
registerRender(helmet_schematic);
|
||||
registerRender(suit_schematic);
|
||||
registerRender(pants_schematic);
|
||||
registerRender(boots_schematic);
|
||||
registerRender(quarry_schematic);
|
||||
registerRender(replicator_schematic);
|
||||
registerRender(extruder_schematic);
|
||||
registerRender(purifier_schematic);
|
||||
registerRender(launch_pad_schematic);
|
||||
registerRender(printer_schematic);
|
||||
registerRender(lv_transformer_schematic);
|
||||
registerRender(mv_transformer_schematic);
|
||||
registerRender(hv_transformer_schematic);
|
||||
registerRender(ev_transformer_schematic);
|
||||
registerRender(lv_solar_panel_schematic);
|
||||
registerRender(mv_solar_panel_schematic);
|
||||
registerRender(hv_solar_panel_schematic);
|
||||
registerRender(ev_solar_panel_schematic);
|
||||
registerRender(iv_solar_panel_schematic);
|
||||
registerRender(lv_cable_schematic);
|
||||
registerRender(mv_cable_schematic);
|
||||
registerRender(hv_cable_schematic);
|
||||
registerRender(ev_cable_schematic);
|
||||
registerRender(iv_cable_schematic);
|
||||
registerRender(filter_schematic);
|
||||
registerRender(mv_wire_schematic);
|
||||
registerRender(hv_wire_schematic);
|
||||
registerRender(ev_wire_schematic);
|
||||
registerRender(iv_wire_schematic);
|
||||
registerRender(in_lv_wire_schematic);
|
||||
registerRender(in_mv_wire_schematic);
|
||||
registerRender(in_hv_wire_schematic);
|
||||
registerRender(in_ev_wire_schematic);
|
||||
registerRender(in_iv_wire_schematic);
|
||||
registerRender(lv_coil_schematic);
|
||||
registerRender(mv_coil_schematic);
|
||||
registerRender(hv_coil_schematic);
|
||||
registerRender(ev_coil_schematic);
|
||||
registerRender(iv_coil_schematic);
|
||||
registerRender(circuit_schematic);
|
||||
registerRender(prepared_circuit_schematic);
|
||||
|
||||
registerRender(chest_schematic);
|
||||
registerRender(hopper_schematic);
|
||||
registerRender(piston_schematic);
|
||||
}
|
||||
|
||||
private static void registerRender(Item item)
|
||||
{
|
||||
Prospect.proxy.registerRenderInformation(item);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.droog71.prospect.init;
|
||||
|
||||
import com.droog71.prospect.Prospect;
|
||||
import com.droog71.prospect.potion.PotionSpore;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = Prospect.MODID)
|
||||
public class ProspectPotions {
|
||||
|
||||
public static final Potion spore = new PotionSpore();
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerPotions(RegistryEvent.Register<Potion> evt)
|
||||
{
|
||||
evt.getRegistry().register(spore);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package com.droog71.prospect.init;
|
||||
|
||||
import com.droog71.prospect.Prospect;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = Prospect.MODID)
|
||||
public class ProspectSounds
|
||||
{
|
||||
static ResourceLocation printerSoundLocation;
|
||||
static ResourceLocation purifierSoundLocation;
|
||||
static ResourceLocation quarrySoundLocation;
|
||||
static ResourceLocation replicatorSoundLocation;
|
||||
static ResourceLocation transmitterSoundLocation;
|
||||
static ResourceLocation capsuleSoundLocation;
|
||||
static ResourceLocation extruderSoundLocation;
|
||||
static ResourceLocation pressSoundLocation;
|
||||
public static SoundEvent printerSoundEvent;
|
||||
public static SoundEvent purifierSoundEvent;
|
||||
public static SoundEvent quarrySoundEvent;
|
||||
public static SoundEvent replicatorSoundEvent;
|
||||
public static SoundEvent transmitterSoundEvent;
|
||||
public static SoundEvent capsuleSoundEvent;
|
||||
public static SoundEvent extruderSoundEvent;
|
||||
public static SoundEvent pressSoundEvent;
|
||||
|
||||
public static void init()
|
||||
{
|
||||
printerSoundLocation = new ResourceLocation("prospect", "printer");
|
||||
purifierSoundLocation = new ResourceLocation("prospect", "purifier");
|
||||
quarrySoundLocation = new ResourceLocation("prospect", "quarry");
|
||||
replicatorSoundLocation = new ResourceLocation("prospect", "replicator");
|
||||
transmitterSoundLocation = new ResourceLocation("prospect", "transmitter");
|
||||
capsuleSoundLocation = new ResourceLocation("prospect", "capsule");
|
||||
extruderSoundLocation = new ResourceLocation("prospect", "extruder");
|
||||
pressSoundLocation = new ResourceLocation("prospect", "press");
|
||||
printerSoundEvent = new SoundEvent(printerSoundLocation);
|
||||
purifierSoundEvent = new SoundEvent(purifierSoundLocation);
|
||||
quarrySoundEvent = new SoundEvent(quarrySoundLocation);
|
||||
replicatorSoundEvent = new SoundEvent(replicatorSoundLocation);
|
||||
transmitterSoundEvent = new SoundEvent(transmitterSoundLocation);
|
||||
capsuleSoundEvent = new SoundEvent(capsuleSoundLocation);
|
||||
extruderSoundEvent = new SoundEvent(extruderSoundLocation);
|
||||
pressSoundEvent = new SoundEvent(pressSoundLocation);
|
||||
}
|
||||
|
||||
public static void registerSoundEvent(String name, SoundEvent event)
|
||||
{
|
||||
event.setRegistryName(name);
|
||||
ForgeRegistries.SOUND_EVENTS.register(event);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
package com.droog71.prospect.inventory;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ExtruderContainer extends Container
|
||||
{
|
||||
private final IInventory tileExtruder;
|
||||
private int extrudeTime;
|
||||
private int totalextrudeTime;
|
||||
private int energyStored;
|
||||
private int energyCapacity;
|
||||
|
||||
public ExtruderContainer(InventoryPlayer playerInventory, IInventory extruderInventory)
|
||||
{
|
||||
this.tileExtruder = extruderInventory;
|
||||
this.addSlotToContainer(new Slot(extruderInventory, 0, 56, 17));
|
||||
this.addSlotToContainer(new Slot(extruderInventory, 2, 116, 35));
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int k = 0; k < 9; ++k)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(playerInventory, k, 8 + k * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(IContainerListener listener)
|
||||
{
|
||||
super.addListener(listener);
|
||||
listener.sendAllWindowProperties(this, this.tileExtruder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks for changes made in the container, sends them to every listener.
|
||||
*/
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (int i = 0; i < this.listeners.size(); ++i)
|
||||
{
|
||||
IContainerListener icontainerlistener = this.listeners.get(i);
|
||||
|
||||
if (this.energyStored != this.tileExtruder.getField(0))
|
||||
{
|
||||
icontainerlistener.sendWindowProperty(this, 0, this.tileExtruder.getField(0));
|
||||
}
|
||||
|
||||
if (this.energyCapacity != this.tileExtruder.getField(1))
|
||||
{
|
||||
icontainerlistener.sendWindowProperty(this, 1, this.tileExtruder.getField(1));
|
||||
}
|
||||
|
||||
if (this.extrudeTime != this.tileExtruder.getField(2))
|
||||
{
|
||||
icontainerlistener.sendWindowProperty(this, 2, this.tileExtruder.getField(2));
|
||||
}
|
||||
|
||||
if (this.totalextrudeTime != this.tileExtruder.getField(3))
|
||||
{
|
||||
icontainerlistener.sendWindowProperty(this, 3, this.tileExtruder.getField(3));
|
||||
}
|
||||
}
|
||||
|
||||
this.energyStored = this.tileExtruder.getField(0);
|
||||
this.energyCapacity = this.tileExtruder.getField(1);
|
||||
this.extrudeTime = this.tileExtruder.getField(2);
|
||||
this.totalextrudeTime = this.tileExtruder.getField(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateProgressBar(int id, int data)
|
||||
{
|
||||
this.tileExtruder.setField(id, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether supplied player can use this container
|
||||
*/
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer playerIn)
|
||||
{
|
||||
return this.tileExtruder.isUsableByPlayer(playerIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle when the stack in slot {@code index} is shift-clicked. Normally this moves the stack between the player
|
||||
* inventory and the other inventory(s).
|
||||
*/
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
|
||||
{
|
||||
ItemStack itemstack = ItemStack.EMPTY;
|
||||
Slot slot = this.inventorySlots.get(index);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (index == 2)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 3, 38, true))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
slot.onSlotChange(itemstack1, itemstack);
|
||||
}
|
||||
else if (index != 1 && index != 0)
|
||||
{
|
||||
if (!itemstack1.isEmpty())
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 0, 1, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
else if (index >= 3 && index < 30)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 30, 38, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
else if (index >= 30 && index < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(itemstack1, 3, 38, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (itemstack1.isEmpty())
|
||||
{
|
||||
slot.putStack(ItemStack.EMPTY);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemstack1.getCount() == itemstack.getCount())
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
slot.onTake(playerIn, itemstack1);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
package com.droog71.prospect.inventory;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class LaunchPadContainer extends Container
|
||||
{
|
||||
private final IInventory tileLaunchPad;
|
||||
private int launchTime;
|
||||
private int totallaunchTime;
|
||||
private int energyStored;
|
||||
private int energyCapacity;
|
||||
|
||||
public LaunchPadContainer(InventoryPlayer playerInventory, IInventory launchpadInventory)
|
||||
{
|
||||
this.tileLaunchPad = launchpadInventory;
|
||||
this.addSlotToContainer(new Slot(launchpadInventory, 0, 56, 17));
|
||||
this.addSlotToContainer(new Slot(launchpadInventory, 2, 116, 35));
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int k = 0; k < 9; ++k)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(playerInventory, k, 8 + k * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(IContainerListener listener)
|
||||
{
|
||||
super.addListener(listener);
|
||||
listener.sendAllWindowProperties(this, this.tileLaunchPad);
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks for changes made in the container, sends them to every listener.
|
||||
*/
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (int i = 0; i < this.listeners.size(); ++i)
|
||||
{
|
||||
IContainerListener icontainerlistener = this.listeners.get(i);
|
||||
|
||||
if (this.energyStored != this.tileLaunchPad.getField(0))
|
||||
{
|
||||
icontainerlistener.sendWindowProperty(this, 0, this.tileLaunchPad.getField(0));
|
||||
}
|
||||
|
||||
if (this.energyCapacity != this.tileLaunchPad.getField(1))
|
||||
{
|
||||
icontainerlistener.sendWindowProperty(this, 1, this.tileLaunchPad.getField(1));
|
||||
}
|
||||
|
||||
if (this.launchTime != this.tileLaunchPad.getField(2))
|
||||
{
|
||||
icontainerlistener.sendWindowProperty(this, 2, this.tileLaunchPad.getField(2));
|
||||
}
|
||||
|
||||
if (this.totallaunchTime != this.tileLaunchPad.getField(3))
|
||||
{
|
||||
icontainerlistener.sendWindowProperty(this, 3, this.tileLaunchPad.getField(3));
|
||||
}
|
||||
}
|
||||
|
||||
this.energyStored = this.tileLaunchPad.getField(0);
|
||||
this.energyCapacity = this.tileLaunchPad.getField(1);
|
||||
this.launchTime = this.tileLaunchPad.getField(2);
|
||||
this.totallaunchTime = this.tileLaunchPad.getField(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateProgressBar(int id, int data)
|
||||
{
|
||||
this.tileLaunchPad.setField(id, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether supplied player can use this container
|
||||
*/
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer playerIn)
|
||||
{
|
||||
return this.tileLaunchPad.isUsableByPlayer(playerIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle when the stack in slot {@code index} is shift-clicked. Normally this moves the stack between the player
|
||||
* inventory and the other inventory(s).
|
||||
*/
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
|
||||
{
|
||||
ItemStack itemstack = ItemStack.EMPTY;
|
||||
Slot slot = this.inventorySlots.get(index);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (index == 2)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 3, 38, true))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
slot.onSlotChange(itemstack1, itemstack);
|
||||
}
|
||||
else if (index != 1 && index != 0)
|
||||
{
|
||||
if (!itemstack1.isEmpty())
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 0, 1, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
else if (index >= 3 && index < 30)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 30, 38, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
else if (index >= 30 && index < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(itemstack1, 3, 38, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (itemstack1.isEmpty())
|
||||
{
|
||||
slot.putStack(ItemStack.EMPTY);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemstack1.getCount() == itemstack.getCount())
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
slot.onTake(playerIn, itemstack1);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
package com.droog71.prospect.inventory;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class PressContainer extends Container
|
||||
{
|
||||
private final IInventory tilePress;
|
||||
private int pressTime;
|
||||
private int totalPressTime;
|
||||
private int energyStored;
|
||||
private int energyCapacity;
|
||||
|
||||
public PressContainer(InventoryPlayer playerInventory, IInventory pressInventory)
|
||||
{
|
||||
this.tilePress = pressInventory;
|
||||
this.addSlotToContainer(new Slot(pressInventory, 0, 56, 17));
|
||||
this.addSlotToContainer(new Slot(pressInventory, 2, 116, 35));
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int k = 0; k < 9; ++k)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(playerInventory, k, 8 + k * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(IContainerListener listener)
|
||||
{
|
||||
super.addListener(listener);
|
||||
listener.sendAllWindowProperties(this, this.tilePress);
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks for changes made in the container, sends them to every listener.
|
||||
*/
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (int i = 0; i < this.listeners.size(); ++i)
|
||||
{
|
||||
IContainerListener icontainerlistener = this.listeners.get(i);
|
||||
|
||||
if (this.energyStored != this.tilePress.getField(0))
|
||||
{
|
||||
icontainerlistener.sendWindowProperty(this, 0, this.tilePress.getField(0));
|
||||
}
|
||||
|
||||
if (this.energyCapacity != this.tilePress.getField(1))
|
||||
{
|
||||
icontainerlistener.sendWindowProperty(this, 1, this.tilePress.getField(1));
|
||||
}
|
||||
|
||||
if (this.pressTime != this.tilePress.getField(2))
|
||||
{
|
||||
icontainerlistener.sendWindowProperty(this, 2, this.tilePress.getField(2));
|
||||
}
|
||||
|
||||
if (this.totalPressTime != this.tilePress.getField(3))
|
||||
{
|
||||
icontainerlistener.sendWindowProperty(this, 3, this.tilePress.getField(3));
|
||||
}
|
||||
}
|
||||
|
||||
this.energyStored = this.tilePress.getField(0);
|
||||
this.energyCapacity = this.tilePress.getField(1);
|
||||
this.pressTime = this.tilePress.getField(2);
|
||||
this.totalPressTime = this.tilePress.getField(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateProgressBar(int id, int data)
|
||||
{
|
||||
this.tilePress.setField(id, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether supplied player can use this container
|
||||
*/
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer playerIn)
|
||||
{
|
||||
return this.tilePress.isUsableByPlayer(playerIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle when the stack in slot {@code index} is shift-clicked. Normally this moves the stack between the player
|
||||
* inventory and the other inventory(s).
|
||||
*/
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
|
||||
{
|
||||
ItemStack itemstack = ItemStack.EMPTY;
|
||||
Slot slot = this.inventorySlots.get(index);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (index == 2)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 3, 38, true))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
slot.onSlotChange(itemstack1, itemstack);
|
||||
}
|
||||
else if (index != 1 && index != 0)
|
||||
{
|
||||
if (!itemstack1.isEmpty())
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 0, 1, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
else if (index >= 3 && index < 30)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 30, 38, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
else if (index >= 30 && index < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(itemstack1, 3, 38, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (itemstack1.isEmpty())
|
||||
{
|
||||
slot.putStack(ItemStack.EMPTY);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemstack1.getCount() == itemstack.getCount())
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
slot.onTake(playerIn, itemstack1);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,171 @@
|
|||
package com.droog71.prospect.inventory;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class PrinterContainer extends Container
|
||||
{
|
||||
private final IInventory tilePrinter;
|
||||
private int printTime;
|
||||
private int totalPrintTime;
|
||||
private int energyCapacity;
|
||||
private int energyStored;
|
||||
|
||||
public PrinterContainer(InventoryPlayer playerInventory, IInventory printerInventory)
|
||||
{
|
||||
this.tilePrinter = printerInventory;
|
||||
this.addSlotToContainer(new Slot(printerInventory, 0, 56, 17));
|
||||
this.addSlotToContainer(new Slot(printerInventory, 2, 116, 35));
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int k = 0; k < 9; ++k)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(playerInventory, k, 8 + k * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(IContainerListener listener)
|
||||
{
|
||||
super.addListener(listener);
|
||||
listener.sendAllWindowProperties(this, this.tilePrinter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks for changes made in the container, sends them to every listener.
|
||||
*/
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (int i = 0; i < this.listeners.size(); ++i)
|
||||
{
|
||||
IContainerListener icontainerlistener = this.listeners.get(i);
|
||||
|
||||
if (this.energyStored != this.tilePrinter.getField(0))
|
||||
{
|
||||
icontainerlistener.sendWindowProperty(this, 0, this.tilePrinter.getField(0));
|
||||
}
|
||||
|
||||
if (this.energyCapacity != this.tilePrinter.getField(1))
|
||||
{
|
||||
icontainerlistener.sendWindowProperty(this, 1, this.tilePrinter.getField(1));
|
||||
}
|
||||
|
||||
if (this.printTime != this.tilePrinter.getField(2))
|
||||
{
|
||||
icontainerlistener.sendWindowProperty(this, 2, this.tilePrinter.getField(2));
|
||||
}
|
||||
|
||||
if (this.totalPrintTime != this.tilePrinter.getField(3))
|
||||
{
|
||||
icontainerlistener.sendWindowProperty(this, 3, this.tilePrinter.getField(3));
|
||||
}
|
||||
}
|
||||
this.energyStored = this.tilePrinter.getField(0);
|
||||
this.energyCapacity = this.tilePrinter.getField(1);
|
||||
this.printTime = this.tilePrinter.getField(2);
|
||||
this.totalPrintTime = this.tilePrinter.getField(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateProgressBar(int id, int data)
|
||||
{
|
||||
this.tilePrinter.setField(id, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether supplied player can use this container
|
||||
*/
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer playerIn)
|
||||
{
|
||||
return this.tilePrinter.isUsableByPlayer(playerIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle when the stack in slot {@code index} is shift-clicked. Normally this moves the stack between the player
|
||||
* inventory and the other inventory(s).
|
||||
*/
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
|
||||
{
|
||||
ItemStack itemstack = ItemStack.EMPTY;
|
||||
Slot slot = this.inventorySlots.get(index);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (index == 2)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 3, 38, true))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
slot.onSlotChange(itemstack1, itemstack);
|
||||
}
|
||||
else if (index != 1 && index != 0)
|
||||
{
|
||||
if (!itemstack1.isEmpty())
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 0, 1, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
else if (index >= 3 && index < 30)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 30, 38, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
else if (index >= 30 && index < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(itemstack1, 3, 38, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (itemstack1.isEmpty())
|
||||
{
|
||||
slot.putStack(ItemStack.EMPTY);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemstack1.getCount() == itemstack.getCount())
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
slot.onTake(playerIn, itemstack1);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,192 @@
|
|||
package com.droog71.prospect.inventory;
|
||||
|
||||
import com.droog71.prospect.init.ProspectItems;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ReplicatorContainer extends Container
|
||||
{
|
||||
private final IInventory tileReplicator;
|
||||
private int replicateTime;
|
||||
private int totalreplicateTime;
|
||||
private int replicatorSpendTime;
|
||||
private int currentCreditSpendTime;
|
||||
private int energyCapacity;
|
||||
private int energyStored;
|
||||
|
||||
public ReplicatorContainer(InventoryPlayer playerInventory, IInventory replicatorInventory)
|
||||
{
|
||||
this.tileReplicator = replicatorInventory;
|
||||
this.addSlotToContainer(new Slot(replicatorInventory, 0, 56, 17));
|
||||
this.addSlotToContainer(new Slot(replicatorInventory, 1, 56, 53));
|
||||
this.addSlotToContainer(new Slot(replicatorInventory, 2, 116, 35));
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int k = 0; k < 9; ++k)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(playerInventory, k, 8 + k * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(IContainerListener listener)
|
||||
{
|
||||
super.addListener(listener);
|
||||
listener.sendAllWindowProperties(this, this.tileReplicator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks for changes made in the container, sends them to every listener.
|
||||
*/
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (int i = 0; i < this.listeners.size(); ++i)
|
||||
{
|
||||
IContainerListener icontainerlistener = this.listeners.get(i);
|
||||
|
||||
if (this.replicateTime != this.tileReplicator.getField(2))
|
||||
{
|
||||
icontainerlistener.sendWindowProperty(this, 2, this.tileReplicator.getField(2));
|
||||
}
|
||||
|
||||
if (this.replicatorSpendTime != this.tileReplicator.getField(0))
|
||||
{
|
||||
icontainerlistener.sendWindowProperty(this, 0, this.tileReplicator.getField(0));
|
||||
}
|
||||
|
||||
if (this.currentCreditSpendTime != this.tileReplicator.getField(1))
|
||||
{
|
||||
icontainerlistener.sendWindowProperty(this, 1, this.tileReplicator.getField(1));
|
||||
}
|
||||
|
||||
if (this.totalreplicateTime != this.tileReplicator.getField(3))
|
||||
{
|
||||
icontainerlistener.sendWindowProperty(this, 3, this.tileReplicator.getField(3));
|
||||
}
|
||||
|
||||
if (this.energyCapacity != this.tileReplicator.getField(4))
|
||||
{
|
||||
icontainerlistener.sendWindowProperty(this, 4, this.tileReplicator.getField(4));
|
||||
}
|
||||
|
||||
if (this.energyStored != this.tileReplicator.getField(5))
|
||||
{
|
||||
icontainerlistener.sendWindowProperty(this, 5, this.tileReplicator.getField(5));
|
||||
}
|
||||
}
|
||||
|
||||
this.replicateTime = this.tileReplicator.getField(2);
|
||||
this.replicatorSpendTime = this.tileReplicator.getField(0);
|
||||
this.currentCreditSpendTime = this.tileReplicator.getField(1);
|
||||
this.totalreplicateTime = this.tileReplicator.getField(3);
|
||||
this.energyCapacity = this.tileReplicator.getField(4);
|
||||
this.energyStored = this.tileReplicator.getField(5);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateProgressBar(int id, int data)
|
||||
{
|
||||
this.tileReplicator.setField(id, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether supplied player can use this container
|
||||
*/
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer playerIn)
|
||||
{
|
||||
return this.tileReplicator.isUsableByPlayer(playerIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle when the stack in slot {@code index} is shift-clicked. Normally this moves the stack between the player
|
||||
* inventory and the other inventory(s).
|
||||
*/
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
|
||||
{
|
||||
ItemStack itemstack = ItemStack.EMPTY;
|
||||
Slot slot = this.inventorySlots.get(index);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (index == 2)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 3, 39, true))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
slot.onSlotChange(itemstack1, itemstack);
|
||||
}
|
||||
else if (index != 1 && index != 0)
|
||||
{
|
||||
if (itemstack1.getItem() == ProspectItems.credit)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 1, 2, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(itemstack1, 0, 1, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
else if (index >= 3 && index < 30)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 30, 39, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
else if (index >= 30 && index < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(itemstack1, 3, 39, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (itemstack1.isEmpty())
|
||||
{
|
||||
slot.putStack(ItemStack.EMPTY);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemstack1.getCount() == itemstack.getCount())
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
slot.onTake(playerIn, itemstack1);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.droog71.prospect.items;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ProspectItem extends Item
|
||||
{
|
||||
public ProspectItem(String name)
|
||||
{
|
||||
setUnlocalizedName(name);
|
||||
setRegistryName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemEnchantability()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBookEnchantable(ItemStack stack, ItemStack book)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,520 @@
|
|||
package com.droog71.prospect.items;
|
||||
import com.droog71.prospect.init.ProspectBlocks;
|
||||
import com.droog71.prospect.init.ProspectItems;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class Schematic extends ProspectItem
|
||||
{
|
||||
public int id;
|
||||
|
||||
public Schematic(String name, int unique_id)
|
||||
{
|
||||
super(name);
|
||||
id = unique_id;
|
||||
}
|
||||
|
||||
public ItemStack getResult() //Returns the item the schematic produces in the fabricator.
|
||||
{
|
||||
if (id == 0)
|
||||
{
|
||||
return new ItemStack(ProspectItems.boots);
|
||||
}
|
||||
if (id == 1)
|
||||
{
|
||||
return new ItemStack(ProspectItems.pants);
|
||||
}
|
||||
if (id == 2)
|
||||
{
|
||||
return new ItemStack(ProspectItems.suit);
|
||||
}
|
||||
if (id == 3)
|
||||
{
|
||||
return new ItemStack(ProspectItems.helmet);
|
||||
}
|
||||
if (id == 4)
|
||||
{
|
||||
return new ItemStack(ProspectItems.filter);
|
||||
}
|
||||
if (id == 5)
|
||||
{
|
||||
return new ItemStack(ProspectBlocks.launch_pad);
|
||||
}
|
||||
if (id == 6)
|
||||
{
|
||||
return new ItemStack(ProspectBlocks.printer);
|
||||
}
|
||||
if (id == 7)
|
||||
{
|
||||
return new ItemStack(ProspectBlocks.extruder);
|
||||
}
|
||||
if (id == 8)
|
||||
{
|
||||
return new ItemStack(ProspectBlocks.purifier);
|
||||
}
|
||||
if (id == 9)
|
||||
{
|
||||
return new ItemStack(ProspectBlocks.quarry);
|
||||
}
|
||||
if (id == 10)
|
||||
{
|
||||
return new ItemStack(ProspectBlocks.replicator);
|
||||
}
|
||||
if (id == 11)
|
||||
{
|
||||
return new ItemStack(ProspectItems.mv_wire);
|
||||
}
|
||||
if (id == 12)
|
||||
{
|
||||
return new ItemStack(ProspectItems.hv_wire);
|
||||
}
|
||||
if (id == 13)
|
||||
{
|
||||
return new ItemStack(ProspectItems.ev_wire);
|
||||
}
|
||||
if (id == 14)
|
||||
{
|
||||
return new ItemStack(ProspectItems.iv_wire);
|
||||
}
|
||||
if (id == 15)
|
||||
{
|
||||
return new ItemStack(ProspectItems.in_lv_wire);
|
||||
}
|
||||
if (id == 16)
|
||||
{
|
||||
return new ItemStack(ProspectItems.in_mv_wire);
|
||||
}
|
||||
if (id == 17)
|
||||
{
|
||||
return new ItemStack(ProspectItems.in_hv_wire);
|
||||
}
|
||||
if (id == 18)
|
||||
{
|
||||
return new ItemStack(ProspectItems.in_ev_wire);
|
||||
}
|
||||
if (id == 19)
|
||||
{
|
||||
return new ItemStack(ProspectItems.in_iv_wire);
|
||||
}
|
||||
if (id == 20)
|
||||
{
|
||||
return new ItemStack(ProspectItems.lv_coil);
|
||||
}
|
||||
if (id == 21)
|
||||
{
|
||||
return new ItemStack(ProspectItems.mv_coil);
|
||||
}
|
||||
if (id == 22)
|
||||
{
|
||||
return new ItemStack(ProspectItems.hv_coil);
|
||||
}
|
||||
if (id == 23)
|
||||
{
|
||||
return new ItemStack(ProspectItems.ev_coil);
|
||||
}
|
||||
if (id == 24)
|
||||
{
|
||||
return new ItemStack(ProspectItems.iv_coil);
|
||||
}
|
||||
if (id == 25)
|
||||
{
|
||||
return new ItemStack(ProspectItems.circuit);
|
||||
}
|
||||
if (id == 26)
|
||||
{
|
||||
return new ItemStack(ProspectItems.prepared_circuit);
|
||||
}
|
||||
if (id == 27)
|
||||
{
|
||||
return new ItemStack(ProspectBlocks.lv_cable);
|
||||
}
|
||||
if (id == 28)
|
||||
{
|
||||
return new ItemStack(ProspectBlocks.mv_cable);
|
||||
}
|
||||
if (id == 29)
|
||||
{
|
||||
return new ItemStack(ProspectBlocks.hv_cable);
|
||||
}
|
||||
if (id == 30)
|
||||
{
|
||||
return new ItemStack(ProspectBlocks.ev_cable);
|
||||
}
|
||||
if (id == 31)
|
||||
{
|
||||
return new ItemStack(ProspectBlocks.iv_cable);
|
||||
}
|
||||
if (id == 32)
|
||||
{
|
||||
return new ItemStack(ProspectBlocks.lv_transformer);
|
||||
}
|
||||
if (id == 33)
|
||||
{
|
||||
return new ItemStack(ProspectBlocks.mv_transformer);
|
||||
}
|
||||
if (id == 34)
|
||||
{
|
||||
return new ItemStack(ProspectBlocks.hv_transformer);
|
||||
}
|
||||
if (id == 35)
|
||||
{
|
||||
return new ItemStack(ProspectBlocks.ev_transformer);
|
||||
}
|
||||
if (id == 36)
|
||||
{
|
||||
return new ItemStack(ProspectBlocks.lv_solar_panel);
|
||||
}
|
||||
if (id == 37)
|
||||
{
|
||||
return new ItemStack(ProspectBlocks.mv_solar_panel);
|
||||
}
|
||||
if (id == 38)
|
||||
{
|
||||
return new ItemStack(ProspectBlocks.hv_solar_panel);
|
||||
}
|
||||
if (id == 39)
|
||||
{
|
||||
return new ItemStack(ProspectBlocks.ev_solar_panel);
|
||||
}
|
||||
if (id == 40)
|
||||
{
|
||||
return new ItemStack(ProspectBlocks.iv_solar_panel);
|
||||
}
|
||||
if (id == 41)
|
||||
{
|
||||
return new ItemStack(Blocks.CHEST);
|
||||
}
|
||||
if (id == 42)
|
||||
{
|
||||
return new ItemStack(Blocks.HOPPER);
|
||||
}
|
||||
if (id == 43)
|
||||
{
|
||||
return new ItemStack(Blocks.PISTON);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack[] getIngredients() //Returns the ingredients for the crafting recipe the schematic produces.
|
||||
{
|
||||
if (id == 0)
|
||||
{
|
||||
ItemStack suit_material = new ItemStack(ProspectItems.suit_material,4);
|
||||
ItemStack[] required = {suit_material};
|
||||
return required;
|
||||
}
|
||||
if (id == 1)
|
||||
{
|
||||
ItemStack suit_material = new ItemStack(ProspectItems.suit_material,7);
|
||||
ItemStack[] required = {suit_material};
|
||||
return required;
|
||||
}
|
||||
if (id == 2)
|
||||
{
|
||||
ItemStack suit_material = new ItemStack(ProspectItems.suit_material,8);
|
||||
ItemStack[] required = {suit_material};
|
||||
return required;
|
||||
}
|
||||
if (id == 3)
|
||||
{
|
||||
ItemStack suit_material = new ItemStack(ProspectItems.suit_material,8);
|
||||
ItemStack glass = new ItemStack(Blocks.GLASS,1);
|
||||
ItemStack[] required = {suit_material,glass};
|
||||
return required;
|
||||
}
|
||||
if (id == 4)
|
||||
{
|
||||
ItemStack tin_plate = new ItemStack(ProspectItems.tin_plate,6);
|
||||
ItemStack suit_material = new ItemStack(ProspectItems.suit_material,2);
|
||||
ItemStack charcoal = new ItemStack(Items.COAL,1,1);
|
||||
ItemStack[] required = {tin_plate,suit_material,charcoal};
|
||||
return required;
|
||||
}
|
||||
if (id == 5)
|
||||
{
|
||||
ItemStack lead_plate = new ItemStack(ProspectItems.lead_plate,5);
|
||||
ItemStack quantum_circuit = new ItemStack(ProspectItems.quantum_circuit,2);
|
||||
ItemStack hopper = new ItemStack(Blocks.HOPPER,1);
|
||||
ItemStack[] required = {lead_plate,quantum_circuit,hopper};
|
||||
return required;
|
||||
}
|
||||
if (id == 6)
|
||||
{
|
||||
ItemStack tin_plate = new ItemStack(ProspectItems.tin_plate,4);
|
||||
ItemStack quantum_circuit = new ItemStack(ProspectItems.quantum_circuit,4);
|
||||
ItemStack replicator = new ItemStack(ProspectBlocks.replicator,1);
|
||||
ItemStack[] required = {tin_plate,quantum_circuit,replicator};
|
||||
return required;
|
||||
}
|
||||
if (id == 7)
|
||||
{
|
||||
ItemStack lead_plate = new ItemStack(ProspectItems.lead_plate,6);
|
||||
ItemStack lv_coil = new ItemStack(ProspectItems.lv_coil,1);
|
||||
ItemStack hopper = new ItemStack(Blocks.HOPPER,1);
|
||||
ItemStack piston = new ItemStack(Blocks.PISTON,1);
|
||||
ItemStack[] required = {lead_plate,lv_coil,hopper,piston};
|
||||
return required;
|
||||
}
|
||||
if (id == 8)
|
||||
{
|
||||
ItemStack tin_plate = new ItemStack(ProspectItems.tin_plate,4);
|
||||
ItemStack hopper = new ItemStack(Blocks.HOPPER,4);
|
||||
ItemStack filter = new ItemStack(ProspectItems.filter,1);
|
||||
ItemStack[] required = {tin_plate,hopper,filter};
|
||||
return required;
|
||||
}
|
||||
if (id == 9)
|
||||
{
|
||||
ItemStack in_iv_wire = new ItemStack(ProspectItems.in_iv_wire,2);
|
||||
ItemStack ev_transformer = new ItemStack(ProspectBlocks.ev_transformer,2);
|
||||
ItemStack piston = new ItemStack(Blocks.PISTON,2);
|
||||
ItemStack quantum_circuit = new ItemStack(ProspectItems.quantum_circuit,1);
|
||||
ItemStack lead_plate = new ItemStack(ProspectItems.lead_plate,2);
|
||||
ItemStack[] required = {in_iv_wire,ev_transformer,piston,quantum_circuit,lead_plate};
|
||||
return required;
|
||||
}
|
||||
if (id == 10)
|
||||
{
|
||||
ItemStack tin_plate = new ItemStack(ProspectItems.tin_plate,4);
|
||||
ItemStack ev_transformer = new ItemStack(ProspectBlocks.ev_transformer,1);
|
||||
ItemStack quantum_circuit = new ItemStack(ProspectItems.quantum_circuit,3);
|
||||
ItemStack diamond = new ItemStack(Items.DIAMOND,1);
|
||||
ItemStack[] required = {tin_plate,ev_transformer,quantum_circuit,diamond};
|
||||
return required;
|
||||
}
|
||||
if (id == 11)
|
||||
{
|
||||
ItemStack copper_wire = new ItemStack(ProspectItems.copper_wire,2);
|
||||
ItemStack[] required = {copper_wire};
|
||||
return required;
|
||||
}
|
||||
if (id == 12)
|
||||
{
|
||||
ItemStack copper_wire = new ItemStack(ProspectItems.copper_wire,3);
|
||||
ItemStack[] required = {copper_wire};
|
||||
return required;
|
||||
}
|
||||
if (id == 13)
|
||||
{
|
||||
ItemStack copper_wire = new ItemStack(ProspectItems.copper_wire,4);
|
||||
ItemStack[] required = {copper_wire};
|
||||
return required;
|
||||
}
|
||||
if (id == 14)
|
||||
{
|
||||
ItemStack copper_wire = new ItemStack(ProspectItems.copper_wire,5);
|
||||
ItemStack[] required = {copper_wire};
|
||||
return required;
|
||||
}
|
||||
if (id == 15)
|
||||
{
|
||||
ItemStack copper_wire = new ItemStack(ProspectItems.copper_wire,1);
|
||||
ItemStack wool = new ItemStack(Blocks.WOOL,1,0);
|
||||
ItemStack[] required = {copper_wire,wool};
|
||||
return required;
|
||||
}
|
||||
if (id == 16)
|
||||
{
|
||||
ItemStack mv_wire = new ItemStack(ProspectItems.mv_wire,1);
|
||||
ItemStack wool = new ItemStack(Blocks.WOOL,1,0);
|
||||
ItemStack[] required = {mv_wire,wool};
|
||||
return required;
|
||||
}
|
||||
if (id == 17)
|
||||
{
|
||||
ItemStack hv_wire = new ItemStack(ProspectItems.hv_wire,1);
|
||||
ItemStack wool = new ItemStack(Blocks.WOOL,1,0);
|
||||
ItemStack[] required = {hv_wire,wool};
|
||||
return required;
|
||||
}
|
||||
if (id == 18)
|
||||
{
|
||||
ItemStack ev_wire = new ItemStack(ProspectItems.ev_wire,1);
|
||||
ItemStack wool = new ItemStack(Blocks.WOOL,1,0);
|
||||
ItemStack[] required = {ev_wire,wool};
|
||||
return required;
|
||||
}
|
||||
if (id == 19)
|
||||
{
|
||||
ItemStack iv_wire = new ItemStack(ProspectItems.iv_wire,1);
|
||||
ItemStack wool = new ItemStack(Blocks.WOOL,1,0);
|
||||
ItemStack[] required = {iv_wire,wool};
|
||||
return required;
|
||||
}
|
||||
if (id == 20)
|
||||
{
|
||||
ItemStack copper_wire = new ItemStack(ProspectItems.copper_wire,8);
|
||||
ItemStack[] required = {copper_wire};
|
||||
return required;
|
||||
}
|
||||
if (id == 21)
|
||||
{
|
||||
ItemStack mv_wire = new ItemStack(ProspectItems.mv_wire,8);
|
||||
ItemStack[] required = {mv_wire};
|
||||
return required;
|
||||
}
|
||||
if (id == 22)
|
||||
{
|
||||
ItemStack hv_wire = new ItemStack(ProspectItems.hv_wire,8);
|
||||
ItemStack[] required = {hv_wire};
|
||||
return required;
|
||||
}
|
||||
if (id == 23)
|
||||
{
|
||||
ItemStack ev_wire = new ItemStack(ProspectItems.ev_wire,8);
|
||||
ItemStack[] required = {ev_wire};
|
||||
return required;
|
||||
}
|
||||
if (id == 24)
|
||||
{
|
||||
ItemStack iv_wire = new ItemStack(ProspectItems.iv_wire,8);
|
||||
ItemStack[] required = {iv_wire};
|
||||
return required;
|
||||
}
|
||||
if (id == 25)
|
||||
{
|
||||
ItemStack copper_wire = new ItemStack(ProspectItems.copper_wire,4);
|
||||
ItemStack silver_plate = new ItemStack(ProspectItems.silver_plate,4);
|
||||
ItemStack silicon = new ItemStack(ProspectItems.silicon,1);
|
||||
ItemStack[] required = {copper_wire,silver_plate,silicon};
|
||||
return required;
|
||||
}
|
||||
if (id == 26)
|
||||
{
|
||||
ItemStack redstone = new ItemStack(Items.REDSTONE,4);
|
||||
ItemStack glowstone_dust = new ItemStack(Items.GLOWSTONE_DUST,4);
|
||||
ItemStack circuit = new ItemStack(ProspectItems.circuit,1);
|
||||
ItemStack[] required = {redstone,glowstone_dust,circuit};
|
||||
return required;
|
||||
}
|
||||
if (id == 27)
|
||||
{
|
||||
ItemStack in_lv_wire = new ItemStack(ProspectItems.in_lv_wire,1);
|
||||
ItemStack aluminum_plate = new ItemStack(ProspectItems.aluminum_plate,8);
|
||||
ItemStack[] required = {in_lv_wire,aluminum_plate};
|
||||
return required;
|
||||
}
|
||||
if (id == 28)
|
||||
{
|
||||
ItemStack in_mv_wire = new ItemStack(ProspectItems.in_mv_wire,1);
|
||||
ItemStack aluminum_plate = new ItemStack(ProspectItems.aluminum_plate,8);
|
||||
ItemStack[] required = {in_mv_wire,aluminum_plate};
|
||||
return required;
|
||||
}
|
||||
if (id == 29)
|
||||
{
|
||||
ItemStack in_hv_wire = new ItemStack(ProspectItems.in_hv_wire,1);
|
||||
ItemStack aluminum_plate = new ItemStack(ProspectItems.aluminum_plate,8);
|
||||
ItemStack[] required = {in_hv_wire,aluminum_plate};
|
||||
return required;
|
||||
}
|
||||
if (id == 30)
|
||||
{
|
||||
ItemStack in_ev_wire = new ItemStack(ProspectItems.in_ev_wire,1);
|
||||
ItemStack aluminum_plate = new ItemStack(ProspectItems.aluminum_plate,8);
|
||||
ItemStack[] required = {in_ev_wire,aluminum_plate};
|
||||
return required;
|
||||
}
|
||||
if (id == 31)
|
||||
{
|
||||
ItemStack in_iv_wire = new ItemStack(ProspectItems.in_iv_wire,1);
|
||||
ItemStack aluminum_plate = new ItemStack(ProspectItems.aluminum_plate,8);
|
||||
ItemStack[] required = {in_iv_wire,aluminum_plate};
|
||||
return required;
|
||||
}
|
||||
if (id == 32)
|
||||
{
|
||||
ItemStack lv_coil = new ItemStack(ProspectItems.lv_coil,1);
|
||||
ItemStack mv_coil = new ItemStack(ProspectItems.mv_coil,1);
|
||||
ItemStack lead_plate = new ItemStack(ProspectItems.lead_plate,6);
|
||||
ItemStack[] required = {lv_coil,mv_coil,lead_plate};
|
||||
return required;
|
||||
}
|
||||
if (id == 33)
|
||||
{
|
||||
ItemStack hv_coil = new ItemStack(ProspectItems.hv_coil,1);
|
||||
ItemStack mv_coil = new ItemStack(ProspectItems.mv_coil,1);
|
||||
ItemStack lead_plate = new ItemStack(ProspectItems.lead_plate,6);
|
||||
ItemStack[] required = {hv_coil,mv_coil,lead_plate};
|
||||
return required;
|
||||
}
|
||||
if (id == 34)
|
||||
{
|
||||
ItemStack hv_coil = new ItemStack(ProspectItems.hv_coil,1);
|
||||
ItemStack ev_coil = new ItemStack(ProspectItems.ev_coil,1);
|
||||
ItemStack lead_plate = new ItemStack(ProspectItems.lead_plate,6);
|
||||
ItemStack[] required = {hv_coil,ev_coil,lead_plate};
|
||||
return required;
|
||||
}
|
||||
if (id == 35)
|
||||
{
|
||||
ItemStack ev_coil = new ItemStack(ProspectItems.ev_coil,1);
|
||||
ItemStack iv_coil = new ItemStack(ProspectItems.iv_coil,1);
|
||||
ItemStack lead_plate = new ItemStack(ProspectItems.lead_plate,6);
|
||||
ItemStack[] required = {ev_coil,iv_coil,lead_plate};
|
||||
return required;
|
||||
}
|
||||
if (id == 36)
|
||||
{
|
||||
ItemStack glass = new ItemStack(Blocks.GLASS,3);
|
||||
ItemStack tin_plate = new ItemStack(ProspectItems.tin_plate,4);
|
||||
ItemStack copper_wire = new ItemStack(ProspectItems.copper_wire,1);
|
||||
ItemStack lv_transformer = new ItemStack(ProspectBlocks.lv_transformer,1);
|
||||
ItemStack[] required = {glass,tin_plate,copper_wire,lv_transformer};
|
||||
return required;
|
||||
}
|
||||
if (id == 37)
|
||||
{
|
||||
ItemStack lv_transformer = new ItemStack(ProspectBlocks.lv_transformer,1);
|
||||
ItemStack lv_solar_panel = new ItemStack(ProspectBlocks.lv_solar_panel,8);
|
||||
ItemStack[] required = {lv_transformer,lv_solar_panel};
|
||||
return required;
|
||||
}
|
||||
if (id == 38)
|
||||
{
|
||||
ItemStack mv_transformer = new ItemStack(ProspectBlocks.mv_transformer,1);
|
||||
ItemStack mv_solar_panel = new ItemStack(ProspectBlocks.mv_solar_panel,8);
|
||||
ItemStack[] required = {mv_transformer,mv_solar_panel};
|
||||
return required;
|
||||
}
|
||||
if (id == 39)
|
||||
{
|
||||
ItemStack hv_transformer = new ItemStack(ProspectBlocks.hv_transformer,1);
|
||||
ItemStack hv_solar_panel = new ItemStack(ProspectBlocks.hv_solar_panel,8);
|
||||
ItemStack[] required = {hv_transformer,hv_solar_panel};
|
||||
return required;
|
||||
}
|
||||
if (id == 40)
|
||||
{
|
||||
ItemStack ev_transformer = new ItemStack(ProspectBlocks.ev_transformer,1);
|
||||
ItemStack ev_solar_panel = new ItemStack(ProspectBlocks.ev_solar_panel,8);
|
||||
ItemStack[] required = {ev_transformer,ev_solar_panel};
|
||||
return required;
|
||||
}
|
||||
if (id == 41)
|
||||
{
|
||||
ItemStack wood = new ItemStack(Blocks.PLANKS,8);
|
||||
ItemStack[] required = {wood};
|
||||
return required;
|
||||
}
|
||||
if (id == 42)
|
||||
{
|
||||
ItemStack chest = new ItemStack(Blocks.CHEST,1);
|
||||
ItemStack iron_ingot = new ItemStack(Items.IRON_INGOT,5);
|
||||
ItemStack[] required = {chest,iron_ingot};
|
||||
return required;
|
||||
}
|
||||
if (id == 43)
|
||||
{
|
||||
ItemStack iron_ingot = new ItemStack(Items.IRON_INGOT,1);
|
||||
ItemStack redstone = new ItemStack(Items.REDSTONE,1);
|
||||
ItemStack cobblestone = new ItemStack(Blocks.COBBLESTONE,4);
|
||||
ItemStack wood = new ItemStack(Blocks.PLANKS,3);
|
||||
ItemStack[] required = {iron_ingot,redstone,cobblestone,wood};
|
||||
return required;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.droog71.prospect.items;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class SporeFilter extends ProspectItem
|
||||
{
|
||||
public SporeFilter(String name)
|
||||
{
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction(ItemStack stack)
|
||||
{
|
||||
return EnumAction.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDroppedByPlayer(ItemStack item, EntityPlayer player)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)
|
||||
{
|
||||
if(itemSlot < 9) //Spore filters must be placed in the hotbar when in use. Extra filters stored in the player's inventory will not take damage.
|
||||
{
|
||||
if (stack.getItemDamage() >= stack.getMaxDamage())
|
||||
{
|
||||
stack.shrink(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
stack.getItem().setDamage(stack, stack.getItemDamage()+1);
|
||||
}
|
||||
super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.droog71.prospect.potion;
|
||||
|
||||
import com.droog71.prospect.Prospect;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class PotionProspect extends Potion
|
||||
{
|
||||
public PotionProspect(String name, boolean badEffect, int color)
|
||||
{
|
||||
super(badEffect, color);
|
||||
setRegistryName(new ResourceLocation(Prospect.MODID, name));
|
||||
setPotionName(name);
|
||||
}
|
||||
|
||||
public boolean hasEffect(EntityLivingBase entity)
|
||||
{
|
||||
return hasEffect(entity, this);
|
||||
}
|
||||
|
||||
public boolean hasEffect(EntityLivingBase entity, Potion potion)
|
||||
{
|
||||
return entity.getActivePotionEffect(potion) != null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,202 @@
|
|||
package com.droog71.prospect.potion;
|
||||
|
||||
import net.machinemuse.powersuits.item.armor.ItemElectricArmor;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import techguns.TGArmors;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.droog71.prospect.armor.ProspectArmor;
|
||||
import com.droog71.prospect.blocks.energy.Purifier;
|
||||
import com.droog71.prospect.config.ConfigHandler;
|
||||
import com.droog71.prospect.init.ProspectBlocks;
|
||||
import com.droog71.prospect.init.ProspectItems;
|
||||
|
||||
import ic2.core.platform.registry.Ic2Items;
|
||||
|
||||
|
||||
public class PotionSpore extends PotionProspect
|
||||
{
|
||||
private int hurtTimer;
|
||||
private int message;
|
||||
|
||||
public PotionSpore()
|
||||
{
|
||||
super("Spores", true, 0x26ADFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady(int duration, int amplifier)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender(PotionEffect effect)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderHUD(PotionEffect effect)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isArmorProtective(ItemStack stack) //Checks if the player's armor will protect them from toxic spores.
|
||||
{
|
||||
if (stack.getItem() instanceof ProspectArmor)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (stack == Ic2Items.hazmatHelmet || stack == Ic2Items.hazmatChest || stack == Ic2Items.hazmatLeggings || stack == Ic2Items.hazmatBoots)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (Loader.isModLoaded("techguns"))
|
||||
{
|
||||
if (stack.getItem() == TGArmors.hazmat_Helmet || stack.getItem() == TGArmors.hazmat_Chestplate || stack.getItem() == TGArmors.hazmat_Leggings || stack.getItem() == TGArmors.hazmat_Boots)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (stack.getItem() == TGArmors.t3_miner_Helmet || stack.getItem() == TGArmors.t3_miner_Chestplate || stack.getItem() == TGArmors.t3_miner_Leggings || stack.getItem() == TGArmors.t3_miner_Boots)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (stack.getItem() == TGArmors.steam_Helmet || stack.getItem() == TGArmors.steam_Chestplate || stack.getItem() == TGArmors.steam_Leggings || stack.getItem() == TGArmors.steam_Boots)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (stack.getItem() == TGArmors.t3_power_Helmet || stack.getItem() == TGArmors.t3_power_Chestplate || stack.getItem() == TGArmors.t3_power_Leggings || stack.getItem() == TGArmors.t3_power_Boots)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (stack.getItem() == TGArmors.t4_power_Helmet || stack.getItem() == TGArmors.t4_power_Chestplate || stack.getItem() == TGArmors.t4_power_Leggings || stack.getItem() == TGArmors.t4_power_Boots)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (Loader.isModLoaded("powersuits"))
|
||||
{
|
||||
if (stack.getItem() instanceof ItemElectricArmor)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performEffect(@Nonnull EntityLivingBase living, int amplified)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) living;
|
||||
if (player != null && ConfigHandler.getSporesEnabled())
|
||||
{
|
||||
boolean isPoisoned = false;
|
||||
boolean nearPurifier = false;
|
||||
BlockPos pos = player.getPosition();
|
||||
BlockPos corner_1 = pos.add(-20, -20, -20);
|
||||
BlockPos corner_2 = pos.add(20, 20, 20);
|
||||
Iterable<BlockPos> allBlocks = BlockPos.getAllInBox(corner_1, corner_2);
|
||||
Iterator<BlockPos> iter = allBlocks.iterator();
|
||||
while(iter.hasNext()) //Check if the player is near an energized purifier block which will protect them from toxic spores.
|
||||
{
|
||||
try
|
||||
{
|
||||
BlockPos found = iter.next();
|
||||
if (player.world.getBlockState(found).getBlock() == ProspectBlocks.purifier)
|
||||
{
|
||||
Purifier purifier = (Purifier) player.world.getBlockState(found).getBlock();
|
||||
if (purifier.powered == true)
|
||||
{
|
||||
nearPurifier = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(NoSuchElementException e)
|
||||
{
|
||||
//NOOP
|
||||
}
|
||||
}
|
||||
if (!nearPurifier)
|
||||
{
|
||||
boolean filterInstalled = false;
|
||||
int i = 0;
|
||||
while (i < 9) //Check if the player has a spore filter in their hotbar.
|
||||
{
|
||||
if (player.inventory.getStackInSlot(i).getItem() == ProspectItems.filter)
|
||||
{
|
||||
filterInstalled = true;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (!filterInstalled)
|
||||
{
|
||||
isPoisoned = true; //The player is not near a purifier and has no spore filter in their hotbar and is therefore vulnerable to toxic spores.
|
||||
}
|
||||
ArrayList<ItemStack> armorList = new ArrayList<ItemStack>();
|
||||
for (int slot=36; slot<40; slot++)
|
||||
{
|
||||
armorList.add(player.inventory.getStackInSlot(slot));
|
||||
}
|
||||
for (ItemStack armorItem : armorList)
|
||||
{
|
||||
if (!(isArmorProtective(armorItem)))
|
||||
{
|
||||
isPoisoned = true; //The player is not near a purifier and is not wearing protective armor and is therefore vulnerable to toxic spores.
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isPoisoned)
|
||||
{
|
||||
hurtTimer++;
|
||||
if (hurtTimer >= 200)
|
||||
{
|
||||
player.attackEntityFrom(DamageSource.GENERIC, 0.5F);
|
||||
}
|
||||
if (hurtTimer >= 240)
|
||||
{
|
||||
if (message == 0)
|
||||
{
|
||||
player.sendMessage(new TextComponentString("Received poisonous spore damage!"));
|
||||
}
|
||||
if (message == 1)
|
||||
{
|
||||
player.sendMessage(new TextComponentString("You need protective armor and a spore filter in your hotbar!"));
|
||||
}
|
||||
if (message == 2)
|
||||
{
|
||||
player.sendMessage(new TextComponentString("Build a purifier to create a protected area!"));
|
||||
}
|
||||
if (message < 2)
|
||||
{
|
||||
message++;
|
||||
}
|
||||
else
|
||||
{
|
||||
message = 0;
|
||||
}
|
||||
hurtTimer = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
message = 0;
|
||||
hurtTimer = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
package com.droog71.prospect.tilentity;
|
||||
|
||||
import com.droog71.prospect.fe.ProspectEnergyStorage;
|
||||
import com.droog71.prospect.init.ProspectBlocks;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class CableTileEntity extends TileEntity implements ITickable
|
||||
{
|
||||
private ProspectEnergyStorage energyStorage = new ProspectEnergyStorage();
|
||||
private int rating;
|
||||
|
||||
public CableTileEntity()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public CableTileEntity(int rating, int capacity)
|
||||
{
|
||||
energyStorage.maxReceive = rating;
|
||||
energyStorage.capacity = capacity;
|
||||
this.rating = rating;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
if (!world.isRemote) //Everything is done on the server.
|
||||
{
|
||||
if (energyStorage.overloaded)
|
||||
{
|
||||
explode();
|
||||
}
|
||||
else
|
||||
{
|
||||
giveEnergy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void giveEnergy()
|
||||
{
|
||||
BlockPos[] sides = {pos.add(0,1,0),pos.add(1,0,0),pos.add(0,0,1),pos.add(0,-1,0),pos.add(-1,0,0),pos.add(0,0,-1)};
|
||||
for (BlockPos p : sides) //Iterate over all adjacent blocks.
|
||||
{
|
||||
TileEntity otherTile = world.getTileEntity(p);
|
||||
if (otherTile != null) //TileEntity exists at adjacent block position.
|
||||
{
|
||||
EnumFacing direction = null;
|
||||
for (EnumFacing facing : EnumFacing.VALUES)
|
||||
{
|
||||
IEnergyStorage otherStorage = otherTile.getCapability(CapabilityEnergy.ENERGY,facing);
|
||||
if (otherStorage != null) //The TileEntity has the required forge energy capability.
|
||||
{
|
||||
if (direction == null)
|
||||
{
|
||||
direction = facing; //The cable will transfer energy in this direction if possible.
|
||||
}
|
||||
}
|
||||
}
|
||||
IEnergyStorage otherStorage = otherTile.getCapability(CapabilityEnergy.ENERGY,direction);
|
||||
if (otherStorage != null)
|
||||
{
|
||||
if (energyStorage.getEnergyStored() > 0) //The cable has the potential to transfer energy to the adjacent block.
|
||||
{
|
||||
if (otherStorage.canReceive()) //The adjacent block can receive the energy.
|
||||
{
|
||||
if (otherStorage.getEnergyStored() < energyStorage.getEnergyStored()) //Potential exists between the two energy storage instances.
|
||||
{
|
||||
int potential = (energyStorage.getEnergyStored() - otherStorage.getEnergyStored())/2; //Calculate the potential.
|
||||
int output = Math.min(potential, rating); //If potential is greater than this cable's maximum transfer rate, use the lower value.
|
||||
energyStorage.useEnergy(output); //Remove energy from this cable.
|
||||
otherStorage.receiveEnergy(rating, true); //Simulate the transfer. If this transaction overloads the receiver, it will explode.
|
||||
if (otherStorage != null) //Recipient did not explode.
|
||||
{
|
||||
otherStorage.receiveEnergy(output,false); //Add the energy to the adjacent block.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void explode()
|
||||
{
|
||||
world.playSound(null, pos, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 0.5f, 1);
|
||||
WorldServer w = (WorldServer) world;
|
||||
w.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, pos.getX(), pos.getY(), pos.getZ(), 1, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.LAVA, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.FLAME, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
world.getBlockState(pos).getBlock().breakBlock(world, pos, ProspectBlocks.extruder.getDefaultState());
|
||||
EntityItem item = new EntityItem(w, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(ProspectBlocks.extruder));
|
||||
w.spawnEntity(item);
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @javax.annotation.Nullable net.minecraft.util.EnumFacing facing)
|
||||
{
|
||||
if (capability == CapabilityEnergy.ENERGY)
|
||||
{
|
||||
return (T) energyStorage;
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing)
|
||||
{
|
||||
if (capability == CapabilityEnergy.ENERGY)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return super.hasCapability(capability, facing);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,636 @@
|
|||
package com.droog71.prospect.tilentity;
|
||||
|
||||
import com.droog71.prospect.fe.ProspectEnergyStorage;
|
||||
import com.droog71.prospect.init.ProspectBlocks;
|
||||
import com.droog71.prospect.init.ProspectItems;
|
||||
import com.droog71.prospect.init.ProspectSounds;
|
||||
import com.droog71.prospect.inventory.ExtruderContainer;
|
||||
|
||||
import ic2.api.energy.prefab.BasicSink;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.inventory.ItemStackHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ExtruderTileEntity extends TileEntity implements ITickable, ISidedInventory
|
||||
{
|
||||
private static final int[] SLOTS_TOP = new int[] {0};
|
||||
private static final int[] SLOTS_BOTTOM = new int[] {2, 1};
|
||||
private static final int[] SLOTS_SIDES = new int[] {1};
|
||||
private NonNullList<ItemStack> extruderItemStacks = NonNullList.<ItemStack>withSize(3, ItemStack.EMPTY);
|
||||
private int energyStored;
|
||||
private int energyCapacity;
|
||||
private int extrudeTime;
|
||||
private int totalextrudeTime;
|
||||
private int effectsTimer = 250;
|
||||
private Object ic2EnergySink;
|
||||
private ProspectEnergyStorage energyStorage = new ProspectEnergyStorage();
|
||||
|
||||
@Override
|
||||
public void onLoad()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink == null))
|
||||
{
|
||||
ic2EnergySink = new BasicSink(this,1000,1);
|
||||
}
|
||||
((BasicSink) ic2EnergySink).onLoad(); // notify the energy sink
|
||||
}
|
||||
energyStorage.capacity = 5000;
|
||||
energyStorage.maxReceive = 1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink != null))
|
||||
{
|
||||
((BasicSink) ic2EnergySink).invalidate(); // notify the energy sink
|
||||
}
|
||||
}
|
||||
super.invalidate(); // this is important for mc!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink != null))
|
||||
{
|
||||
((BasicSink) ic2EnergySink).onChunkUnload(); // notify the energy sink
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of slots in the inventory.
|
||||
*/
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return extruderItemStacks.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
for (ItemStack itemstack : extruderItemStacks)
|
||||
{
|
||||
if (!itemstack.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stack in the given slot.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int index)
|
||||
{
|
||||
return extruderItemStacks.get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes up to a specified number of items from an inventory slot and returns them in a new stack.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack decrStackSize(int index, int count)
|
||||
{
|
||||
return ItemStackHelper.getAndSplit(extruderItemStacks, index, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a stack from the given slot and returns it.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int index)
|
||||
{
|
||||
return ItemStackHelper.getAndRemove(extruderItemStacks, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
|
||||
*/
|
||||
@Override
|
||||
public void setInventorySlotContents(int index, ItemStack stack)
|
||||
{
|
||||
ItemStack itemstack = extruderItemStacks.get(index);
|
||||
boolean flag = !stack.isEmpty() && stack.isItemEqual(itemstack) && ItemStack.areItemStackTagsEqual(stack, itemstack);
|
||||
extruderItemStacks.set(index, stack);
|
||||
|
||||
if (stack.getCount() > getInventoryStackLimit())
|
||||
{
|
||||
stack.setCount(getInventoryStackLimit());
|
||||
}
|
||||
|
||||
if (index == 0 && !flag)
|
||||
{
|
||||
totalextrudeTime = getextrudeTime(stack);
|
||||
extrudeTime = 0;
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of this object. For players this returns their username
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "Extruder";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this thing is named
|
||||
*/
|
||||
@Override
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setCustomInventoryName(String p_145951_1_)
|
||||
{
|
||||
//NOOP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound)
|
||||
{
|
||||
super.readFromNBT(compound);
|
||||
extruderItemStacks = NonNullList.<ItemStack>withSize(getSizeInventory(), ItemStack.EMPTY);
|
||||
ItemStackHelper.loadAllItems(compound, extruderItemStacks);
|
||||
energyStored = compound.getInteger("EnergyStored");
|
||||
extrudeTime = compound.getInteger("extrudeTime");
|
||||
totalextrudeTime = compound.getInteger("TotalextrudeTime");
|
||||
energyCapacity = compound.getInteger("EnergyCapacity");
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if ((BasicSink) ic2EnergySink == null)
|
||||
{
|
||||
ic2EnergySink = new BasicSink(this,1000,1);
|
||||
}
|
||||
((BasicSink) ic2EnergySink).readFromNBT(compound);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound)
|
||||
{
|
||||
super.writeToNBT(compound);
|
||||
compound.setInteger("EnergyStored", (short)energyStored);
|
||||
compound.setInteger("EnergyCapacity", (short)energyCapacity);
|
||||
compound.setInteger("extrudeTime", (short)extrudeTime);
|
||||
compound.setInteger("TotalextrudeTime", (short)totalextrudeTime);
|
||||
ItemStackHelper.saveAllItems(compound, extruderItemStacks);
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if ((BasicSink) ic2EnergySink == null)
|
||||
{
|
||||
ic2EnergySink = new BasicSink(this,1000,1);
|
||||
}
|
||||
((BasicSink) ic2EnergySink).writeToNBT(compound);
|
||||
}
|
||||
return compound;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended.
|
||||
*/
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
/**
|
||||
* Machine isEnergized
|
||||
*/
|
||||
public boolean isEnergized()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink).getEnergyStored() > 0)
|
||||
{
|
||||
return ((BasicSink) ic2EnergySink).getEnergyStored() > 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return energyStorage.getEnergyStored() > 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return energyStorage.getEnergyStored() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static boolean isEnergized(IInventory inventory)
|
||||
{
|
||||
return inventory.getField(0) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Like the old updateEntity(), except more generic.
|
||||
*/
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (energyStorage.overloaded)
|
||||
{
|
||||
explode();
|
||||
}
|
||||
else
|
||||
{
|
||||
updateEnergy();
|
||||
if (isEnergized())
|
||||
{
|
||||
if (canExtrude())
|
||||
{
|
||||
if (useEnergy())
|
||||
{
|
||||
doWork();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
extrudeTime = 0;
|
||||
}
|
||||
}
|
||||
else if (!isEnergized() && extrudeTime > 0)
|
||||
{
|
||||
extrudeTime = MathHelper.clamp(extrudeTime - 2, 0, totalextrudeTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void explode()
|
||||
{
|
||||
world.playSound(null, pos, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 0.5f, 1);
|
||||
WorldServer w = (WorldServer) world;
|
||||
w.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, pos.getX(), pos.getY(), pos.getZ(), 1, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.LAVA, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.FLAME, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
world.getBlockState(pos).getBlock().breakBlock(world, pos, ProspectBlocks.extruder.getDefaultState());
|
||||
EntityItem item = new EntityItem(w, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(ProspectBlocks.extruder));
|
||||
w.spawnEntity(item);
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
private void doWork()
|
||||
{
|
||||
boolean flag1 = false;
|
||||
++extrudeTime;
|
||||
|
||||
if (extrudeTime == totalextrudeTime)
|
||||
{
|
||||
extrudeTime = 0;
|
||||
totalextrudeTime = getextrudeTime(extruderItemStacks.get(0));
|
||||
extrudeItem();
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
effectsTimer++;
|
||||
if (effectsTimer > 200)
|
||||
{
|
||||
world.playSound(null, pos, ProspectSounds.extruderSoundEvent, SoundCategory.BLOCKS, 0.5f, 1);
|
||||
effectsTimer = 0;
|
||||
}
|
||||
if (flag1)
|
||||
{
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateEnergy()
|
||||
{
|
||||
if (energyStorage.getEnergyStored() > 0)
|
||||
{
|
||||
energyStored = energyStorage.getEnergyStored();
|
||||
energyCapacity = energyStorage.getMaxEnergyStored();
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
((BasicSink) ic2EnergySink).setEnergyStored(0);
|
||||
((BasicSink) ic2EnergySink).setCapacity(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
((BasicSink) ic2EnergySink).setCapacity(1000);
|
||||
if (((BasicSink) ic2EnergySink).getEnergyStored() > 0)
|
||||
{
|
||||
energyStored = (int) ((BasicSink) ic2EnergySink).getEnergyStored();
|
||||
energyCapacity = (int) ((BasicSink) ic2EnergySink).getCapacity();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean useEnergy()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink).useEnergy(2))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (energyStorage != null)
|
||||
{
|
||||
if (energyStorage.getEnergyStored() >= 8)
|
||||
{
|
||||
energyStorage.useEnergy(8);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (energyStorage != null)
|
||||
{
|
||||
if (energyStorage.getEnergyStored() >= 8)
|
||||
{
|
||||
energyStorage.useEnergy(8);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getextrudeTime(ItemStack stack)
|
||||
{
|
||||
return 200;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the extruder can extrude an item, i.e. has a source item, destination stack isn't full, etc.
|
||||
*/
|
||||
private boolean canExtrude()
|
||||
{
|
||||
if (extruderItemStacks.get(0).isEmpty() || extruderItemStacks.get(0).getItem() != ProspectItems.copper_ingot)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack itemstack = new ItemStack(ProspectItems.copper_wire);
|
||||
|
||||
if (itemstack.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack itemstack1 = extruderItemStacks.get(2);
|
||||
|
||||
if (itemstack1.isEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (!itemstack1.isItemEqual(itemstack))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (itemstack1.getCount() + itemstack.getCount() <= getInventoryStackLimit() && itemstack1.getCount() + itemstack.getCount() <= itemstack1.getMaxStackSize()) // Forge fix: respect stack sizes
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return itemstack1.getCount() + itemstack.getCount() <= itemstack.getMaxStackSize(); // Forge fix: respect stack sizes
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn one item from the extruder source stack into the appropriate resulting item in the extruder result stack
|
||||
*/
|
||||
public void extrudeItem()
|
||||
{
|
||||
if (canExtrude())
|
||||
{
|
||||
ItemStack itemstack = extruderItemStacks.get(0);
|
||||
ItemStack itemstack1 = new ItemStack(ProspectItems.copper_wire);
|
||||
ItemStack itemstack2 = extruderItemStacks.get(2);
|
||||
|
||||
if (itemstack2.isEmpty())
|
||||
{
|
||||
extruderItemStacks.set(2, itemstack1.copy());
|
||||
}
|
||||
else if (itemstack2.getItem() == itemstack1.getItem())
|
||||
{
|
||||
itemstack2.grow(itemstack1.getCount());
|
||||
}
|
||||
|
||||
itemstack.shrink(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't rename this method to canInteractWith due to conflicts with Container
|
||||
*/
|
||||
@Override
|
||||
public boolean isUsableByPlayer(EntityPlayer player)
|
||||
{
|
||||
if (world.getTileEntity(pos) != this)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return player.getDistanceSq(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D) <= 64.0D;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(EntityPlayer player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(EntityPlayer player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot. For
|
||||
* guis use Slot.isItemValid
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack)
|
||||
{
|
||||
if (index == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side)
|
||||
{
|
||||
if (side == EnumFacing.DOWN)
|
||||
{
|
||||
return SLOTS_BOTTOM;
|
||||
}
|
||||
else
|
||||
{
|
||||
return side == EnumFacing.UP ? SLOTS_TOP : SLOTS_SIDES;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if automation can insert the given item in the given slot from the given side.
|
||||
*/
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction)
|
||||
{
|
||||
return isItemValidForSlot(index, itemStackIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if automation can extract the given item in the given slot from the given side.
|
||||
*/
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getGuiID()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
|
||||
{
|
||||
return new ExtruderContainer(playerInventory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getField(int id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case 0:
|
||||
return energyStored;
|
||||
case 1:
|
||||
return energyCapacity;
|
||||
case 2:
|
||||
return extrudeTime;
|
||||
case 3:
|
||||
return totalextrudeTime;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setField(int id, int value)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case 0:
|
||||
energyStored = value;
|
||||
break;
|
||||
case 1:
|
||||
energyCapacity = value;
|
||||
break;
|
||||
case 2:
|
||||
extrudeTime = value;
|
||||
break;
|
||||
case 3:
|
||||
totalextrudeTime = value;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFieldCount()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
extruderItemStacks.clear();
|
||||
}
|
||||
|
||||
net.minecraftforge.items.IItemHandler handlerTop = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.UP);
|
||||
net.minecraftforge.items.IItemHandler handlerBottom = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.DOWN);
|
||||
net.minecraftforge.items.IItemHandler handlerSide = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.WEST);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@javax.annotation.Nullable
|
||||
public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @javax.annotation.Nullable net.minecraft.util.EnumFacing facing)
|
||||
{
|
||||
if (facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||
{
|
||||
if (facing == EnumFacing.DOWN)
|
||||
{
|
||||
return (T) handlerBottom;
|
||||
}
|
||||
|
||||
else if (facing == EnumFacing.UP)
|
||||
{
|
||||
return (T) handlerTop;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return (T) handlerSide;
|
||||
}
|
||||
}
|
||||
if (capability == CapabilityEnergy.ENERGY)
|
||||
{
|
||||
return (T) energyStorage;
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing)
|
||||
{
|
||||
if (capability == CapabilityEnergy.ENERGY)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return super.hasCapability(capability, facing);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,776 @@
|
|||
package com.droog71.prospect.tilentity;
|
||||
|
||||
import com.droog71.prospect.fe.ProspectEnergyStorage;
|
||||
import com.droog71.prospect.init.ProspectBlocks;
|
||||
import com.droog71.prospect.init.ProspectItems;
|
||||
import com.droog71.prospect.init.ProspectSounds;
|
||||
import com.droog71.prospect.inventory.LaunchPadContainer;
|
||||
import ic2.api.energy.prefab.BasicSink;
|
||||
import ic2.core.platform.registry.Ic2Items;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.inventory.ItemStackHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import techguns.TGBlocks;
|
||||
import techguns.TGItems;
|
||||
|
||||
public class LaunchPadTileEntity extends TileEntity implements ITickable, ISidedInventory
|
||||
{
|
||||
private static final int[] SLOTS_TOP = new int[] {0};
|
||||
private static final int[] SLOTS_BOTTOM = new int[] {2, 1};
|
||||
private static final int[] SLOTS_SIDES = new int[] {1};
|
||||
private NonNullList<ItemStack> launchPadItemStacks = NonNullList.<ItemStack>withSize(3, ItemStack.EMPTY);
|
||||
private int energyStored;
|
||||
private int energyCapacity;
|
||||
private int launchTime;
|
||||
private int totalLaunchTime;
|
||||
private int currentPayout;
|
||||
private Object ic2EnergySink;
|
||||
private ProspectEnergyStorage energyStorage = new ProspectEnergyStorage();
|
||||
public int capsuleYpos;
|
||||
|
||||
@Override
|
||||
public void onLoad()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink == null))
|
||||
{
|
||||
ic2EnergySink = new BasicSink(this,10000,2);
|
||||
}
|
||||
((BasicSink) ic2EnergySink).onLoad(); // notify the energy sink
|
||||
}
|
||||
energyStorage.capacity = 10000;
|
||||
energyStorage.maxReceive = 20000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink) != null)
|
||||
{
|
||||
((BasicSink) ic2EnergySink).invalidate(); // notify the energy sink
|
||||
}
|
||||
}
|
||||
super.invalidate(); // this is important for mc!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink) != null)
|
||||
{
|
||||
((BasicSink) ic2EnergySink).onChunkUnload(); // notify the energy sink
|
||||
}
|
||||
}
|
||||
world.setBlockToAir(new BlockPos(pos.getX(),pos.getY()+capsuleYpos,pos.getZ()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of slots in the inventory.
|
||||
*/
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return launchPadItemStacks.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
for (ItemStack itemstack : launchPadItemStacks)
|
||||
{
|
||||
if (!itemstack.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stack in the given slot.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int index)
|
||||
{
|
||||
return launchPadItemStacks.get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes up to a specified number of items from an inventory slot and returns them in a new stack.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack decrStackSize(int index, int count)
|
||||
{
|
||||
return ItemStackHelper.getAndSplit(launchPadItemStacks, index, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a stack from the given slot and returns it.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int index)
|
||||
{
|
||||
return ItemStackHelper.getAndRemove(launchPadItemStacks, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
|
||||
*/
|
||||
@Override
|
||||
public void setInventorySlotContents(int index, ItemStack stack)
|
||||
{
|
||||
ItemStack itemstack = launchPadItemStacks.get(index);
|
||||
boolean flag = !stack.isEmpty() && stack.isItemEqual(itemstack) && ItemStack.areItemStackTagsEqual(stack, itemstack);
|
||||
launchPadItemStacks.set(index, stack);
|
||||
|
||||
if (stack.getCount() > getInventoryStackLimit())
|
||||
{
|
||||
stack.setCount(getInventoryStackLimit());
|
||||
}
|
||||
|
||||
if (index == 0 && !flag)
|
||||
{
|
||||
totalLaunchTime = getlaunchTime(stack);
|
||||
launchTime = 0;
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of this object. For players this returns their username
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "Launch Pad";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this thing is named
|
||||
*/
|
||||
@Override
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setCustomInventoryName(String p_145951_1_)
|
||||
{
|
||||
//NOOP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound)
|
||||
{
|
||||
super.readFromNBT(compound);
|
||||
launchPadItemStacks = NonNullList.<ItemStack>withSize(getSizeInventory(), ItemStack.EMPTY);
|
||||
ItemStackHelper.loadAllItems(compound, launchPadItemStacks);
|
||||
energyStored = compound.getInteger("EnergyStored");
|
||||
launchTime = compound.getInteger("launchTime");
|
||||
totalLaunchTime = compound.getInteger("totalLaunchTime");
|
||||
energyCapacity = compound.getInteger("EnergyCapacity");
|
||||
capsuleYpos = compound.getInteger("CapsulePosition");
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if ((BasicSink) ic2EnergySink == null)
|
||||
{
|
||||
ic2EnergySink = new BasicSink(this,10000,2);
|
||||
}
|
||||
((BasicSink) ic2EnergySink).readFromNBT(compound);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound)
|
||||
{
|
||||
super.writeToNBT(compound);
|
||||
compound.setInteger("EnergyStored", (short)energyStored);
|
||||
compound.setInteger("EnergyCapacity", (short)energyCapacity);
|
||||
compound.setInteger("launchTime", (short)launchTime);
|
||||
compound.setInteger("totalLaunchTime", (short)totalLaunchTime);
|
||||
compound.setInteger("CapsulePosition", (short)capsuleYpos);
|
||||
ItemStackHelper.saveAllItems(compound, launchPadItemStacks);
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if ((BasicSink) ic2EnergySink == null)
|
||||
{
|
||||
ic2EnergySink = new BasicSink(this,10000,2);
|
||||
}
|
||||
((BasicSink) ic2EnergySink).writeToNBT(compound);
|
||||
}
|
||||
return compound;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended.
|
||||
*/
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
/**
|
||||
* Machine isEnergized
|
||||
*/
|
||||
public boolean isEnergized()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink).getEnergyStored() > 0)
|
||||
{
|
||||
return ((BasicSink) ic2EnergySink).getEnergyStored() > 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return energyStorage.getEnergyStored() > 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return energyStorage.getEnergyStored() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static boolean isEnergized(IInventory inventory)
|
||||
{
|
||||
return inventory.getField(0) > 0;
|
||||
}
|
||||
|
||||
private void explode()
|
||||
{
|
||||
world.playSound(null, pos, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 0.5f, 1);
|
||||
WorldServer w = (WorldServer) world;
|
||||
w.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, pos.getX(), pos.getY(), pos.getZ(), 1, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.LAVA, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.FLAME, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
world.getBlockState(pos).getBlock().breakBlock(world, pos, ProspectBlocks.extruder.getDefaultState());
|
||||
EntityItem item = new EntityItem(w, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(ProspectBlocks.extruder));
|
||||
w.spawnEntity(item);
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Like the old updateEntity(), except more generic.
|
||||
*/
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (energyStorage.overloaded)
|
||||
{
|
||||
explode();
|
||||
}
|
||||
else
|
||||
{
|
||||
updateEnergy();
|
||||
if (isEnergized())
|
||||
{
|
||||
if (canLaunch())
|
||||
{
|
||||
if (useEnergy())
|
||||
{
|
||||
if (capsuleYpos == 0)
|
||||
{
|
||||
WorldServer w = (WorldServer) world;
|
||||
w.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, pos.getX(), pos.getY(), pos.getZ(), 1, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.LAVA, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.FLAME, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
world.playSound(null, pos, ProspectSounds.capsuleSoundEvent, SoundCategory.BLOCKS, 0.5f, 1);
|
||||
capsuleYpos = 1;
|
||||
}
|
||||
else if (capsuleYpos < 500)
|
||||
{
|
||||
if (capsuleYpos > 1)
|
||||
{
|
||||
world.setBlockToAir(new BlockPos(pos.getX(),pos.getY()+capsuleYpos-1,pos.getZ()));
|
||||
}
|
||||
world.setBlockState(new BlockPos(pos.getX(),pos.getY()+capsuleYpos,pos.getZ()), ProspectBlocks.capsule.getDefaultState());
|
||||
capsuleYpos++;
|
||||
}
|
||||
else
|
||||
{
|
||||
world.setBlockToAir(new BlockPos(pos.getX(),pos.getY()+capsuleYpos-1,pos.getZ()));
|
||||
capsuleYpos = 0;
|
||||
}
|
||||
doWork();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (capsuleYpos > 1)
|
||||
{
|
||||
world.setBlockToAir(new BlockPos(pos.getX(),pos.getY()+capsuleYpos-1,pos.getZ()));
|
||||
}
|
||||
capsuleYpos = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (capsuleYpos > 1)
|
||||
{
|
||||
world.setBlockToAir(new BlockPos(pos.getX(),pos.getY()+capsuleYpos-1,pos.getZ()));
|
||||
}
|
||||
capsuleYpos = 0;
|
||||
launchTime = 0;
|
||||
}
|
||||
}
|
||||
else if (!isEnergized() && launchTime > 0)
|
||||
{
|
||||
launchTime = MathHelper.clamp(launchTime - 2, 0, totalLaunchTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void doWork()
|
||||
{
|
||||
boolean flag1 = false;
|
||||
++launchTime;
|
||||
|
||||
if (launchTime == totalLaunchTime)
|
||||
{
|
||||
launchTime = 0;
|
||||
totalLaunchTime = getlaunchTime(launchPadItemStacks.get(0));
|
||||
launchItem();
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
if (flag1)
|
||||
{
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateEnergy()
|
||||
{
|
||||
if (energyStorage.getEnergyStored() > 0)
|
||||
{
|
||||
energyStored = energyStorage.getEnergyStored();
|
||||
energyCapacity = energyStorage.getMaxEnergyStored();
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
((BasicSink) ic2EnergySink).setEnergyStored(0);
|
||||
((BasicSink) ic2EnergySink).setCapacity(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
((BasicSink) ic2EnergySink).setCapacity(1000);
|
||||
if (((BasicSink) ic2EnergySink).getEnergyStored() > 0)
|
||||
{
|
||||
energyStored = (int) ((BasicSink) ic2EnergySink).getEnergyStored();
|
||||
energyCapacity = (int) ((BasicSink) ic2EnergySink).getCapacity();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean useEnergy()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink).useEnergy(10))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (energyStorage != null)
|
||||
{
|
||||
if (energyStorage.getEnergyStored() >= 40)
|
||||
{
|
||||
energyStorage.useEnergy(40);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (energyStorage != null)
|
||||
{
|
||||
if (energyStorage.getEnergyStored() >= 40)
|
||||
{
|
||||
energyStorage.useEnergy(40);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getlaunchTime(ItemStack stack)
|
||||
{
|
||||
return 1000;
|
||||
}
|
||||
|
||||
private int getCurrentPayout()
|
||||
{
|
||||
Item item = launchPadItemStacks.get(0).getItem();
|
||||
if (Loader.isModLoaded("techguns"))
|
||||
{
|
||||
if (item == TGItems.PLASMA_GENERATOR.getItem())
|
||||
{
|
||||
currentPayout = 32;
|
||||
return currentPayout;
|
||||
}
|
||||
if (item == TGBlocks.BASIC_MACHINE.getItemblock())
|
||||
{
|
||||
currentPayout = 16;
|
||||
return currentPayout;
|
||||
}
|
||||
if (item == TGItems.CIRCUIT_BOARD_ELITE.getItem())
|
||||
{
|
||||
currentPayout = 8;
|
||||
return currentPayout;
|
||||
}
|
||||
if (item == TGItems.ELECTRIC_ENGINE.getItem())
|
||||
{
|
||||
currentPayout = 4;
|
||||
return currentPayout;
|
||||
}
|
||||
if (item == TGItems.CIRCUIT_BOARD_BASIC.getItem())
|
||||
{
|
||||
currentPayout = 2;
|
||||
return currentPayout;
|
||||
}
|
||||
if (item == TGItems.ENERGY_CELL.getItem())
|
||||
{
|
||||
currentPayout = 1;
|
||||
return currentPayout;
|
||||
}
|
||||
}
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (item == Ic2Items.massfabricator.getItem() || item == Ic2Items.adjustableTransformer.getItem())
|
||||
{
|
||||
currentPayout = 32;
|
||||
return currentPayout;
|
||||
}
|
||||
if (item == Ic2Items.nuclearReactor.getItem())
|
||||
{
|
||||
currentPayout = 16;
|
||||
return currentPayout;
|
||||
}
|
||||
if (item == Ic2Items.advancedCircuit.getItem() || item == Ic2Items.macerator.getItem() || item == Ic2Items.compressor.getItem() || item == Ic2Items.electroFurnace.getItem() || item == Ic2Items.extractor.getItem())
|
||||
{
|
||||
currentPayout = 8;
|
||||
return currentPayout;
|
||||
}
|
||||
if (item == Ic2Items.electricCircuit.getItem())
|
||||
{
|
||||
currentPayout = 4;
|
||||
return currentPayout;
|
||||
}
|
||||
if (item == Ic2Items.doubleInsulatedGoldCable.getItem() || item == Ic2Items.tribbleInsulatedIronCable.getItem())
|
||||
{
|
||||
currentPayout = 2;
|
||||
return currentPayout;
|
||||
}
|
||||
if (item == Ic2Items.copperCable.getItem())
|
||||
{
|
||||
currentPayout = 1;
|
||||
return currentPayout;
|
||||
}
|
||||
}
|
||||
if (item == Item.getItemFromBlock(ProspectBlocks.replicator) || item == Item.getItemFromBlock(ProspectBlocks.iv_solar_panel))
|
||||
{
|
||||
currentPayout = 32;
|
||||
return currentPayout;
|
||||
}
|
||||
if (item == Item.getItemFromBlock(ProspectBlocks.quarry) || item == Item.getItemFromBlock(ProspectBlocks.ev_solar_panel))
|
||||
{
|
||||
currentPayout = 16;
|
||||
return currentPayout;
|
||||
}
|
||||
if (item == Item.getItemFromBlock(ProspectBlocks.hv_solar_panel) || item == Item.getItemFromBlock(ProspectBlocks.printer) || item == Item.getItemFromBlock(ProspectBlocks.ev_transformer) || item == Item.getItemFromBlock(ProspectBlocks.iv_cable))
|
||||
{
|
||||
currentPayout = 8;
|
||||
return currentPayout;
|
||||
}
|
||||
if (item == Item.getItemFromBlock(ProspectBlocks.purifier) || item == Item.getItemFromBlock(ProspectBlocks.hv_transformer) || item == Item.getItemFromBlock(ProspectBlocks.ev_cable) || item == ProspectItems.in_iv_wire)
|
||||
{
|
||||
currentPayout = 4;
|
||||
return currentPayout;
|
||||
}
|
||||
if (item == Item.getItemFromBlock(ProspectBlocks.extruder) || item == Item.getItemFromBlock(ProspectBlocks.press) || item == Item.getItemFromBlock(ProspectBlocks.lv_solar_panel) || item == Item.getItemFromBlock(ProspectBlocks.hv_cable) || item == Item.getItemFromBlock(ProspectBlocks.mv_transformer) || item == ProspectItems.in_ev_wire)
|
||||
{
|
||||
currentPayout = 2;
|
||||
return currentPayout;
|
||||
}
|
||||
if (item == Item.getItemFromBlock(ProspectBlocks.lv_cable) || item == Item.getItemFromBlock(ProspectBlocks.mv_cable) || item == ProspectItems.in_hv_wire || item == ProspectItems.in_mv_wire || item == ProspectItems.in_lv_wire || item == ProspectItems.quantum_circuit || item == ProspectItems.gem)
|
||||
{
|
||||
currentPayout = 1;
|
||||
return currentPayout;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the launch pad can launch an item, i.e. has a source item, destination stack isn't full, etc.
|
||||
*/
|
||||
private boolean canLaunch()
|
||||
{
|
||||
if (getCurrentPayout() < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack itemstack = new ItemStack(ProspectItems.credit,currentPayout);
|
||||
|
||||
if (itemstack.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack itemstack1 = launchPadItemStacks.get(2);
|
||||
|
||||
if (itemstack1.isEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (!itemstack1.isItemEqual(itemstack))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (itemstack1.getCount() + itemstack.getCount() <= getInventoryStackLimit() && itemstack1.getCount() + itemstack.getCount() <= itemstack1.getMaxStackSize()) // Forge fix: respect stack sizes
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return itemstack1.getCount() + itemstack.getCount() <= itemstack.getMaxStackSize(); // Forge fix: respect stack sizes
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn one item from the launch pad source stack into the appropriate resulting item in the launch pad result stack
|
||||
*/
|
||||
public void launchItem()
|
||||
{
|
||||
if (canLaunch())
|
||||
{
|
||||
ItemStack itemstack = launchPadItemStacks.get(0);
|
||||
ItemStack itemstack1 = new ItemStack(ProspectItems.credit,currentPayout);
|
||||
ItemStack itemstack2 = launchPadItemStacks.get(2);
|
||||
|
||||
if (itemstack2.isEmpty())
|
||||
{
|
||||
launchPadItemStacks.set(2, itemstack1.copy());
|
||||
}
|
||||
else if (itemstack2.getItem() == itemstack1.getItem())
|
||||
{
|
||||
itemstack2.grow(itemstack1.getCount());
|
||||
}
|
||||
|
||||
itemstack.shrink(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't rename this method to canInteractWith due to conflicts with Container
|
||||
*/
|
||||
@Override
|
||||
public boolean isUsableByPlayer(EntityPlayer player)
|
||||
{
|
||||
if (world.getTileEntity(pos) != this)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return player.getDistanceSq(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D) <= 64.0D;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(EntityPlayer player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(EntityPlayer player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot. For
|
||||
* guis use Slot.isItemValid
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack)
|
||||
{
|
||||
if (index == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side)
|
||||
{
|
||||
if (side == EnumFacing.DOWN)
|
||||
{
|
||||
return SLOTS_BOTTOM;
|
||||
}
|
||||
else
|
||||
{
|
||||
return side == EnumFacing.UP ? SLOTS_TOP : SLOTS_SIDES;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if automation can insert the given item in the given slot from the given side.
|
||||
*/
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction)
|
||||
{
|
||||
return isItemValidForSlot(index, itemStackIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if automation can extract the given item in the given slot from the given side.
|
||||
*/
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getGuiID()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
|
||||
{
|
||||
return new LaunchPadContainer(playerInventory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getField(int id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case 0:
|
||||
return energyStored;
|
||||
case 1:
|
||||
return energyCapacity;
|
||||
case 2:
|
||||
return launchTime;
|
||||
case 3:
|
||||
return totalLaunchTime;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setField(int id, int value)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case 0:
|
||||
energyStored = value;
|
||||
break;
|
||||
case 1:
|
||||
energyCapacity = value;
|
||||
break;
|
||||
case 2:
|
||||
launchTime = value;
|
||||
break;
|
||||
case 3:
|
||||
totalLaunchTime = value;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFieldCount()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
launchPadItemStacks.clear();
|
||||
}
|
||||
|
||||
net.minecraftforge.items.IItemHandler handlerTop = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.UP);
|
||||
net.minecraftforge.items.IItemHandler handlerBottom = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.DOWN);
|
||||
net.minecraftforge.items.IItemHandler handlerSide = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.WEST);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@javax.annotation.Nullable
|
||||
public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @javax.annotation.Nullable net.minecraft.util.EnumFacing facing)
|
||||
{
|
||||
if (facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||
{
|
||||
if (facing == EnumFacing.DOWN)
|
||||
{
|
||||
return (T) handlerBottom;
|
||||
}
|
||||
|
||||
else if (facing == EnumFacing.UP)
|
||||
{
|
||||
return (T) handlerTop;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return (T) handlerSide;
|
||||
}
|
||||
}
|
||||
if (capability == CapabilityEnergy.ENERGY)
|
||||
{
|
||||
return (T) energyStorage;
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing)
|
||||
{
|
||||
if (capability == CapabilityEnergy.ENERGY)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return super.hasCapability(capability, facing);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,684 @@
|
|||
package com.droog71.prospect.tilentity;
|
||||
|
||||
import com.droog71.prospect.fe.ProspectEnergyStorage;
|
||||
import com.droog71.prospect.init.ProspectBlocks;
|
||||
import com.droog71.prospect.init.ProspectItems;
|
||||
import com.droog71.prospect.init.ProspectSounds;
|
||||
import com.droog71.prospect.inventory.PressContainer;
|
||||
import ic2.api.energy.prefab.BasicSink;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.inventory.ItemStackHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class PressTileEntity extends TileEntity implements ITickable, ISidedInventory
|
||||
{
|
||||
private static final int[] SLOTS_TOP = new int[] {0};
|
||||
private static final int[] SLOTS_BOTTOM = new int[] {2, 1};
|
||||
private static final int[] SLOTS_SIDES = new int[] {1};
|
||||
private NonNullList<ItemStack> pressItemStacks = NonNullList.<ItemStack>withSize(3, ItemStack.EMPTY);
|
||||
private int energyStored;
|
||||
private int energyCapacity;
|
||||
private int pressTime;
|
||||
private int totalpressTime;
|
||||
private int effectsTimer = 60;
|
||||
private Object ic2EnergySink;
|
||||
private ProspectEnergyStorage energyStorage = new ProspectEnergyStorage();
|
||||
|
||||
@Override
|
||||
public void onLoad()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink == null))
|
||||
{
|
||||
ic2EnergySink = new BasicSink(this,1000,1);
|
||||
}
|
||||
((BasicSink) ic2EnergySink).onLoad(); // notify the energy sink
|
||||
}
|
||||
energyStorage.capacity = 5000;
|
||||
energyStorage.maxReceive = 1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink != null))
|
||||
{
|
||||
((BasicSink) ic2EnergySink).invalidate(); // notify the energy sink
|
||||
}
|
||||
}
|
||||
super.invalidate(); // this is important for mc!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink != null))
|
||||
{
|
||||
((BasicSink) ic2EnergySink).onChunkUnload(); // notify the energy sink
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of slots in the inventory.
|
||||
*/
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return pressItemStacks.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
for (ItemStack itemstack : pressItemStacks)
|
||||
{
|
||||
if (!itemstack.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stack in the given slot.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int index)
|
||||
{
|
||||
return pressItemStacks.get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes up to a specified number of items from an inventory slot and returns them in a new stack.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack decrStackSize(int index, int count)
|
||||
{
|
||||
return ItemStackHelper.getAndSplit(pressItemStacks, index, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a stack from the given slot and returns it.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int index)
|
||||
{
|
||||
return ItemStackHelper.getAndRemove(pressItemStacks, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
|
||||
*/
|
||||
@Override
|
||||
public void setInventorySlotContents(int index, ItemStack stack)
|
||||
{
|
||||
ItemStack itemstack = pressItemStacks.get(index);
|
||||
boolean flag = !stack.isEmpty() && stack.isItemEqual(itemstack) && ItemStack.areItemStackTagsEqual(stack, itemstack);
|
||||
pressItemStacks.set(index, stack);
|
||||
|
||||
if (stack.getCount() > getInventoryStackLimit())
|
||||
{
|
||||
stack.setCount(getInventoryStackLimit());
|
||||
}
|
||||
|
||||
if (index == 0 && !flag)
|
||||
{
|
||||
totalpressTime = getpressTime(stack);
|
||||
pressTime = 0;
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of this object. For players this returns their username
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "Press";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this thing is named
|
||||
*/
|
||||
@Override
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setCustomInventoryName(String p_145951_1_)
|
||||
{
|
||||
//NOOP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound)
|
||||
{
|
||||
super.readFromNBT(compound);
|
||||
pressItemStacks = NonNullList.<ItemStack>withSize(getSizeInventory(), ItemStack.EMPTY);
|
||||
ItemStackHelper.loadAllItems(compound, pressItemStacks);
|
||||
energyStored = compound.getInteger("EnergyStored");
|
||||
pressTime = compound.getInteger("pressTime");
|
||||
totalpressTime = compound.getInteger("TotalpressTime");
|
||||
energyCapacity = compound.getInteger("EnergyCapacity");
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if ((BasicSink) ic2EnergySink == null)
|
||||
{
|
||||
ic2EnergySink = new BasicSink(this,1000,1);
|
||||
}
|
||||
((BasicSink) ic2EnergySink).readFromNBT(compound);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound)
|
||||
{
|
||||
super.writeToNBT(compound);
|
||||
compound.setInteger("EnergyStored", (short)energyStored);
|
||||
compound.setInteger("EnergyCapacity", (short)energyCapacity);
|
||||
compound.setInteger("pressTime", (short)pressTime);
|
||||
compound.setInteger("TotalpressTime", (short)totalpressTime);
|
||||
ItemStackHelper.saveAllItems(compound, pressItemStacks);
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if ((BasicSink) ic2EnergySink == null)
|
||||
{
|
||||
ic2EnergySink = new BasicSink(this,1000,1);
|
||||
}
|
||||
((BasicSink) ic2EnergySink).writeToNBT(compound);
|
||||
}
|
||||
return compound;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended.
|
||||
*/
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
/**
|
||||
* Machine isEnergized
|
||||
*/
|
||||
public boolean isEnergized()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink).getEnergyStored() > 0)
|
||||
{
|
||||
return ((BasicSink) ic2EnergySink).getEnergyStored() > 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return energyStorage.getEnergyStored() > 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return energyStorage.getEnergyStored() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static boolean isEnergized(IInventory inventory)
|
||||
{
|
||||
return inventory.getField(0) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Like the old updateEntity(), except more generic.
|
||||
*/
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (energyStorage.overloaded)
|
||||
{
|
||||
explode();
|
||||
}
|
||||
else
|
||||
{
|
||||
updateEnergy();
|
||||
if (isEnergized())
|
||||
{
|
||||
if (canPress())
|
||||
{
|
||||
if (useEnergy())
|
||||
{
|
||||
doWork();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pressTime = 0;
|
||||
}
|
||||
}
|
||||
else if (!isEnergized() && pressTime > 0)
|
||||
{
|
||||
pressTime = MathHelper.clamp(pressTime - 2, 0, totalpressTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void explode()
|
||||
{
|
||||
world.playSound(null, pos, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 0.5f, 1);
|
||||
WorldServer w = (WorldServer) world;
|
||||
w.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, pos.getX(), pos.getY(), pos.getZ(), 1, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.LAVA, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.FLAME, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
world.getBlockState(pos).getBlock().breakBlock(world, pos, ProspectBlocks.press.getDefaultState());
|
||||
EntityItem item = new EntityItem(w, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(ProspectBlocks.press));
|
||||
w.spawnEntity(item);
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
private void doWork()
|
||||
{
|
||||
boolean flag1 = false;
|
||||
++pressTime;
|
||||
|
||||
if (pressTime == totalpressTime)
|
||||
{
|
||||
pressTime = 0;
|
||||
totalpressTime = getpressTime(pressItemStacks.get(0));
|
||||
pressItem();
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
effectsTimer++;
|
||||
if (effectsTimer > 55)
|
||||
{
|
||||
world.playSound(null, pos, ProspectSounds.pressSoundEvent, SoundCategory.BLOCKS, 1.0f, 1);
|
||||
effectsTimer = 0;
|
||||
}
|
||||
if (flag1)
|
||||
{
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateEnergy()
|
||||
{
|
||||
if (energyStorage.getEnergyStored() > 0)
|
||||
{
|
||||
energyStored = energyStorage.getEnergyStored();
|
||||
energyCapacity = energyStorage.getMaxEnergyStored();
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
((BasicSink) ic2EnergySink).setEnergyStored(0);
|
||||
((BasicSink) ic2EnergySink).setCapacity(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
((BasicSink) ic2EnergySink).setCapacity(1000);
|
||||
if (((BasicSink) ic2EnergySink).getEnergyStored() > 0)
|
||||
{
|
||||
energyStored = (int) ((BasicSink) ic2EnergySink).getEnergyStored();
|
||||
energyCapacity = (int) ((BasicSink) ic2EnergySink).getCapacity();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean useEnergy()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink).useEnergy(2))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (energyStorage != null)
|
||||
{
|
||||
if (energyStorage.getEnergyStored() >= 8)
|
||||
{
|
||||
energyStorage.useEnergy(8);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (energyStorage != null)
|
||||
{
|
||||
if (energyStorage.getEnergyStored() >= 8)
|
||||
{
|
||||
energyStorage.useEnergy(8);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getpressTime(ItemStack stack)
|
||||
{
|
||||
return 200;
|
||||
}
|
||||
|
||||
private ItemStack getPlate(ItemStack stack)
|
||||
{
|
||||
NonNullList<ItemStack> copper = OreDictionary.getOres("ingotCopper");
|
||||
for (ItemStack s : copper)
|
||||
{
|
||||
if (s.getDisplayName() == stack.getDisplayName())
|
||||
{
|
||||
return new ItemStack(ProspectItems.copper_plate);
|
||||
}
|
||||
}
|
||||
NonNullList<ItemStack> tin = OreDictionary.getOres("ingotTin");
|
||||
for (ItemStack s : tin)
|
||||
{
|
||||
if (s.getDisplayName() == stack.getDisplayName())
|
||||
{
|
||||
return new ItemStack(ProspectItems.tin_plate);
|
||||
}
|
||||
}
|
||||
NonNullList<ItemStack> silver = OreDictionary.getOres("ingotSilver");
|
||||
for (ItemStack s : silver)
|
||||
{
|
||||
if (s.getDisplayName() == stack.getDisplayName())
|
||||
{
|
||||
return new ItemStack(ProspectItems.silver_plate);
|
||||
}
|
||||
}
|
||||
NonNullList<ItemStack> lead = OreDictionary.getOres("ingotLead");
|
||||
for (ItemStack s : lead)
|
||||
{
|
||||
if (s.getDisplayName() == stack.getDisplayName())
|
||||
{
|
||||
return new ItemStack(ProspectItems.lead_plate);
|
||||
}
|
||||
}
|
||||
NonNullList<ItemStack> aluminum = OreDictionary.getOres("ingotAluminum");
|
||||
for (ItemStack s : aluminum)
|
||||
{
|
||||
if (s.getDisplayName() == stack.getDisplayName())
|
||||
{
|
||||
return new ItemStack(ProspectItems.aluminum_plate);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the press can press an item, i.e. has a source item, destination stack isn't full, etc.
|
||||
*/
|
||||
private boolean canPress()
|
||||
{
|
||||
if (pressItemStacks.get(0).isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack itemstack = getPlate(pressItemStacks.get(0));
|
||||
|
||||
if (itemstack == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack itemstack1 = pressItemStacks.get(2);
|
||||
|
||||
if (itemstack1.isEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (!itemstack1.isItemEqual(itemstack))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (itemstack1.getCount() + itemstack.getCount() <= getInventoryStackLimit() && itemstack1.getCount() + itemstack.getCount() <= itemstack1.getMaxStackSize()) // Forge fix: respect stack sizes
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return itemstack1.getCount() + itemstack.getCount() <= itemstack.getMaxStackSize(); // Forge fix: respect stack sizes
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn one item from the press source stack into the appropriate resulting item in the press result stack
|
||||
*/
|
||||
public void pressItem()
|
||||
{
|
||||
if (canPress())
|
||||
{
|
||||
ItemStack source = pressItemStacks.get(0);
|
||||
ItemStack output = pressItemStacks.get(2);
|
||||
ItemStack result = getPlate(pressItemStacks.get(0));
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
if (output.isEmpty())
|
||||
{
|
||||
pressItemStacks.set(2, result.copy());
|
||||
}
|
||||
else if (output.getItem() == result.getItem())
|
||||
{
|
||||
output.grow(result.getCount());
|
||||
}
|
||||
|
||||
source.shrink(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't rename this method to canInteractWith due to conflicts with Container
|
||||
*/
|
||||
@Override
|
||||
public boolean isUsableByPlayer(EntityPlayer player)
|
||||
{
|
||||
if (world.getTileEntity(pos) != this)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return player.getDistanceSq(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D) <= 64.0D;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(EntityPlayer player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(EntityPlayer player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot. For
|
||||
* guis use Slot.isItemValid
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack)
|
||||
{
|
||||
if (index == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side)
|
||||
{
|
||||
if (side == EnumFacing.DOWN)
|
||||
{
|
||||
return SLOTS_BOTTOM;
|
||||
}
|
||||
else
|
||||
{
|
||||
return side == EnumFacing.UP ? SLOTS_TOP : SLOTS_SIDES;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if automation can insert the given item in the given slot from the given side.
|
||||
*/
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction)
|
||||
{
|
||||
return isItemValidForSlot(index, itemStackIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if automation can extract the given item in the given slot from the given side.
|
||||
*/
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getGuiID()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
|
||||
{
|
||||
return new PressContainer(playerInventory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getField(int id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case 0:
|
||||
return energyStored;
|
||||
case 1:
|
||||
return energyCapacity;
|
||||
case 2:
|
||||
return pressTime;
|
||||
case 3:
|
||||
return totalpressTime;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setField(int id, int value)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case 0:
|
||||
energyStored = value;
|
||||
break;
|
||||
case 1:
|
||||
energyCapacity = value;
|
||||
break;
|
||||
case 2:
|
||||
pressTime = value;
|
||||
break;
|
||||
case 3:
|
||||
totalpressTime = value;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFieldCount()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
pressItemStacks.clear();
|
||||
}
|
||||
|
||||
net.minecraftforge.items.IItemHandler handlerTop = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.UP);
|
||||
net.minecraftforge.items.IItemHandler handlerBottom = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.DOWN);
|
||||
net.minecraftforge.items.IItemHandler handlerSide = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.WEST);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@javax.annotation.Nullable
|
||||
public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @javax.annotation.Nullable net.minecraft.util.EnumFacing facing)
|
||||
{
|
||||
if (facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||
{
|
||||
if (facing == EnumFacing.DOWN)
|
||||
{
|
||||
return (T) handlerBottom;
|
||||
}
|
||||
|
||||
else if (facing == EnumFacing.UP)
|
||||
{
|
||||
return (T) handlerTop;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return (T) handlerSide;
|
||||
}
|
||||
}
|
||||
if (capability == CapabilityEnergy.ENERGY)
|
||||
{
|
||||
return (T) energyStorage;
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing)
|
||||
{
|
||||
if (capability == CapabilityEnergy.ENERGY)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return super.hasCapability(capability, facing);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,784 @@
|
|||
package com.droog71.prospect.tilentity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.droog71.prospect.fe.ProspectEnergyStorage;
|
||||
import com.droog71.prospect.init.ProspectBlocks;
|
||||
import com.droog71.prospect.init.ProspectSounds;
|
||||
import com.droog71.prospect.inventory.PrinterContainer;
|
||||
import com.droog71.prospect.items.Schematic;
|
||||
import ic2.api.energy.prefab.BasicSink;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockChest;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.inventory.ItemStackHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.util.EntitySelectors;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class PrinterTileEntity extends TileEntity implements ITickable, ISidedInventory
|
||||
{
|
||||
private static final int[] SLOTS_TOP = new int[] {0};
|
||||
private static final int[] SLOTS_BOTTOM = new int[] {2, 1};
|
||||
private static final int[] SLOTS_SIDES = new int[] {1};
|
||||
private NonNullList<ItemStack> printerItemStacks = NonNullList.<ItemStack>withSize(3, ItemStack.EMPTY);
|
||||
private int energyStored;
|
||||
private int energyCapacity;
|
||||
private int printTime;
|
||||
private int totalPrintTime;
|
||||
private int effectsTimer;
|
||||
private Object ic2EnergySink;
|
||||
private ProspectEnergyStorage energyStorage = new ProspectEnergyStorage();
|
||||
|
||||
@Override
|
||||
public void onLoad()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink == null))
|
||||
{
|
||||
ic2EnergySink = new BasicSink(this,400000,4);
|
||||
}
|
||||
((BasicSink) ic2EnergySink).onLoad(); // notify the energy sink
|
||||
}
|
||||
energyStorage.capacity = 80000;
|
||||
energyStorage.maxReceive = 16000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink) != null)
|
||||
{
|
||||
((BasicSink) ic2EnergySink).invalidate(); // notify the energy sink
|
||||
}
|
||||
}
|
||||
super.invalidate(); // this is important for mc!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink) != null)
|
||||
{
|
||||
((BasicSink) ic2EnergySink).onChunkUnload(); // notify the energy sink
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of slots in the inventory.
|
||||
*/
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return printerItemStacks.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
for (ItemStack itemstack : printerItemStacks)
|
||||
{
|
||||
if (!itemstack.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stack in the given slot.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int index)
|
||||
{
|
||||
return printerItemStacks.get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes up to a specified number of items from an inventory slot and returns them in a new stack.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack decrStackSize(int index, int count)
|
||||
{
|
||||
return ItemStackHelper.getAndSplit(printerItemStacks, index, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a stack from the given slot and returns it.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int index)
|
||||
{
|
||||
return ItemStackHelper.getAndRemove(printerItemStacks, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
|
||||
*/
|
||||
@Override
|
||||
public void setInventorySlotContents(int index, ItemStack stack)
|
||||
{
|
||||
ItemStack itemstack = printerItemStacks.get(index);
|
||||
boolean flag = !stack.isEmpty() && stack.isItemEqual(itemstack) && ItemStack.areItemStackTagsEqual(stack, itemstack);
|
||||
printerItemStacks.set(index, stack);
|
||||
|
||||
if (stack.getCount() > getInventoryStackLimit())
|
||||
{
|
||||
stack.setCount(getInventoryStackLimit());
|
||||
}
|
||||
|
||||
if (index == 0 && !flag)
|
||||
{
|
||||
totalPrintTime = getPrintTime(stack);
|
||||
printTime = 0;
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of this object. For players this returns their username
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "Fabricator";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this thing is named
|
||||
*/
|
||||
@Override
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setCustomInventoryName(String p_145951_1_)
|
||||
{
|
||||
//NOOP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound)
|
||||
{
|
||||
super.readFromNBT(compound);
|
||||
printerItemStacks = NonNullList.<ItemStack>withSize(getSizeInventory(), ItemStack.EMPTY);
|
||||
ItemStackHelper.loadAllItems(compound, printerItemStacks);
|
||||
energyStored = compound.getInteger("EnergyStored");
|
||||
printTime = compound.getInteger("PrintTime");
|
||||
totalPrintTime = compound.getInteger("PrintTimeTotal");
|
||||
energyCapacity = compound.getInteger("EnergyCapacity");
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if ((BasicSink) ic2EnergySink == null)
|
||||
{
|
||||
ic2EnergySink = new BasicSink(this,400000,4);
|
||||
}
|
||||
((BasicSink) ic2EnergySink).readFromNBT(compound);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound)
|
||||
{
|
||||
super.writeToNBT(compound);
|
||||
compound.setInteger("EnergyStored", (short)energyStored);
|
||||
compound.setInteger("EnergyCapacity", (short)energyCapacity);
|
||||
compound.setInteger("PrintTime", (short)printTime);
|
||||
compound.setInteger("PrintTimeTotal", (short)totalPrintTime);
|
||||
ItemStackHelper.saveAllItems(compound, printerItemStacks);
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if ((BasicSink) ic2EnergySink == null)
|
||||
{
|
||||
ic2EnergySink = new BasicSink(this,400000,4);
|
||||
}
|
||||
((BasicSink) ic2EnergySink).writeToNBT(compound);
|
||||
}
|
||||
return compound;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended.
|
||||
*/
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
/**
|
||||
* Machine isEnergized
|
||||
*/
|
||||
public boolean isEnergized()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink).getEnergyStored() > 0)
|
||||
{
|
||||
return ((BasicSink) ic2EnergySink).getEnergyStored() > 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return energyStorage.getEnergyStored() > 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return energyStorage.getEnergyStored() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static boolean isEnergized(IInventory inventory)
|
||||
{
|
||||
return inventory.getField(0) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Like the old updateEntity(), except more generic.
|
||||
*/
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (energyStorage.overloaded)
|
||||
{
|
||||
explode();
|
||||
}
|
||||
else
|
||||
{
|
||||
updateEnergy();
|
||||
if (isEnergized())
|
||||
{
|
||||
if (canPrint())
|
||||
{
|
||||
if (useEnergy())
|
||||
{
|
||||
doWork();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void doWork()
|
||||
{
|
||||
boolean flag1 = false;
|
||||
++printTime;
|
||||
|
||||
if (printTime == totalPrintTime)
|
||||
{
|
||||
printTime = 0;
|
||||
totalPrintTime = getPrintTime(printerItemStacks.get(0));
|
||||
printItem();
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
if (flag1)
|
||||
{
|
||||
markDirty();
|
||||
}
|
||||
|
||||
effectsTimer++;
|
||||
if (effectsTimer > 40)
|
||||
{
|
||||
world.playSound(null, pos, ProspectSounds.printerSoundEvent, SoundCategory.BLOCKS, 0.25f, 1);
|
||||
effectsTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void explode()
|
||||
{
|
||||
world.playSound(null, pos, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 0.5f, 1);
|
||||
WorldServer w = (WorldServer) world;
|
||||
w.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, pos.getX(), pos.getY(), pos.getZ(), 1, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.LAVA, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.FLAME, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
world.getBlockState(pos).getBlock().breakBlock(world, pos, ProspectBlocks.extruder.getDefaultState());
|
||||
EntityItem item = new EntityItem(w, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(ProspectBlocks.extruder));
|
||||
w.spawnEntity(item);
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
private void updateEnergy()
|
||||
{
|
||||
if (energyStorage.getEnergyStored() > 0)
|
||||
{
|
||||
energyStored = energyStorage.getEnergyStored();
|
||||
energyCapacity = energyStorage.getMaxEnergyStored();
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
((BasicSink) ic2EnergySink).setEnergyStored(0);
|
||||
((BasicSink) ic2EnergySink).setCapacity(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
((BasicSink) ic2EnergySink).setCapacity(80000);
|
||||
if (((BasicSink) ic2EnergySink).getEnergyStored() > 0)
|
||||
{
|
||||
energyStored = (int) ((BasicSink) ic2EnergySink).getEnergyStored();
|
||||
energyCapacity = (int) ((BasicSink) ic2EnergySink).getCapacity();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean useEnergy()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink).useEnergy(512))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (energyStorage != null)
|
||||
{
|
||||
if (energyStorage.getEnergyStored() >= 2048)
|
||||
{
|
||||
energyStorage.useEnergy(2048);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (energyStorage != null)
|
||||
{
|
||||
if (energyStorage.getEnergyStored() >= 2048)
|
||||
{
|
||||
energyStorage.useEnergy(2048);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getPrintTime(ItemStack stack)
|
||||
{
|
||||
return 200;
|
||||
}
|
||||
|
||||
private boolean canCraft(ItemStack[] stacks, IInventory iinventory)
|
||||
{
|
||||
if (iinventory != null)
|
||||
{
|
||||
int stacksFound = 0;
|
||||
int size = iinventory.getSizeInventory();
|
||||
for (ItemStack requiredStack : stacks)
|
||||
{
|
||||
boolean foundStack = false;
|
||||
for (int index = 0; index < size; ++index)
|
||||
{
|
||||
ItemStack containerStack = iinventory.getStackInSlot(index);
|
||||
if (containerStack.getItem() == requiredStack.getItem())
|
||||
{
|
||||
if (containerStack.getCount() >= requiredStack.getCount())
|
||||
{
|
||||
if (foundStack == false)
|
||||
{
|
||||
foundStack = true;
|
||||
stacksFound++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stacksFound >= stacks.length)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void consumeItems(ItemStack[] stacks)
|
||||
{
|
||||
IInventory iinventory = getInventoryForCrafting(stacks);
|
||||
if (iinventory != null)
|
||||
{
|
||||
int size = iinventory.getSizeInventory();
|
||||
for (ItemStack requiredStack : stacks)
|
||||
{
|
||||
boolean foundStack = false;
|
||||
for (int index = 0; index < size; ++index)
|
||||
{
|
||||
ItemStack containerStack = iinventory.getStackInSlot(index);
|
||||
if (containerStack.getItem() == requiredStack.getItem())
|
||||
{
|
||||
if (containerStack.getCount() >= requiredStack.getCount())
|
||||
{
|
||||
if (foundStack == false)
|
||||
{
|
||||
foundStack = true;
|
||||
containerStack.shrink(requiredStack.getCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
iinventory.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public IInventory getInventoryForCrafting(ItemStack[] stacks)
|
||||
{
|
||||
List<IInventory> invList = new ArrayList<IInventory>();
|
||||
BlockPos[] positions = {pos.add(0,1,0),pos.add(0,-1,0),pos.add(1,0,0),pos.add(-1,0,0),pos.add(0,0,1),pos.add(0,0,-1)};
|
||||
for (BlockPos p : positions)
|
||||
{
|
||||
invList.add(getInventoryAtPosition(world,p.getX(),p.getY(),p.getZ()));
|
||||
}
|
||||
for (IInventory inventory : invList)
|
||||
{
|
||||
if (inventory != null)
|
||||
{
|
||||
if (canCraft(stacks,inventory))
|
||||
{
|
||||
return inventory;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IInventory getInventoryAtPosition(World worldIn, double x, double y, double z)
|
||||
{
|
||||
IInventory iinventory = null;
|
||||
int i = MathHelper.floor(x);
|
||||
int j = MathHelper.floor(y);
|
||||
int k = MathHelper.floor(z);
|
||||
BlockPos blockpos = new BlockPos(i, j, k);
|
||||
net.minecraft.block.state.IBlockState state = worldIn.getBlockState(blockpos);
|
||||
Block block = state.getBlock();
|
||||
|
||||
if (block.hasTileEntity(state))
|
||||
{
|
||||
TileEntity tileentity = worldIn.getTileEntity(blockpos);
|
||||
|
||||
if (tileentity instanceof IInventory)
|
||||
{
|
||||
iinventory = (IInventory)tileentity;
|
||||
|
||||
if (iinventory instanceof TileEntityChest && block instanceof BlockChest)
|
||||
{
|
||||
iinventory = ((BlockChest)block).getContainer(worldIn, blockpos, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (iinventory == null)
|
||||
{
|
||||
List<Entity> list = worldIn.getEntitiesInAABBexcluding((Entity)null, new AxisAlignedBB(x - 0.5D, y - 0.5D, z - 0.5D, x + 0.5D, y + 0.5D, z + 0.5D), EntitySelectors.HAS_INVENTORY);
|
||||
|
||||
if (!list.isEmpty())
|
||||
{
|
||||
iinventory = (IInventory)list.get(worldIn.rand.nextInt(list.size()));
|
||||
}
|
||||
}
|
||||
|
||||
return iinventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the printer can print an item, i.e. has a source item, destination stack isn't full, etc.
|
||||
*/
|
||||
private boolean canPrint()
|
||||
{
|
||||
if (printerItemStacks.get(0).isEmpty() || !(printerItemStacks.get(0).getItem() instanceof Schematic))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack itemstack = null;
|
||||
Item item = printerItemStacks.get(0).getItem();
|
||||
ItemStack[] required = ((Schematic) item).getIngredients();
|
||||
ItemStack result = ((Schematic) item).getResult();
|
||||
|
||||
IInventory inventoryToUse = getInventoryForCrafting(required);
|
||||
|
||||
if (inventoryToUse != null)
|
||||
{
|
||||
itemstack = result;
|
||||
}
|
||||
|
||||
if (itemstack == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack itemstack1 = printerItemStacks.get(2);
|
||||
|
||||
if (itemstack1.isEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (!itemstack1.isItemEqual(itemstack))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (itemstack1.getCount() + itemstack.getCount() <= getInventoryStackLimit() && itemstack1.getCount() + itemstack.getCount() <= itemstack1.getMaxStackSize()) // Forge fix: respect stack sizes
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return itemstack1.getCount() + itemstack.getCount() <= itemstack.getMaxStackSize(); // Forge fix: respect stack sizes
|
||||
}
|
||||
}
|
||||
|
||||
public void printItem()
|
||||
{
|
||||
if (canPrint())
|
||||
{
|
||||
ItemStack itemstack1 = new ItemStack(Items.AIR);
|
||||
|
||||
Item item = printerItemStacks.get(0).getItem();
|
||||
|
||||
if (item instanceof Schematic)
|
||||
{
|
||||
ItemStack[] required = ((Schematic) item).getIngredients();
|
||||
ItemStack result = ((Schematic) item).getResult();
|
||||
|
||||
IInventory inventoryToUse = getInventoryForCrafting(required);
|
||||
|
||||
if (inventoryToUse != null)
|
||||
{
|
||||
consumeItems(required);
|
||||
itemstack1 = result;
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack itemstack2 = printerItemStacks.get(2);
|
||||
|
||||
if (itemstack2.isEmpty())
|
||||
{
|
||||
printerItemStacks.set(2, itemstack1.copy());
|
||||
}
|
||||
else if (itemstack2.getItem() == itemstack1.getItem())
|
||||
{
|
||||
itemstack2.grow(itemstack1.getCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't rename this method to canInteractWith due to conflicts with Container
|
||||
*/
|
||||
@Override
|
||||
public boolean isUsableByPlayer(EntityPlayer player)
|
||||
{
|
||||
if (world.getTileEntity(pos) != this)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return player.getDistanceSq(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D) <= 64.0D;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(EntityPlayer player)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(EntityPlayer player)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot. For
|
||||
* guis use Slot.isItemValid
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack)
|
||||
{
|
||||
if (index == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side)
|
||||
{
|
||||
if (side == EnumFacing.DOWN)
|
||||
{
|
||||
return SLOTS_BOTTOM;
|
||||
}
|
||||
else
|
||||
{
|
||||
return side == EnumFacing.UP ? SLOTS_TOP : SLOTS_SIDES;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if automation can insert the given item in the given slot from the given side.
|
||||
*/
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction)
|
||||
{
|
||||
return isItemValidForSlot(index, itemStackIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if automation can extract the given item in the given slot from the given side.
|
||||
*/
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction)
|
||||
{
|
||||
if (direction == EnumFacing.DOWN && index == 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getGuiID()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
|
||||
{
|
||||
return new PrinterContainer(playerInventory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getField(int id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case 0:
|
||||
return energyStored;
|
||||
case 1:
|
||||
return energyCapacity;
|
||||
case 2:
|
||||
return printTime;
|
||||
case 3:
|
||||
return totalPrintTime;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setField(int id, int value)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case 0:
|
||||
energyStored = value;
|
||||
break;
|
||||
case 1:
|
||||
energyCapacity = value;
|
||||
break;
|
||||
case 2:
|
||||
printTime = value;
|
||||
break;
|
||||
case 3:
|
||||
totalPrintTime = value;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFieldCount()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
printerItemStacks.clear();
|
||||
}
|
||||
|
||||
net.minecraftforge.items.IItemHandler handlerTop = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.UP);
|
||||
net.minecraftforge.items.IItemHandler handlerBottom = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.DOWN);
|
||||
net.minecraftforge.items.IItemHandler handlerSide = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.WEST);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@javax.annotation.Nullable
|
||||
public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @javax.annotation.Nullable net.minecraft.util.EnumFacing facing)
|
||||
{
|
||||
if (facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||
{
|
||||
if (facing == EnumFacing.DOWN)
|
||||
{
|
||||
return (T) handlerBottom;
|
||||
}
|
||||
|
||||
else if (facing == EnumFacing.UP)
|
||||
{
|
||||
return (T) handlerTop;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return (T) handlerSide;
|
||||
}
|
||||
}
|
||||
if (capability == CapabilityEnergy.ENERGY)
|
||||
{
|
||||
return (T) energyStorage;
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing)
|
||||
{
|
||||
if (capability == CapabilityEnergy.ENERGY)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return super.hasCapability(capability, facing);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,208 @@
|
|||
package com.droog71.prospect.tilentity;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
import com.droog71.prospect.blocks.energy.Purifier;
|
||||
import com.droog71.prospect.fe.ProspectEnergyStorage;
|
||||
import com.droog71.prospect.init.ProspectBlocks;
|
||||
import com.droog71.prospect.init.ProspectSounds;
|
||||
import ic2.api.energy.prefab.BasicSink;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class PurifierTileEntity extends TileEntity implements ITickable
|
||||
{
|
||||
private Object ic2EnergySink;
|
||||
private int effectsTimer;
|
||||
private ProspectEnergyStorage energyStorage = new ProspectEnergyStorage();
|
||||
|
||||
@Override
|
||||
public void onLoad()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink == null))
|
||||
{
|
||||
ic2EnergySink = new BasicSink(this,10000,2);
|
||||
}
|
||||
((BasicSink) ic2EnergySink).onLoad(); // notify the energy sink
|
||||
}
|
||||
energyStorage.capacity = 10000;
|
||||
energyStorage.maxReceive = 20000;
|
||||
super.onLoad();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink) != null)
|
||||
{
|
||||
((BasicSink) ic2EnergySink).invalidate(); // notify the energy sink
|
||||
}
|
||||
}
|
||||
super.invalidate(); // this is important for mc!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink) != null)
|
||||
{
|
||||
((BasicSink) ic2EnergySink).onChunkUnload(); // notify the energy sink
|
||||
}
|
||||
}
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.readFromNBT(tag);
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if ((BasicSink) ic2EnergySink == null)
|
||||
{
|
||||
ic2EnergySink = new BasicSink(this,10000,2);
|
||||
}
|
||||
((BasicSink) ic2EnergySink).readFromNBT(tag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.writeToNBT(tag);
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if ((BasicSink) ic2EnergySink == null)
|
||||
{
|
||||
ic2EnergySink = new BasicSink(this,10000,2);
|
||||
}
|
||||
((BasicSink) ic2EnergySink).writeToNBT(tag);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
if (!world.isRemote) //Everything is done on the server.
|
||||
{
|
||||
if (energyStorage.overloaded)
|
||||
{
|
||||
explode();
|
||||
}
|
||||
else
|
||||
{
|
||||
Purifier purifier = (Purifier) world.getBlockState(pos).getBlock();
|
||||
if (useEnergy())
|
||||
{
|
||||
purifier.powered = true;
|
||||
doWork();
|
||||
}
|
||||
else
|
||||
{
|
||||
purifier.powered = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void doWork()
|
||||
{
|
||||
effectsTimer++;
|
||||
if (effectsTimer > 40)
|
||||
{
|
||||
WorldServer w = (WorldServer) world;
|
||||
BlockPos corner_1 = pos.add(-20, -20, -20);
|
||||
BlockPos corner_2 = pos.add(20, 20, 20);
|
||||
Iterable<BlockPos> allBlocks = BlockPos.getAllInBox(corner_1, corner_2);
|
||||
Iterator<BlockPos> iter = allBlocks.iterator();
|
||||
while(iter.hasNext())
|
||||
{
|
||||
try
|
||||
{
|
||||
w.spawnParticle(EnumParticleTypes.TOWN_AURA, iter.next().getX(), iter.next().getY(), iter.next().getZ(), 1, 0, 0, 0, 1, null);
|
||||
}
|
||||
catch(NoSuchElementException e)
|
||||
{
|
||||
//NOOP
|
||||
}
|
||||
}
|
||||
world.playSound(null, pos, ProspectSounds.purifierSoundEvent, SoundCategory.BLOCKS, 0.25f, 1);
|
||||
effectsTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void explode()
|
||||
{
|
||||
world.playSound(null, pos, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 0.5f, 1);
|
||||
WorldServer w = (WorldServer) world;
|
||||
w.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, pos.getX(), pos.getY(), pos.getZ(), 1, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.LAVA, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.FLAME, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
world.getBlockState(pos).getBlock().breakBlock(world, pos, ProspectBlocks.extruder.getDefaultState());
|
||||
EntityItem item = new EntityItem(w, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(ProspectBlocks.extruder));
|
||||
w.spawnEntity(item);
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
private boolean useEnergy()
|
||||
{
|
||||
if (energyStorage.getEnergyStored() >= 40)
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
((BasicSink) ic2EnergySink).setEnergyStored(0);
|
||||
((BasicSink) ic2EnergySink).setCapacity(0);
|
||||
}
|
||||
energyStorage.useEnergy(40);
|
||||
return true;
|
||||
}
|
||||
else if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
((BasicSink) ic2EnergySink).setCapacity(10000);
|
||||
if (((BasicSink) ic2EnergySink).useEnergy(10))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @javax.annotation.Nullable net.minecraft.util.EnumFacing facing)
|
||||
{
|
||||
if (capability == CapabilityEnergy.ENERGY)
|
||||
{
|
||||
return (T) energyStorage;
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing)
|
||||
{
|
||||
if (capability == CapabilityEnergy.ENERGY)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return super.hasCapability(capability, facing);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,666 @@
|
|||
package com.droog71.prospect.tilentity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import com.droog71.prospect.fe.ProspectEnergyStorage;
|
||||
import com.droog71.prospect.init.ProspectBlocks;
|
||||
import com.droog71.prospect.init.ProspectSounds;
|
||||
import ic2.api.energy.prefab.BasicSink;
|
||||
import net.minecraft.util.EntitySelectors;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.fluids.BlockFluidBase;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockChest;
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
|
||||
public class QuarryTileEntity extends TileEntity implements ITickable
|
||||
{
|
||||
private int quarryTimer;
|
||||
private int soundTimer;
|
||||
private int level = 1;
|
||||
private int miningX = 100000000;
|
||||
private int miningZ = 100000000;
|
||||
private boolean quarryFinished;
|
||||
private boolean overflow;
|
||||
private IInventory currentInventory;
|
||||
private List<BlockPos> quarryPositions = new ArrayList<BlockPos>();
|
||||
private int energyStored;
|
||||
private Object ic2EnergySink;
|
||||
private ProspectEnergyStorage energyStorage = new ProspectEnergyStorage();
|
||||
|
||||
@Override
|
||||
public void onLoad()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink == null))
|
||||
{
|
||||
ic2EnergySink = new BasicSink(this,400000,4);
|
||||
}
|
||||
((BasicSink) ic2EnergySink).onLoad(); // notify the energy sink
|
||||
}
|
||||
energyStorage.capacity = 80000;
|
||||
energyStorage.maxReceive = 16000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink) != null)
|
||||
{
|
||||
((BasicSink) ic2EnergySink).invalidate(); // notify the energy sink
|
||||
}
|
||||
}
|
||||
super.invalidate(); // this is important for mc!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink) != null)
|
||||
{
|
||||
((BasicSink) ic2EnergySink).onChunkUnload(); // notify the energy sink
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound)
|
||||
{
|
||||
super.readFromNBT(compound);
|
||||
|
||||
quarryTimer = compound.getInteger("quarryTimer");
|
||||
level = compound.getInteger("level");
|
||||
miningX = compound.getInteger("miningX");
|
||||
miningZ = compound.getInteger("miningZ");
|
||||
quarryFinished = compound.getBoolean("quarryFinished");
|
||||
energyStored = compound.getInteger("energyStored");
|
||||
|
||||
int[] quarryPosX = compound.getIntArray("quarryPosX");
|
||||
int[] quarryPosY = compound.getIntArray("quarryPosY");
|
||||
int[] quarryPosZ = compound.getIntArray("quarryPosZ");
|
||||
for (int i=0; i<quarryPosX.length; i++)
|
||||
{
|
||||
quarryPositions.add(new BlockPos(quarryPosX[i],quarryPosY[i],quarryPosZ[i]));
|
||||
}
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if ((BasicSink) ic2EnergySink == null)
|
||||
{
|
||||
ic2EnergySink = new BasicSink(this,400000,4);
|
||||
}
|
||||
((BasicSink) ic2EnergySink).readFromNBT(compound);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound)
|
||||
{
|
||||
super.writeToNBT(compound);
|
||||
|
||||
compound.setInteger("quarryTimer", (short)quarryTimer);
|
||||
compound.setInteger("level", (short)level);
|
||||
compound.setInteger("miningX", (short)miningX);
|
||||
compound.setInteger("miningZ", (short)miningZ);
|
||||
compound.setBoolean("quarryFinished", quarryFinished);
|
||||
compound.setInteger("energyStored", energyStored);
|
||||
|
||||
int[] quarryPosX = new int[quarryPositions.size()];
|
||||
int[] quarryPosY = new int[quarryPositions.size()];
|
||||
int[] quarryPosZ = new int[quarryPositions.size()];
|
||||
for (int i=0; i<quarryPositions.size(); i++)
|
||||
{
|
||||
quarryPosX[i] = quarryPositions.get(i).getX();
|
||||
quarryPosY[i] = quarryPositions.get(i).getY();
|
||||
quarryPosZ[i] = quarryPositions.get(i).getZ();
|
||||
}
|
||||
compound.setIntArray("quarryPosX", quarryPosX);
|
||||
compound.setIntArray("quarryPosY", quarryPosY);
|
||||
compound.setIntArray("quarryPosZ", quarryPosZ);
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if ((BasicSink) ic2EnergySink == null)
|
||||
{
|
||||
ic2EnergySink = new BasicSink(this,400000,4);
|
||||
}
|
||||
((BasicSink) ic2EnergySink).writeToNBT(compound);
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
private void transferItemOut(ItemStack stack)
|
||||
{
|
||||
IInventory iinventory = getInventoryForTransfer();
|
||||
if (iinventory != null)
|
||||
{
|
||||
if (!isInventoryFull(iinventory))
|
||||
{
|
||||
if (!isLiquid(stack))
|
||||
{
|
||||
int size = iinventory.getSizeInventory();
|
||||
boolean flag = false;
|
||||
for (int index = 0; index < size; ++index)
|
||||
{
|
||||
ItemStack itemstack = iinventory.getStackInSlot(index);
|
||||
if (itemstack.isEmpty())
|
||||
{
|
||||
iinventory.setInventorySlotContents(index, stack);
|
||||
stack = ItemStack.EMPTY;
|
||||
flag = true;
|
||||
}
|
||||
else if (canCombine(itemstack, stack))
|
||||
{
|
||||
int i = stack.getMaxStackSize() - itemstack.getCount();
|
||||
int j = Math.min(stack.getCount(), i);
|
||||
stack.shrink(j);
|
||||
itemstack.grow(j);
|
||||
flag = j > 0;
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
overflow = false;
|
||||
iinventory.markDirty();
|
||||
}
|
||||
else
|
||||
{
|
||||
overflow = true;
|
||||
WorldServer w = (WorldServer) world;
|
||||
EntityItem item = new EntityItem(w, pos.getX(), pos.getY(), pos.getZ(), stack);
|
||||
w.spawnEntity(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldServer w = (WorldServer) world;
|
||||
EntityItem item = new EntityItem(w, pos.getX(), pos.getY(), pos.getZ(), stack);
|
||||
w.spawnEntity(item);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldServer w = (WorldServer) world;
|
||||
EntityItem item = new EntityItem(w, pos.getX(), pos.getY(), pos.getZ(), stack);
|
||||
w.spawnEntity(item);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isLiquid(ItemStack stack)
|
||||
{
|
||||
Block b = Block.getBlockFromItem(stack.getItem());
|
||||
if (b instanceof BlockLiquid || b instanceof BlockFluidBase || b instanceof IFluidBlock || b.getMaterial(b.getDefaultState()).isLiquid())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean canCombine(ItemStack stack1, ItemStack stack2)
|
||||
{
|
||||
if (stack1.getItem() != stack2.getItem())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (stack1.getMetadata() != stack2.getMetadata())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (stack1.getCount() > stack1.getMaxStackSize())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ItemStack.areItemStackTagsEqual(stack1, stack2);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isInventoryFull(IInventory inventoryIn)
|
||||
{
|
||||
if (inventoryIn instanceof ISidedInventory)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = inventoryIn.getSizeInventory();
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
ItemStack itemstack = inventoryIn.getStackInSlot(j);
|
||||
|
||||
if (itemstack.isEmpty() || itemstack.getCount() != itemstack.getMaxStackSize())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean inventoryHasEmptySlot(IInventory inventoryIn)
|
||||
{
|
||||
if (inventoryIn instanceof ISidedInventory)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = inventoryIn.getSizeInventory();
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
ItemStack itemstack = inventoryIn.getStackInSlot(j);
|
||||
|
||||
if (itemstack.isEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public IInventory getInventoryForTransfer()
|
||||
{
|
||||
List<IInventory> invList = new ArrayList<IInventory>();
|
||||
BlockPos[] positions = {pos.add(0,1,0),pos.add(0,-1,0),pos.add(1,0,0),pos.add(-1,0,0),pos.add(0,0,1),pos.add(0,0,-1)};
|
||||
for (BlockPos p : positions)
|
||||
{
|
||||
invList.add(getInventoryAtPosition(world,p.getX(),p.getY(),p.getZ()));
|
||||
}
|
||||
for (IInventory inventory : invList)
|
||||
{
|
||||
if (inventory != null)
|
||||
{
|
||||
if (!isInventoryFull(inventory))
|
||||
{
|
||||
if (currentInventory != null)
|
||||
{
|
||||
if (overflow)
|
||||
{
|
||||
if (currentInventory != inventory)
|
||||
{
|
||||
if (inventoryHasEmptySlot(inventory))
|
||||
{
|
||||
currentInventory = inventory;
|
||||
return inventory;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (currentInventory == inventory)
|
||||
{
|
||||
currentInventory = inventory;
|
||||
return inventory;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
currentInventory = inventory;
|
||||
return inventory;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IInventory getInventoryAtPosition(World worldIn, double x, double y, double z)
|
||||
{
|
||||
IInventory iinventory = null;
|
||||
int i = MathHelper.floor(x);
|
||||
int j = MathHelper.floor(y);
|
||||
int k = MathHelper.floor(z);
|
||||
BlockPos blockpos = new BlockPos(i, j, k);
|
||||
net.minecraft.block.state.IBlockState state = worldIn.getBlockState(blockpos);
|
||||
Block block = state.getBlock();
|
||||
|
||||
if (block.hasTileEntity(state))
|
||||
{
|
||||
TileEntity tileentity = worldIn.getTileEntity(blockpos);
|
||||
|
||||
if (tileentity instanceof IInventory)
|
||||
{
|
||||
iinventory = (IInventory)tileentity;
|
||||
|
||||
if (iinventory instanceof TileEntityChest && block instanceof BlockChest)
|
||||
{
|
||||
iinventory = ((BlockChest)block).getContainer(worldIn, blockpos, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (iinventory == null)
|
||||
{
|
||||
List<Entity> list = worldIn.getEntitiesInAABBexcluding((Entity)null, new AxisAlignedBB(x - 0.5D, y - 0.5D, z - 0.5D, x + 0.5D, y + 0.5D, z + 0.5D), EntitySelectors.HAS_INVENTORY);
|
||||
|
||||
if (!list.isEmpty())
|
||||
{
|
||||
iinventory = (IInventory)list.get(worldIn.rand.nextInt(list.size()));
|
||||
}
|
||||
}
|
||||
|
||||
return iinventory;
|
||||
}
|
||||
|
||||
private void initPos()
|
||||
{
|
||||
if (miningX == 100000000)
|
||||
{
|
||||
miningX = pos.getX() - 10;
|
||||
}
|
||||
if (miningZ == 100000000)
|
||||
{
|
||||
miningZ = pos.getZ() - 10;
|
||||
}
|
||||
}
|
||||
|
||||
private void playMiningSound(BlockPos p)
|
||||
{
|
||||
if (world.getBlockState(p).getBlock() != Blocks.AIR)
|
||||
{
|
||||
world.playSound(null, p, world.getBlockState(p).getBlock().getSoundType().getBreakSound(), SoundCategory.BLOCKS, 1.0f, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private int getEnergyStored()
|
||||
{
|
||||
if (energyStorage.getEnergyStored() > 0)
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
((BasicSink) ic2EnergySink).setEnergyStored(0);
|
||||
((BasicSink) ic2EnergySink).setCapacity(0);
|
||||
}
|
||||
energyStored = energyStorage.getEnergyStored()/4;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
((BasicSink) ic2EnergySink).setCapacity(400000);
|
||||
if (((BasicSink) ic2EnergySink).getEnergyStored() > 0)
|
||||
{
|
||||
energyStored = (int) ((BasicSink) ic2EnergySink).getEnergyStored();
|
||||
}
|
||||
}
|
||||
}
|
||||
return energyStored;
|
||||
}
|
||||
|
||||
private boolean useEnergy(int amount)
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink).useEnergy(amount))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (energyStorage != null)
|
||||
{
|
||||
if (energyStorage.getEnergyStored() >= amount)
|
||||
{
|
||||
energyStorage.useEnergy(amount*4);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (energyStorage != null)
|
||||
{
|
||||
if (energyStorage.getEnergyStored() >= amount)
|
||||
{
|
||||
energyStorage.useEnergy(amount*4);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void explode()
|
||||
{
|
||||
world.playSound(null, pos, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 0.5f, 1);
|
||||
WorldServer w = (WorldServer) world;
|
||||
w.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, pos.getX(), pos.getY(), pos.getZ(), 1, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.LAVA, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.FLAME, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
world.getBlockState(pos).getBlock().breakBlock(world, pos, ProspectBlocks.extruder.getDefaultState());
|
||||
EntityItem item = new EntityItem(w, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(ProspectBlocks.extruder));
|
||||
w.spawnEntity(item);
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
if (!world.isRemote) // Everything is done on the server
|
||||
{
|
||||
if (energyStorage.overloaded)
|
||||
{
|
||||
explode();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (quarryFinished == false)
|
||||
{
|
||||
if (getEnergyStored() >= 5)
|
||||
{
|
||||
soundTimer++;
|
||||
if (soundTimer >= 60)
|
||||
{
|
||||
world.playSound(null, pos, ProspectSounds.quarrySoundEvent, SoundCategory.BLOCKS, 1.0f, 1);
|
||||
soundTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (getEnergyStored() >= 1024)
|
||||
{
|
||||
useEnergy(1024);
|
||||
quarryTimer += 32;
|
||||
}
|
||||
else if (getEnergyStored() >= 512)
|
||||
{
|
||||
useEnergy(512);
|
||||
quarryTimer += 16;
|
||||
}
|
||||
else if (getEnergyStored() >= 128)
|
||||
{
|
||||
useEnergy(128);
|
||||
quarryTimer += 8;
|
||||
}
|
||||
else if (getEnergyStored() >= 32)
|
||||
{
|
||||
useEnergy(32);
|
||||
quarryTimer += 4;
|
||||
}
|
||||
else if (getEnergyStored() >= 5)
|
||||
{
|
||||
useEnergy(5);
|
||||
quarryTimer += 2;
|
||||
}
|
||||
else if (getEnergyStored() >= 1)
|
||||
{
|
||||
useEnergy(1);
|
||||
quarryTimer += 1;
|
||||
}
|
||||
if (quarryTimer >= 32)
|
||||
{
|
||||
initPos();
|
||||
if (miningX < pos.getX() + 11)
|
||||
{
|
||||
if (miningZ < pos.getZ() + 11)
|
||||
{
|
||||
BlockPos p = new BlockPos(miningX,pos.getY()-level,miningZ);
|
||||
Block b = world.getBlockState(p).getBlock();
|
||||
if (b != Blocks.BEDROCK)
|
||||
{
|
||||
ItemStack stack = new ItemStack(Items.AIR);
|
||||
Item itemDropped = b.getItemDropped(b.getDefaultState(), new Random(), 0);
|
||||
if (itemDropped != Item.getItemFromBlock(b))
|
||||
{
|
||||
stack = new ItemStack(itemDropped);
|
||||
}
|
||||
else
|
||||
{
|
||||
stack = new ItemStack(Item.getItemFromBlock(b));
|
||||
}
|
||||
|
||||
transferItemOut(stack);
|
||||
|
||||
if (level == 1)
|
||||
{
|
||||
if (p.getX() == pos.getX() && p.getZ() == pos.getZ())
|
||||
{
|
||||
world.setBlockState(p, ProspectBlocks.quarry_tube.getDefaultState());
|
||||
world.getBlockState(p).getBlock().setHardness(1000.0f);
|
||||
quarryPositions.add(p);
|
||||
}
|
||||
else if (p.getX() == pos.getX() - 10 || p.getX() == pos.getX() + 10 || p.getZ() == pos.getZ() - 10 || p.getZ() == pos.getZ() + 10)
|
||||
{
|
||||
world.setBlockState(p, ProspectBlocks.quarry_frame.getDefaultState());
|
||||
world.getBlockState(p).getBlock().setHardness(1000.0f);
|
||||
quarryPositions.add(p);
|
||||
}
|
||||
else if (p.getX() == pos.getX() && p.getZ() != pos.getZ())
|
||||
{
|
||||
world.setBlockState(p, ProspectBlocks.quarry_frame.getDefaultState());
|
||||
world.getBlockState(p).getBlock().setHardness(1000.0f);
|
||||
quarryPositions.add(p);
|
||||
}
|
||||
else if (p.getX() != pos.getX() && p.getZ() == pos.getZ())
|
||||
{
|
||||
world.setBlockState(p, ProspectBlocks.quarry_frame.getDefaultState());
|
||||
world.getBlockState(p).getBlock().setHardness(1000.0f);
|
||||
quarryPositions.add(p);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p.getX() == pos.getX() && p.getZ() == pos.getZ())
|
||||
{
|
||||
world.setBlockState(p, ProspectBlocks.quarry_tube.getDefaultState());
|
||||
world.getBlockState(p).getBlock().setHardness(1000.0f);
|
||||
quarryPositions.add(p);
|
||||
}
|
||||
else if (p.getX() == pos.getX() - 10 && p.getZ() == pos.getZ() - 10 || p.getX() == pos.getX() + 10 && p.getZ() == pos.getZ() + 10 || p.getX() == pos.getX() + 10 && p.getZ() == pos.getZ() - 10 || p.getX() == pos.getX() - 10 && p.getZ() == pos.getZ() + 10)
|
||||
{
|
||||
world.setBlockState(p, ProspectBlocks.quarry_frame.getDefaultState());
|
||||
world.getBlockState(p).getBlock().setHardness(1000.0f);
|
||||
quarryPositions.add(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (level == 2)
|
||||
{
|
||||
if (p.getX() != pos.getX() && p.getZ() != pos.getZ())
|
||||
{
|
||||
if (p.getX() != pos.getX() - 10 && p.getX() != pos.getX() + 10 && p.getZ() != pos.getZ() - 10 && p.getZ() != pos.getZ() + 10)
|
||||
{
|
||||
world.setBlockToAir(p.add(0,1,0));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
world.setBlockToAir(p.add(0,1,0));
|
||||
if (world.getBlockState(p).getBlock() != Blocks.AIR)
|
||||
{
|
||||
playMiningSound(p);
|
||||
WorldServer w = (WorldServer) world;
|
||||
w.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, p.getX(), p.getY(), p.getZ(), 1, 0, 0, 0, 1, null);
|
||||
}
|
||||
}
|
||||
world.setBlockToAir(p);
|
||||
world.setBlockState(p, ProspectBlocks.quarry_drill.getDefaultState());
|
||||
world.getBlockState(p).getBlock().setHardness(1000.0f);
|
||||
quarryPositions.add(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
quarryFinished = true;
|
||||
}
|
||||
miningZ++;
|
||||
}
|
||||
else
|
||||
{
|
||||
miningZ = pos.getZ() - 10;
|
||||
miningX++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
world.playSound(null, pos, ProspectSounds.quarrySoundEvent, SoundCategory.BLOCKS, 1.0f, 1);
|
||||
miningX = pos.getX() - 10;
|
||||
level++;
|
||||
markDirty();
|
||||
}
|
||||
quarryTimer = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (BlockPos p : quarryPositions)
|
||||
{
|
||||
world.getBlockState(p).getBlock().setHardness(1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @javax.annotation.Nullable net.minecraft.util.EnumFacing facing)
|
||||
{
|
||||
if (capability == CapabilityEnergy.ENERGY)
|
||||
{
|
||||
return (T) energyStorage;
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing)
|
||||
{
|
||||
if (capability == CapabilityEnergy.ENERGY)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return super.hasCapability(capability, facing);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,763 @@
|
|||
package com.droog71.prospect.tilentity;
|
||||
|
||||
import com.droog71.prospect.fe.ProspectEnergyStorage;
|
||||
import com.droog71.prospect.init.ProspectBlocks;
|
||||
import com.droog71.prospect.init.ProspectItems;
|
||||
import com.droog71.prospect.init.ProspectSounds;
|
||||
import com.droog71.prospect.inventory.ReplicatorContainer;
|
||||
import ic2.api.energy.prefab.BasicSink;
|
||||
import ic2.core.platform.registry.Ic2Items;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.inventory.ItemStackHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class ReplicatorTileEntity extends TileEntity implements ITickable, ISidedInventory
|
||||
{
|
||||
private static final int[] SLOTS_TOP = new int[] {0};
|
||||
private static final int[] SLOTS_BOTTOM = new int[] {2, 1};
|
||||
private static final int[] SLOTS_SIDES = new int[] {1};
|
||||
private NonNullList<ItemStack> replicatorItemStacks = NonNullList.<ItemStack>withSize(3, ItemStack.EMPTY);
|
||||
private int energyStored;
|
||||
private int energyCapacity;
|
||||
private int replicatorSpendTime;
|
||||
private int currentCreditSpendTime;
|
||||
private int replicateTime;
|
||||
private int totalreplicateTime;
|
||||
private Object ic2EnergySink;
|
||||
private int effectsTimer;
|
||||
private ProspectEnergyStorage energyStorage = new ProspectEnergyStorage();
|
||||
|
||||
@Override
|
||||
public void onLoad()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink == null))
|
||||
{
|
||||
ic2EnergySink = new BasicSink(this,1000000,5);
|
||||
}
|
||||
((BasicSink) ic2EnergySink).onLoad(); // notify the energy sink
|
||||
}
|
||||
energyStorage.capacity = 125000;
|
||||
energyStorage.maxReceive = 25000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink) != null)
|
||||
{
|
||||
((BasicSink) ic2EnergySink).invalidate(); // notify the energy sink
|
||||
}
|
||||
super.invalidate(); // this is important for mc!
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink) != null)
|
||||
{
|
||||
((BasicSink) ic2EnergySink).onChunkUnload(); // notify the energy sink
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of slots in the inventory.
|
||||
*/
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return replicatorItemStacks.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
for (ItemStack itemstack : replicatorItemStacks)
|
||||
{
|
||||
if (!itemstack.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stack in the given slot.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int index)
|
||||
{
|
||||
return replicatorItemStacks.get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes up to a specified number of items from an inventory slot and returns them in a new stack.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack decrStackSize(int index, int count)
|
||||
{
|
||||
return ItemStackHelper.getAndSplit(replicatorItemStacks, index, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a stack from the given slot and returns it.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int index)
|
||||
{
|
||||
return ItemStackHelper.getAndRemove(replicatorItemStacks, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
|
||||
*/
|
||||
@Override
|
||||
public void setInventorySlotContents(int index, ItemStack stack)
|
||||
{
|
||||
ItemStack itemstack = replicatorItemStacks.get(index);
|
||||
boolean flag = !stack.isEmpty() && stack.isItemEqual(itemstack) && ItemStack.areItemStackTagsEqual(stack, itemstack);
|
||||
replicatorItemStacks.set(index, stack);
|
||||
|
||||
if (stack.getCount() > getInventoryStackLimit())
|
||||
{
|
||||
stack.setCount(getInventoryStackLimit());
|
||||
}
|
||||
|
||||
if (index == 0 && !flag)
|
||||
{
|
||||
totalreplicateTime = getreplicateTime(stack);
|
||||
replicateTime = 0;
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of this object. For players this returns their username
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "Replicator";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this thing is named
|
||||
*/
|
||||
@Override
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setCustomInventoryName(String p_145951_1_)
|
||||
{
|
||||
//NOOP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound)
|
||||
{
|
||||
super.readFromNBT(compound);
|
||||
replicatorItemStacks = NonNullList.<ItemStack>withSize(getSizeInventory(), ItemStack.EMPTY);
|
||||
ItemStackHelper.loadAllItems(compound, replicatorItemStacks);
|
||||
energyStored = compound.getInteger("EnergyStored");
|
||||
replicatorSpendTime = compound.getInteger("SpendTime");
|
||||
replicateTime = compound.getInteger("replicateTime");
|
||||
totalreplicateTime = compound.getInteger("replicateTimeTotal");
|
||||
currentCreditSpendTime = getCreditSpendTime(replicatorItemStacks.get(1));
|
||||
energyCapacity = compound.getInteger("EnergyCapacity");
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if ((BasicSink) ic2EnergySink == null)
|
||||
{
|
||||
ic2EnergySink = new BasicSink(this,1000000,5);
|
||||
}
|
||||
((BasicSink) ic2EnergySink).readFromNBT(compound);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound)
|
||||
{
|
||||
super.writeToNBT(compound);
|
||||
compound.setInteger("EnergyStored", (short)energyStored);
|
||||
compound.setInteger("EnergyCapacity", (short)energyCapacity);
|
||||
compound.setInteger("SpendTime", (short)replicatorSpendTime);
|
||||
compound.setInteger("replicateTime", (short)replicateTime);
|
||||
compound.setInteger("replicateTimeTotal", (short)totalreplicateTime);
|
||||
ItemStackHelper.saveAllItems(compound, replicatorItemStacks);
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if ((BasicSink) ic2EnergySink == null)
|
||||
{
|
||||
ic2EnergySink = new BasicSink(this,1000000,5);
|
||||
}
|
||||
((BasicSink) ic2EnergySink).writeToNBT(compound);
|
||||
}
|
||||
return compound;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended.
|
||||
*/
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
/**
|
||||
* Machine isEnergized
|
||||
*/
|
||||
public boolean isEnergized()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink).getEnergyStored() > 0)
|
||||
{
|
||||
return ((BasicSink) ic2EnergySink).getEnergyStored() > 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return energyStorage.getEnergyStored() > 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return energyStorage.getEnergyStored() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static boolean isEnergized(IInventory inventory)
|
||||
{
|
||||
return inventory.getField(5) > 0;
|
||||
}
|
||||
|
||||
public boolean isReplicating()
|
||||
{
|
||||
return replicatorSpendTime > 0;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static boolean isReplicating(IInventory inventory)
|
||||
{
|
||||
return inventory.getField(0) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Like the old updateEntity(), except more generic.
|
||||
*/
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
boolean flag1 = false;
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (energyStorage.overloaded)
|
||||
{
|
||||
explode();
|
||||
}
|
||||
else
|
||||
{
|
||||
updateEnergy();
|
||||
|
||||
ItemStack itemstack = replicatorItemStacks.get(1);
|
||||
|
||||
if (!itemstack.isEmpty() && !replicatorItemStacks.get(0).isEmpty())
|
||||
{
|
||||
if (isEnergized() && canReplicate())
|
||||
{
|
||||
if (useEnergy())
|
||||
{
|
||||
--replicatorSpendTime;
|
||||
if (replicatorSpendTime <= 0)
|
||||
{
|
||||
itemstack.shrink(1);
|
||||
replicatorSpendTime = getCreditSpendTime(itemstack);
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
++replicateTime;
|
||||
if (replicateTime == totalreplicateTime)
|
||||
{
|
||||
replicateTime = 0;
|
||||
totalreplicateTime = getreplicateTime(replicatorItemStacks.get(0));
|
||||
replicateItem();
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
effectsTimer++;
|
||||
if (effectsTimer > 40)
|
||||
{
|
||||
world.playSound(null, pos, ProspectSounds.replicatorSoundEvent, SoundCategory.BLOCKS, 0.25f, 1);
|
||||
effectsTimer = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
replicateTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag1)
|
||||
{
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flag1)
|
||||
{
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
private void explode()
|
||||
{
|
||||
world.playSound(null, pos, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 0.5f, 1);
|
||||
WorldServer w = (WorldServer) world;
|
||||
w.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, pos.getX(), pos.getY(), pos.getZ(), 1, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.LAVA, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.FLAME, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
world.getBlockState(pos).getBlock().breakBlock(world, pos, ProspectBlocks.extruder.getDefaultState());
|
||||
EntityItem item = new EntityItem(w, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(ProspectBlocks.extruder));
|
||||
w.spawnEntity(item);
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
private void updateEnergy()
|
||||
{
|
||||
if (energyStorage.getEnergyStored() > 0)
|
||||
{
|
||||
energyStored = energyStorage.getEnergyStored();
|
||||
energyCapacity = energyStorage.getMaxEnergyStored();
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
((BasicSink) ic2EnergySink).setEnergyStored(0);
|
||||
((BasicSink) ic2EnergySink).setCapacity(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
((BasicSink) ic2EnergySink).setCapacity(1000000);
|
||||
if (((BasicSink) ic2EnergySink).getEnergyStored() > 0)
|
||||
{
|
||||
energyStored = (int) ((BasicSink) ic2EnergySink).getEnergyStored();
|
||||
energyCapacity = (int) ((BasicSink) ic2EnergySink).getCapacity();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean useEnergy()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSink) ic2EnergySink).useEnergy(4096))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (energyStorage != null)
|
||||
{
|
||||
if (energyStorage.getEnergyStored() >= 16384)
|
||||
{
|
||||
energyStorage.useEnergy(16384);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (energyStorage != null)
|
||||
{
|
||||
if (energyStorage.getEnergyStored() >= 16384)
|
||||
{
|
||||
energyStorage.useEnergy(16384);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getreplicateTime(ItemStack stack)
|
||||
{
|
||||
Item i = stack.getItem();
|
||||
if (i == Items.EMERALD || i == Items.DIAMOND)
|
||||
{
|
||||
return 400;
|
||||
}
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (stack == Ic2Items.uraniumDrop)
|
||||
{
|
||||
return 400;
|
||||
}
|
||||
}
|
||||
return 200;
|
||||
}
|
||||
|
||||
private boolean invalidReplicatorItem(ItemStack stack)
|
||||
{
|
||||
Item i = stack.getItem();
|
||||
if (i == Item.getItemFromBlock(Blocks.WOOL) || i == Items.GLOWSTONE_DUST || i == Items.IRON_INGOT || i == Items.GOLD_INGOT || i == Items.REDSTONE || i == Items.DIAMOND || i == Items.CLAY_BALL || i == Items.QUARTZ || i == Items.COAL || i == Items.EMERALD)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (stack == Ic2Items.stickyResin || stack == Ic2Items.uraniumDrop)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
NonNullList<ItemStack> copper = OreDictionary.getOres("ingotCopper");
|
||||
for (ItemStack s : copper)
|
||||
{
|
||||
if (s.getDisplayName() == stack.getDisplayName())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
NonNullList<ItemStack> tin = OreDictionary.getOres("ingotTin");
|
||||
for (ItemStack s : tin)
|
||||
{
|
||||
if (s.getDisplayName() == stack.getDisplayName())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
NonNullList<ItemStack> silver = OreDictionary.getOres("ingotSilver");
|
||||
for (ItemStack s : silver)
|
||||
{
|
||||
if (s.getDisplayName() == stack.getDisplayName())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
NonNullList<ItemStack> lead = OreDictionary.getOres("ingotLead");
|
||||
for (ItemStack s : lead)
|
||||
{
|
||||
if (s.getDisplayName() == stack.getDisplayName())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
NonNullList<ItemStack> aluminum = OreDictionary.getOres("ingotAluminum");
|
||||
for (ItemStack s : aluminum)
|
||||
{
|
||||
if (s.getDisplayName() == stack.getDisplayName())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
NonNullList<ItemStack> silicon = OreDictionary.getOres("silicon");
|
||||
for (ItemStack s : silicon)
|
||||
{
|
||||
if (s.getDisplayName() == stack.getDisplayName())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the transmitter can transmit an item, i.e. has a source item, destination stack isn't full, etc.
|
||||
*/
|
||||
private boolean canReplicate()
|
||||
{
|
||||
Item item = replicatorItemStacks.get(0).getItem();
|
||||
ItemStack itemstack = new ItemStack(item);
|
||||
|
||||
if (itemstack.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (invalidReplicatorItem(itemstack))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack itemstack1 = replicatorItemStacks.get(2);
|
||||
|
||||
if (itemstack1.isEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (!itemstack1.isItemEqual(itemstack))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (itemstack1.getCount() + itemstack.getCount() <= getInventoryStackLimit() && itemstack1.getCount() + itemstack.getCount() <= itemstack1.getMaxStackSize()) // Forge fix: respect stack sizes
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return itemstack1.getCount() + itemstack.getCount() <= itemstack.getMaxStackSize(); // Forge fix: respect stack sizes
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void replicateItem()
|
||||
{
|
||||
if (canReplicate())
|
||||
{
|
||||
ItemStack itemstack = replicatorItemStacks.get(0);
|
||||
ItemStack itemstack1 = new ItemStack(itemstack.getItem());
|
||||
ItemStack itemstack2 = replicatorItemStacks.get(2);
|
||||
|
||||
if (itemstack2.isEmpty())
|
||||
{
|
||||
replicatorItemStacks.set(2, itemstack1.copy());
|
||||
}
|
||||
else if (itemstack2.getItem() == itemstack1.getItem())
|
||||
{
|
||||
itemstack2.grow(itemstack1.getCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int getCreditSpendTime(ItemStack stack) //Could eventually be used for differing denominations of currency.
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
public static boolean isCredit(ItemStack stack)
|
||||
{
|
||||
return stack.getItem() == ProspectItems.credit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't rename this method to canInteractWith due to conflicts with Container
|
||||
*/
|
||||
@Override
|
||||
public boolean isUsableByPlayer(EntityPlayer player)
|
||||
{
|
||||
if (world.getTileEntity(pos) != this)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return player.getDistanceSq(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D) <= 64.0D;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(EntityPlayer player)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(EntityPlayer player)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot. For
|
||||
* guis use Slot.isItemValid
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack)
|
||||
{
|
||||
if (index == 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (index != 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return stack.getItem() == ProspectItems.credit;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side)
|
||||
{
|
||||
if (side == EnumFacing.DOWN)
|
||||
{
|
||||
return SLOTS_BOTTOM;
|
||||
}
|
||||
else
|
||||
{
|
||||
return side == EnumFacing.UP ? SLOTS_TOP : SLOTS_SIDES;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if automation can insert the given item in the given slot from the given side.
|
||||
*/
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction)
|
||||
{
|
||||
return isItemValidForSlot(index, itemStackIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if automation can extract the given item in the given slot from the given side.
|
||||
*/
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction)
|
||||
{
|
||||
if (direction == EnumFacing.DOWN && index == 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getGuiID()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
|
||||
{
|
||||
return new ReplicatorContainer(playerInventory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getField(int id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case 0:
|
||||
return replicatorSpendTime;
|
||||
case 1:
|
||||
return currentCreditSpendTime;
|
||||
case 2:
|
||||
return replicateTime;
|
||||
case 3:
|
||||
return totalreplicateTime;
|
||||
case 4:
|
||||
return energyCapacity;
|
||||
case 5:
|
||||
return energyStored;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setField(int id, int value)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case 0:
|
||||
replicatorSpendTime = value;
|
||||
break;
|
||||
case 1:
|
||||
currentCreditSpendTime = value;
|
||||
break;
|
||||
case 2:
|
||||
replicateTime = value;
|
||||
break;
|
||||
case 3:
|
||||
totalreplicateTime = value;
|
||||
break;
|
||||
case 4:
|
||||
energyCapacity = value;
|
||||
break;
|
||||
case 5:
|
||||
energyStored = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFieldCount()
|
||||
{
|
||||
return 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
replicatorItemStacks.clear();
|
||||
}
|
||||
|
||||
net.minecraftforge.items.IItemHandler handlerTop = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.UP);
|
||||
net.minecraftforge.items.IItemHandler handlerBottom = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.DOWN);
|
||||
net.minecraftforge.items.IItemHandler handlerSide = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.WEST);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@javax.annotation.Nullable
|
||||
public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @javax.annotation.Nullable net.minecraft.util.EnumFacing facing)
|
||||
{
|
||||
if (facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||
{
|
||||
if (facing == EnumFacing.DOWN)
|
||||
{
|
||||
return (T) handlerBottom;
|
||||
}
|
||||
|
||||
else if (facing == EnumFacing.UP)
|
||||
{
|
||||
return (T) handlerTop;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return (T) handlerSide;
|
||||
}
|
||||
}
|
||||
if (capability == CapabilityEnergy.ENERGY)
|
||||
{
|
||||
return (T) energyStorage;
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing)
|
||||
{
|
||||
if (capability == CapabilityEnergy.ENERGY)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return super.hasCapability(capability, facing);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,210 @@
|
|||
package com.droog71.prospect.tilentity;
|
||||
|
||||
import com.droog71.prospect.fe.ProspectEnergyStorage;
|
||||
import ic2.api.energy.prefab.BasicSource;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class SolarPanelTileEntity extends TileEntity implements ITickable
|
||||
{
|
||||
private Object ic2EnergySource;
|
||||
private ProspectEnergyStorage energyStorage = new ProspectEnergyStorage();
|
||||
private int rating;
|
||||
private int tier;
|
||||
|
||||
public SolarPanelTileEntity()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public SolarPanelTileEntity(int capacity, int rating, int tier)
|
||||
{
|
||||
energyStorage.capacity = capacity;
|
||||
this.rating = rating;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSource) ic2EnergySource == null))
|
||||
{
|
||||
ic2EnergySource = new BasicSource(this,energyStorage.capacity/4,tier);
|
||||
}
|
||||
((BasicSource) ic2EnergySource).onLoad(); // notify the energy sink
|
||||
}
|
||||
energyStorage.maxReceive = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSource) ic2EnergySource) != null)
|
||||
{
|
||||
((BasicSource) ic2EnergySource).invalidate(); // notify the energy sink
|
||||
}
|
||||
}
|
||||
super.invalidate(); // this is important for mc!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSource) ic2EnergySource) != null)
|
||||
{
|
||||
((BasicSource) ic2EnergySource).onChunkUnload(); // notify the energy sink
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.readFromNBT(tag);
|
||||
if ((BasicSource) ic2EnergySource == null)
|
||||
{
|
||||
ic2EnergySource = new BasicSource(this,10,1);
|
||||
}
|
||||
((BasicSource) ic2EnergySource).readFromNBT(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.writeToNBT(tag);
|
||||
if ((BasicSource) ic2EnergySource == null)
|
||||
{
|
||||
ic2EnergySource = new BasicSource(this,10,1);
|
||||
}
|
||||
((BasicSource) ic2EnergySource).writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
if (!world.isRemote) //Everything is done on the server.
|
||||
{
|
||||
addEnergy();
|
||||
giveEnergy();
|
||||
}
|
||||
}
|
||||
|
||||
private void addEnergy()
|
||||
{
|
||||
if (world.canBlockSeeSky(pos.offset(EnumFacing.UP)))
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
if (((BasicSource) ic2EnergySource).getCapacity() > 0)
|
||||
{
|
||||
((BasicSource) ic2EnergySource).addEnergy(world.getSunBrightnessFactor(1F) * 5);
|
||||
}
|
||||
}
|
||||
energyStorage.generateEnergy((int)world.getSunBrightnessFactor(1F) * rating);
|
||||
}
|
||||
}
|
||||
|
||||
private void giveEnergy()
|
||||
{
|
||||
boolean connectedFE = false;
|
||||
BlockPos[] sides = {pos.add(0,1,0),pos.add(1,0,0),pos.add(0,0,1),pos.add(0,-1,0),pos.add(-1,0,0),pos.add(0,0,-1)};
|
||||
for (BlockPos p : sides)
|
||||
{
|
||||
TileEntity otherTile = world.getTileEntity(p);
|
||||
if (otherTile != null)
|
||||
{
|
||||
EnumFacing direction = null;
|
||||
for (EnumFacing facing : EnumFacing.VALUES)
|
||||
{
|
||||
IEnergyStorage otherStorage = otherTile.getCapability(CapabilityEnergy.ENERGY,facing);
|
||||
if (otherStorage != null)
|
||||
{
|
||||
if (direction == null)
|
||||
{
|
||||
direction = facing;
|
||||
}
|
||||
}
|
||||
}
|
||||
IEnergyStorage otherStorage = otherTile.getCapability(CapabilityEnergy.ENERGY,direction);
|
||||
if (otherStorage != null)
|
||||
{
|
||||
if (Loader.isModLoaded("ic2"))
|
||||
{
|
||||
((BasicSource) ic2EnergySource).setEnergyStored(0);
|
||||
((BasicSource) ic2EnergySource).setCapacity(0);
|
||||
connectedFE = true;
|
||||
}
|
||||
if (energyStorage.getEnergyStored() >= rating)
|
||||
{
|
||||
if (otherStorage.canReceive())
|
||||
{
|
||||
if (otherStorage.getEnergyStored() <= otherStorage.getMaxEnergyStored() - rating)
|
||||
{
|
||||
otherStorage.receiveEnergy(rating,false);
|
||||
energyStorage.useEnergy(rating);
|
||||
}
|
||||
else
|
||||
{
|
||||
otherStorage.receiveEnergy(otherStorage.getMaxEnergyStored() - otherStorage.getEnergyStored(),false);
|
||||
energyStorage.useEnergy(otherStorage.getMaxEnergyStored() - otherStorage.getEnergyStored());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (energyStorage.getEnergyStored() > 0)
|
||||
{
|
||||
if (otherStorage.canReceive())
|
||||
{
|
||||
if (otherStorage.getEnergyStored() <= otherStorage.getMaxEnergyStored() - energyStorage.getEnergyStored())
|
||||
{
|
||||
otherStorage.receiveEnergy(energyStorage.getEnergyStored(),false);
|
||||
energyStorage.useEnergy(energyStorage.getEnergyStored());
|
||||
}
|
||||
else
|
||||
{
|
||||
otherStorage.receiveEnergy(otherStorage.getMaxEnergyStored() - otherStorage.getEnergyStored(),false);
|
||||
energyStorage.useEnergy(otherStorage.getMaxEnergyStored() - otherStorage.getEnergyStored());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (connectedFE == false)
|
||||
{
|
||||
((BasicSource) ic2EnergySource).setCapacity(10);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @javax.annotation.Nullable net.minecraft.util.EnumFacing facing)
|
||||
{
|
||||
if (capability == CapabilityEnergy.ENERGY)
|
||||
{
|
||||
return (T) energyStorage;
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing)
|
||||
{
|
||||
if (capability == CapabilityEnergy.ENERGY)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return super.hasCapability(capability, facing);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,147 @@
|
|||
package com.droog71.prospect.tilentity;
|
||||
|
||||
import com.droog71.prospect.fe.ProspectEnergyStorage;
|
||||
import com.droog71.prospect.init.ProspectBlocks;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TransformerTileEntity extends TileEntity implements ITickable
|
||||
{
|
||||
private ProspectEnergyStorage energyStorage = new ProspectEnergyStorage();
|
||||
private int rating;
|
||||
private int stepDownRating;
|
||||
private int stepDownMaxReceive;
|
||||
|
||||
public TransformerTileEntity()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public TransformerTileEntity(int maxReceive, int capacity, int rating)
|
||||
{
|
||||
energyStorage.maxReceive = maxReceive;
|
||||
energyStorage.capacity = capacity;
|
||||
stepDownMaxReceive = energyStorage.maxReceive;
|
||||
stepDownRating = rating;
|
||||
this.rating = rating;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
if (!world.isRemote) //Everything is done on the server.
|
||||
{
|
||||
if (energyStorage.overloaded)
|
||||
{
|
||||
explode();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (world.isBlockPowered(pos))
|
||||
{
|
||||
energyStorage.maxReceive = stepDownRating;
|
||||
rating = stepDownMaxReceive;
|
||||
}
|
||||
else
|
||||
{
|
||||
energyStorage.maxReceive = stepDownMaxReceive;
|
||||
rating = stepDownRating;
|
||||
}
|
||||
giveEnergy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void giveEnergy()
|
||||
{
|
||||
BlockPos[] sides = {pos.add(0,1,0),pos.add(1,0,0),pos.add(0,0,1),pos.add(0,-1,0),pos.add(-1,0,0),pos.add(0,0,-1)};
|
||||
for (BlockPos p : sides)
|
||||
{
|
||||
TileEntity otherTile = world.getTileEntity(p);
|
||||
if (otherTile != null)
|
||||
{
|
||||
EnumFacing direction = null;
|
||||
for (EnumFacing facing : EnumFacing.VALUES)
|
||||
{
|
||||
IEnergyStorage otherStorage = otherTile.getCapability(CapabilityEnergy.ENERGY,facing);
|
||||
if (otherStorage != null)
|
||||
{
|
||||
if (direction == null)
|
||||
{
|
||||
direction = facing;
|
||||
}
|
||||
}
|
||||
}
|
||||
IEnergyStorage otherStorage = otherTile.getCapability(CapabilityEnergy.ENERGY,direction);
|
||||
if (otherStorage != null)
|
||||
{
|
||||
if (energyStorage.getEnergyStored() > 0)
|
||||
{
|
||||
if (otherStorage.canReceive())
|
||||
{
|
||||
if (otherStorage.getEnergyStored() < otherStorage.getMaxEnergyStored())
|
||||
{
|
||||
if (otherStorage.getEnergyStored() < energyStorage.getEnergyStored())
|
||||
{
|
||||
int potential = (energyStorage.getEnergyStored() - otherStorage.getEnergyStored())/2;
|
||||
int output = Math.min(potential, rating);
|
||||
energyStorage.useEnergy(output);
|
||||
otherStorage.receiveEnergy(rating, true);
|
||||
if (otherStorage != null)
|
||||
{
|
||||
otherStorage.receiveEnergy(output,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void explode()
|
||||
{
|
||||
world.playSound(null, pos, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 0.5f, 1);
|
||||
WorldServer w = (WorldServer) world;
|
||||
w.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, pos.getX(), pos.getY(), pos.getZ(), 1, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.LAVA, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
w.spawnParticle(EnumParticleTypes.FLAME, pos.getX(), pos.getY(), pos.getZ(), 10, 0, 0, 0, 1, null);
|
||||
world.getBlockState(pos).getBlock().breakBlock(world, pos, ProspectBlocks.extruder.getDefaultState());
|
||||
EntityItem item = new EntityItem(w, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(ProspectBlocks.extruder));
|
||||
w.spawnEntity(item);
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @javax.annotation.Nullable net.minecraft.util.EnumFacing facing)
|
||||
{
|
||||
if (capability == CapabilityEnergy.ENERGY)
|
||||
{
|
||||
return (T) energyStorage;
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing)
|
||||
{
|
||||
if (capability == CapabilityEnergy.ENERGY)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return super.hasCapability(capability, facing);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package com.droog71.prospect.worldgen;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.droog71.prospect.init.ProspectBlocks;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.IChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.WorldGenMinable;
|
||||
import net.minecraftforge.fml.common.IWorldGenerator;
|
||||
|
||||
public class OreGen implements IWorldGenerator
|
||||
{
|
||||
@Override
|
||||
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
|
||||
{
|
||||
if (world.provider.getDimension() == 0)
|
||||
{
|
||||
generateOverworld(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider);
|
||||
}
|
||||
}
|
||||
|
||||
private void generateOverworld(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
|
||||
{
|
||||
generateOre(ProspectBlocks.living_ore.getDefaultState(), world, random, chunkX * 16, chunkZ * 16, 16, 64, random.nextInt(7) + 4, 18);
|
||||
generateOre(ProspectBlocks.copper_ore.getDefaultState(), world, random, chunkX * 16, chunkZ * 16, 16, 64, random.nextInt(7) + 4, 18);
|
||||
generateOre(ProspectBlocks.tin_ore.getDefaultState(), world, random, chunkX * 16, chunkZ * 16, 16, 64, random.nextInt(7) + 4, 18);
|
||||
generateOre(ProspectBlocks.silver_ore.getDefaultState(), world, random, chunkX * 16, chunkZ * 16, 16, 64, random.nextInt(7) + 4, 18);
|
||||
generateOre(ProspectBlocks.aluminum_ore.getDefaultState(), world, random, chunkX * 16, chunkZ * 16, 16, 64, random.nextInt(7) + 4, 18);
|
||||
generateOre(ProspectBlocks.lead_ore.getDefaultState(), world, random, chunkX * 16, chunkZ * 16, 16, 64, random.nextInt(7) + 4, 18);
|
||||
generateOre(ProspectBlocks.silicon_ore.getDefaultState(), world, random, chunkX * 16, chunkZ * 16, 16, 64, random.nextInt(7) + 4, 18);
|
||||
}
|
||||
|
||||
private void generateOre(IBlockState ore, World world, Random random, int x, int z, int minY, int maxY, int size, int chances)
|
||||
{
|
||||
int deltaY = maxY - minY;
|
||||
|
||||
for (int i = 0; i < chances; i++)
|
||||
{
|
||||
BlockPos pos = new BlockPos(x + random.nextInt(16), minY + random.nextInt(deltaY), z + random.nextInt(16));
|
||||
WorldGenMinable generator = new WorldGenMinable(ore, size);
|
||||
generator.generate(world, random, pos);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:aluminum_ore" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:capsule" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:copper_ore" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:ev_cable" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:ev_solar_panel" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:ev_transformer" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:extruder" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:hv_cable" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:hv_solar_panel" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:hv_transformer" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:iv_cable" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:iv_solar_panel" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:launch_pad" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:lead_ore" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:living_ore" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:lv_cable" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:lv_solar_panel" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:lv_transformer" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:mv_cable" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:mv_solar_panel" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:mv_transformer" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:press" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:printer" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:purifier" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:quarry" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:quarry_drill" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:quarry_frame" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:quarry_tube" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:replicator" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:silicon_ore" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:silver_ore" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:lv_solar_panel" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:tin_ore" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": [
|
||||
{ "model": "prospect:transmitter" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
item.gem.name=Gem
|
||||
item.credit.name=IGC
|
||||
item.circuit.name=Circuit
|
||||
item.suit_material.name=Suit Material
|
||||
item.prepared_circuit.name=Prepared Circuit
|
||||
item.quantum_circuit.name=Quantum Circuit
|
||||
item.copper_ingot.name=Copper Ingot
|
||||
item.lead_ingot.name=Lead Ingot
|
||||
item.silver_ingot.name=Silver Ingot
|
||||
item.aluminum_ingot.name=Aluminum Ingot
|
||||
item.tin_ingot.name=Tin Ingot
|
||||
item.copper_plate.name=Copper Plate
|
||||
item.lead_plate.name=Lead Plate
|
||||
item.silver_plate.name=Silver Plate
|
||||
item.aluminum_plate.name=Aluminum Plate
|
||||
item.tin_plate.name=Tin Plate
|
||||
item.silicon.name=Silicon
|
||||
item.copper_wire.name=Copper Wire
|
||||
item.mv_wire.name=MV wire
|
||||
item.hv_wire.name=HV Wire
|
||||
item.ev_wire.name=EV Wire
|
||||
item.iv_wire.name=IV Wire
|
||||
item.in_lv_wire.name=Insulated LV Wire
|
||||
item.in_mv_wire.name=Insulated MV wire
|
||||
item.in_hv_wire.name=Insulated HV Wire
|
||||
item.in_ev_wire.name=Insulated EV Wire
|
||||
item.in_iv_wire.name=Insulated IV Wire
|
||||
item.lv_coil.name=LV Coil
|
||||
item.mv_coil.name=MV Coil
|
||||
item.hv_coil.name=HV Coil
|
||||
item.ev_coil.name=EV Coil
|
||||
item.iv_coil.name=IV Coil
|
||||
item.purifier_schematic.name=Purifier Schematic
|
||||
item.printer_schematic.name=Printer Schematic
|
||||
item.helmet_schematic.name=Prospector's Helmet Schematic
|
||||
item.suit_schematic.name=Prospector's Suit Schematic
|
||||
item.pants_schematic.name=Prospector's Pants Schematic
|
||||
item.boots_schematic.name=Prospector's Boots Schematic
|
||||
item.filter_schematic.name=Spore Filter Schematic
|
||||
item.quarry_schematic.name=Industrial Quarry Schematic
|
||||
item.replicator_schematic.name=Replicator Schematic
|
||||
item.launch_pad_schematic.name=Launch Pad Schematic
|
||||
item.extruder_schematic.name=Extruder Schematic
|
||||
item.mv_wire_schematic.name=MV Wire Schematic
|
||||
item.hv_wire_schematic.name=HV Wire Schematic
|
||||
item.ev_wire_schematic.name=EV Wire Schematic
|
||||
item.iv_wire_schematic.name=IV Wire Schematic
|
||||
item.in_lv_wire_schematic.name=Insulated LV Wire Schematic
|
||||
item.in_mv_wire_schematic.name=Insulated MV Wire Schematic
|
||||
item.in_hv_wire_schematic.name=Insulated HV Wire Schematic
|
||||
item.in_ev_wire_schematic.name=Insulated EV Wire Schematic
|
||||
item.in_iv_wire_schematic.name=Insulated IV Wire Schematic
|
||||
item.lv_coil_schematic.name=LV Coil Schematic
|
||||
item.mv_coil_schematic.name=MV Coil Schematic
|
||||
item.hv_coil_schematic.name=HV Coil Schematic
|
||||
item.ev_coil_schematic.name=EV Coil Schematic
|
||||
item.iv_coil_schematic.name=IV Coil Schematic
|
||||
item.circuit_schematic.name=Circuit Schematic
|
||||
item.prepared_circuit_schematic.name=Prepared Circuit Schematic
|
||||
item.lv_cable_schematic.name=LV Conduit Schematic
|
||||
item.mv_cable_schematic.name=MV Conduit Schematic
|
||||
item.hv_cable_schematic.name=HV Conduit Schematic
|
||||
item.ev_cable_schematic.name=EV Conduit Schematic
|
||||
item.iv_cable_schematic.name=IV Conduit Schematic
|
||||
item.lv_transformer_schematic.name=LV Transformer Schematic
|
||||
item.mv_transformer_schematic.name=MV Transformer Schematic
|
||||
item.hv_transformer_schematic.name=HV Transformer Schematic
|
||||
item.ev_transformer_schematic.name=EV Transformer Schematic
|
||||
item.lv_solar_panel_schematic.name=LV Solar Panel Schematic
|
||||
item.mv_solar_panel_schematic.name=MV Solar Panel Schematic
|
||||
item.hv_solar_panel_schematic.name=HV Solar Panel Schematic
|
||||
item.ev_solar_panel_schematic.name=EV Solar Panel Schematic
|
||||
item.iv_solar_panel_schematic.name=IV Solar Panel Schematic
|
||||
item.chest_schematic.name=Chest Schematic
|
||||
item.hopper_schematic.name=Hopper Schematic
|
||||
item.piston_schematic.name=Piston Schematic
|
||||
item.filter.name=Spore Filter
|
||||
item.helmet.name=Prospector's Helmet
|
||||
item.suit.name=Prospector's Suit
|
||||
item.pants.name=Prospector's Pants
|
||||
item.boots.name=Prospector's Boots
|
||||
tile.quarry.name=Industrial Quarry
|
||||
tile.lv_solar_panel.name=LV Solar Panel
|
||||
tile.mv_solar_panel.name=MV Solar Panel
|
||||
tile.hv_solar_panel.name=HV Solar Panel
|
||||
tile.ev_solar_panel.name=EV Solar Panel
|
||||
tile.iv_solar_panel.name=IV Solar Panel
|
||||
tile.extruder.name=Extruder
|
||||
tile.printer.name=Fabricator
|
||||
tile.purifier.name=Purifier
|
||||
tile.living_ore.name=Living Ore
|
||||
tile.copper_ore.name=Copper Ore
|
||||
tile.tin_ore.name=Tin Ore
|
||||
tile.aluminum_ore.name=Aluminum Ore
|
||||
tile.silver_ore.name=Silver Ore
|
||||
tile.lead_ore.name=Lead Ore
|
||||
tile.silicon_ore.name=Silicon ore
|
||||
tile.quarry_frame.name=Quarry Frame
|
||||
tile.quarry_tube.name=Quarry Tube
|
||||
tile.quarry_drill.name=Drilling Apparatus
|
||||
tile.replicator.name=Replicator
|
||||
tile.launch_pad.name=Launch Pad
|
||||
tile.capsule.name=Capsule
|
||||
tile.press.name=Press
|
||||
tile.lv_cable.name=LV Conduit
|
||||
tile.mv_cable.name=MV Conduit
|
||||
tile.hv_cable.name=HV Conduit
|
||||
tile.ev_cable.name=EV Conduit
|
||||
tile.iv_cable.name=IV Conduit
|
||||
tile.lv_transformer.name=LV Transformer
|
||||
tile.mv_transformer.name=MV Transformer
|
||||
tile.hv_transformer.name=HV Transformer
|
||||
tile.ev_transformer.name=EV Transformer
|
||||
itemGroup.Prospect=Prospect
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parent": "block/cube_bottom_top",
|
||||
"textures": {
|
||||
"side": "prospect:blocks/aluminum_ore",
|
||||
"bottom": "prospect:blocks/aluminum_ore",
|
||||
"top": "prospect:blocks/aluminum_ore"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parent": "block/cube_bottom_top",
|
||||
"textures": {
|
||||
"side": "prospect:blocks/quarry_tube_sides",
|
||||
"bottom": "prospect:blocks/quarry_tube_top_bottom",
|
||||
"top": "prospect:blocks/quarry_drill_top"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parent": "block/cube_bottom_top",
|
||||
"textures": {
|
||||
"side": "prospect:blocks/copper_ore",
|
||||
"bottom": "prospect:blocks/copper_ore",
|
||||
"top": "prospect:blocks/copper_ore"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parent": "block/cube_bottom_top",
|
||||
"textures": {
|
||||
"side": "prospect:blocks/ev_cable",
|
||||
"bottom": "prospect:blocks/ev_cable",
|
||||
"top": "prospect:blocks/ev_cable"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parent": "block/cube_bottom_top",
|
||||
"textures": {
|
||||
"side": "prospect:blocks/plating_dark",
|
||||
"bottom": "prospect:blocks/plating_dark",
|
||||
"top": "prospect:blocks/solar_panel"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parent": "block/cube_bottom_top",
|
||||
"textures": {
|
||||
"side": "prospect:blocks/ev_transformer",
|
||||
"bottom": "prospect:blocks/ev_transformer",
|
||||
"top": "prospect:blocks/ev_transformer"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parent": "block/cube_bottom_top",
|
||||
"textures": {
|
||||
"side": "prospect:blocks/extruder_sides",
|
||||
"bottom": "prospect:blocks/plating_dark",
|
||||
"top": "prospect:blocks/plating_dark"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parent": "block/cube_bottom_top",
|
||||
"textures": {
|
||||
"side": "prospect:blocks/hv_cable",
|
||||
"bottom": "prospect:blocks/hv_cable",
|
||||
"top": "prospect:blocks/hv_cable"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parent": "block/cube_bottom_top",
|
||||
"textures": {
|
||||
"side": "prospect:blocks/plating_dark",
|
||||
"bottom": "prospect:blocks/plating_dark",
|
||||
"top": "prospect:blocks/solar_panel"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parent": "block/cube_bottom_top",
|
||||
"textures": {
|
||||
"side": "prospect:blocks/hv_transformer",
|
||||
"bottom": "prospect:blocks/hv_transformer",
|
||||
"top": "prospect:blocks/hv_transformer"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parent": "block/cube_bottom_top",
|
||||
"textures": {
|
||||
"side": "prospect:blocks/iv_cable",
|
||||
"bottom": "prospect:blocks/iv_cable",
|
||||
"top": "prospect:blocks/iv_cable"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parent": "block/cube_bottom_top",
|
||||
"textures": {
|
||||
"side": "prospect:blocks/plating_dark",
|
||||
"bottom": "prospect:blocks/plating_dark",
|
||||
"top": "prospect:blocks/solar_panel"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parent": "block/cube_bottom_top",
|
||||
"textures": {
|
||||
"side": "prospect:blocks/launchpad_sides",
|
||||
"bottom": "prospect:blocks/launchpad_sides",
|
||||
"top": "prospect:blocks/launchpad_top"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parent": "block/cube_bottom_top",
|
||||
"textures": {
|
||||
"side": "prospect:blocks/lead_ore",
|
||||
"bottom": "prospect:blocks/lead_ore",
|
||||
"top": "prospect:blocks/lead_ore"
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue