mirror of
https://github.com/turbodiesel4598/NuclearCraft
synced 2025-10-07 12:44:41 +02:00
Compare commits
No commits in common. "7c736bf14dea9980ea725e3418d9bd2d6c1a34d5" and "a979dead3372d322093649bd343d189bc5eb860e" have entirely different histories.
7c736bf14d
...
a979dead33
@ -1,13 +1,3 @@
|
|||||||
v2o.5.1
|
|
||||||
|
|
||||||
* Increased script addon max zip size to 50 MB
|
|
||||||
|
|
||||||
* Updated Chinese language file [thanks to WuzgXY!]
|
|
||||||
|
|
||||||
+ Added fluid colour blend methods to CraftTweaker
|
|
||||||
|
|
||||||
- Removed old, unused accelerator configs
|
|
||||||
|
|
||||||
v2o.5.0
|
v2o.5.0
|
||||||
|
|
||||||
+ Added fission reactor decay heat and neutron poisoning
|
+ Added fission reactor decay heat and neutron poisoning
|
||||||
|
@ -537,24 +537,3 @@ mods.nuclearcraft.Registration.registerRTG(String rtgID, long power, double radi
|
|||||||
mods.nuclearcraft.Registration.registerBattery(String batteryID, long capacity, int euEnergyTier);
|
mods.nuclearcraft.Registration.registerBattery(String batteryID, long capacity, int euEnergyTier);
|
||||||
___________________________________________________________________________________________________________________________
|
___________________________________________________________________________________________________________________________
|
||||||
---------------------------------------------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
Helper Methods
|
|
||||||
#==============#
|
|
||||||
|
|
||||||
mods.nuclearcraft.ColorHelper.getAlpha(int color);
|
|
||||||
mods.nuclearcraft.ColorHelper.getRed(int color);
|
|
||||||
mods.nuclearcraft.ColorHelper.getGreen(int color);
|
|
||||||
mods.nuclearcraft.ColorHelper.getBlue(int color);
|
|
||||||
|
|
||||||
mods.nuclearcraft.ColorHelper.blend(int color1, int color2, float blendRatio);
|
|
||||||
mods.nuclearcraft.ColorHelper.glow(int color1, int color2, float glowFactor);
|
|
||||||
|
|
||||||
mods.nuclearcraft.ColorHelper.waterBlend(int soluteColor, float blendRatio);
|
|
||||||
mods.nuclearcraft.ColorHelper.getNAKColor(int color);
|
|
||||||
mods.nuclearcraft.ColorHelper.getFluorideColor(int color);
|
|
||||||
mods.nuclearcraft.ColorHelper.getFLIBEColor(int color);
|
|
||||||
mods.nuclearcraft.ColorHelper.getZAColor(int color);
|
|
||||||
|
|
||||||
___________________________________________________________________________________________________________________________
|
|
||||||
---------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
mc_version=1.12.2
|
mc_version=1.12.2
|
||||||
forge_version=14.23.5.2847
|
forge_version=14.23.5.2847
|
||||||
mapping_version=stable_39
|
mapping_version=stable_39
|
||||||
mod_version=2o.5.1
|
mod_version=2o.5.0
|
||||||
|
|
||||||
ic2_version=2.8.197-ex112
|
ic2_version=2.8.197-ex112
|
||||||
jei_version=4.15.0.293
|
jei_version=4.15.0.293
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package nc.fluid;
|
package nc.fluid;
|
||||||
|
|
||||||
|
import nc.util.ColorHelper;
|
||||||
import net.minecraft.init.SoundEvents;
|
import net.minecraft.init.SoundEvents;
|
||||||
|
|
||||||
public class FluidCoolant extends NCFluid {
|
public class FluidCoolant extends NCFluid {
|
||||||
|
|
||||||
|
private static final Integer NAK_COLOR = 0xFFE5BC;
|
||||||
|
|
||||||
public FluidCoolant(String fluidName) {
|
public FluidCoolant(String fluidName) {
|
||||||
super(fluidName, true);
|
super(fluidName, true);
|
||||||
setViscosity(15000);
|
setViscosity(15000);
|
||||||
@ -21,4 +24,8 @@ public class FluidCoolant extends NCFluid {
|
|||||||
setEmptySound(SoundEvents.ITEM_BUCKET_EMPTY_LAVA);
|
setEmptySound(SoundEvents.ITEM_BUCKET_EMPTY_LAVA);
|
||||||
setFillSound(SoundEvents.ITEM_BUCKET_FILL_LAVA);
|
setFillSound(SoundEvents.ITEM_BUCKET_FILL_LAVA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getNAKColor(Integer colour) {
|
||||||
|
return ColorHelper.blend(colour.intValue(), NAK_COLOR, 0.375F);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
package nc.fluid;
|
package nc.fluid;
|
||||||
|
|
||||||
|
import nc.util.ColorHelper;
|
||||||
|
|
||||||
public class FluidFission extends FluidMolten {
|
public class FluidFission extends FluidMolten {
|
||||||
|
|
||||||
|
private static final Integer FLUORINE_COLOR = 0xD3C85D;
|
||||||
|
private static final Integer FLIBE_COLOR = 0xC1C8B0;
|
||||||
|
private static final Integer ZA_COLOR = 0xDBDBAD;
|
||||||
|
|
||||||
public FluidFission(String fluidName) {
|
public FluidFission(String fluidName) {
|
||||||
super(fluidName);
|
super(fluidName);
|
||||||
}
|
}
|
||||||
@ -9,4 +15,16 @@ public class FluidFission extends FluidMolten {
|
|||||||
public FluidFission(String fluidName, Integer color) {
|
public FluidFission(String fluidName, Integer color) {
|
||||||
super(fluidName, color);
|
super(fluidName, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getFluorideColor(Integer color) {
|
||||||
|
return ColorHelper.blend(color.intValue(), FLUORINE_COLOR, 0.125F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getFLIBEColor(Integer color) {
|
||||||
|
return ColorHelper.blend(color.intValue(), FLIBE_COLOR, 0.4F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getZAColor(Integer color) {
|
||||||
|
return ColorHelper.glow(color.intValue(), ZA_COLOR, 0.4F);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import nc.*;
|
|||||||
import nc.block.fluid.*;
|
import nc.block.fluid.*;
|
||||||
import nc.block.item.NCItemBlock;
|
import nc.block.item.NCItemBlock;
|
||||||
import nc.fluid.*;
|
import nc.fluid.*;
|
||||||
import nc.util.ColorHelper;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
@ -127,7 +126,7 @@ public class NCCoolantFluids {
|
|||||||
|
|
||||||
private static void addNAKPairs(String name, int color) {
|
private static void addNAKPairs(String name, int color) {
|
||||||
COOLANTS.add(name);
|
COOLANTS.add(name);
|
||||||
FluidCoolant coolant = new FluidCoolant(name + "_nak", ColorHelper.getNAKColor(color));
|
FluidCoolant coolant = new FluidCoolant(name + "_nak", FluidCoolant.getNAKColor(color));
|
||||||
fluidPairList.add(Pair.of(coolant, register_fluid_blocks ? new BlockFluidCoolant(coolant) : null));
|
fluidPairList.add(Pair.of(coolant, register_fluid_blocks ? new BlockFluidCoolant(coolant) : null));
|
||||||
FluidHotCoolant hotCoolant = new FluidHotCoolant(name + "_nak_hot", FluidHotCoolant.getNAKColor(color));
|
FluidHotCoolant hotCoolant = new FluidHotCoolant(name + "_nak_hot", FluidHotCoolant.getNAKColor(color));
|
||||||
fluidPairList.add(Pair.of(hotCoolant, register_fluid_blocks ? new BlockFluidHotCoolant(hotCoolant) : null));
|
fluidPairList.add(Pair.of(hotCoolant, register_fluid_blocks ? new BlockFluidHotCoolant(hotCoolant) : null));
|
||||||
|
@ -8,7 +8,6 @@ import nc.*;
|
|||||||
import nc.block.fluid.*;
|
import nc.block.fluid.*;
|
||||||
import nc.block.item.NCItemBlock;
|
import nc.block.item.NCItemBlock;
|
||||||
import nc.fluid.FluidFission;
|
import nc.fluid.FluidFission;
|
||||||
import nc.util.ColorHelper;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
@ -53,7 +52,8 @@ public class NCFissionFluids {
|
|||||||
addIsotopeFluids("californium_252", 0x430B0E);
|
addIsotopeFluids("californium_252", 0x430B0E);
|
||||||
|
|
||||||
addFuelFluids("tbu", 0x272727);
|
addFuelFluids("tbu", 0x272727);
|
||||||
// fluidList.add(new FluidFission("tbu_za", FluidFission.getZAColor(0x272727)));
|
// fluidList.add(new FluidFission("tbu_za",
|
||||||
|
// FluidFission.getZAColor(0x272727)));
|
||||||
|
|
||||||
addFuelFluids("leu_233", 0x1D321B);
|
addFuelFluids("leu_233", 0x1D321B);
|
||||||
addFuelFluids("heu_233", 0x123B0D);
|
addFuelFluids("heu_233", 0x123B0D);
|
||||||
@ -134,8 +134,8 @@ public class NCFissionFluids {
|
|||||||
|
|
||||||
private static void addFuelFluids(String name, int color) {
|
private static void addFuelFluids(String name, int color) {
|
||||||
fluidList.add(new FluidFission(name, color));
|
fluidList.add(new FluidFission(name, color));
|
||||||
fluidList.add(new FluidFission(name + "_fluoride", ColorHelper.getFluorideColor(color)));
|
fluidList.add(new FluidFission(name + "_fluoride", FluidFission.getFluorideColor(color)));
|
||||||
fluidList.add(new FluidFission(name + "_fluoride_flibe", ColorHelper.getFLIBEColor(color)));
|
fluidList.add(new FluidFission(name + "_fluoride_flibe", FluidFission.getFLIBEColor(color)));
|
||||||
// fluidList.add(new FluidFission(name + "_za", FluidFission.getZAColor(color)));
|
// fluidList.add(new FluidFission(name + "_za", FluidFission.getZAColor(color)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,15 +87,15 @@ public class NCFluids {
|
|||||||
addFluidPair(FluidType.ACID, "boric_acid", 0x696939);
|
addFluidPair(FluidType.ACID, "boric_acid", 0x696939);
|
||||||
addFluidPair(FluidType.ACID, "sulfuric_acid", 0x454500);
|
addFluidPair(FluidType.ACID, "sulfuric_acid", 0x454500);
|
||||||
|
|
||||||
addFluidPair(FluidType.SALT_SOLUTION, "boron_nitride_solution", ColorHelper.waterBlend(0x6F8E5C, 0.5F));
|
addFluidPair(FluidType.SALT_SOLUTION, "boron_nitride_solution", waterBlend(0x6F8E5C, 0.5F));
|
||||||
addFluidPair(FluidType.SALT_SOLUTION, "fluorite_water", ColorHelper.waterBlend(0x8AB492, 0.5F));
|
addFluidPair(FluidType.SALT_SOLUTION, "fluorite_water", waterBlend(0x8AB492, 0.5F));
|
||||||
addFluidPair(FluidType.SALT_SOLUTION, "calcium_sulfate_solution", ColorHelper.waterBlend(0xB8B0A6, 0.5F));
|
addFluidPair(FluidType.SALT_SOLUTION, "calcium_sulfate_solution", waterBlend(0xB8B0A6, 0.5F));
|
||||||
addFluidPair(FluidType.SALT_SOLUTION, "sodium_fluoride_solution", ColorHelper.waterBlend(0xC2B1A1, 0.5F));
|
addFluidPair(FluidType.SALT_SOLUTION, "sodium_fluoride_solution", waterBlend(0xC2B1A1, 0.5F));
|
||||||
addFluidPair(FluidType.SALT_SOLUTION, "potassium_fluoride_solution", ColorHelper.waterBlend(0xC1C99D, 0.5F));
|
addFluidPair(FluidType.SALT_SOLUTION, "potassium_fluoride_solution", waterBlend(0xC1C99D, 0.5F));
|
||||||
addFluidPair(FluidType.SALT_SOLUTION, "sodium_hydroxide_solution", ColorHelper.waterBlend(0xC2B7BB, 0.5F));
|
addFluidPair(FluidType.SALT_SOLUTION, "sodium_hydroxide_solution", waterBlend(0xC2B7BB, 0.5F));
|
||||||
addFluidPair(FluidType.SALT_SOLUTION, "potassium_hydroxide_solution", ColorHelper.waterBlend(0xB8C6B0, 0.5F));
|
addFluidPair(FluidType.SALT_SOLUTION, "potassium_hydroxide_solution", waterBlend(0xB8C6B0, 0.5F));
|
||||||
addFluidPair(FluidType.SALT_SOLUTION, "borax_solution", ColorHelper.waterBlend(0xEEEEEE, 0.5F));
|
addFluidPair(FluidType.SALT_SOLUTION, "borax_solution", waterBlend(0xEEEEEE, 0.5F));
|
||||||
addFluidPair(FluidType.SALT_SOLUTION, "irradiated_borax_solution", ColorHelper.waterBlend(0xFFD0A3, 0.5F));
|
addFluidPair(FluidType.SALT_SOLUTION, "irradiated_borax_solution", waterBlend(0xFFD0A3, 0.5F));
|
||||||
|
|
||||||
addFluidPair(FluidType.CORIUM, "corium", 0x7C7C6F);
|
addFluidPair(FluidType.CORIUM, "corium", 0x7C7C6F);
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ public class NCFluids {
|
|||||||
addFluidPair(FluidType.CHOCOLATE, "milk_chocolate", 0x884121);
|
addFluidPair(FluidType.CHOCOLATE, "milk_chocolate", 0x884121);
|
||||||
addFluidPair(FluidType.SUGAR, "sugar", 0xFFD59A);
|
addFluidPair(FluidType.SUGAR, "sugar", 0xFFD59A);
|
||||||
addFluidPair(FluidType.SUGAR, "gelatin", 0xDDD09C);
|
addFluidPair(FluidType.SUGAR, "gelatin", 0xDDD09C);
|
||||||
addFluidPair(FluidType.SUGAR, "hydrated_gelatin", ColorHelper.waterBlend(0xDDD09C, 0.8F));
|
addFluidPair(FluidType.SUGAR, "hydrated_gelatin", waterBlend(0xDDD09C, 0.8F));
|
||||||
addFluidPair(FluidType.CHOCOLATE, "marshmallow", 0xE1E1E3);
|
addFluidPair(FluidType.CHOCOLATE, "marshmallow", 0xE1E1E3);
|
||||||
addFluidPair(FluidType.LIQUID, "milk");
|
addFluidPair(FluidType.LIQUID, "milk");
|
||||||
|
|
||||||
@ -191,6 +191,10 @@ public class NCFluids {
|
|||||||
return block.setTranslationKey(Global.MOD_ID + "." + block.name).setRegistryName(new ResourceLocation(Global.MOD_ID, block.name));
|
return block.setTranslationKey(Global.MOD_ID + "." + block.name).setRegistryName(new ResourceLocation(Global.MOD_ID, block.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int waterBlend(int soluteColor, float blendRatio) {
|
||||||
|
return ColorHelper.blend(0x2F43F4, soluteColor, blendRatio);
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean registerCoFHAlt() {
|
private static boolean registerCoFHAlt() {
|
||||||
return register_cofh_fluids || !ModCheck.thermalFoundationLoaded();
|
return register_cofh_fluids || !ModCheck.thermalFoundationLoaded();
|
||||||
}
|
}
|
||||||
|
@ -2,51 +2,46 @@ package nc.util;
|
|||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
|
||||||
import crafttweaker.annotations.ZenRegister;
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import stanhebben.zenscript.annotations.*;
|
|
||||||
|
|
||||||
@ZenClass("mods.nuclearcraft.ColorHelper")
|
|
||||||
@ZenRegister
|
|
||||||
public class ColorHelper {
|
public class ColorHelper {
|
||||||
|
|
||||||
public static Color getColor(int color) {
|
public static int fixColor(int rgb) {
|
||||||
return new Color(color);
|
int color = rgb;
|
||||||
|
if ((color >> 24 & 0xFF) == 0) {
|
||||||
|
color |= 0xFF << 24;
|
||||||
|
}
|
||||||
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenMethod
|
public static Color getColor(int rgb) {
|
||||||
public static int getAlpha(int color) {
|
return new Color(fixColor(rgb));
|
||||||
return color >> 24 & 0xFF;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenMethod
|
public static int getRed(int rgb) {
|
||||||
public static int getRed(int color) {
|
return getColor(rgb).getRed();
|
||||||
return (color & 0xFF0000) >> 16;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenMethod
|
public static int getGreen(int rgb) {
|
||||||
public static int getGreen(int color) {
|
return getColor(rgb).getGreen();
|
||||||
return (color & 0xFF00) >> 8;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenMethod
|
public static int getBlue(int rgb) {
|
||||||
public static int getBlue(int color) {
|
return getColor(rgb).getBlue();
|
||||||
return color & 0xFF;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static int blend(int color1, int color2, float blendRatio) {
|
public static int blend(int color1, int color2, float blendRatio) {
|
||||||
blendRatio = MathHelper.clamp(blendRatio, 0F, 1F);
|
blendRatio = MathHelper.clamp(blendRatio, 0F, 1F);
|
||||||
|
|
||||||
int alpha1 = getAlpha(color1);
|
int alpha1 = color1 >> 24 & 0xFF;
|
||||||
int red1 = getRed(color1);
|
int red1 = (color1 & 0xFF0000) >> 16;
|
||||||
int green1 = getGreen(color1);
|
int green1 = (color1 & 0xFF00) >> 8;
|
||||||
int blue1 = getBlue(color1);
|
int blue1 = color1 & 0xFF;
|
||||||
|
|
||||||
int alpha2 = getAlpha(color2);
|
int alpha2 = color2 >> 24 & 0xFF;
|
||||||
int red2 = getRed(color2);
|
int red2 = (color2 & 0xFF0000) >> 16;
|
||||||
int green2 = getGreen(color2);
|
int green2 = (color2 & 0xFF00) >> 8;
|
||||||
int blue2 = getBlue(color2);
|
int blue2 = color2 & 0xFF;
|
||||||
|
|
||||||
int alpha = Math.max(alpha1, alpha2);
|
int alpha = Math.max(alpha1, alpha2);
|
||||||
int red = (int) (red1 + (red2 - red1) * blendRatio);
|
int red = (int) (red1 + (red2 - red1) * blendRatio);
|
||||||
@ -56,20 +51,19 @@ public class ColorHelper {
|
|||||||
return alpha << 24 | red << 16 | green << 8 | blue;
|
return alpha << 24 | red << 16 | green << 8 | blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static int glow(int color1, int color2, float glowFactor) {
|
public static int glow(int color1, int color2, float glowFactor) {
|
||||||
int alpha1 = getAlpha(color1);
|
int alpha1 = color1 >> 24 & 0xFF;
|
||||||
int red1 = getRed(color1);
|
int red1 = (color1 & 0xFF0000) >> 16;
|
||||||
int green1 = getGreen(color1);
|
int green1 = (color1 & 0xFF00) >> 8;
|
||||||
int blue1 = getBlue(color1);
|
int blue1 = color1 & 0xFF;
|
||||||
|
|
||||||
int alpha2 = getAlpha(color2);
|
|
||||||
int red2 = getRed(color2);
|
|
||||||
int green2 = getGreen(color2);
|
|
||||||
int blue2 = getBlue(color2);
|
|
||||||
|
|
||||||
glowFactor = MathHelper.clamp(glowFactor, 0F, 1F) * 255F / Math.max(red1, Math.max(green1, blue1));
|
glowFactor = MathHelper.clamp(glowFactor, 0F, 1F) * 255F / Math.max(red1, Math.max(green1, blue1));
|
||||||
|
|
||||||
|
int alpha2 = color2 >> 24 & 0xFF;
|
||||||
|
int red2 = (color2 & 0xFF0000) >> 16;
|
||||||
|
int green2 = (color2 & 0xFF00) >> 8;
|
||||||
|
int blue2 = color2 & 0xFF;
|
||||||
|
|
||||||
int alpha = Math.max(alpha1, alpha2);
|
int alpha = Math.max(alpha1, alpha2);
|
||||||
int red = (int) (red1 + (red2 - red1) * glowFactor * red1 / 255F);
|
int red = (int) (red1 + (red2 - red1) * glowFactor * red1 / 255F);
|
||||||
int green = (int) (green1 + (green2 - green1) * glowFactor * green1 / 255F);
|
int green = (int) (green1 + (green2 - green1) * glowFactor * green1 / 255F);
|
||||||
@ -77,31 +71,4 @@ public class ColorHelper {
|
|||||||
|
|
||||||
return alpha << 24 | red << 16 | green << 8 | blue;
|
return alpha << 24 | red << 16 | green << 8 | blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specific color methods
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static int waterBlend(int soluteColor, float blendRatio) {
|
|
||||||
return ColorHelper.blend(0x2F43F4, soluteColor, blendRatio);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static int getNAKColor(int color) {
|
|
||||||
return ColorHelper.blend(color, 0xFFE5BC, 0.375F);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static int getFluorideColor(int color) {
|
|
||||||
return ColorHelper.blend(color, 0xD3C85D, 0.125F);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static int getFLIBEColor(int color) {
|
|
||||||
return ColorHelper.blend(color, 0xC1C8B0, 0.4F);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static int getZAColor(int color) {
|
|
||||||
return ColorHelper.glow(color, 0xDBDBAD, 0.4F);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ public class IOHelper {
|
|||||||
|
|
||||||
public static final String NEW_LINE = System.lineSeparator();
|
public static final String NEW_LINE = System.lineSeparator();
|
||||||
|
|
||||||
public static final int MAX_ZIP_SIZE = 50000000;
|
public static final int MAX_ZIP_SIZE = 0x100000;
|
||||||
public static final int ZIP_READ_SIZE = 0x2000;
|
public static final int ZIP_READ_SIZE = 0x2000;
|
||||||
|
|
||||||
/** Modified from Srikanth A's answer at https://stackoverflow.com/a/45951007 */
|
/** Modified from Srikanth A's answer at https://stackoverflow.com/a/45951007 */
|
||||||
@ -71,20 +71,19 @@ public class IOHelper {
|
|||||||
zipStream.close();
|
zipStream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the number of bytes extracted plus the original value of currentBytes */
|
private static int extract(ZipInputStream zipStream, String fileDest, int bytes) throws IOException {
|
||||||
private static int extract(ZipInputStream zipStream, String fileDest, int currentBytes) throws IOException {
|
|
||||||
try (BufferedOutputStream outStream = new BufferedOutputStream(new FileOutputStream(fileDest))) {
|
try (BufferedOutputStream outStream = new BufferedOutputStream(new FileOutputStream(fileDest))) {
|
||||||
byte[] bytesIn = new byte[ZIP_READ_SIZE];
|
byte[] bytesIn = new byte[ZIP_READ_SIZE];
|
||||||
int read = 0;
|
int read = 0;
|
||||||
while ((read = zipStream.read(bytesIn)) != -1) {
|
while ((read = zipStream.read(bytesIn)) != -1) {
|
||||||
currentBytes += read;
|
bytes += read;
|
||||||
if (currentBytes > MAX_ZIP_SIZE) {
|
if (bytes > MAX_ZIP_SIZE) {
|
||||||
throw new IOException("Zip file being extracted to \"" + fileDest + "\" is too big!");
|
throw new IOException("Zip file being extracted to \"" + fileDest + "\" is too big!");
|
||||||
}
|
}
|
||||||
outStream.write(bytesIn, 0, read);
|
outStream.write(bytesIn, 0, read);
|
||||||
}
|
}
|
||||||
outStream.close();
|
outStream.close();
|
||||||
}
|
}
|
||||||
return currentBytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user