Minor Tweaks, Compressor improvements

This commit is contained in:
Jeremy Diamond committed 2015-08-16 16:30:44 -07:00
1 parent 9d14de583e
commit f608b28027
8 files changed
+160 -52

No files matched your search

@@ -33,6 +33,7 @@ public class Config {
public static boolean metallurgy = true;
public static boolean enderio = true;
public static boolean forestry = true;
public static boolean ee3 = true;
public static boolean copper = true;
public static boolean tin = true;
@@ -41,6 +42,9 @@ public class Config {
public static boolean steel = true;
public static boolean nickel = true;
public static int modifier = 0;
public static int multiplier = 0;
public static void configurate(File file){
Configuration conf = new Configuration(file);
@@ -74,6 +78,7 @@ public class Config {
metallurgy = conf.get("compatibility", "Metallurgy", true).getBoolean(true);
enderio = conf.get("compatibility", "EnderIO", true).getBoolean(true);
forestry = conf.get("compatibility", "Forestry", true).getBoolean(true);
ee3 = conf.get("compatibility", "Equivalent Exchange 3", 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);
@@ -82,6 +87,9 @@ public class Config {
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);
modifier = conf.get("balance!", "Cost Modifier", "Added to the existing modifier to make prices more expensive or cheaper. Can be negative.").getInt(0);
multiplier = conf.get("balance!", "Cost Multiplier", "Added to the existing multiplier to make prices more expensive or cheaper. Can be negative.").getInt(0);
}
catch(Exception e){
Lumberjack.log(Level.ERROR, e, "Avaritia couldn't find its config!");
@@ -250,12 +250,10 @@ public class Compat {
if(Loader.isModLoaded("TwilightForest") && Config.twilight){
try {
Item ironwood = getItem("TwilightForest", "item.ironwoodIngot");
ItemStack wood = new ItemStack(ironwood, 1);
Grinder.catalyst.getInput().add(wood);
Grinder.catalyst.getInput().add(new ItemStack(ironwood, 1));
}
catch (Throwable e){
Lumberjack.log(Level.INFO, "Avaritia was killed by a hydra.");
e.printStackTrace();
Lumberjack.log(Level.INFO, e, "Avaritia was killed by a hydra.");
}
}
@@ -344,6 +342,16 @@ public class Compat {
}
}
if(Loader.isModLoaded("EE3") && Config.ee3){
try {
Block fuel = getBlock("EE3", "alchemicalFuelBlock");
Grinder.catalyst.getInput().add(new ItemStack(fuel, 1, 2));
}
catch (Throwable e){
Lumberjack.log(Level.INFO, e, "Avaritia tried to do human transmutation.");
}
}
}
public static Block getBlock(String mod, String block) throws ItemNotFoundException {
@@ -1,5 +1,6 @@
package fox.spiteful.avaritia.compat.thaumcraft;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;
import fox.spiteful.avaritia.Lumberjack;
import fox.spiteful.avaritia.blocks.LudicrousBlocks;
@@ -73,15 +74,16 @@ public class Lucrum {
'C', new ItemStack(LudicrousItems.resource, 1, 1),
'N', new ItemStack(LudicrousItems.resource, 1, 4));
boolean kami = false;
try {
kami = Class.forName("thaumic.tinkerer.common.core.handler.ConfigHandler").getField("enableKami").getBoolean(null);
if(kami){
Item kamiResource = Compat.getItem("ThaumicTinkerer", "kamiResource");
Grinder.catalyst.getInput().add(new ItemStack(kamiResource, 1, 2));
if(Loader.isModLoaded("ThaumicTinkerer")) {
try {
boolean kami = Class.forName("thaumic.tinkerer.common.core.handler.ConfigHandler").getField("enableKami").getBoolean(null);
if (kami) {
Item kamiResource = Compat.getItem("ThaumicTinkerer", "kamiResource");
Grinder.catalyst.getInput().add(new ItemStack(kamiResource, 1, 2));
}
} catch (Exception e) {
Lumberjack.log(Level.INFO, e, "Avaritia couldn't find the last research it needs to unlock Ichor.");
}
} catch (Exception e) {
Lumberjack.log(Level.INFO, e, "LOLKAMI LOLOLOLOLOLOLOL");
}
}
@@ -25,6 +25,9 @@ public class CompressorManager {
}
public static int getCost(ItemStack input){
if(input == null)
return 0;
for(CompressorRecipe recipe : recipes){
if(recipe.validInput(input))
return recipe.getCost();
@@ -32,6 +35,17 @@ public class CompressorManager {
return 0;
}
public static int getPrice(ItemStack output){
if(output == null)
return 0;
for(CompressorRecipe recipe : recipes){
if(recipe.getOutput().isItemEqual(output))
return recipe.getCost();
}
return 0;
}
public static String getName(ItemStack input){
for(CompressorRecipe recipe : recipes){
if(recipe.validInput(input))
@@ -1,6 +1,7 @@
package fox.spiteful.avaritia.crafting;
import cpw.mods.fml.common.Loader;
import fox.spiteful.avaritia.Config;
public class Gregorizer {
@@ -9,15 +10,13 @@ public class Gregorizer {
public static void balance(){
if(Loader.isModLoaded("magicalcrops"))
multiplier += 3;
multiplier += 2;
if(Loader.isModLoaded("MineFactoryReloaded"))
multiplier += 1;
if(Loader.isModLoaded("BigReactors"))
modifier += 100;
if(Loader.isModLoaded("ProjectE"))
multiplier += 9;
if(Loader.isModLoaded("EE3"))
multiplier += 9;
if(Loader.isModLoaded("EE3")||Loader.isModLoaded("ProjectE"))
multiplier += 4;
if(Loader.isModLoaded("Botania"))
modifier += 50;
if(Loader.isModLoaded("IC2"))
@@ -27,15 +26,22 @@ public class Gregorizer {
if(Loader.isModLoaded("technom"))
modifier += 500;
if(Loader.isModLoaded("ExtraUtilities"))
modifier += 100;
modifier += 150;
if(Loader.isModLoaded("Thaumcraft"))
modifier += 100;
if(Loader.isModLoaded("appliedenergistics2"))
modifier += 200;
if(Loader.isModLoaded("gregtech"))
multiplier += 3;
if(Loader.isModLoaded("TSteelworks"))
modifier += 300;
if(Loader.isModLoaded("ImmersiveEngineering"))
modifier += 400;
if(Loader.isModLoaded("Mekanism")) {
modifier += 300;
multiplier += 1;
}
modifier += Config.modifier;
multiplier += Config.multiplier;
}
public static int balanceCost(int cost){
@@ -36,6 +36,7 @@ public class Grinder {
GameRegistry.addShapedRecipe(new ItemStack(LudicrousItems.resource, 1, 3), "CCC", "CCC", "CCC", 'C', new ItemStack(LudicrousItems.resource, 1, 2));
GameRegistry.addShapedRecipe(new ItemStack(LudicrousItems.resource, 1, 4), "CCC", "CCC", "CCC", 'C', new ItemStack(LudicrousItems.resource, 1, 3));
GameRegistry.addShapedRecipe(new ItemStack(LudicrousItems.resource, 9, 3), "C", 'C', new ItemStack(LudicrousItems.resource, 1, 4));
GameRegistry.addShapedRecipe(new ItemStack(LudicrousItems.resource, 9, 2), "C", 'C', new ItemStack(LudicrousItems.resource, 1, 3));
GameRegistry.addShapedRecipe(new ItemStack(LudicrousBlocks.resource_block, 1, 0), "CCC", "CCC", "CCC", 'C', new ItemStack(LudicrousItems.resource, 1, 4));
GameRegistry.addShapedRecipe(new ItemStack(LudicrousItems.resource, 9, 4), "C", 'C', new ItemStack(LudicrousBlocks.resource_block, 1, 0));
@@ -64,12 +65,12 @@ public class Grinder {
'N', new ItemStack(LudicrousItems.resource, 1, 4),
'X', new ItemStack(LudicrousItems.resource, 1, 5));
catalyst = ExtremeCraftingManager.getInstance().addShapelessOreRecipe(new ItemStack(LudicrousItems.resource, 1, 5), new Object[]{
catalyst = ExtremeCraftingManager.getInstance().addShapelessOreRecipe(new ItemStack(LudicrousItems.resource, 1, 5),
new ItemStack(Blocks.emerald_block, 1),
new ItemStack(LudicrousItems.singularity, 1, 0), new ItemStack(LudicrousItems.singularity, 1, 1),
new ItemStack(LudicrousItems.singularity, 1, 2), new ItemStack(LudicrousItems.singularity, 1, 3),
new ItemStack(LudicrousItems.singularity, 1, 4), new ItemStack(LudicrousItems.ultimate_stew),
new ItemStack(LudicrousItems.cosmic_meatballs), new ItemStack(LudicrousItems.endest_pearl)});
new ItemStack(LudicrousItems.cosmic_meatballs), new ItemStack(LudicrousItems.endest_pearl));
ItemStack result = new ItemStack(LudicrousItems.infinity_pickaxe, 1);
result.addEnchantment(Enchantment.fortune, 10);
@@ -228,6 +229,23 @@ public class Grinder {
'P', new ItemStack(Items.ender_pearl),
'S', new ItemStack(Items.nether_star),
'N', new ItemStack(LudicrousItems.resource, 1, 4));
ExtremeCraftingManager.getInstance().addRecipe(new ItemStack(LudicrousBlocks.compressor),
"IIIHHHIII",
"X N N X",
"I N N I",
"X N N X",
"RNN O NNR",
"X N N X",
"I N N I",
"X N N X",
"IIIXIXIII",
'X', new ItemStack(LudicrousItems.resource, 1, 1),
'N', new ItemStack(LudicrousItems.resource, 1, 4),
'I', new ItemStack(Blocks.iron_block, 1),
'H', new ItemStack(Blocks.hopper, 1),
'R', new ItemStack(Blocks.redstone_block, 1),
'O', new ItemStack(LudicrousBlocks.resource_block, 1, 0));
}
public static void lastMinuteChanges(){
@@ -16,8 +16,16 @@ public class TileEntityCompressor extends TileLudicrous implements ISidedInvento
private int target = 0;
private String ingredient;
private int packetCount;
private boolean packet;
private static final int[] top = new int[]{0};
private static final int[] sides = new int[]{1};
@Override
public void updateEntity(){
if(packetCount > 0)
packetCount--;
if(input != null){
if(CompressorManager.getOutput(input) != null && (output == null || CompressorManager.getOutput(input).isItemEqual(output))) {
if (processing == null) {
@@ -30,7 +38,7 @@ public class TileEntityCompressor extends TileLudicrous implements ISidedInvento
input = null;
}
markDirty();
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
packet = true;
}
}
if (progress >= target && processing != null && (output == null || output.isItemEqual(processing))) {
@@ -42,11 +50,15 @@ public class TileEntityCompressor extends TileLudicrous implements ISidedInvento
progress -= target;
if(progress == 0) {
processing = null;
progress = 0;
ingredient = null;
}
markDirty();
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
packet = true;
}
if(packet && packetCount <= 0) {
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
packetCount = 10;
packet = false;
}
}
@@ -76,22 +88,27 @@ public class TileEntityCompressor extends TileLudicrous implements ISidedInvento
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");
if(processing != null) {
this.target = CompressorManager.getPrice(processing);
if(target != 0) {
this.progress = tag.getInteger("Progress");
if (tag.hasKey("Ingredient"))
this.ingredient = tag.getString("Ingredient");
}
else
processing = null;
}
else {
progress = 0;
target = 0;
ingredient = null;
}
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();
@@ -104,9 +121,18 @@ public class TileEntityCompressor extends TileLudicrous implements ISidedInvento
NBTTagCompound produce = new NBTTagCompound();
processing.writeToNBT(produce);
tag.setTag("Processing", produce);
tag.setInteger("Progress", this.progress);
if(ingredient != null)
tag.setString("Ingredient", this.ingredient);
else
tag.removeTag("Ingredient");
}
else
else {
tag.removeTag("Processing");
tag.removeTag("Progress");
tag.removeTag("Target");
tag.removeTag("Ingredient");
}
if(output != null) {
NBTTagCompound produce = new NBTTagCompound();
output.writeToNBT(produce);
@@ -119,15 +145,13 @@ public class TileEntityCompressor extends TileLudicrous implements ISidedInvento
@Override
public int getSizeInventory()
{
return 3;
return 2;
}
@Override
public ItemStack getStackInSlot(int slot){
if(slot == 0)
return input;
else if(slot == 2)
return processing;
else
return output;
}
@@ -202,8 +226,6 @@ public class TileEntityCompressor extends TileLudicrous implements ISidedInvento
input = stack;
else if(slot == 1)
output = stack;
else
processing = stack;
}
@Override
@@ -231,24 +253,18 @@ public class TileEntityCompressor extends TileLudicrous implements ISidedInvento
@Override
public int[] getAccessibleSlotsFromSide(int side){
if(side == 0)
return new int[]{0};
if(side == 1)
return top;
else
return new int[]{1};
return sides;
}
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;
return isItemValidForSlot(slot, stack);
}
public boolean canExtractItem(int slot, ItemStack stack, int side){
if(slot == 1 && side != 0)
if(slot == 1 && side != 1)
return true;
return false;
}
@@ -0,0 +1,36 @@
/**
* Code blatantly copied from Vazkii
*
* Get the original here: https://github.com/Vazkii/Botania/blob/master/src/main/java/vazkii/botania/api/internal/VanillaPacketDispatcher.java
*/
package fox.spiteful.avaritia.tile;
import java.util.List;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public final class VanillaPacketDispatcher {
public static void dispatchTEToNearbyPlayers(TileEntity tile) {
World world = tile.getWorldObj();
List players = world.playerEntities;
for(Object player : players)
if(player instanceof EntityPlayerMP) {
EntityPlayerMP mp = (EntityPlayerMP) player;
if(pointDistancePlane(mp.posX, mp.posZ, tile.xCoord + 0.5, tile.zCoord + 0.5) < 64)
((EntityPlayerMP) player).playerNetServerHandler.sendPacket(tile.getDescriptionPacket());
}
}
public static void dispatchTEToNearbyPlayers(World world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
if(tile != null)
dispatchTEToNearbyPlayers(tile);
}
public static float pointDistancePlane(double x1, double y1, double x2, double y2) {
return (float) Math.hypot(x1 - x2, y1 - y2);
}
}