1
0
mirror of https://github.com/chylex/Hardcore-Ender-Expansion.git synced 2025-04-14 05:15:42 +02:00

TODOs, Energy regen, Blob debug test

This commit is contained in:
chylex 2014-11-08 13:10:30 +01:00
parent d9fa641b94
commit 6866e30eb0
7 changed files with 57 additions and 56 deletions

View File

@ -13,6 +13,8 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import chylex.hee.entity.fx.EntityEnergyClusterFX;
import chylex.hee.system.savedata.WorldDataHandler;
import chylex.hee.system.savedata.types.EnergySavefile;
import chylex.hee.system.util.DragonUtil;
import chylex.hee.system.util.MathUtil;
import chylex.hee.tileentity.TileEntityEnergyCluster;
@ -140,7 +142,7 @@ public class BlockEnergyCluster extends BlockContainer{
DragonUtil.createExplosion(world,x+0.5D,y+0.5D,z+0.5D,2.8F+(energyMeta-3)*0.225F,true);
// TODO return some to environment
WorldDataHandler.<EnergySavefile>get(EnergySavefile.class).getFromBlockCoords(x,z,true).addEnergy(tile.data.getEnergyLevel()*0.2F);
for(int xx = x-4; xx <= x+4; xx++){
for(int zz = z-4; zz <= z+4; zz++){

View File

@ -137,6 +137,11 @@ public final class FXHandler{
for(int a = 0; a < 25; a++)HardcoreEnderExpansion.fx.omnipresent("smoke",world,x+randCenter(width),y+rand.nextDouble()*height,z+randCenter(width),randCenter(0.05D),randCenter(0.05D),randCenter(0.05D));
for(int a = 0; a < 8; a++)HardcoreEnderExpansion.fx.omnipresent("largesmoke",world,x+randCenter(width),y+rand.nextDouble()*height,z+randCenter(width),randCenter(0.05D),randCenter(0.05D),randCenter(0.05D));
break;
case BABY_ENDERMAN_GROW:
for(int a = 0; a < 20; a++)HardcoreEnderExpansion.fx.omnipresent("smoke",world,x+randCenter(width),y+rand.nextDouble()*height,z+randCenter(width),randCenter(0.05D),randCenter(0.05D),randCenter(0.05D));
for(int a = 0; a < 20; a++)HardcoreEnderExpansion.fx.omnipresent("portal",world,x+randCenter(width),y+rand.nextDouble()*height,z+randCenter(width),randCenter(0.1D),randCenter(0.1D),randCenter(0.1D));
break;
}
}

View File

@ -27,7 +27,8 @@ public final class FXType{
GEM_TELEPORT_FROM,
ORB_TRANSFORMATION,
LOUSE_REGEN,
HOMELAND_ENDERMAN_RECRUIT;
HOMELAND_ENDERMAN_RECRUIT,
BABY_ENDERMAN_GROW;
public static FXType.Entity[] values = values();
}

View File

@ -1,15 +1,17 @@
package chylex.hee.mechanics.energy;
import java.util.Random;
import chylex.hee.system.util.MathUtil;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import chylex.hee.block.BlockList;
import chylex.hee.system.util.MathUtil;
public class EnergyChunkData{
public static final float minSignificantEnergy = 0.0001F;
public static final float energyDrainUnit = 0.05F;
private int x, z;
private float energyLevel, maxEnergyLevel, regenLimiter;
private byte regenTimer;
private float energyLevel, maxEnergyLevel;
private byte regenTimer, releaseTimer;
private EnergyChunkData(){}
@ -24,10 +26,19 @@ public class EnergyChunkData{
energyLevel = maxEnergyLevel-maxEnergyLevel*rand.nextFloat()*rand.nextFloat();
}
public void onUpdate(Random rand){
if (regenLimiter > 0F && (regenTimer == 0 || --regenTimer == 0)){
regenLimiter = regenLimiter < 0.05F ? 0F : regenLimiter*0.85F;
regenTimer = 3; // 0.6 seconds
public void onUpdate(World world, Random rand){
if ((regenTimer == 0 || --regenTimer == 0) && energyLevel < maxEnergyLevel){
regenTimer = (byte)(8+rand.nextInt(12+rand.nextInt(6))+(int)Math.floor((16F*energyLevel/maxEnergyLevel)+maxEnergyLevel*0.2F));
}
if ((energyLevel > maxEnergyLevel || (energyLevel > maxEnergyLevel*0.8F && rand.nextInt(10) == 0)) && (releaseTimer == 0 || --releaseTimer == 0)){
float release = (0.2F+rand.nextFloat()*0.5F)*maxEnergyLevel*0.0625F;
if (energyLevel < release)release = energyLevel; // precaution
energyLevel -= release;
releaseTimer = (byte)(4+rand.nextInt(7));
world.setBlock(x+rand.nextInt(16),8+rand.nextInt(116),z+rand.nextInt(16),BlockList.corrupted_energy_low,Math.min(Math.max(2,(int)Math.floor(1F+release*12F)),8),3);
}
}
@ -42,18 +53,9 @@ public class EnergyChunkData{
}
}
public float tryRegenerate(float amount){
float maxRegen = maxEnergyLevel*0.0625F;
float regen = Math.min(amount,maxEnergyLevel-energyLevel);
if (regenLimiter+regen > maxRegen)regen = maxRegen-regenLimiter;
if (regen <= minSignificantEnergy)return amount;
energyLevel += regen;
regenLimiter += regen;
regenTimer = 10; // 2 seconds
return MathUtil.floatEquals(regen,amount) ? 0F : amount-regen;
public void addEnergy(float amount){
if (energyLevel+amount <= maxEnergyLevel*2)energyLevel += amount;
else energyLevel = maxEnergyLevel*2;
}
public boolean drainEnergyUnit(){
@ -96,9 +98,10 @@ public class EnergyChunkData{
public NBTTagCompound saveToNBT(){
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("x",x);
tag.setInteger("z",z);
tag.setFloat("lvl",energyLevel);
tag.setFloat("max",maxEnergyLevel);
tag.setFloat("lim",regenLimiter);
return tag;
}
@ -107,8 +110,7 @@ public class EnergyChunkData{
data.x = nbt.getInteger("x");
data.z = nbt.getInteger("z");
data.energyLevel = nbt.getFloat("lvl");
data.maxEnergyLevel = nbt.getFloat("max");
data.regenLimiter = nbt.getFloat("lim");
if (MathUtil.floatEquals(data.maxEnergyLevel = nbt.getFloat("max"),0F))data.maxEnergyLevel = minSignificantEnergy;
return data;
}
}

View File

@ -39,7 +39,7 @@ public final class EnergyEvents{
EnergyChunkData data = file.getFromChunkCoords(chunk.xPosition,chunk.zPosition,true);
if (usedData.contains(data))continue;
data.onUpdate(e.world.rand);
data.onUpdate(e.world,e.world.rand);
for(int a = 0; a < 4; a++){
data.onAdjacentInteract(e.world.rand,file.getFromChunkCoords(chunk.xPosition+Direction.offsetX[a]*EnergySavefile.sectionSize,chunk.zPosition+Direction.offsetZ[a]*EnergySavefile.sectionSize,true));
@ -59,12 +59,7 @@ public final class EnergyEvents{
float energy = MobEnergy.getEnergy(e.entityLiving);
if (MathUtil.floatEquals(energy,-1F))return;
EnergyChunkData data = WorldDataHandler.<EnergySavefile>get(EnergySavefile.class).getFromBlockCoords((int)Math.floor(e.entity.posX),(int)Math.floor(e.entity.posZ),true);
energy = data.tryRegenerate(energy);
if (energy > EnergyChunkData.minSignificantEnergy){
// TODO leak corrupted energy
}
WorldDataHandler.<EnergySavefile>get(EnergySavefile.class).getFromBlockCoords((int)Math.floor(e.entity.posX),(int)Math.floor(e.entity.posZ),true).addEnergy(energy);
}
private byte updateTimer;

View File

@ -6,7 +6,6 @@ import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import org.apache.commons.lang3.tuple.Pair;
import chylex.hee.system.commands.HeeDebugCommand.HeeTest;
import chylex.hee.system.logging.Log;
import chylex.hee.system.weight.ObjectWeightPair;
import chylex.hee.system.weight.WeightedList;
import chylex.hee.world.feature.blobs.BlobGenerator;
@ -34,36 +33,16 @@ public class WorldGenBlob extends WorldGenerator{
});
}
private DecoratorFeatureGenerator gen = new DecoratorFeatureGenerator();
@Override
public boolean generate(World world, Random rand, int x, int y, int z){
if (Log.isDeobfEnvironment){ // TODO remove debug
BlobType.COMMON.patterns.clear();
BlobType.COMMON.patterns.addAll(new BlobPattern[]{
new BlobPattern(10).addGenerators(new BlobGenerator[]{
}).addPopulators(new BlobPopulator[]{
}).setPopulatorAmountProvider(IRandomAmount.linear,1,5)
});
Pair<BlobGenerator,List<BlobPopulator>> pattern = BlobType.COMMON.patterns.getRandomItem(rand).generatePattern(rand);
pattern.getLeft().generate(gen,rand);
for(BlobPopulator populator:pattern.getRight())populator.generate(gen,rand);
gen.generate(world,rand,x,y,z);
return true;
}
if (world.getBlock(x-8,y,z) != Blocks.air ||
world.getBlock(x+8,y,z) != Blocks.air ||
world.getBlock(x,y,z-8) != Blocks.air ||
world.getBlock(x,y,z+8) != Blocks.air ||
world.getBlock(x,y-8,z) != Blocks.air ||
world.getBlock(x,y+8,z) != Blocks.air)return false;
DecoratorFeatureGenerator gen = new DecoratorFeatureGenerator();
Pair<BlobGenerator,List<BlobPopulator>> pattern = types.getRandomItem(rand).getObject().patterns.getRandomItem(rand).generatePattern(rand);
@ -77,7 +56,21 @@ public class WorldGenBlob extends WorldGenerator{
public static final HeeTest $debugTest = new HeeTest(){
@Override
public void run(){
new WorldGenBlob().generate(world,world.rand,(int)player.posX+10,(int)player.posY,(int)player.posZ);
WeightedList<BlobPattern> patterns = new WeightedList<>(new BlobPattern[]{
new BlobPattern(10).addGenerators(new BlobGenerator[]{
}).addPopulators(new BlobPopulator[]{
}).setPopulatorAmountProvider(IRandomAmount.linear,1,5)
});
DecoratorFeatureGenerator gen = new DecoratorFeatureGenerator();
Pair<BlobGenerator,List<BlobPopulator>> pattern = patterns.getRandomItem(world.rand).generatePattern(world.rand);
pattern.getLeft().generate(gen,world.rand);
for(BlobPopulator populator:pattern.getRight())populator.generate(gen,world.rand);
gen.generate(world,world.rand,(int)player.posX+10,(int)player.posY,(int)player.posZ);
}
};
}

View File

@ -7,11 +7,14 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
import chylex.hee.block.BlockEndstoneTerrain;
import chylex.hee.entity.fx.FXType;
import chylex.hee.entity.mob.EntityMobBabyEnderman;
import chylex.hee.entity.mob.EntityMobEnderGuardian;
import chylex.hee.entity.mob.EntityMobEndermage;
import chylex.hee.entity.mob.EntityMobHomelandEnderman;
import chylex.hee.mechanics.misc.HomelandEndermen.HomelandRole;
import chylex.hee.packets.PacketPipeline;
import chylex.hee.packets.client.C21EffectEntity;
import chylex.hee.world.structure.island.ComponentIsland;
import chylex.hee.world.structure.island.biome.data.AbstractBiomeInteraction.BiomeInteraction;
import chylex.hee.world.structure.island.biome.data.BiomeContentVariation;
@ -91,7 +94,7 @@ public class IslandBiomeEnchantedIsland extends IslandBiomeBase{
grown.setHomelandRole(HomelandRole.getRandomRole(world.rand));
world.spawnEntityInWorld(grown);
// TODO particles
PacketPipeline.sendToAllAround(grown,64D,new C21EffectEntity(FXType.Entity.BABY_ENDERMAN_GROW,grown));
}
break;