mirror of
https://github.com/GTNewHorizons/Avaritia.git
synced 2026-11-20 20:22:18 +00:00
Planar Conjunction
https: //github.com/SpitefulFox/Avaritia/commit/ff6ab98288aba77c2c7b362c7f1480c02c4623bc Co-Authored-By: SpitefulFox <[email protected]>
This commit is contained in:
1 parent
30de3c00a1
commit
76929e9c8f
19 files changed
+1855
-4
No files matched your search
@@ -13,6 +13,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import fox.spiteful.avaritia.achievements.Achievements;
|
||||
import fox.spiteful.avaritia.blocks.LudicrousBlocks;
|
||||
import fox.spiteful.avaritia.compat.Compat;
|
||||
import fox.spiteful.avaritia.compat.botania.alfheim.Alfheim;
|
||||
import fox.spiteful.avaritia.crafting.Gregorizer;
|
||||
import fox.spiteful.avaritia.crafting.Grinder;
|
||||
import fox.spiteful.avaritia.crafting.Mincer;
|
||||
@@ -21,10 +22,7 @@ import fox.spiteful.avaritia.gui.GooeyHandler;
|
||||
import fox.spiteful.avaritia.items.ItemFracturedOre;
|
||||
import fox.spiteful.avaritia.items.LudicrousItems;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
@Mod(modid = "Avaritia", name = "Avaritia", dependencies = "after:Thaumcraft;after:AWWayofTime;after:Botania")
|
||||
@@ -62,6 +60,8 @@ public class Avaritia {
|
||||
|
||||
LudicrousEntities.letLooseTheDogsOfWar();
|
||||
proxy.prepareForPretty();
|
||||
if(Compat.botan && Config.alfheim)
|
||||
Alfheim.packYourBags();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
@@ -40,6 +40,9 @@ public class Config {
|
||||
public static boolean extracells = true;
|
||||
public static boolean witch = true;
|
||||
public static boolean rotisserie = true;
|
||||
|
||||
public static boolean alfheim = false;
|
||||
public static int alfheimID;
|
||||
|
||||
public static boolean copper = true;
|
||||
public static boolean tin = true;
|
||||
@@ -91,6 +94,9 @@ public class Config {
|
||||
extracells = conf.get("compatibility", "Extra Cells", true).getBoolean(true);
|
||||
witch = conf.get("compatibility", "Witchery", true).getBoolean(true);
|
||||
rotisserie = conf.get("compatibility", "Rotarycraft", true).getBoolean(true);
|
||||
|
||||
alfheim = conf.get("compatibility", "Alfheim", false).getBoolean(false);
|
||||
alfheimID = conf.get("compatibility", "AlfheimID", 13).getInt(13);
|
||||
|
||||
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);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package fox.spiteful.avaritia.compat.botania;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import fox.spiteful.avaritia.Config;
|
||||
import fox.spiteful.avaritia.blocks.LudicrousBlocks;
|
||||
import fox.spiteful.avaritia.compat.Compat;
|
||||
import fox.spiteful.avaritia.compat.botania.alfheim.Alfheim;
|
||||
import fox.spiteful.avaritia.compat.nei.NotEnough;
|
||||
import fox.spiteful.avaritia.crafting.ExtremeCraftingManager;
|
||||
import fox.spiteful.avaritia.crafting.ExtremeShapedRecipe;
|
||||
@@ -42,6 +42,9 @@ public class Tsundere {
|
||||
SubTileCheaty.lexicon = new LudicrousLexicon("asgardandelion", BotaniaAPI.categoryGenerationFlowers);
|
||||
SubTileCheaty.lexicon.addPage(BotaniaAPI.internalHandler.textPage("avaritia.lexicon.asgardandelion.0"));
|
||||
SubTileCheaty.lexicon.setIcon(cheaty);
|
||||
|
||||
if(Config.alfheim)
|
||||
Alfheim.vacationTime();
|
||||
|
||||
ExtremeCraftingManager.getInstance().addRecipe(cheaty, new Object[]{
|
||||
" III ",
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package fox.spiteful.avaritia.compat.botania.alfheim;
|
||||
|
||||
import net.minecraft.world.gen.structure.MapGenStructureIO;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
public class Alfheim {
|
||||
public static void vacationTime() {
|
||||
AlfheimBlocks.alfheimify();
|
||||
|
||||
if(FMLCommonHandler.instance().getSide().isClient()) {
|
||||
AlfheimEvents alfevents = new AlfheimEvents();
|
||||
FMLCommonHandler.instance().bus().register(alfevents);
|
||||
MinecraftForge.EVENT_BUS.register(alfevents);
|
||||
}
|
||||
}
|
||||
|
||||
// this stuff needs to happen whether or not botania is active it seems D:
|
||||
// DON'T LIE LIKE THAT, CUTS >:P
|
||||
public static void packYourBags() {
|
||||
int dim = WorldProviderAlfheim.dimensionID;
|
||||
DimensionManager.registerProviderType(dim, WorldProviderAlfheim.class, false);
|
||||
DimensionManager.registerDimension(dim, dim);
|
||||
|
||||
MapGenStructureIO.registerStructure(MapGenCity.Start.class, "AlfCity");
|
||||
ComponentCityParts.registerParts();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package fox.spiteful.avaritia.compat.botania.alfheim;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import fox.spiteful.avaritia.blocks.ItemBlockWithMetadataUnderp;
|
||||
|
||||
public class AlfheimBlocks {
|
||||
public static Block deadrock;
|
||||
|
||||
public static void alfheimify() {
|
||||
deadrock = GameRegistry.registerBlock(new BlockDeadrock(), ItemBlockWithMetadataUnderp.class, "Alf_Deadrock");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
package fox.spiteful.avaritia.compat.botania.alfheim;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.util.Timer;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import fox.spiteful.avaritia.FieldHelper;
|
||||
import fox.spiteful.avaritia.Lumberjack;
|
||||
|
||||
public class AlfheimEvents {
|
||||
public static Field lightmapUpdateNeededField;
|
||||
public static Field mcTimerField;
|
||||
public static Field torchFlickerField;
|
||||
public static Field lightmapColorsField;
|
||||
public static Field lightmapTextureField;
|
||||
public static Field bossColorModifierField;
|
||||
public static Field bossColorModifierPrevField;
|
||||
public static Method getNightVisionBrightnessMethod = ReflectionHelper.findMethod(EntityRenderer.class, Minecraft.getMinecraft().entityRenderer, new String[]{"getNightVisionBrightness", "func_82830_a"}, EntityPlayer.class, float.class);
|
||||
|
||||
static {
|
||||
try {
|
||||
mcTimerField = ReflectionHelper.findField(Minecraft.class, "timer", "field_71428_T");
|
||||
lightmapUpdateNeededField = ReflectionHelper.findField(EntityRenderer.class, "lightmapUpdateNeeded", "field_78536_aa");
|
||||
torchFlickerField = ReflectionHelper.findField(EntityRenderer.class, "torchFlickerX", "field_78514_e");
|
||||
lightmapColorsField = ReflectionHelper.findField(EntityRenderer.class, "lightmapColors", "field_78504_Q");
|
||||
lightmapTextureField = ReflectionHelper.findField(EntityRenderer.class, "lightmapTexture", "field_78513_d");
|
||||
bossColorModifierField = ReflectionHelper.findField(EntityRenderer.class, "bossColorModifier", "field_82831_U");
|
||||
bossColorModifierPrevField = ReflectionHelper.findField(EntityRenderer.class, "bossColorModifierPrev", "field_82832_V");
|
||||
//getNightVisionBrightnessMethod = ReflectionHelper.findMethod(EntityRenderer.class, Minecraft.getMinecraft().entityRenderer, new String[]{"getNightVisionBrightness", "func_82830_a"}, Float.class);
|
||||
} catch(Exception e) {
|
||||
Lumberjack.log(Level.ERROR, e);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRenderStart(TickEvent.RenderTickEvent event) {
|
||||
if (event.phase == Phase.START) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
if (mc.theWorld == null) {
|
||||
return;
|
||||
}
|
||||
World world = mc.theWorld;
|
||||
if (world.provider == null || !(world.provider instanceof WorldProviderAlfheim)) {
|
||||
return;
|
||||
}
|
||||
EntityRenderer er = mc.entityRenderer;
|
||||
|
||||
boolean needsupdate = FieldHelper.get(lightmapUpdateNeededField, er);
|
||||
|
||||
if (needsupdate) {
|
||||
updateLightmapRedGiant();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateLightmapRedGiant() {
|
||||
//Lumberjack.info("Lightmap update");
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
EntityRenderer er = mc.entityRenderer;
|
||||
Timer timer = FieldHelper.get(mcTimerField, mc);
|
||||
float partialTicks = timer.renderPartialTicks;
|
||||
float flicker = FieldHelper.get(torchFlickerField, er);
|
||||
float bossColorModifier = FieldHelper.get(bossColorModifierField, er);
|
||||
float bossColorModifierPrev = FieldHelper.get(bossColorModifierPrevField, er);
|
||||
int[] lightmapColors = FieldHelper.get(lightmapColorsField, er);
|
||||
DynamicTexture lightmapTexture = FieldHelper.get(lightmapTextureField, er);
|
||||
|
||||
WorldClient worldclient = mc.theWorld;
|
||||
|
||||
if (worldclient != null)
|
||||
{
|
||||
for (int i = 0; i < 256; ++i)
|
||||
{
|
||||
float brightness = worldclient.getSunBrightness(1.0F) * 0.95F + 0.05F;
|
||||
float sun = worldclient.provider.lightBrightnessTable[i / 16] * brightness;
|
||||
float torch = worldclient.provider.lightBrightnessTable[i % 16] * (flicker * 0.1F + 1.5F);
|
||||
|
||||
if (worldclient.lastLightningBolt > 0)
|
||||
{
|
||||
sun = worldclient.provider.lightBrightnessTable[i / 16];
|
||||
}
|
||||
|
||||
float sunr = sun * (worldclient.getSunBrightness(1.0F) * 0.65F + 0.35F);
|
||||
float sung = sun * (worldclient.getSunBrightness(1.0F) * 0.65F + 0.35F);
|
||||
float torchg = torch * ((torch * 0.6F + 0.4F) * 0.6F + 0.4F);
|
||||
float torchb = torch * (torch * torch * 0.6F + 0.4F);
|
||||
float fr = sunr + torch;
|
||||
float fg = sung * 0.3f + torchg;
|
||||
float fb = sun * 0.2f + torchb;
|
||||
fr = fr * 0.96F + 0.03F;
|
||||
fg = fg * 0.96F + 0.03F;
|
||||
fb = fb * 0.96F + 0.03F;
|
||||
float modifier;
|
||||
|
||||
if (bossColorModifier > 0.0F)
|
||||
{
|
||||
modifier = bossColorModifierPrev + (bossColorModifier - bossColorModifierPrev) * partialTicks;
|
||||
fr = fr * (1.0F - modifier) + fr * 0.7F * modifier;
|
||||
fg = fg * (1.0F - modifier) + fg * 0.6F * modifier;
|
||||
fb = fb * (1.0F - modifier) + fb * 0.6F * modifier;
|
||||
}
|
||||
|
||||
if (worldclient.provider.dimensionId == 1)
|
||||
{
|
||||
fr = 0.22F + torch * 0.75F;
|
||||
fg = 0.28F + torchg * 0.75F;
|
||||
fb = 0.25F + torchb * 0.75F;
|
||||
}
|
||||
|
||||
if (mc.thePlayer.isPotionActive(Potion.nightVision))
|
||||
{
|
||||
modifier = FieldHelper.invoke(getNightVisionBrightnessMethod, er, mc.thePlayer, partialTicks);
|
||||
|
||||
float nightvision = 1.0F / fr;
|
||||
|
||||
if (nightvision > 1.0F / fg)
|
||||
{
|
||||
nightvision = 1.0F / fg;
|
||||
}
|
||||
|
||||
if (nightvision > 1.0F / fb)
|
||||
{
|
||||
nightvision = 1.0F / fb;
|
||||
}
|
||||
|
||||
fr = fr * (1.0F - modifier) + fr * nightvision * modifier;
|
||||
fg = fg * (1.0F - modifier) + fg * nightvision * modifier;
|
||||
fb = fb * (1.0F - modifier) + fb * nightvision * modifier;
|
||||
}
|
||||
|
||||
if (fr > 1.0F) { fr = 1.0F; }
|
||||
if (fg > 1.0F) { fg = 1.0F; }
|
||||
if (fb > 1.0F) { fb = 1.0F; }
|
||||
|
||||
modifier = mc.gameSettings.gammaSetting;
|
||||
float gr = 1.0F - fr;
|
||||
float gg = 1.0F - fg + 0.25f*sun;
|
||||
float gb = 1.0F - fb + 0.2f*sun;
|
||||
gr = 1.0F - gr * gr * gr * gr;
|
||||
gg = 1.0F - gg * gg * gg * gg;
|
||||
gb = 1.0F - gb * gb * gb * gb;
|
||||
fr = fr * (1.0F - modifier) + gr * modifier;
|
||||
fg = fg * (1.0F - modifier) + gg * modifier;
|
||||
fb = fb * (1.0F - modifier) + gb * modifier;
|
||||
fr = fr * 0.96F + 0.03F;
|
||||
fg = fg * 0.96F + 0.03F;
|
||||
fb = fb * 0.96F + 0.03F;
|
||||
|
||||
if (fr > 1.0F) { fr = 1.0F; }
|
||||
if (fg > 1.0F) { fg = 1.0F; }
|
||||
if (fb > 1.0F) { fb = 1.0F; }
|
||||
|
||||
if (fr < 0.0F) { fr = 0.0F; }
|
||||
if (fg < 0.0F) { fg = 0.0F; }
|
||||
if (fb < 0.0F) { fb = 0.0F; }
|
||||
|
||||
short alpha = 255;
|
||||
int r = (int)(fr * 255.0F);
|
||||
int g = (int)(fg * 255.0F);
|
||||
int b = (int)(fb * 255.0F);
|
||||
lightmapColors[i] = alpha << 24 | r << 16 | g << 8 | b;
|
||||
}
|
||||
|
||||
lightmapTexture.updateDynamicTexture();
|
||||
FieldHelper.set(lightmapUpdateNeededField, er, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
package fox.spiteful.avaritia.compat.botania.alfheim;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
|
||||
|
||||
public class AlfheimNoise {
|
||||
|
||||
public final long seed;
|
||||
private final double[] randomSource;
|
||||
|
||||
private static int XSEED = 1619;
|
||||
private static int ZSEED = 31337;
|
||||
private static int NSEED = 1013;
|
||||
private static int NSHIFT = 8;
|
||||
|
||||
public AlfheimNoise(long seed) {
|
||||
this.seed = seed;
|
||||
this.randomSource = new double[256*2];
|
||||
Random randy = new Random(this.seed);
|
||||
for (int i=0; i<256; i++) {
|
||||
double r = randy.nextDouble();
|
||||
double a = randy.nextDouble()*2*Math.PI;
|
||||
|
||||
this.randomSource[i*2] = Math.sin(a)*r;
|
||||
this.randomSource[i*2+1] = Math.cos(a)*r;
|
||||
}
|
||||
}
|
||||
|
||||
private double getNoise(double x, double z, double period, long seed) {
|
||||
double frequency = period == 0 ? 1.0 : 1.0/period;
|
||||
return this.calcNoise(x * frequency, z * frequency, seed);
|
||||
}
|
||||
|
||||
private double calcNoise(double x, double z, long seed) {
|
||||
int x0 = (x > 0 ? MathHelper.floor_double(x) : MathHelper.floor_double(x)-1);
|
||||
int x1 = x0 + 1;
|
||||
int z0 = (z > 0 ? MathHelper.floor_double(z) : MathHelper.floor_double(z)-1);
|
||||
int z1 = z0 + 1;
|
||||
|
||||
double xs = deriv1(x-x0);
|
||||
double zs = deriv1(z-z0);
|
||||
|
||||
double tl = this.gradientNoise(x,z, x0,z0, seed);
|
||||
double tr = this.gradientNoise(x,z, x1,z0, seed);
|
||||
double top = lerp(tl,tr, xs);
|
||||
|
||||
double bl = this.gradientNoise(x,z, x0,z1, seed);
|
||||
double br = this.gradientNoise(x,z, x1,z1, seed);
|
||||
double bot = lerp(bl,br, xs);
|
||||
|
||||
return lerp(top, bot, zs);
|
||||
}
|
||||
|
||||
private double gradientNoise(double fx, double fz, int ix, int iz, long seed) {
|
||||
Vec3 grad = this.getGradient(ix, iz, seed);
|
||||
Vec3 point = Vec3.createVectorHelper(fx-ix, fz-iz, 0);
|
||||
|
||||
return grad.dotProduct(point) * 2.12;
|
||||
}
|
||||
|
||||
private Vec3 getGradient(int x, int z, long seed) {
|
||||
long vectorindex = (
|
||||
XSEED * x
|
||||
+ ZSEED * z
|
||||
+ NSEED * seed
|
||||
) & 0xffffffff;
|
||||
vectorindex ^= (vectorindex >> NSHIFT);
|
||||
vectorindex &= 0xff;
|
||||
int vi = (int)vectorindex;
|
||||
|
||||
return Vec3.createVectorHelper(this.randomSource[vi*2], this.randomSource[vi*2+1], 0);
|
||||
}
|
||||
|
||||
private Vec3 calcDerivative(double x, double z, long seed) {
|
||||
int ix = MathHelper.floor_double(x);
|
||||
int iz = MathHelper.floor_double(z);
|
||||
double fx = x-ix;
|
||||
double fz = z-iz;
|
||||
|
||||
double wx = deriv1(fx);
|
||||
double wz = deriv1(fz);
|
||||
|
||||
double dwx = deriv2(fx);
|
||||
double dwz = deriv2(fz);
|
||||
|
||||
double dwpx = deriv3(fx);
|
||||
double dwpz = deriv3(fz);
|
||||
|
||||
Vec3 vtl = getGradient(ix, iz, seed);
|
||||
Vec3 vtr = getGradient(ix+1, iz, seed);
|
||||
Vec3 vbl = getGradient(ix, iz+1, seed);
|
||||
Vec3 vbr = getGradient(ix+1, iz+1, seed);
|
||||
|
||||
double tl = vtl.xCoord * (x - ix) + vtl.yCoord * (z - iz);
|
||||
double tr = vtr.xCoord * (x - (ix+1)) + vtr.yCoord * (z - iz);
|
||||
double bl = vbl.xCoord * (x - ix) + vbl.yCoord * (z - (iz+1));
|
||||
double br = vbr.xCoord * (x - (ix+1)) + vbr.yCoord * (z - (iz+1));
|
||||
|
||||
double top = lerp(tl,tr,wx);
|
||||
double bot = lerp(bl,br,wx);
|
||||
double n = lerp(top,bot,wz);
|
||||
|
||||
double dx = (vtl.xCoord + (vbl.xCoord-vtl.xCoord)*wz) + ((vtr.yCoord-vtl.yCoord)*fz - vtr.xCoord +
|
||||
((vtl.yCoord-vtr.yCoord-vbl.yCoord+vbr.yCoord)*fz + vtr.xCoord + vbl.yCoord - vbr.xCoord - vbr.yCoord)*wz)*
|
||||
dwx + ((vtr.xCoord-vtl.xCoord) + (vtl.xCoord-vtr.xCoord-vbl.xCoord+vbr.xCoord)*wz)*dwpx;
|
||||
|
||||
double dz = (vtl.yCoord + (vtr.yCoord-vtl.yCoord)*wx) + ((vbl.xCoord-vtl.xCoord)*fx - vbl.yCoord + ((vtl.xCoord-
|
||||
vtr.xCoord-vbl.xCoord+vbr.xCoord)*fx + vtr.xCoord + vbl.yCoord - vbr.xCoord - vbr.yCoord)*wx)*dwz +
|
||||
((vbl.yCoord-vtl.yCoord) + (vtl.yCoord-vtr.yCoord-vbl.yCoord+vbr.yCoord)*wx)*dwpz;
|
||||
|
||||
return Vec3.createVectorHelper(n*2, dx*2, dz*2);
|
||||
}
|
||||
|
||||
private double getNoiseOctaves(double x, double z, int octaves, double period, double lacunarity, double gain, long seed) {
|
||||
double sum = 0.0;
|
||||
double freq = period == 0 ? 1.0 : 1.0 / period;
|
||||
double amp = 1.0;
|
||||
|
||||
for (int i=0; i<octaves; i++) {
|
||||
double n = this.getNoise(x, z, period*i, seed + i);
|
||||
sum += n*amp;
|
||||
freq *= lacunarity;
|
||||
amp *= gain;
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
private double getJordanRaw(double x, double z, int octaves, double period, double lacunarity, double gain0, double gain, double warp0, double warp, double damp0, double damp, double dampscale, long seed) {
|
||||
double amp = gain0;
|
||||
double freq = (period == 0 ? 1.0 : 1.0 / period) * lacunarity;
|
||||
double damped_amp = amp * gain;
|
||||
|
||||
Vec3 n = this.calcDerivative(x*freq, z*freq, seed);
|
||||
Vec3 n2 = Vec3.createVectorHelper(n.xCoord*n.xCoord, n.yCoord*n.xCoord, n.zCoord*n.xCoord);
|
||||
double sum = n2.xCoord;
|
||||
double dswx = n2.yCoord * warp0;
|
||||
double dswz = n2.zCoord * warp0;
|
||||
double dsdx = n2.yCoord * damp0;
|
||||
double dsdz = n2.zCoord * damp0;
|
||||
double dsddot;
|
||||
|
||||
for (int i=1; i<octaves; i++) {
|
||||
n = this.calcDerivative(x*freq + dswx, z*freq + dswz, seed + i);
|
||||
n2 = Vec3.createVectorHelper(n.xCoord*n.xCoord, n.yCoord*n.xCoord, n.zCoord*n.xCoord);
|
||||
sum += damped_amp * ((n2.xCoord * 1.5) +0.1);
|
||||
dswx += n2.yCoord * warp;
|
||||
dswz += n2.zCoord * warp;
|
||||
dsdx += n2.yCoord * damp;
|
||||
dsdz += n2.zCoord * damp;
|
||||
freq *= lacunarity;
|
||||
amp *= gain;
|
||||
dsddot = dsdx*dsdx + dsdz*dsdz;
|
||||
damped_amp = amp * (1.0-dampscale/(1.0+dsddot));
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
public double getJordan(double x, double z, int octaves, double period, double lacunarity, double gain0, double gain, double warp0, double warp, double damp0, double damp, double dampscale, int distortionoctaves, double distortionscale, double distortion, double distortiongain, long seed) {
|
||||
x += this.getNoiseOctaves(x, z, distortionoctaves, period * distortionscale, lacunarity, distortiongain, seed + 1) * distortion * period * distortionscale;
|
||||
z += this.getNoiseOctaves(x, z, distortionoctaves, period * distortionscale, lacunarity, distortiongain, seed + 2) * distortion * period * distortionscale;
|
||||
return this.getJordanRaw(x, z, octaves, period, lacunarity, gain0, gain, warp0, warp, damp0, damp, dampscale, seed);
|
||||
}
|
||||
|
||||
public double getJordanDefault(double x, double z) {
|
||||
return this.getJordan(x, z, 4, 750.0, 4, 0.9, 0.7, 0.8, 0.6, 1.0, 0.8, 1.0, 1, 0.001, 0.35, 0.5, this.seed);
|
||||
}
|
||||
|
||||
private double deriv1(double n) {
|
||||
return n * n * n * (n * (n * 6 - 15) + 10);
|
||||
}
|
||||
|
||||
private double deriv2(double n) {
|
||||
return n * n * (n * (n * 30 - 60) + 30);
|
||||
}
|
||||
|
||||
private double deriv3(double n) {
|
||||
return n * n * n * (n * (n * 36 - 75) + 40);
|
||||
}
|
||||
|
||||
private double lerp(double a, double b, double n) {
|
||||
return a*(1.0-n) + b*n;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package fox.spiteful.avaritia.compat.botania.alfheim;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraftforge.client.IRenderHandler;
|
||||
|
||||
public class ApocalypseCloudRenderer extends IRenderHandler {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void render(float partialTicks, WorldClient world, Minecraft mc) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package fox.spiteful.avaritia.compat.botania.alfheim;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.IRenderHandler;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
|
||||
public class ApocalypseSkyRenderer extends IRenderHandler {
|
||||
private static IModelCustom model;
|
||||
private static final ResourceLocation texture = new ResourceLocation("avaritia", "textures/models/sun.png");
|
||||
private static final ResourceLocation halo = new ResourceLocation("avaritia", "textures/entity/voidhalo.png");
|
||||
private static final ResourceLocation glow = new ResourceLocation("avaritia", "textures/items/halo128.png");
|
||||
|
||||
public ApocalypseSkyRenderer() {
|
||||
if (model == null) {
|
||||
model = AdvancedModelLoader.loadModel(new ResourceLocation("avaritia", "model/sun.obj"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void render(float partialTicks, WorldClient world, Minecraft mc) {
|
||||
GL11.glDisable(GL11.GL_FOG);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDepthMask(false);
|
||||
|
||||
Tessellator t = Tessellator.instance;
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotated(25, 1, 0, 0);
|
||||
|
||||
GL11.glTranslated(0, 0, -350);
|
||||
GL11.glScaled(500, 500, 500);
|
||||
|
||||
GL11.glRotated(90, -1, 0, 0);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(glow);
|
||||
GL11.glColor4d(242/255.0, 61/255.0, 1/255.0, 0.3);
|
||||
double bound = 0.7;
|
||||
double depth = -0.4;
|
||||
t.startDrawingQuads();
|
||||
t.addVertexWithUV(-bound, depth, -bound, 0.0D, 0.0D);
|
||||
t.addVertexWithUV(bound, depth, -bound, 1.0D, 0.0D);
|
||||
t.addVertexWithUV(bound, depth, bound, 1.0D, 1.0D);
|
||||
t.addVertexWithUV(-bound, depth, bound, 0.0D, 1.0D);
|
||||
t.draw();
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(halo);
|
||||
GL11.glColor3d(242/255.0, 61/255.0, 1/255.0);
|
||||
bound = 0.562;
|
||||
depth = -0.2;
|
||||
t.startDrawingQuads();
|
||||
t.addVertexWithUV(-bound, depth, -bound, 0.0D, 0.0D);
|
||||
t.addVertexWithUV(bound, depth, -bound, 1.0D, 0.0D);
|
||||
t.addVertexWithUV(bound, depth, bound, 1.0D, 1.0D);
|
||||
t.addVertexWithUV(-bound, depth, bound, 0.0D, 1.0D);
|
||||
t.draw();
|
||||
|
||||
GL11.glRotated(90, 1, 0, 0);
|
||||
GL11.glColor3d(1, 1, 1);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
|
||||
model.renderAll();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package fox.spiteful.avaritia.compat.botania.alfheim;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.Teleporter;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
public class BasicTeleporter extends Teleporter {
|
||||
public BasicTeleporter(WorldServer world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean makePortal(Entity entity){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeInPortal(Entity entity, double x, double y, double z, float yaw){
|
||||
int newX = MathHelper.floor_double(entity.posX);
|
||||
int newY = MathHelper.floor_double(entity.posY);
|
||||
int newZ = MathHelper.floor_double(entity.posZ);
|
||||
entity.setLocationAndAngles(newX, newY, newZ, entity.rotationYaw, 0.0F);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package fox.spiteful.avaritia.compat.botania.alfheim;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import vazkii.botania.api.lexicon.ILexiconable;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockDeadrock extends Block implements ILexiconable {
|
||||
|
||||
private static final int TYPES = 5;
|
||||
IIcon[] icons;
|
||||
|
||||
public BlockDeadrock() {
|
||||
super(Material.rock);
|
||||
setHardness(2.0F);
|
||||
setResistance(10.0F);
|
||||
setStepSound(soundTypeStone);
|
||||
setBlockName("alfheim_deadrock");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int par1) {
|
||||
return par1;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
for(int i = 0; i < TYPES; i++)
|
||||
par3List.add(new ItemStack(par1, 1, i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister ir) {
|
||||
icons = new IIcon[TYPES];
|
||||
for(int i = 0; i < TYPES; i++)
|
||||
icons[i] = ir.registerIcon("avaritia:deadrock"+i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int par1, int par2) {
|
||||
return icons[Math.min(TYPES - 1, par2)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
return new ItemStack(this, 1, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
//return meta == 0 ? LexiconData.pureDaisy : LexiconData.decorativeBlocks;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
package fox.spiteful.avaritia.compat.botania.alfheim;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
import net.minecraft.util.IProgressUpdate;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
|
||||
public class ChunkProviderAlfheim implements IChunkProvider {
|
||||
public static final int CITYRADIUS = 600;
|
||||
public static final int FLATRADIUS = CITYRADIUS + 20;
|
||||
public static final int HILLRADIUS = FLATRADIUS + 250;
|
||||
|
||||
public final long seed;
|
||||
public Random rand;
|
||||
public final World world;
|
||||
|
||||
protected AlfheimNoise noise;
|
||||
protected MapGenAlfheimRavines cracks = new MapGenAlfheimRavines();
|
||||
protected MapGenCity city = new MapGenCity();
|
||||
|
||||
public ChunkProviderAlfheim(World world, long seed) {
|
||||
this.seed = seed;
|
||||
this.rand = new Random(this.seed);
|
||||
this.world = world;
|
||||
this.noise = new AlfheimNoise(this.rand.nextLong());
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public List spawnList = new ArrayList();
|
||||
|
||||
@Override
|
||||
public boolean chunkExists(int chunkX, int chunkZ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk provideChunk(int chunkX, int chunkZ) {
|
||||
this.rand.setSeed((long)chunkX * 1497631652873L + (long)chunkZ * 902659997773L);
|
||||
Block[] blocks = new Block[65536];
|
||||
byte[] meta = new byte[65536];
|
||||
|
||||
this.fillChunkArray(chunkX, chunkZ, blocks, meta);
|
||||
|
||||
//this.cracks.func_151539_a(this, this.world, chunkX, chunkZ, blocks);
|
||||
|
||||
int cityrad = (int)Math.ceil(CITYRADIUS / 16.0) + 1;
|
||||
if (chunkX * chunkX + chunkZ * chunkZ <= cityrad) {
|
||||
this.city.func_151539_a(this, this.world, chunkX, chunkZ, blocks);
|
||||
}
|
||||
|
||||
Chunk chunk = new Chunk(this.world, blocks, meta, chunkX, chunkZ);
|
||||
byte[] biomes = chunk.getBiomeArray();
|
||||
|
||||
for (int i=0; i<biomes.length; i++) {
|
||||
biomes[i] = (byte) BiomeGenBase.desert.biomeID;
|
||||
}
|
||||
|
||||
chunk.generateSkylightMap();
|
||||
|
||||
return chunk;
|
||||
}
|
||||
|
||||
public void fillChunkArray(int chunkX, int chunkZ, Block[] blocks, byte[] meta) {
|
||||
|
||||
for(int x = 0; x<=15; x++) {
|
||||
for(int z = 0; z<=15; z++) {
|
||||
int blockX = chunkX * 16 + x;
|
||||
int blockZ = chunkZ * 16 + z;
|
||||
double dist = Math.sqrt(blockX*blockX + blockZ*blockZ);
|
||||
|
||||
int threshold = 64;
|
||||
|
||||
double mix = (dist - FLATRADIUS) / (double)(HILLRADIUS - FLATRADIUS);
|
||||
mix = Math.max(0, Math.min(1, mix));
|
||||
mix = mix * mix * (3 - (2 * mix));
|
||||
|
||||
double height = this.noise.getJordanDefault(chunkX * 16 + x, chunkZ * 16 + z);
|
||||
|
||||
double hill = mix * height * 64;
|
||||
double lumps = Math.min(3, (1-mix) * height * 5);
|
||||
|
||||
threshold = MathHelper.floor_double(64 + hill+lumps);
|
||||
|
||||
for(int y = 0; y<254; y++) {
|
||||
int pos = y | z << 8 | x << 12;
|
||||
|
||||
if (y <= threshold) {
|
||||
|
||||
if (y < threshold - (15 + this.rand.nextInt(3))) {
|
||||
// INTERIOR
|
||||
blocks[pos] = ModBlocks.livingrock;
|
||||
meta[pos] = 0;
|
||||
} else {
|
||||
// CRUST
|
||||
blocks[pos] = AlfheimBlocks.deadrock;
|
||||
meta[pos] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk loadChunk(int chunkX, int chunkZ) {
|
||||
return this.provideChunk(chunkX, chunkZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populate(IChunkProvider provider, int chunkX, int chunkZ) {
|
||||
this.rand.setSeed(this.world.getSeed());
|
||||
long xseed = this.rand.nextLong() / 2L * 2L + 1L;
|
||||
long zseed = this.rand.nextLong() / 2L * 2L + 1L;
|
||||
this.rand.setSeed((long)chunkX * xseed + (long)chunkZ * zseed ^ this.world.getSeed());
|
||||
|
||||
int cityrad = (int)Math.ceil(CITYRADIUS / 16.0) + 1;
|
||||
if (Math.sqrt(chunkX * chunkX + chunkZ * chunkZ) <= cityrad) {
|
||||
this.city.generateStructuresInChunk(this.world, this.rand, chunkX, chunkZ);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveChunks(boolean mode, IProgressUpdate progress) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unloadQueuedChunks() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSave() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String makeString() {
|
||||
return "AlfheimEternalSource";
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public List getPossibleCreatures(EnumCreatureType type, int x, int y, int z) {
|
||||
return this.spawnList;
|
||||
}
|
||||
|
||||
// structure location check
|
||||
@Override
|
||||
public ChunkPosition func_147416_a(World world, String structureType, int x, int y, int z) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLoadedChunkCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recreateStructures(int chunkX, int chunkZ) {
|
||||
int cityrad = (int)Math.ceil(CITYRADIUS / 16.0) + 1;
|
||||
if (chunkX * chunkX + chunkZ * chunkZ <= cityrad) {
|
||||
this.city.func_151539_a(this, this.world, chunkX, chunkZ, (Block[])null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveExtraData() {}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
package fox.spiteful.avaritia.compat.botania.alfheim;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import fox.spiteful.avaritia.Lumberjack;
|
||||
import fox.spiteful.avaritia.compat.botania.alfheim.Ruin.BlockArray;
|
||||
import fox.spiteful.avaritia.compat.botania.alfheim.Ruin.BlockMeta;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.structure.MapGenStructureIO;
|
||||
import net.minecraft.world.gen.structure.StructureBoundingBox;
|
||||
import net.minecraft.world.gen.structure.StructureComponent;
|
||||
|
||||
public class ComponentCityParts {
|
||||
|
||||
public static void registerParts() {
|
||||
MapGenStructureIO.func_143031_a(CityRuin.class, "AlfRuin");
|
||||
}
|
||||
|
||||
public static class CityRuin extends CityPart {
|
||||
public static final int outline = 5;
|
||||
|
||||
public CityRuin() {}
|
||||
|
||||
public CityRuin(Random rand, int x, int z, int xsize, int zsize, int floors) {
|
||||
super(rand, x-outline, 64, z-outline, xsize+outline*2, floors * 7 + 3 + 8, zsize+outline*2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addComponentParts(World world, Random rand, StructureBoundingBox bounds) {
|
||||
if (!this.processHeight(world, bounds, -3)) {
|
||||
return false;
|
||||
}
|
||||
this.genRand.setSeed(this.randSeed);
|
||||
|
||||
int border = 16;
|
||||
|
||||
int minx = Math.max(this.boundingBox.minX, bounds.minX - border);
|
||||
int maxx = Math.min(this.boundingBox.maxX, bounds.maxX + border);
|
||||
int minz = Math.max(this.boundingBox.minZ, bounds.minZ - border);
|
||||
int maxz = Math.min(this.boundingBox.maxZ, bounds.maxZ + border);
|
||||
|
||||
int xsize = this.boundingBox.getXSize();
|
||||
int ysize = this.boundingBox.getYSize();
|
||||
int zsize = this.boundingBox.getZSize();
|
||||
|
||||
int axsize = (maxx-minx)+1;
|
||||
int aysize = ysize;
|
||||
int azsize = (maxz-minz)+1;
|
||||
|
||||
int xoffset = minx - this.boundingBox.minX;
|
||||
int zoffset = minz - this.boundingBox.minZ;
|
||||
|
||||
Lumberjack.info("xyz: "+this.boundingBox+", chunk: "+bounds+", size: "+xsize+","+ysize+","+zsize+", mxmy: "+minx+","+minz+"; "+maxx+","+maxz+", asize: "+axsize+","+aysize+","+azsize+", offset: "+xoffset+","+zoffset);
|
||||
|
||||
BlockArray blocks = new BlockArray(axsize, aysize, azsize);
|
||||
|
||||
blocks.fillBlocks(outline-xoffset, 0, outline-zoffset, (xsize-outline-1)-xoffset, ysize, (zsize-outline-1)-zoffset, new BlockMeta(Blocks.cobblestone, 0));
|
||||
//blocks.fillBlocks(-xoffset, 0, -zoffset, (xsize-1)-xoffset, ysize, (zsize-1)-zoffset, new BlockMeta(Blocks.cobblestone, 0));
|
||||
|
||||
new Ruin(blocks, 0.3 + this.genRand.nextDouble()*0.7, this.genRand, xsize,ysize,zsize, xoffset,0,zoffset);
|
||||
|
||||
for (int x = 0; x<axsize; x++) {
|
||||
for (int y = 0; y<aysize; y++) {
|
||||
for (int z = 0; z<azsize; z++) {
|
||||
BlockMeta block = blocks.getBlock(x, y, z);
|
||||
if (block != null) {
|
||||
this.placeBlockAtCurrentPosition(world, block.block, block.meta, x + xoffset, y, z + zoffset, bounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//this.fillWithMetadataBlocks(world, bounds, 0, 0, 0, this.boundingBox.getXSize(), this.boundingBox.getYSize(), this.boundingBox.getZSize(), Blocks.planks, 1, Blocks.planks, 1, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class CityPart extends StructureComponent {
|
||||
protected int partSizeX;
|
||||
protected int partSizeY;
|
||||
protected int partSizeZ;
|
||||
protected int partPosY = -1;
|
||||
|
||||
protected Random genRand;
|
||||
protected long randSeed;
|
||||
|
||||
public CityPart() {};
|
||||
|
||||
protected CityPart(Random rand, int x, int y, int z, int xsize, int ysize, int zsize) {
|
||||
super(0);
|
||||
this.partSizeX = xsize;
|
||||
this.partSizeY = ysize;
|
||||
this.partSizeZ = zsize;
|
||||
this.coordBaseMode = 0;
|
||||
|
||||
this.boundingBox = new StructureBoundingBox(x, y, z, x+xsize-1, y+ysize-1, z+zsize-1);
|
||||
|
||||
this.randSeed = rand.nextLong();
|
||||
this.genRand = new Random(this.randSeed);
|
||||
}
|
||||
|
||||
// save to NBT
|
||||
@Override
|
||||
protected void func_143012_a(NBTTagCompound tag)
|
||||
{
|
||||
tag.setInteger("Width", this.partSizeX);
|
||||
tag.setInteger("Height", this.partSizeY);
|
||||
tag.setInteger("Depth", this.partSizeZ);
|
||||
tag.setInteger("HPos", this.partPosY);
|
||||
tag.setLong("RSeed", this.randSeed);
|
||||
}
|
||||
|
||||
// load from NBT
|
||||
@Override
|
||||
protected void func_143011_b(NBTTagCompound tag)
|
||||
{
|
||||
this.partSizeX = tag.getInteger("Width");
|
||||
this.partSizeY = tag.getInteger("Height");
|
||||
this.partSizeZ = tag.getInteger("Depth");
|
||||
this.partPosY = tag.getInteger("HPos");
|
||||
this.randSeed = tag.getLong("RSeed");
|
||||
this.genRand = new Random(this.randSeed);
|
||||
}
|
||||
|
||||
protected boolean processHeight(World world, StructureBoundingBox bounds, int offset)
|
||||
{
|
||||
if (this.partPosY >= 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int j = 0;
|
||||
int k = 0;
|
||||
|
||||
for (int l = this.boundingBox.minZ; l <= this.boundingBox.maxZ; ++l)
|
||||
{
|
||||
for (int i1 = this.boundingBox.minX; i1 <= this.boundingBox.maxX; ++i1)
|
||||
{
|
||||
if (bounds.isVecInside(i1, 64, l))
|
||||
{
|
||||
j += Math.max(world.getTopSolidOrLiquidBlock(i1, l), world.provider.getAverageGroundLevel());
|
||||
++k;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (k == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.partPosY = j / k;
|
||||
this.boundingBox.offset(0, this.partPosY - this.boundingBox.minY + offset, 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package fox.spiteful.avaritia.compat.botania.alfheim;
|
||||
|
||||
import fox.spiteful.avaritia.Lumberjack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.MapGenRavine;
|
||||
|
||||
public class MapGenAlfheimRavines extends MapGenRavine {
|
||||
|
||||
@Override
|
||||
protected void func_151538_a(World world, int originChunkX, int originChunkZ, int chunkX, int chunkZ, Block[] blocks)
|
||||
{
|
||||
if (this.rand.nextInt(6) == 0) {
|
||||
Lumberjack.info("crack!");
|
||||
double x = (double)(originChunkX * 16 + this.rand.nextInt(16));
|
||||
double y = 67;//(double)(this.rand.nextInt(20) + 50);
|
||||
double z = (double)(originChunkZ * 16 + this.rand.nextInt(16));
|
||||
|
||||
int angles = this.rand.nextInt(4)+3;
|
||||
double angleinc = (Math.PI*2.0) / angles;
|
||||
double baseangle = this.rand.nextDouble() * Math.PI * 2.0;
|
||||
|
||||
for (int i=0; i<angles; i++) {
|
||||
float f1 = 1f;//(this.rand.nextFloat() - 0.5F) * 2.0F / 8.0F;
|
||||
float f2 = 1f;//(this.rand.nextFloat() * 2.0F + this.rand.nextFloat()) * 2.0F;
|
||||
float a = (float)(baseangle + angleinc * i);
|
||||
this.func_151540_a(this.rand.nextLong(), chunkX, chunkZ, blocks, x, y, z, f2, a, f1, 0, 0, 3.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void digBlock(Block[] data, int index, int x, int y, int z, int chunkX, int chunkZ, boolean foundTop)
|
||||
{
|
||||
Block block = data[index];
|
||||
|
||||
if (block != null)
|
||||
{
|
||||
/*if (y < 10)
|
||||
{
|
||||
data[index] = Blocks.flowing_lava;
|
||||
}
|
||||
else
|
||||
{*/
|
||||
data[index] = null;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
package fox.spiteful.avaritia.compat.botania.alfheim;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.structure.MapGenStructure;
|
||||
import net.minecraft.world.gen.structure.StructureStart;
|
||||
|
||||
public class MapGenCity extends MapGenStructure {
|
||||
|
||||
|
||||
public MapGenCity() {
|
||||
this.range = (int) Math.ceil(ChunkProviderAlfheim.CITYRADIUS / 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String func_143025_a() {
|
||||
return "AlfCity";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canSpawnStructureAtCoords(int chunkX, int chunkZ) {
|
||||
return chunkX == 0 && chunkZ == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected StructureStart getStructureStart(int chunkX, int chunkZ) {
|
||||
return new Start(this.worldObj, this.rand, chunkX, chunkZ);
|
||||
}
|
||||
|
||||
|
||||
public static class Start extends StructureStart {
|
||||
protected int CITYRADIUS;
|
||||
protected int ROADSIZE = 8;
|
||||
protected int BLOCKSIZE = 24;
|
||||
protected int BLOCKS;
|
||||
|
||||
public Start() {}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Start(World world, Random rand, int chunkX, int chunkZ) {
|
||||
super(chunkX, chunkZ);
|
||||
this.CITYRADIUS = ChunkProviderAlfheim.CITYRADIUS;
|
||||
this.BLOCKS = MathHelper.floor_double((CITYRADIUS*2 + ROADSIZE) / (double)(BLOCKSIZE + ROADSIZE));
|
||||
if (this.BLOCKS % 2 != 0) {
|
||||
this.BLOCKS--;
|
||||
}
|
||||
|
||||
int blockwidth = BLOCKS * BLOCKSIZE + (BLOCKS-1) * ROADSIZE;
|
||||
int origin = -blockwidth/2;
|
||||
|
||||
List<ChunkCoordinates> cells = new ArrayList<ChunkCoordinates>();
|
||||
int[] cellfill = new int[BLOCKS*BLOCKS];
|
||||
for (int i=0; i<cellfill.length; i++) {
|
||||
cellfill[i] = 0;
|
||||
}
|
||||
|
||||
for (int bx = 0; bx < BLOCKS; bx++) {
|
||||
for (int bz = 0; bz < BLOCKS; bz++) {
|
||||
if (bx > BLOCKS/2-3 && bx < BLOCKS/2+2 && bz > BLOCKS/2-3 && bz < BLOCKS/2+2) {
|
||||
continue;
|
||||
}
|
||||
int x = origin + (BLOCKSIZE + ROADSIZE) * bx;
|
||||
int z = origin + (BLOCKSIZE + ROADSIZE) * bz;
|
||||
|
||||
double cx = x + BLOCKSIZE * 0.5;
|
||||
double cz = z + BLOCKSIZE * 0.5;
|
||||
|
||||
double rad = Math.sqrt(cx*cx + cz*cz) / (CITYRADIUS - (BLOCKSIZE*0.75));
|
||||
|
||||
if (rad < 1.0) {
|
||||
if (rand.nextDouble() > rad - 0.4) {
|
||||
cells.add(new ChunkCoordinates(bx,bz,0));
|
||||
cellfill[bz*BLOCKS + bx] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Collections.shuffle(cells);
|
||||
|
||||
while (cells.size() > 0) {
|
||||
ChunkCoordinates cell = cells.remove(0);
|
||||
int bx = cell.posX;
|
||||
int bz = cell.posY;
|
||||
int index = bz * BLOCKS + bx;
|
||||
if (cellfill[index] != 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int dx = BLOCKS/2 - bx;
|
||||
int dz = BLOCKS/2 - bz;
|
||||
double dist = Math.sqrt(dx*dx + dz*dz) / (BLOCKS*0.5);
|
||||
|
||||
int width = 1;
|
||||
int height = 1;
|
||||
|
||||
if (rand.nextDouble() < 1.5 * (1-dist) - 0.05) {
|
||||
width += 1;
|
||||
height += 1;
|
||||
|
||||
if (rand.nextDouble() < 0.1) {
|
||||
width += 1;
|
||||
}
|
||||
if (rand.nextDouble() < 0.1) {
|
||||
height += 1;
|
||||
}
|
||||
}
|
||||
|
||||
while(true) {
|
||||
if (width == 1 && height == 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
boolean ok = true;
|
||||
for (int cx = 0; cx < width; cx++) {
|
||||
for (int cz = 0; cz < height; cz++) {
|
||||
if (bx+cx >= BLOCKS || bz+cz >= BLOCKS) {
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
if ((bx < BLOCKS/2 && bx+cx >= BLOCKS/2) || (bz < BLOCKS/2 && bz+cz >= BLOCKS/2)) {
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
int cindex = (bz+cz)*BLOCKS + (bx+cx);
|
||||
if (cellfill[cindex] != 1) {
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
break;
|
||||
} else {
|
||||
if (width > 1 && height > 1) {
|
||||
if (rand.nextBoolean()) {
|
||||
width--;
|
||||
} else {
|
||||
height--;
|
||||
}
|
||||
} else if (width > 1) {
|
||||
width--;
|
||||
} else {
|
||||
height--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int cx = 0; cx < width; cx++) {
|
||||
for (int cz = 0; cz < height; cz++) {
|
||||
int cindex = (bz+cz)*BLOCKS + (bx+cx);
|
||||
cellfill[cindex] = 2;
|
||||
}
|
||||
}
|
||||
|
||||
double size = Math.sqrt(width*height);
|
||||
int floors = (int)Math.round(0.5 + (size * 1.45 * ((1-dist) + 0.3) * (rand.nextDouble() * rand.nextDouble())) + (rand.nextDouble() * (1-dist) * 0.6) + rand.nextDouble() * 0.2);
|
||||
|
||||
int x = origin + (BLOCKSIZE+ROADSIZE) * bx;
|
||||
int z = origin + (BLOCKSIZE+ROADSIZE) * bz;
|
||||
int structurewidth = width * BLOCKSIZE + (width-1) * ROADSIZE;
|
||||
int structureheight = height * BLOCKSIZE + (height-1) * ROADSIZE;
|
||||
|
||||
/*ComponentScatteredFeaturePieces.SwampHut swamphut = new ComponentScatteredFeaturePieces.SwampHut(rand, x, z);
|
||||
this.components.add(swamphut);*/
|
||||
|
||||
ComponentCityParts.CityRuin ruin = new ComponentCityParts.CityRuin(rand, x, z, structurewidth, structureheight, floors);
|
||||
this.components.add(ruin);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//ComponentScatteredFeaturePieces.SwampHut swamphut = new ComponentScatteredFeaturePieces.SwampHut(rand, (chunkX) * 16, (chunkZ) * 16);
|
||||
//this.components.add(swamphut);
|
||||
|
||||
this.updateBoundingBox();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,397 @@
|
||||
package fox.spiteful.avaritia.compat.botania.alfheim;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import fox.spiteful.avaritia.compat.botania.alfheim.Ruin.BlockRuinPalette.BlockPaletteInfo;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
public class Ruin {
|
||||
public BlockArray blocks;
|
||||
public double ruinLevel;
|
||||
public Random rand;
|
||||
public BlockRuinPalette palette;
|
||||
|
||||
public int xSize;
|
||||
public int ySize;
|
||||
public int zSize;
|
||||
public int xOffset;
|
||||
public int yOffset;
|
||||
public int zOffset;
|
||||
|
||||
public Ruin(BlockArray blocks, double ruinLevel, Random rand) {
|
||||
this(blocks, ruinLevel, rand, new BlockRuinPalette());
|
||||
}
|
||||
public Ruin(BlockArray blocks, double ruinLevel, Random rand, BlockRuinPalette palette) {
|
||||
this (blocks, ruinLevel, rand, blocks.xSize, blocks.ySize, blocks.zSize, 0,0,0, palette);
|
||||
}
|
||||
public Ruin(BlockArray blocks, double ruinLevel, Random rand, int xSize, int ySize, int zSize, int xOffset, int yOffset, int zOffset) {
|
||||
this (blocks, ruinLevel, rand, xSize, ySize, zSize, xOffset,yOffset,zOffset, new BlockRuinPalette());
|
||||
}
|
||||
public Ruin(BlockArray blocks, double ruinLevel, Random rand, int xSize, int ySize, int zSize, int xOffset, int yOffset, int zOffset, BlockRuinPalette palette) {
|
||||
this.blocks = blocks;
|
||||
this.ruinLevel = ruinLevel;
|
||||
this.rand = rand;
|
||||
this.palette = palette;
|
||||
|
||||
this.xSize = xSize;
|
||||
this.ySize = ySize;
|
||||
this.zSize = zSize;
|
||||
|
||||
this.xOffset = xOffset;
|
||||
this.yOffset = yOffset;
|
||||
this.zOffset = zOffset;
|
||||
|
||||
int volume = this.xSize * this.ySize * this.zSize;
|
||||
int breaks = (int) Math.ceil((volume/16.0) * ruinLevel);
|
||||
|
||||
for (int i=0; i<breaks; i++) {
|
||||
int x = rand.nextInt(this.xSize) - this.xOffset;
|
||||
int z = rand.nextInt(this.zSize) - this.zOffset;
|
||||
|
||||
double ylevel = 1 - (rand.nextDouble() * rand.nextDouble());
|
||||
|
||||
int y = (int) Math.round(ylevel * this.ySize) - this.yOffset;
|
||||
double rad = (6*rand.nextDouble() + 1)*ylevel*(0.1 + 0.9*ruinLevel) + 0.45 + (0.55*ruinLevel);
|
||||
|
||||
this.ruinArea(x, y, z, rad);
|
||||
}
|
||||
|
||||
this.disconnectionCheck();
|
||||
this.disconnectionCheck();
|
||||
}
|
||||
|
||||
|
||||
protected void dropBlock(int ox, int oy, int oz) {
|
||||
this.dropBlock(ox, oy, oz, 0);
|
||||
}
|
||||
protected void dropBlock(int ox, int oy, int oz, int initialdistance) {
|
||||
int x = ox;
|
||||
int y = oy;
|
||||
int z = oz;
|
||||
BlockMeta block = blocks.getBlock(x,y,z);
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
blocks.setBlock(ox,oy,oz, null);
|
||||
|
||||
int falldistance = initialdistance;
|
||||
|
||||
while(true) {
|
||||
BlockMeta below = blocks.getBlock(x,y-1,z);
|
||||
|
||||
if(blocks.outOfBounds(x,y-1,z)) {
|
||||
blocks.setBlock(x,y,z, block);
|
||||
break;
|
||||
}
|
||||
|
||||
if(below == null) {
|
||||
y--;
|
||||
falldistance++;
|
||||
} else {
|
||||
boolean slide = false;
|
||||
int slidedir = 0;
|
||||
List<Integer> falldirs = new ArrayList<Integer>();
|
||||
if (!blocks.outOfBounds(x-1,y,z) && blocks.getBlock(x-1,y,z) == null && blocks.getBlock(x-1,y-1,z) == null) {
|
||||
falldirs.add(0);
|
||||
}
|
||||
if (!blocks.outOfBounds(x+1,y,z) && blocks.getBlock(x+1,y,z) == null && blocks.getBlock(x+1,y-1,z) == null) {
|
||||
falldirs.add(1);
|
||||
}
|
||||
if (!blocks.outOfBounds(x,y,z-1) && blocks.getBlock(x,y,z-1) == null && blocks.getBlock(x,y-1,z-1) == null) {
|
||||
falldirs.add(2);
|
||||
}
|
||||
if (!blocks.outOfBounds(x,y,z+1) && blocks.getBlock(x,y,z+1) == null && blocks.getBlock(x,y-1,z+1) == null) {
|
||||
falldirs.add(3);
|
||||
}
|
||||
|
||||
if (!falldirs.isEmpty()) {
|
||||
slide = true;
|
||||
slidedir = falldirs.get(rand.nextInt(falldirs.size()));
|
||||
}
|
||||
|
||||
if (slide) {
|
||||
impact(x,y-1,z, falldistance/4, block);
|
||||
if (slidedir == 0) {
|
||||
x--;
|
||||
} else if (slidedir == 1) {
|
||||
x++;
|
||||
} else if (slidedir == 2) {
|
||||
z--;
|
||||
} else {
|
||||
z++;
|
||||
}
|
||||
} else {
|
||||
BlockPaletteInfo blockinfo = this.palette.get(block);
|
||||
double breakchance = fallBreakChance(falldistance) * blockinfo.breakchance;
|
||||
if (rand.nextDouble() <= breakchance) {
|
||||
blocks.setBlock(x,y,z,blockinfo.broken);
|
||||
} else {
|
||||
if (blockinfo.hardness >= 1) {
|
||||
blocks.setBlock(x,y,z,block);
|
||||
}
|
||||
}
|
||||
impact(x,y-1,z, falldistance, block);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void impact(int x, int y, int z, int falldistance, BlockMeta fallingblock) {
|
||||
BlockMeta block = blocks.getBlock(x,y,z);
|
||||
BlockPaletteInfo blockinfo = this.palette.get(block);
|
||||
double smashchance = fallBreakChance(falldistance) * blockinfo.smashchance;
|
||||
|
||||
if (rand.nextDouble() <= smashchance) {
|
||||
blocks.setBlock(x,y,z, null);
|
||||
dropBlock(x,y+1,z, falldistance/3);
|
||||
}
|
||||
|
||||
double breakchance = fallBreakChance(falldistance) * blockinfo.breakchance;
|
||||
if (blocks.getBlock(x,y-1,z) != null) {
|
||||
breakchance *= 0.75;
|
||||
}
|
||||
|
||||
if (rand.nextDouble() <= breakchance) {
|
||||
if (blockinfo.broken != null) {
|
||||
blocks.setBlock(x,y,z, blockinfo.broken);
|
||||
impact(x,y,z, falldistance/2, fallingblock);
|
||||
} else {
|
||||
dropBlock(x,y,z);
|
||||
dropBlock(x,y+1,z, falldistance/3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void ruinArea(int ox, int oy, int oz, double radius) {
|
||||
int range = (int)Math.ceil(radius*2);
|
||||
int offset = range/2;
|
||||
|
||||
for (int y = 0; y<=range; y++) {
|
||||
List<Coord> coords = new ArrayList<Coord>();
|
||||
for (int x = 0; x<=range; x++) {
|
||||
if (x < 0 || x >= blocks.xSize) {
|
||||
continue;
|
||||
}
|
||||
for (int z = 0; z<=range; z++) {
|
||||
if (z < 0 || z >= blocks.zSize) {
|
||||
continue;
|
||||
}
|
||||
BlockMeta block = blocks.getBlock(ox+x-offset,oy+y-offset,oz+z-offset);
|
||||
if (block == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockPaletteInfo blockinfo = this.palette.get(block);
|
||||
|
||||
double rx = (x - range/2);
|
||||
double ry = (y - range/2);
|
||||
double rz = (z - range/2);
|
||||
|
||||
double dist = Math.sqrt(rx*rx+ry*ry+rz*rz) / radius;
|
||||
if(dist <= 1.0) {
|
||||
if (dist > .75) {
|
||||
double dchance = (dist - 0.75)*4;
|
||||
if (rand.nextDouble() > dchance) {
|
||||
coords.add(new Coord(x,y,z));
|
||||
} else if (blockinfo.broken != null || blockinfo.hardness < 1) {
|
||||
blocks.setBlock(ox+x-offset,oy+y-offset,oz+z-offset,blockinfo.broken);
|
||||
}
|
||||
} else {
|
||||
coords.add(new Coord(x,y,z));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.shuffle(coords, rand);
|
||||
for (int i=0; i<coords.size(); i++) {
|
||||
Coord c = coords.get(i);
|
||||
dropBlock(ox + c.x - range/2, oy + c.y - range/2, oz + c.z - range/2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void disconnectionCheck() {
|
||||
int ox = blocks.xSize/2;
|
||||
int oz = blocks.zSize/2;
|
||||
|
||||
boolean[] connected = new boolean[this.blocks.length];
|
||||
List<Coord> open = new ArrayList<Coord>();
|
||||
open.add(new Coord(ox,0,oz));
|
||||
|
||||
while(!open.isEmpty()) {
|
||||
Coord c = open.remove(open.size()-1);
|
||||
if (!blocks.outOfBounds(c.x, c.y, c.z) && blocks.getBlock(c.x, c.y, c.z) != null) {
|
||||
connected[blocks.index(c.x,c.y,c.z)] = true;
|
||||
|
||||
if(!blocks.outOfBounds(c.x-1, c.y, c.z) && blocks.getBlock(c.x-1, c.y, c.z) != null && connected[blocks.index(c.x-1,c.y,c.z)] == false) {
|
||||
open.add(new Coord(c.x-1,c.y,c.z));
|
||||
}
|
||||
if(!blocks.outOfBounds(c.x+1, c.y, c.z) && blocks.getBlock(c.x+1, c.y, c.z) != null && connected[blocks.index(c.x+1,c.y,c.z)] == false) {
|
||||
open.add(new Coord(c.x+1,c.y,c.z));
|
||||
}
|
||||
if(!blocks.outOfBounds(c.x, c.y, c.z-1) && blocks.getBlock(c.x, c.y, c.z-1) != null && connected[blocks.index(c.x,c.y,c.z-1)] == false) {
|
||||
open.add(new Coord(c.x,c.y,c.z-1));
|
||||
}
|
||||
if(!blocks.outOfBounds(c.x, c.y, c.z+1) && blocks.getBlock(c.x, c.y, c.z+1) != null && connected[blocks.index(c.x,c.y,c.z+1)] == false) {
|
||||
open.add(new Coord(c.x,c.y,c.z+1));
|
||||
}
|
||||
if(!blocks.outOfBounds(c.x, c.y-1, c.z) && blocks.getBlock(c.x, c.y-1, c.z) != null && connected[blocks.index(c.x,c.y-1,c.z)] == false) {
|
||||
open.add(new Coord(c.x,c.y-1,c.z));
|
||||
}
|
||||
if(!blocks.outOfBounds(c.x, c.y+1, c.z) && blocks.getBlock(c.x, c.y+1, c.z) != null && connected[blocks.index(c.x,c.y+1,c.z)] == false) {
|
||||
open.add(new Coord(c.x,c.y+1,c.z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int y = 0; y<=blocks.ySize; y++) {
|
||||
List<Coord> coords = new ArrayList<Coord>();
|
||||
for (int x = 0; x<=blocks.xSize; x++) {
|
||||
for (int z = 0; z<=blocks.zSize; z++) {
|
||||
if (blocks.getBlock(x,y,z) != null && !connected[blocks.index(x,y,z)]) {
|
||||
coords.add(new Coord(x,y,z));
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.shuffle(coords, rand);
|
||||
for (int i=0; i<coords.size(); i++) {
|
||||
Coord c = coords.get(i);
|
||||
dropBlock(c.x,c.y,c.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected double fallBreakChance(int distance) {
|
||||
double maxdist = 2;
|
||||
return Math.min(distance, maxdist) / maxdist;
|
||||
}
|
||||
|
||||
// #################################################################################
|
||||
// Utility Classes
|
||||
// #################################################################################
|
||||
public static class BlockArray {
|
||||
public BlockMeta[] blocks;
|
||||
public int xSize;
|
||||
public int ySize;
|
||||
public int zSize;
|
||||
public int length;
|
||||
|
||||
public BlockArray(int xSize, int ySize, int zSize) {
|
||||
this.length = xSize*ySize*zSize;
|
||||
this.blocks = new BlockMeta[this.length];
|
||||
this.xSize = xSize;
|
||||
this.ySize = ySize;
|
||||
this.zSize = zSize;
|
||||
}
|
||||
|
||||
public boolean outOfBounds(int x, int y, int z) {
|
||||
return (x<0||x>=xSize||y<0||y>=ySize||z<0||z>=zSize);
|
||||
}
|
||||
|
||||
public void setBlock(int x, int y, int z, BlockMeta block) {
|
||||
if (outOfBounds(x,y,z)) {
|
||||
return;
|
||||
}
|
||||
|
||||
blocks[index(x,y,z)] = block;
|
||||
}
|
||||
|
||||
public BlockMeta getBlock(int x, int y, int z) {
|
||||
if (outOfBounds(x,y,z)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return blocks[index(x,y,z)];
|
||||
}
|
||||
|
||||
public void fillBlocks(int x, int y, int z, int x2, int y2, int z2, BlockMeta block) {
|
||||
for (int ix = x; ix<=x2; ix++) {
|
||||
for (int iy = y; iy<=y2; iy++) {
|
||||
for (int iz = z; iz<=z2; iz++) {
|
||||
setBlock(ix,iy,iz, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected int index(int x, int y, int z) {
|
||||
return y * zSize * xSize + z * xSize + x;
|
||||
}
|
||||
}
|
||||
|
||||
public static class BlockMeta {
|
||||
public Block block;
|
||||
public byte meta;
|
||||
|
||||
public BlockMeta(Block block, int meta) {
|
||||
this.block = block;
|
||||
this.meta = (byte)(meta & 0xFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.block.toString()+"#"+this.meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.block.hashCode() + this.meta;
|
||||
}
|
||||
}
|
||||
|
||||
public static class BlockRuinPalette {
|
||||
protected Map<BlockMeta, BlockPaletteInfo> infomap = new HashMap<BlockMeta, BlockPaletteInfo>();
|
||||
|
||||
public BlockPaletteInfo get(BlockMeta block) {
|
||||
if (infomap.containsKey(block)) {
|
||||
return infomap.get(block);
|
||||
}
|
||||
return BlockPaletteInfo.DEFAULT;
|
||||
}
|
||||
|
||||
public void set(BlockMeta block, double hardness, double breakchance, double smashchance) {
|
||||
this.set(block, hardness, breakchance, smashchance, null);
|
||||
}
|
||||
public void set(BlockMeta block, double hardness, double breakchance, double smashchance, BlockMeta broken) {
|
||||
infomap.put(block, new BlockPaletteInfo(hardness, breakchance, smashchance, broken));
|
||||
}
|
||||
|
||||
public static class BlockPaletteInfo {
|
||||
public static final BlockPaletteInfo DEFAULT = new BlockPaletteInfo(1.0, 0.2, 0.2, null);
|
||||
|
||||
public final double hardness;
|
||||
public final double breakchance;
|
||||
public final double smashchance;
|
||||
public final BlockMeta broken;
|
||||
|
||||
public BlockPaletteInfo(double hardness, double breakchance, double smashchance, BlockMeta broken) {
|
||||
this.hardness = hardness;
|
||||
this.breakchance = breakchance;
|
||||
this.smashchance = smashchance;
|
||||
this.broken = broken;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// #################################################################################
|
||||
// Internal Classes
|
||||
// #################################################################################
|
||||
protected static class Coord {
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
|
||||
public Coord(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package fox.spiteful.avaritia.compat.botania.alfheim;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
public class TeleportHelper {
|
||||
public static void travelToDimension(Entity ent, int x, int y, int z, int dim){
|
||||
if(ent instanceof EntityPlayerMP){
|
||||
MinecraftServer minecraftserver = MinecraftServer.getServer();
|
||||
WorldServer newWorldServer = minecraftserver.worldServerForDimension(dim);
|
||||
minecraftserver.getConfigurationManager().transferPlayerToDimension((EntityPlayerMP)ent, dim, new BasicTeleporter(newWorldServer));
|
||||
((EntityPlayer)ent).setPositionAndUpdate(x+0.5, y+0.5, z+0.5);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!ent.worldObj.isRemote && !ent.isDead)
|
||||
{
|
||||
ent.worldObj.theProfiler.startSection("changeDimension");
|
||||
MinecraftServer minecraftserver = MinecraftServer.getServer();
|
||||
int j = ent.dimension;
|
||||
WorldServer worldserver = minecraftserver.worldServerForDimension(j);
|
||||
WorldServer worldserver1 = minecraftserver.worldServerForDimension(dim);
|
||||
ent.dimension = dim;
|
||||
|
||||
if (j == 1 && dim == 1)
|
||||
{
|
||||
worldserver1 = minecraftserver.worldServerForDimension(0);
|
||||
ent.dimension = 0;
|
||||
}
|
||||
|
||||
ent.worldObj.removeEntity(ent);
|
||||
ent.isDead = false;
|
||||
ent.worldObj.theProfiler.startSection("reposition");
|
||||
minecraftserver.getConfigurationManager().transferEntityToWorld(ent, j, worldserver, worldserver1);
|
||||
ent.worldObj.theProfiler.endStartSection("reloading");
|
||||
Entity entity = EntityList.createEntityByName(EntityList.getEntityString(ent), worldserver1);
|
||||
|
||||
if (entity != null)
|
||||
{
|
||||
entity.copyDataFrom(ent, true);
|
||||
|
||||
if (j == 1 && dim == 1)
|
||||
{
|
||||
entity.setLocationAndAngles(x+0.5, y+0.5, z+0.5, entity.rotationYaw, entity.rotationPitch);
|
||||
}
|
||||
|
||||
worldserver1.spawnEntityInWorld(entity);
|
||||
entity.setPosition(x+0.5, y+0.5, z+0.5);
|
||||
}
|
||||
|
||||
ent.isDead = true;
|
||||
ent.worldObj.theProfiler.endSection();
|
||||
worldserver.resetUpdateEntityTick();
|
||||
worldserver1.resetUpdateEntityTick();
|
||||
ent.worldObj.theProfiler.endSection();
|
||||
}
|
||||
}
|
||||
|
||||
public static void travelToOrFromAlfheim(EntityPlayer player) {
|
||||
if (DimensionManager.getWorld(0) == player.worldObj) {
|
||||
// overworld to alfheim
|
||||
travelToDimension(player, 0, 85, 0, WorldProviderAlfheim.dimensionID);
|
||||
} else {
|
||||
// alfheim to overworld
|
||||
sendPlayerHome(player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendPlayerHome(EntityPlayer player) {
|
||||
World world = DimensionManager.getWorld(0);
|
||||
ChunkCoordinates coord = player.getBedLocation(0);
|
||||
|
||||
if (coord == null) {
|
||||
coord = world.getSpawnPoint();
|
||||
}
|
||||
|
||||
coord = forceLocation(world, coord);
|
||||
|
||||
if (coord == null) {
|
||||
coord = world.getSpawnPoint();
|
||||
}
|
||||
|
||||
travelToDimension(player, coord.posX, coord.posY, coord.posZ, 0);
|
||||
|
||||
while (!world.getCollidingBoundingBoxes(player, player.boundingBox).isEmpty())
|
||||
{
|
||||
player.setPositionAndUpdate(player.posX, player.posY + 1.0D, player.posZ);
|
||||
}
|
||||
}
|
||||
|
||||
public static ChunkCoordinates forceLocation(World world, ChunkCoordinates coord) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package fox.spiteful.avaritia.compat.botania.alfheim;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import fox.spiteful.avaritia.FieldHelper;
|
||||
import fox.spiteful.avaritia.Lumberjack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.Timer;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.WorldProvider;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.biome.WorldChunkManagerHell;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
|
||||
public class WorldProviderAlfheim extends WorldProvider {
|
||||
|
||||
public static int dimensionID = 13;
|
||||
|
||||
@Override
|
||||
public void registerWorldChunkManager()
|
||||
{
|
||||
this.worldChunkMgr = new WorldChunkManagerHell(BiomeGenBase.hell, 0.0F);
|
||||
this.isHellWorld = true;
|
||||
this.hasNoSky = false;
|
||||
if(FMLCommonHandler.instance().getSide().isClient()) {
|
||||
this.setCloudRenderer(new ApocalypseCloudRenderer());
|
||||
this.setSkyRenderer(new ApocalypseSkyRenderer());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Vec3D with biome specific fog color
|
||||
*/
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Vec3 getFogColor(float p_76562_1_, float p_76562_2_)
|
||||
{
|
||||
/*double r = 0.1;
|
||||
double g = 0.04;
|
||||
double b = 0;
|
||||
|
||||
double nr = 1.0;
|
||||
double ng = 0.5;
|
||||
double nb = 0.0;
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
Timer t = FieldHelper.get(AlfheimEvents.mcTimerField, mc);
|
||||
float partialTicks = t.renderPartialTicks;
|
||||
|
||||
float n = FieldHelper.invoke(AlfheimEvents.getNightVisionBrightnessMethod, mc.entityRenderer, mc.thePlayer, partialTicks);
|
||||
double notn = 1.0 - n;
|
||||
|
||||
return Vec3.createVectorHelper(n*nr + notn*r, n*ng + notn*g, n*nb + notn*b);*/
|
||||
return Vec3.createVectorHelper(0.1, 0.04, 0.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new chunk provider which generates chunks for this world
|
||||
*/
|
||||
@Override
|
||||
public IChunkProvider createChunkGenerator()
|
||||
{
|
||||
return new ChunkProviderAlfheim(this.worldObj, this.worldObj.getSeed());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 'true' if in the "main surface world", but 'false' if in the Nether or End dimensions.
|
||||
*/
|
||||
@Override
|
||||
public boolean isSurfaceWorld()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will check if the x, z position specified is alright to be set as the map spawn point
|
||||
*/
|
||||
@Override
|
||||
public boolean canCoordinateBeSpawn(int x, int z)
|
||||
{
|
||||
return true; // need to improve
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the angle of sun and moon in the sky relative to a specified time (usually worldTime)
|
||||
*/
|
||||
@Override
|
||||
public float calculateCelestialAngle(long tick, float partialTick)
|
||||
{
|
||||
return 1f;//0.425F;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if the player can respawn in this dimension (true = overworld, false = nether).
|
||||
*/
|
||||
@Override
|
||||
public boolean canRespawnHere()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given X,Z coordinate should show environmental fog.
|
||||
*/
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean doesXZShowFog(int x, int z)
|
||||
{
|
||||
return false;
|
||||
//return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDimensionName() {
|
||||
return "Alfheim Eternal";
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSunBrightnessFactor(float par1)
|
||||
{
|
||||
return 0.6f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkCoordinates getEntrancePortalLocation()
|
||||
{
|
||||
return new ChunkCoordinates(0, 85, 0);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import fox.spiteful.avaritia.Avaritia;
|
||||
import fox.spiteful.avaritia.compat.botania.alfheim.TeleportHelper;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -41,4 +42,25 @@ public class ItemMorvInABox extends Item {
|
||||
this.nameoverlay = ir.registerIcon("avaritia:morvinabox2");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
/*//if (world.isRemote) {
|
||||
Lumberjack.info("DESTROY SPACE");
|
||||
WorldProvider p = world.provider;//DimensionManager.getProvider(0);
|
||||
Lumberjack.info(p);
|
||||
p.setSkyRenderer(new ApocalypseSkyRenderer());
|
||||
p.setCloudRenderer(new ApocalypseCloudRenderer());
|
||||
Lumberjack.info(p.getCloudRenderer());
|
||||
//}*/
|
||||
/*if (DimensionManager.getWorld(0) == world) {
|
||||
player.travelToDimension(13);
|
||||
} else {
|
||||
player.travelToDimension(0);
|
||||
}*/
|
||||
|
||||
TeleportHelper.travelToOrFromAlfheim(player);
|
||||
return stack;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user