mirror of
https://github.com/GTNewHorizons/Avaritia.git
synced 2026-11-20 12:19:39 +00:00
Squishy
This commit is contained in:
1 parent
cda8ce6b17
commit
fb7992270e
26 files changed
+1031
-87
No files matched your search
@@ -31,6 +31,8 @@ public class Config {
|
||||
public static boolean te = true;
|
||||
public static boolean numanuma = true;
|
||||
public static boolean metallurgy = true;
|
||||
public static boolean enderio = true;
|
||||
public static boolean forestry = true;
|
||||
|
||||
public static boolean copper = true;
|
||||
public static boolean tin = true;
|
||||
@@ -39,7 +41,6 @@ public class Config {
|
||||
public static boolean steel = true;
|
||||
public static boolean nickel = true;
|
||||
|
||||
|
||||
public static void configurate(File file){
|
||||
Configuration conf = new Configuration(file);
|
||||
|
||||
@@ -56,7 +57,7 @@ public class Config {
|
||||
sc2 = conf.get("compatibility", "Steve's Carts 2", true).getBoolean(true);
|
||||
ae2 = conf.get("compatibility", "Applied Energistics 2", true).getBoolean(true);
|
||||
exu = conf.get("compatibility", "Extra Utilities", true).getBoolean(true);
|
||||
ic2 = conf.get("compatibility", "Industrialcraft 2 Exp", true).getBoolean(true);
|
||||
ic2 = conf.get("compatibility", "Industrialcraft 2 Experimental", true).getBoolean(true);
|
||||
gt = conf.get("compatibility", "Gregtech 5", true).getBoolean(true);
|
||||
botan = conf.get("compatibility", "Botania", true).getBoolean(true);
|
||||
blood = conf.get("compatibility", "Blood Magic", true).getBoolean(true);
|
||||
@@ -71,14 +72,16 @@ public class Config {
|
||||
te = conf.get("compatibility", "Thermal Expansion", true).getBoolean(true);
|
||||
numanuma = conf.get("compatibility", "Pneumaticraft", true).getBoolean(true);
|
||||
metallurgy = conf.get("compatibility", "Metallurgy", true).getBoolean(true);
|
||||
enderio = conf.get("compatibility", "EnderIO", true).getBoolean(true);
|
||||
forestry = conf.get("compatibility", "Forestry", true).getBoolean(true);
|
||||
|
||||
conf.addCustomCategoryComment("metal", "Disable to stop using that metal in recipes. Useful if a mod adds unobtainable placeholder metal.");
|
||||
copper = conf.get("metal", "Copper", true).getBoolean(true);
|
||||
tin = conf.get("metal", "Tin", true).getBoolean(true);
|
||||
silver = conf.get("metal", "Silver", true).getBoolean(true);
|
||||
lead = conf.get("metal", "Lead", true).getBoolean(true);
|
||||
nickel = conf.get("metal", "Nickel/Ferrous", true).getBoolean(true);
|
||||
steel = conf.get("metal", "Steel", true).getBoolean(true);
|
||||
conf.addCustomCategoryComment("materials", "Disable to stop using that material in recipes. Useful if a mod adds unobtainable placeholder ores.");
|
||||
copper = conf.get("materials", "Copper", true).getBoolean(true);
|
||||
tin = conf.get("materials", "Tin", true).getBoolean(true);
|
||||
silver = conf.get("materials", "Silver", true).getBoolean(true);
|
||||
lead = conf.get("materials", "Lead", true).getBoolean(true);
|
||||
nickel = conf.get("materials", "Nickel/Ferrous", true).getBoolean(true);
|
||||
steel = conf.get("materials", "Steel", true).getBoolean(true);
|
||||
}
|
||||
catch(Exception e){
|
||||
Lumberjack.log(Level.ERROR, e, "Avaritia couldn't find its config!");
|
||||
|
||||
@@ -7,6 +7,9 @@ import fox.spiteful.avaritia.compat.Compat;
|
||||
import fox.spiteful.avaritia.items.LudicrousItems;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
|
||||
import static net.minecraftforge.event.world.BlockEvent.BreakEvent;
|
||||
|
||||
public class AchievementTrigger {
|
||||
|
||||
@@ -50,4 +53,10 @@ public class AchievementTrigger {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onBorken(BreakEvent event){
|
||||
if(event.block == LudicrousBlocks.dire_crafting && event.getPlayer() != null)
|
||||
event.getPlayer().addStat(Achievements.dire_uncrafting, 1);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.Achievement;
|
||||
import net.minecraftforge.common.AchievementPage;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public class Achievements {
|
||||
|
||||
@@ -16,6 +17,7 @@ public class Achievements {
|
||||
|
||||
public static Achievement crystal_matrix;
|
||||
public static Achievement dire_crafting;
|
||||
public static Achievement dire_uncrafting;
|
||||
public static Achievement collector;
|
||||
public static Achievement neutronium;
|
||||
public static Achievement singularity;
|
||||
@@ -34,6 +36,7 @@ public class Achievements {
|
||||
catalyst = new LudicrousAchievement("catalyst", 6, -3, new ItemStack(LudicrousItems.resource, 1, 5), singularity).setSpecial();
|
||||
infinity = new LudicrousAchievement("infinity", 4, -6, new ItemStack(LudicrousItems.resource, 1, 6), neutronium).setSpecial();
|
||||
creative_kill = new LudicrousAchievement("creative_kill", -6, -6, new ItemStack(Items.skull, 1, 3), null).setSpecial();
|
||||
dire_uncrafting = new LudicrousAchievement("dire_uncrafting", -1, 3, new ItemStack(Items.diamond_pickaxe), dire_crafting);
|
||||
|
||||
if(Compat.blood)
|
||||
armok = new LudicrousAchievement("armok", 2, -5, LudicrousItems.armok_orb, infinity);
|
||||
@@ -41,6 +44,8 @@ public class Achievements {
|
||||
page = new AchievementPage("Avaritia", LudicrousAchievement.achievements.toArray(new Achievement[LudicrousAchievement.achievements.size()]));
|
||||
AchievementPage.registerAchievementPage(page);
|
||||
|
||||
FMLCommonHandler.instance().bus().register(new AchievementTrigger());
|
||||
AchievementTrigger tigger = new AchievementTrigger();
|
||||
FMLCommonHandler.instance().bus().register(tigger);
|
||||
MinecraftForge.EVENT_BUS.register(tigger);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package fox.spiteful.avaritia.blocks;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import fox.spiteful.avaritia.Avaritia;
|
||||
import fox.spiteful.avaritia.tile.TileEntityCompressor;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockCompressor extends BlockContainer {
|
||||
|
||||
private IIcon top, sides, front;
|
||||
private Random randy = new Random();
|
||||
|
||||
public BlockCompressor(){
|
||||
super(Material.iron);
|
||||
setStepSound(Block.soundTypeMetal);
|
||||
setHardness(20.0F);
|
||||
setBlockName("neutronium_compressor");
|
||||
setHarvestLevel("pickaxe", 3);
|
||||
setCreativeTab(Avaritia.tab);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
this.top = iconRegister.registerIcon("avaritia:compressor_top");
|
||||
this.sides = iconRegister.registerIcon("avaritia:compressor_side");
|
||||
this.front = iconRegister.registerIcon("avaritia:compressor_front");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){
|
||||
if(side == 1)
|
||||
return top;
|
||||
int facing = 2;
|
||||
TileEntityCompressor machine = (TileEntityCompressor)world.getTileEntity(x, y, z);
|
||||
if(machine != null)
|
||||
facing = machine.getFacing();
|
||||
if(side == facing)
|
||||
return front;
|
||||
else
|
||||
return sides;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int metadata)
|
||||
{
|
||||
if(side == 1)
|
||||
return top;
|
||||
if(side == 3)
|
||||
return front;
|
||||
return sides;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.openGui(Avaritia.instance, 3, world, x, y, z);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta)
|
||||
{
|
||||
return new TileEntityCompressor();
|
||||
}
|
||||
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack item)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile instanceof TileEntityCompressor) {
|
||||
TileEntityCompressor machine = (TileEntityCompressor)tile;
|
||||
int l = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
|
||||
if (l == 0)
|
||||
machine.setFacing(2);
|
||||
|
||||
if (l == 1)
|
||||
machine.setFacing(5);
|
||||
|
||||
if (l == 2)
|
||||
machine.setFacing(3);
|
||||
|
||||
if (l == 3)
|
||||
machine.setFacing(4);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int wut)
|
||||
{
|
||||
TileEntityCompressor compressor = (TileEntityCompressor)world.getTileEntity(x, y, z);
|
||||
|
||||
if (compressor != null)
|
||||
{
|
||||
for(int i = 0;i < 2;i++) {
|
||||
ItemStack itemstack = compressor.getStackInSlot(i);
|
||||
|
||||
if (itemstack != null) {
|
||||
float f = this.randy.nextFloat() * 0.8F + 0.1F;
|
||||
float f1 = this.randy.nextFloat() * 0.8F + 0.1F;
|
||||
float f2 = this.randy.nextFloat() * 0.8F + 0.1F;
|
||||
|
||||
while (itemstack.stackSize > 0) {
|
||||
int j1 = this.randy.nextInt(21) + 10;
|
||||
|
||||
if (j1 > itemstack.stackSize) {
|
||||
j1 = itemstack.stackSize;
|
||||
}
|
||||
|
||||
itemstack.stackSize -= j1;
|
||||
EntityItem entityitem = new EntityItem(world, (double) ((float) x + f), (double) ((float) y + f1), (double) ((float) z + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
|
||||
|
||||
if (itemstack.hasTagCompound()) {
|
||||
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
|
||||
}
|
||||
|
||||
float f3 = 0.05F;
|
||||
entityitem.motionX = (double) ((float) this.randy.nextGaussian() * f3);
|
||||
entityitem.motionY = (double) ((float) this.randy.nextGaussian() * f3 + 0.2F);
|
||||
entityitem.motionZ = (double) ((float) this.randy.nextGaussian() * f3);
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
world.func_147453_f(x, y, z, block);
|
||||
}
|
||||
|
||||
super.breakBlock(world, x, y, z, block, wut);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package fox.spiteful.avaritia.blocks;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import fox.spiteful.avaritia.Config;
|
||||
import fox.spiteful.avaritia.tile.TileEntityCompressor;
|
||||
import fox.spiteful.avaritia.tile.TileEntityDireCrafting;
|
||||
import fox.spiteful.avaritia.tile.TileEntityNeutron;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -14,6 +15,7 @@ public class LudicrousBlocks {
|
||||
public static Block resource_block;
|
||||
public static Block dire_crafting;
|
||||
public static Block neutron_collector;
|
||||
public static Block compressor;
|
||||
|
||||
public static Block infinitato;
|
||||
|
||||
@@ -30,5 +32,7 @@ public class LudicrousBlocks {
|
||||
resource_block = GameRegistry.registerBlock(new BlockResource(), ItemBlockResource.class, "Resource_Block");
|
||||
neutron_collector = GameRegistry.registerBlock(new BlockNeutronCollector(), "Neutron_Collector");
|
||||
GameRegistry.registerTileEntity(TileEntityNeutron.class, "Avaritia_Neutron");
|
||||
compressor = GameRegistry.registerBlock(new BlockCompressor(), "Neutronium_Compressor");
|
||||
GameRegistry.registerTileEntity(TileEntityCompressor.class, "Avaritia_Compressor");
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import fox.spiteful.avaritia.Lumberjack;
|
||||
import fox.spiteful.avaritia.compat.bloodmagic.Bloody;
|
||||
import fox.spiteful.avaritia.compat.botania.Tsundere;
|
||||
import fox.spiteful.avaritia.compat.modtweaker.Tweak;
|
||||
import fox.spiteful.avaritia.compat.nei.NotEnough;
|
||||
import fox.spiteful.avaritia.compat.thaumcraft.Lucrum;
|
||||
import fox.spiteful.avaritia.compat.ticon.Tonkers;
|
||||
import fox.spiteful.avaritia.crafting.Grinder;
|
||||
@@ -32,6 +33,7 @@ public class Compat {
|
||||
public static boolean tweak = false;
|
||||
public static boolean mfr = false;
|
||||
public static boolean am2 = false;
|
||||
public static boolean forestry = false;
|
||||
|
||||
public static void census(){
|
||||
nei = Loader.isModLoaded("NotEnoughItems");
|
||||
@@ -48,23 +50,18 @@ public class Compat {
|
||||
pe = Loader.isModLoaded("ProjectE") && Config.pe;
|
||||
mfr = Loader.isModLoaded("MineFactoryReloaded") && Config.mfr;
|
||||
am2 = Loader.isModLoaded("arsmagica2") && Config.am2;
|
||||
forestry = Loader.isModLoaded("Forestry") && Config.forestry;
|
||||
}
|
||||
|
||||
public static void compatify(){
|
||||
if(nei){
|
||||
try
|
||||
{
|
||||
Class<?> handler = Class.forName("fox.spiteful.avaritia.compat.ExtremeShapedRecipeHandler");
|
||||
Class<?> handler2 = Class.forName("fox.spiteful.avaritia.compat.ExtremeShapelessRecipeHandler");
|
||||
Class<?> api = Class.forName("codechicken.nei.api.API");
|
||||
api.getMethod("registerRecipeHandler", Class.forName("codechicken.nei.recipe.ICraftingHandler")).invoke(null, handler.newInstance());
|
||||
api.getMethod("registerUsageHandler", Class.forName("codechicken.nei.recipe.IUsageHandler")).invoke(null, handler.newInstance());
|
||||
api.getMethod("registerRecipeHandler", Class.forName("codechicken.nei.recipe.ICraftingHandler")).invoke(null, handler2.newInstance());
|
||||
api.getMethod("registerUsageHandler", Class.forName("codechicken.nei.recipe.IUsageHandler")).invoke(null, handler2.newInstance());
|
||||
NotEnough.items();
|
||||
}
|
||||
catch(Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
Lumberjack.log(Level.INFO, e, "Avaritia had Too Many Items.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,8 +71,7 @@ public class Compat {
|
||||
Tweak.registrate();
|
||||
}
|
||||
catch(Throwable e){
|
||||
Lumberjack.log(Level.INFO, "Avaritia is too good for tweaking, apparently.");
|
||||
e.printStackTrace();
|
||||
Lumberjack.log(Level.INFO, e, "Avaritia is too good for tweaking, apparently.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,6 +332,18 @@ public class Compat {
|
||||
}
|
||||
}
|
||||
|
||||
if(forestry){
|
||||
try {
|
||||
Item panel = getItem("Forestry", "craftingMaterial");
|
||||
|
||||
Grinder.catalyst.getInput().add(new ItemStack(panel, 1, 6));
|
||||
}
|
||||
catch (Throwable e){
|
||||
Lumberjack.log(Level.INFO, e, "Avaritia got stung by a bee.");
|
||||
forestry = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Block getBlock(String mod, String block) throws ItemNotFoundException {
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
package fox.spiteful.avaritia.compat.nei;
|
||||
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import fox.spiteful.avaritia.crafting.CompressOreRecipe;
|
||||
import fox.spiteful.avaritia.crafting.CompressorManager;
|
||||
import fox.spiteful.avaritia.crafting.CompressorRecipe;
|
||||
import fox.spiteful.avaritia.gui.GUICompressor;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
public class CompressionHandler extends TemplateRecipeHandler
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
private FontRenderer fontRender;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CompressionHandler(){
|
||||
super();
|
||||
fontRender = Minecraft.getMinecraft().fontRenderer;
|
||||
}
|
||||
|
||||
public class CachedCompression extends CachedRecipe
|
||||
{
|
||||
public CachedCompression(CompressorRecipe recipe) {
|
||||
this.ingred = new PositionedStack(recipe.getIngredient(), 51, 16);
|
||||
this.result = new PositionedStack(recipe.getOutput(), 111, 16);
|
||||
this.cost = recipe.getCost();
|
||||
}
|
||||
public CachedCompression(ItemStack output, int price, ItemStack ingredient){
|
||||
this.ingred = new PositionedStack(ingredient, 51, 16);
|
||||
this.result = new PositionedStack(output, 111, 16);
|
||||
cost = price;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients() {
|
||||
return getCycledIngredients(cycleticks / 48, Arrays.asList(ingred));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void computeVisuals() {
|
||||
ingred.generatePermutations();
|
||||
}
|
||||
|
||||
public int getCost(){
|
||||
return cost;
|
||||
}
|
||||
|
||||
private int cost;
|
||||
|
||||
PositionedStack ingred;
|
||||
PositionedStack result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
transferRects.add(new RecipeTransferRect(new Rectangle(74, 23, 24, 18), "extreme_compression"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiContainer> getGuiClass() {
|
||||
return GUICompressor.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return StatCollector.translateToLocal("crafting.extreme_compression");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results) {
|
||||
if (outputId.equals("extreme_compression") && getClass() == CompressionHandler.class) {
|
||||
for (CompressorRecipe recipe : CompressorManager.getRecipes()) {
|
||||
if(safeOre(recipe)) {
|
||||
CachedCompression r = new CachedCompression(recipe);
|
||||
r.computeVisuals();
|
||||
arecipes.add(r);
|
||||
}
|
||||
}
|
||||
} else
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
for (CompressorRecipe recipe : CompressorManager.getRecipes()) {
|
||||
if(safeOre(recipe) && NEIServerUtils.areStacksSameTypeCrafting(recipe.getOutput(), result)){
|
||||
CachedCompression r = new CachedCompression(recipe);
|
||||
r.computeVisuals();
|
||||
arecipes.add(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(String inputId, Object... ingredients) {
|
||||
if (inputId.equals("extreme_compression") && getClass() == CompressionHandler.class)
|
||||
loadCraftingRecipes("extreme_compression");
|
||||
else
|
||||
super.loadUsageRecipes(inputId, ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
for (CompressorRecipe recipe : CompressorManager.getRecipes()) {
|
||||
if(safeOre(recipe) && recipe.validInput(ingredient)){
|
||||
CachedCompression r = new CachedCompression(recipe.getOutput(), recipe.getCost(), ingredient);
|
||||
arecipes.add(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean safeOre(CompressorRecipe recipe){
|
||||
if(!(recipe instanceof CompressOreRecipe))
|
||||
return true;
|
||||
return !((ArrayList)recipe.getIngredient()).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return "avaritia:textures/gui/compressor.png";
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void drawForeground(int recipe){
|
||||
fontRender.drawString(((CachedCompression)arecipes.get(recipe)).getCost() + "", 36, 38, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipe) {
|
||||
drawProgressBar(74, 15, 176, 14, 24, 16, 48, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier() {
|
||||
return "extreme_compression";
|
||||
}
|
||||
}
|
||||
+1
-4
@@ -1,7 +1,5 @@
|
||||
package fox.spiteful.avaritia.compat;
|
||||
package fox.spiteful.avaritia.compat.nei;
|
||||
|
||||
import codechicken.core.ReflectionManager;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import fox.spiteful.avaritia.crafting.ExtremeCraftingManager;
|
||||
import fox.spiteful.avaritia.crafting.ExtremeShapedOreRecipe;
|
||||
import fox.spiteful.avaritia.crafting.ExtremeShapedRecipe;
|
||||
@@ -11,7 +9,6 @@ import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
+1
-2
@@ -1,4 +1,4 @@
|
||||
package fox.spiteful.avaritia.compat;
|
||||
package fox.spiteful.avaritia.compat.nei;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.recipe.RecipeInfo;
|
||||
@@ -7,7 +7,6 @@ import fox.spiteful.avaritia.crafting.ExtremeCraftingManager;
|
||||
import fox.spiteful.avaritia.crafting.ExtremeShapelessRecipe;
|
||||
import fox.spiteful.avaritia.gui.GUIExtremeCrafting;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
@@ -0,0 +1,18 @@
|
||||
package fox.spiteful.avaritia.compat.nei;
|
||||
|
||||
import codechicken.nei.api.API;
|
||||
|
||||
public class NotEnough {
|
||||
|
||||
public static void items(){
|
||||
ExtremeShapedRecipeHandler shaped = new ExtremeShapedRecipeHandler();
|
||||
ExtremeShapelessRecipeHandler shapeless = new ExtremeShapelessRecipeHandler();
|
||||
CompressionHandler compress = new CompressionHandler();
|
||||
API.registerRecipeHandler(shaped);
|
||||
API.registerRecipeHandler(shapeless);
|
||||
API.registerRecipeHandler(compress);
|
||||
API.registerUsageHandler(shaped);
|
||||
API.registerUsageHandler(shapeless);
|
||||
API.registerUsageHandler(compress);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package fox.spiteful.avaritia.crafting;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CompressOreRecipe extends CompressorRecipe {
|
||||
|
||||
private int oreID;
|
||||
|
||||
public CompressOreRecipe(ItemStack output, int amount, String lex){
|
||||
super(output, amount, null);
|
||||
oreID = OreDictionary.getOreID(lex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validInput(ItemStack ingredient){
|
||||
|
||||
int[] ids = OreDictionary.getOreIDs(ingredient);
|
||||
for(int x = 0;x < ids.length;x++){
|
||||
if(oreID == ids[x])
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIngredientName(){
|
||||
ArrayList<ItemStack> ores = OreDictionary.getOres(OreDictionary.getOreName(oreID));
|
||||
if(!ores.isEmpty())
|
||||
return ores.get(0).getDisplayName();
|
||||
return OreDictionary.getOreName(oreID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getIngredient(){
|
||||
return OreDictionary.getOres(OreDictionary.getOreName(oreID));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package fox.spiteful.avaritia.crafting;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CompressorManager {
|
||||
|
||||
private static ArrayList<CompressorRecipe> recipes = new ArrayList<CompressorRecipe>();
|
||||
|
||||
public static void addRecipe(ItemStack output, int amount, ItemStack input){
|
||||
recipes.add(new CompressorRecipe(output, amount, input));
|
||||
}
|
||||
|
||||
public static void addOreRecipe(ItemStack output, int amount, String ore){
|
||||
recipes.add(new CompressOreRecipe(output, amount, ore));
|
||||
}
|
||||
|
||||
public static ItemStack getOutput(ItemStack input){
|
||||
for(CompressorRecipe recipe : recipes){
|
||||
if(recipe.validInput(input))
|
||||
return recipe.getOutput();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getCost(ItemStack input){
|
||||
for(CompressorRecipe recipe : recipes){
|
||||
if(recipe.validInput(input))
|
||||
return recipe.getCost();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static String getName(ItemStack input){
|
||||
for(CompressorRecipe recipe : recipes){
|
||||
if(recipe.validInput(input))
|
||||
return recipe.getIngredientName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ArrayList<CompressorRecipe> getRecipes(){
|
||||
return recipes;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package fox.spiteful.avaritia.crafting;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class CompressorRecipe {
|
||||
|
||||
private ItemStack product;
|
||||
private int cost;
|
||||
private ItemStack input;
|
||||
|
||||
public CompressorRecipe(ItemStack output, int amount, ItemStack ingredient){
|
||||
product = output;
|
||||
cost = amount;
|
||||
input = ingredient;
|
||||
}
|
||||
|
||||
public ItemStack getOutput(){
|
||||
return product.copy();
|
||||
}
|
||||
|
||||
public int getCost(){
|
||||
return cost;
|
||||
}
|
||||
|
||||
public boolean validInput(ItemStack ingredient){
|
||||
return ingredient.isItemEqual(input);
|
||||
}
|
||||
|
||||
public String getIngredientName(){
|
||||
return input.getDisplayName();
|
||||
}
|
||||
|
||||
public Object getIngredient(){
|
||||
return input;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -193,59 +193,41 @@ public class Grinder {
|
||||
'D', new ItemStack(Items.nether_star),
|
||||
'W', "logWood");
|
||||
|
||||
ExtremeCraftingManager.getInstance().addSingularityRecipe(new ItemStack(LudicrousItems.singularity, 1, 0), new ItemStack(Blocks.iron_block, 1));
|
||||
ExtremeCraftingManager.getInstance().addSingularityRecipe(new ItemStack(LudicrousItems.singularity, 1, 1), new ItemStack(Blocks.gold_block, 1));
|
||||
ExtremeCraftingManager.getInstance().addSingularityRecipe(new ItemStack(LudicrousItems.singularity, 1, 2), new ItemStack(Blocks.lapis_block, 1));
|
||||
ExtremeCraftingManager.getInstance().addSingularityRecipe(new ItemStack(LudicrousItems.singularity, 1, 3), new ItemStack(Blocks.redstone_block, 1));
|
||||
ExtremeCraftingManager.getInstance().addSingularityRecipe(new ItemStack(LudicrousItems.singularity, 1, 4), new ItemStack(Blocks.quartz_block, 1));
|
||||
CompressorManager.addRecipe(new ItemStack(LudicrousItems.singularity, 1, 0), 400, new ItemStack(Blocks.iron_block));
|
||||
CompressorManager.addRecipe(new ItemStack(LudicrousItems.singularity, 1, 1), 200, new ItemStack(Blocks.gold_block, 1));
|
||||
CompressorManager.addRecipe(new ItemStack(LudicrousItems.singularity, 1, 2), 400, new ItemStack(Blocks.lapis_block, 1));
|
||||
CompressorManager.addRecipe(new ItemStack(LudicrousItems.singularity, 1, 3), 500, new ItemStack(Blocks.redstone_block, 1));
|
||||
CompressorManager.addRecipe(new ItemStack(LudicrousItems.singularity, 1, 4), 300, new ItemStack(Blocks.quartz_block, 1));
|
||||
|
||||
if(Config.copper && !OreDictionary.getOres("blockCopper").isEmpty()){
|
||||
ExtremeCraftingManager.getInstance().addOreSingularityRecipe(new ItemStack(LudicrousItems.singularity, 1, 5), "blockCopper");
|
||||
catalyst.getInput().add(new ItemStack(LudicrousItems.singularity, 1, 5));
|
||||
}
|
||||
if(Config.tin && !OreDictionary.getOres("blockTin").isEmpty()){
|
||||
ExtremeCraftingManager.getInstance().addOreSingularityRecipe(new ItemStack(LudicrousItems.singularity, 1, 6), "blockTin");
|
||||
catalyst.getInput().add(new ItemStack(LudicrousItems.singularity, 1, 6));
|
||||
}
|
||||
if(Config.lead && !OreDictionary.getOres("blockLead").isEmpty()){
|
||||
ExtremeCraftingManager.getInstance().addOreSingularityRecipe(new ItemStack(LudicrousItems.singularity, 1, 7), "blockLead");
|
||||
catalyst.getInput().add(new ItemStack(LudicrousItems.singularity, 1, 7));
|
||||
}
|
||||
if(Config.silver && !OreDictionary.getOres("blockSilver").isEmpty()){
|
||||
ExtremeCraftingManager.getInstance().addOreSingularityRecipe(new ItemStack(LudicrousItems.singularity, 1, 8), "blockSilver");
|
||||
catalyst.getInput().add(new ItemStack(LudicrousItems.singularity, 1, 8));
|
||||
}
|
||||
if(Config.nickel && !OreDictionary.getOres("blockNickel").isEmpty()){
|
||||
ExtremeCraftingManager.getInstance().addOreSingularityRecipe(new ItemStack(LudicrousItems.singularity, 1, 9), "blockNickel");
|
||||
catalyst.getInput().add(new ItemStack(LudicrousItems.singularity, 1, 9));
|
||||
}
|
||||
if(Config.te && !OreDictionary.getOres("blockEnderium").isEmpty()){
|
||||
catalyst.getInput().add(OreDictionary.getOres("blockEnderium"));
|
||||
}
|
||||
if(Config.steel &&!OreDictionary.getOres("blockSteel").isEmpty()){
|
||||
catalyst.getInput().add(OreDictionary.getOres("blockSteel"));
|
||||
}
|
||||
if(Config.metallurgy && !OreDictionary.getOres("ingotTartarite").isEmpty()){
|
||||
catalyst.getInput().add(OreDictionary.getOres("ingotTartarite"));
|
||||
}
|
||||
if(Config.numanuma && !OreDictionary.getOres("blockIronCompressed").isEmpty()){
|
||||
catalyst.getInput().add(OreDictionary.getOres("blockIronCompressed"));
|
||||
}
|
||||
|
||||
ExtremeCraftingManager.getInstance().addExtremeShapedOreRecipe(new ItemStack(LudicrousItems.endest_pearl),
|
||||
" EEE ",
|
||||
" EEPPPEE ",
|
||||
" EPPPPPE ",
|
||||
"EPPPNPPPE",
|
||||
"EPPNSNPPE",
|
||||
"EPPPNPPPE",
|
||||
" EPPPPPE ",
|
||||
" EEPPPEE ",
|
||||
" EEE ",
|
||||
'E', new ItemStack(Blocks.end_stone),
|
||||
'P', new ItemStack(Items.ender_pearl),
|
||||
'S', new ItemStack(Items.nether_star),
|
||||
'N', new ItemStack(LudicrousItems.resource, 1, 4));
|
||||
if(Config.endStone)
|
||||
ExtremeCraftingManager.getInstance().addExtremeShapedOreRecipe(new ItemStack(LudicrousItems.endest_pearl),
|
||||
" EEE ",
|
||||
" EEPPPEE ",
|
||||
" EPPPPPE ",
|
||||
"EPPPNPPPE",
|
||||
"EPPNSNPPE",
|
||||
"EPPPNPPPE",
|
||||
" EPPPPPE ",
|
||||
" EEPPPEE ",
|
||||
" EEE ",
|
||||
'E', new ItemStack(Blocks.end_stone),
|
||||
'P', new ItemStack(Items.ender_pearl),
|
||||
'S', new ItemStack(Items.nether_star),
|
||||
'N', new ItemStack(LudicrousItems.resource, 1, 4));
|
||||
else
|
||||
ExtremeCraftingManager.getInstance().addExtremeShapedOreRecipe(new ItemStack(LudicrousItems.endest_pearl),
|
||||
" EEE ",
|
||||
" EEPPPEE ",
|
||||
" EPPPPPE ",
|
||||
"EPPPNPPPE",
|
||||
"EPPNSNPPE",
|
||||
"EPPPNPPPE",
|
||||
" EPPPPPE ",
|
||||
" EEPPPEE ",
|
||||
" EEE ",
|
||||
'P', new ItemStack(Items.ender_pearl),
|
||||
'S', new ItemStack(Items.nether_star),
|
||||
'N', new ItemStack(LudicrousItems.resource, 1, 4));
|
||||
}
|
||||
|
||||
public static void lastMinuteChanges(){
|
||||
@@ -261,5 +243,41 @@ public class Grinder {
|
||||
//}
|
||||
GameRegistry.addRecipe(smashysmashy);
|
||||
}
|
||||
|
||||
if(Config.copper && !OreDictionary.getOres("blockCopper").isEmpty()){
|
||||
CompressorManager.addOreRecipe(new ItemStack(LudicrousItems.singularity, 1, 5), 400, "blockCopper");
|
||||
catalyst.getInput().add(new ItemStack(LudicrousItems.singularity, 1, 5));
|
||||
}
|
||||
if(Config.tin && !OreDictionary.getOres("blockTin").isEmpty()){
|
||||
CompressorManager.addOreRecipe(new ItemStack(LudicrousItems.singularity, 1, 6), 400, "blockTin");
|
||||
catalyst.getInput().add(new ItemStack(LudicrousItems.singularity, 1, 6));
|
||||
}
|
||||
if(Config.lead && !OreDictionary.getOres("blockLead").isEmpty()){
|
||||
CompressorManager.addOreRecipe(new ItemStack(LudicrousItems.singularity, 1, 7), 300, "blockLead");
|
||||
catalyst.getInput().add(new ItemStack(LudicrousItems.singularity, 1, 7));
|
||||
}
|
||||
if(Config.silver && !OreDictionary.getOres("blockSilver").isEmpty()){
|
||||
CompressorManager.addOreRecipe(new ItemStack(LudicrousItems.singularity, 1, 8), 300, "blockSilver");
|
||||
catalyst.getInput().add(new ItemStack(LudicrousItems.singularity, 1, 8));
|
||||
}
|
||||
if(Config.nickel && !OreDictionary.getOres("blockNickel").isEmpty()){
|
||||
CompressorManager.addOreRecipe(new ItemStack(LudicrousItems.singularity, 1, 9), 400, "blockNickel");
|
||||
catalyst.getInput().add(new ItemStack(LudicrousItems.singularity, 1, 9));
|
||||
}
|
||||
if(Config.te && !OreDictionary.getOres("blockEnderium").isEmpty()){
|
||||
catalyst.getInput().add(OreDictionary.getOres("blockEnderium"));
|
||||
}
|
||||
if(Config.steel &&!OreDictionary.getOres("blockSteel").isEmpty()){
|
||||
catalyst.getInput().add(OreDictionary.getOres("blockSteel"));
|
||||
}
|
||||
if(Config.metallurgy && !OreDictionary.getOres("ingotTartarite").isEmpty()){
|
||||
catalyst.getInput().add(OreDictionary.getOres("ingotTartarite"));
|
||||
}
|
||||
if(Config.numanuma && !OreDictionary.getOres("blockIronCompressed").isEmpty()){
|
||||
catalyst.getInput().add(OreDictionary.getOres("blockIronCompressed"));
|
||||
}
|
||||
if(Config.enderio && !OreDictionary.getOres("blockDarkSteel").isEmpty()){
|
||||
catalyst.getInput().add(OreDictionary.getOres("blockDarkSteel"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package fox.spiteful.avaritia.gui;
|
||||
|
||||
import fox.spiteful.avaritia.crafting.CompressorManager;
|
||||
import fox.spiteful.avaritia.tile.TileEntityCompressor;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.SlotFurnace;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerCompressor extends Container {
|
||||
private TileEntityCompressor compressor;
|
||||
|
||||
public ContainerCompressor(InventoryPlayer player, TileEntityCompressor machine)
|
||||
{
|
||||
this.compressor = machine;
|
||||
this.addSlotToContainer(new Slot(compressor, 0, 56, 27));
|
||||
this.addSlotToContainer(new SlotFurnace(player.player, machine, 1, 116, 27));
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return this.compressor.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that.
|
||||
*/
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slotNumber)
|
||||
{
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot)this.inventorySlots.get(slotNumber);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (slotNumber == 1)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 2, 38, true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onSlotChange(itemstack1, itemstack);
|
||||
}
|
||||
else if (slotNumber != 0)
|
||||
{
|
||||
if (CompressorManager.getOutput(itemstack1) != null)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 0, 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (slotNumber >= 3 && slotNumber < 30)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 29, 38, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (slotNumber >= 29 && slotNumber < 38 && !this.mergeItemStack(itemstack1, 2, 29, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(itemstack1, 2, 38, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == 0)
|
||||
{
|
||||
slot.putStack((ItemStack)null);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == itemstack.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onPickupFromSlot(player, itemstack1);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package fox.spiteful.avaritia.gui;
|
||||
|
||||
import fox.spiteful.avaritia.tile.TileEntityCompressor;
|
||||
import fox.spiteful.avaritia.tile.TileEntityNeutron;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GUICompressor extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation furnaceGuiTextures = new ResourceLocation("avaritia", "textures/gui/compressor.png");
|
||||
private TileEntityCompressor compressor;
|
||||
|
||||
public GUICompressor(InventoryPlayer player, TileEntityCompressor machine)
|
||||
{
|
||||
super(new ContainerCompressor(player, machine));
|
||||
compressor = machine;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items)
|
||||
*/
|
||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)
|
||||
{
|
||||
String s = StatCollector.translateToLocal("container.neutronium_compressor");
|
||||
this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752);
|
||||
if(compressor.getProgress() > 0) {
|
||||
s = compressor.getProgress() + " / " + compressor.getTarget();
|
||||
this.fontRendererObj.drawString(s, 41, 49, 4210752);
|
||||
this.fontRendererObj.drawString(compressor.getIngredient(), 41, 60, 4210752);
|
||||
}
|
||||
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(furnaceGuiTextures);
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
if(compressor.getProgress() > 0){
|
||||
int i1 = compressor.getProgress() * 24 / compressor.getTarget();
|
||||
this.drawTexturedModalRect(k + 79, l + 26, 176, 14, i1 + 1, 16);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package fox.spiteful.avaritia.gui;
|
||||
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import fox.spiteful.avaritia.tile.TileEntityCompressor;
|
||||
import fox.spiteful.avaritia.tile.TileEntityDireCrafting;
|
||||
import fox.spiteful.avaritia.tile.TileEntityNeutron;
|
||||
import net.minecraft.client.gui.inventory.GuiCrafting;
|
||||
@@ -17,6 +18,8 @@ public class GooeyHandler implements IGuiHandler {
|
||||
return new GUIExtremeCrafting(player.inventory, world, x, y, z, (TileEntityDireCrafting)world.getTileEntity(x, y, z));
|
||||
else if(ID == 2)
|
||||
return new GUINeutron(player.inventory, (TileEntityNeutron)world.getTileEntity(x, y, z));
|
||||
else if(ID == 3)
|
||||
return new GUICompressor(player.inventory, (TileEntityCompressor)world.getTileEntity(x, y, z));
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -28,6 +31,8 @@ public class GooeyHandler implements IGuiHandler {
|
||||
return new ContainerExtremeCrafting(player.inventory, world, x, y, z, (TileEntityDireCrafting)world.getTileEntity(x, y, z));
|
||||
else if(ID == 2)
|
||||
return new ContainerNeutron(player.inventory, (TileEntityNeutron)world.getTileEntity(x, y, z));
|
||||
else if(ID == 3)
|
||||
return new ContainerCompressor(player.inventory, (TileEntityCompressor)world.getTileEntity(x, y, z));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,256 @@
|
||||
package fox.spiteful.avaritia.tile;
|
||||
|
||||
import fox.spiteful.avaritia.crafting.CompressorManager;
|
||||
import fox.spiteful.avaritia.items.LudicrousItems;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class TileEntityCompressor extends TileLudicrous implements ISidedInventory {
|
||||
|
||||
private ItemStack input, processing, output;
|
||||
private int facing = 2;
|
||||
private int progress = 0;
|
||||
private int target = 0;
|
||||
private String ingredient;
|
||||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
if(input != null){
|
||||
if(CompressorManager.getOutput(input) != null && (output == null || CompressorManager.getOutput(input).isItemEqual(output))) {
|
||||
if (processing == null) {
|
||||
processing = CompressorManager.getOutput(input);
|
||||
target = CompressorManager.getCost(input);
|
||||
ingredient = CompressorManager.getName(input);
|
||||
}
|
||||
if (CompressorManager.getOutput(input).isItemEqual(processing)) {
|
||||
progress += input.stackSize;
|
||||
input = null;
|
||||
}
|
||||
markDirty();
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
if (progress >= target && processing != null && (output == null || output.isItemEqual(processing))) {
|
||||
if(output == null)
|
||||
output = processing.copy();
|
||||
else if(output.isItemEqual(processing))
|
||||
output.stackSize++;
|
||||
|
||||
progress -= target;
|
||||
if(progress == 0) {
|
||||
processing = null;
|
||||
progress = 0;
|
||||
ingredient = null;
|
||||
}
|
||||
markDirty();
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
public int getFacing(){
|
||||
return facing;
|
||||
}
|
||||
|
||||
public void setFacing(int dir){
|
||||
facing = dir;
|
||||
}
|
||||
|
||||
public int getProgress(){
|
||||
return progress;
|
||||
}
|
||||
|
||||
public int getTarget(){
|
||||
return target;
|
||||
}
|
||||
|
||||
public String getIngredient(){
|
||||
return ingredient;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomNBT(NBTTagCompound tag)
|
||||
{
|
||||
this.input = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("Input"));
|
||||
this.processing = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("Processing"));
|
||||
this.output = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("Output"));
|
||||
this.progress = tag.getInteger("Progress");
|
||||
this.target = tag.getInteger("Target");
|
||||
if(tag.hasKey("Ingredient"))
|
||||
this.ingredient = tag.getString("Ingredient");
|
||||
this.facing = tag.getShort("Facing");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomNBT(NBTTagCompound tag)
|
||||
{
|
||||
tag.setInteger("Progress", this.progress);
|
||||
tag.setInteger("Target", this.target);
|
||||
if(ingredient != null)
|
||||
tag.setString("Ingredient", this.ingredient);
|
||||
else
|
||||
tag.removeTag("Ingredient");
|
||||
tag.setShort("Facing", (short) this.facing);
|
||||
if(input != null) {
|
||||
NBTTagCompound produce = new NBTTagCompound();
|
||||
input.writeToNBT(produce);
|
||||
tag.setTag("Input", produce);
|
||||
}
|
||||
else
|
||||
tag.removeTag("Input");
|
||||
if(processing != null) {
|
||||
NBTTagCompound produce = new NBTTagCompound();
|
||||
processing.writeToNBT(produce);
|
||||
tag.setTag("Processing", produce);
|
||||
}
|
||||
else
|
||||
tag.removeTag("Processing");
|
||||
if(output != null) {
|
||||
NBTTagCompound produce = new NBTTagCompound();
|
||||
output.writeToNBT(produce);
|
||||
tag.setTag("Output", produce);
|
||||
}
|
||||
else
|
||||
tag.removeTag("Output");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot){
|
||||
if(slot == 0)
|
||||
return input;
|
||||
else if(slot == 2)
|
||||
return processing;
|
||||
else
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int decrement){
|
||||
if(slot == 0) {
|
||||
if (input == null)
|
||||
return null;
|
||||
else {
|
||||
if (decrement < input.stackSize) {
|
||||
ItemStack take = input.splitStack(decrement);
|
||||
if (input.stackSize <= 0)
|
||||
input = null;
|
||||
return take;
|
||||
} else {
|
||||
ItemStack take = input;
|
||||
input = null;
|
||||
return take;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (slot == 1){
|
||||
if (output == null)
|
||||
return null;
|
||||
else {
|
||||
if (decrement < output.stackSize) {
|
||||
ItemStack take = output.splitStack(decrement);
|
||||
if (output.stackSize <= 0)
|
||||
output = null;
|
||||
return take;
|
||||
} else {
|
||||
ItemStack take = output;
|
||||
output = null;
|
||||
return take;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {}
|
||||
@Override
|
||||
public void closeInventory() {}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player)
|
||||
{
|
||||
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) == this && player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack){
|
||||
if(slot == 0){
|
||||
if(processing == null)
|
||||
return true;
|
||||
if(CompressorManager.getOutput(stack).isItemEqual(processing))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit(){
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack){
|
||||
if(slot == 0)
|
||||
input = stack;
|
||||
else if(slot == 1)
|
||||
output = stack;
|
||||
else
|
||||
processing = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot){
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the inventory
|
||||
*/
|
||||
@Override
|
||||
public String getInventoryName()
|
||||
{
|
||||
return "container.neutronium_compressor";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the inventory is named
|
||||
*/
|
||||
@Override
|
||||
public boolean hasCustomInventoryName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side){
|
||||
if(side == 0)
|
||||
return new int[]{0};
|
||||
else
|
||||
return new int[]{1};
|
||||
}
|
||||
|
||||
public boolean canInsertItem(int slot, ItemStack stack, int side){
|
||||
if(slot == 0 && side == 0){
|
||||
if(processing == null)
|
||||
return true;
|
||||
if(CompressorManager.getOutput(stack).isItemEqual(processing))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canExtractItem(int slot, ItemStack stack, int side){
|
||||
if(slot == 1 && side != 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,12 @@ public class TileEntityDireCrafting extends TileLudicrous implements IInventory,
|
||||
private ItemStack result;
|
||||
private ItemStack[] matrix = new ItemStack[81];
|
||||
|
||||
@Override
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomNBT(NBTTagCompound tag)
|
||||
{
|
||||
|
||||
@@ -14,13 +14,14 @@ public class TileEntityNeutron extends TileLudicrous implements IInventory {
|
||||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
if(++progress >= 10665){
|
||||
if(++progress >= 7111){
|
||||
//if(++progress >= 300){
|
||||
if(neutrons == null)
|
||||
neutrons = new ItemStack(LudicrousItems.resource, 1, 2);
|
||||
else if(neutrons.getItem() == LudicrousItems.resource && neutrons.getItemDamage() == 2 && neutrons.stackSize < 64)
|
||||
neutrons.stackSize++;
|
||||
progress = 0;
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,11 +113,7 @@ public class TileEntityNeutron extends TileLudicrous implements IInventory {
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot){
|
||||
if(neutrons == null)
|
||||
return null;
|
||||
ItemStack take = neutrons;
|
||||
neutrons = null;
|
||||
return take;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user