Skip to content

Commit

Permalink
dimension and entity packages
Browse files Browse the repository at this point in the history
  • Loading branch information
tterrag1098 committed Feb 16, 2014
1 parent b0761a6 commit 09be750
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 46 deletions.
3 changes: 2 additions & 1 deletion src/main/java/mods/natura/dimension/NetheriteChunk.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package mods.natura.dimension;

import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
Expand Down Expand Up @@ -30,7 +31,7 @@ public NetheriteChunk(World world, byte[] lowerIDs, int chunkX, int chunkZ)
storage[k1] = new ExtendedBlockStorage(k1 << 4, !world.provider.hasNoSky);
}

storage[k1].setExtBlockID(x, y & 15, z, id);
storage[k1].func_150818_a(x, y & 15, z, Block.getBlockById(id));
}
}
}
Expand Down
61 changes: 32 additions & 29 deletions src/main/java/mods/natura/dimension/NetheriteChunkProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.MapGenBase;
import net.minecraft.world.gen.MapGenCavesHell;
import net.minecraft.world.gen.NoiseGenerator;
import net.minecraft.world.gen.NoiseGeneratorOctaves;
import net.minecraft.world.gen.feature.WorldGenGlowStone1;
import net.minecraft.world.gen.feature.WorldGenGlowStone2;
Expand Down Expand Up @@ -101,15 +102,16 @@ public NetheriteChunkProvider(World par1World, long par2)
this.netherNoiseGen4 = new NoiseGeneratorOctaves(this.hellRNG, 10);
this.netherNoiseGen5 = new NoiseGeneratorOctaves(this.hellRNG, 16);

NoiseGeneratorOctaves[] noiseGens = { netherNoiseGen1, netherNoiseGen2, netherNoiseGen3, slowsandGravelNoiseGen, netherrackExculsivityNoiseGen, netherNoiseGen4, netherNoiseGen5 };
// TODO 1.7 check these casts somehow
NoiseGenerator[] noiseGens = { netherNoiseGen1, netherNoiseGen2, netherNoiseGen3, slowsandGravelNoiseGen, netherrackExculsivityNoiseGen, netherNoiseGen4, netherNoiseGen5 };
noiseGens = TerrainGen.getModdedNoiseGenerators(par1World, this.hellRNG, noiseGens);
this.netherNoiseGen1 = noiseGens[0];
this.netherNoiseGen2 = noiseGens[1];
this.netherNoiseGen3 = noiseGens[2];
this.slowsandGravelNoiseGen = noiseGens[3];
this.netherrackExculsivityNoiseGen = noiseGens[4];
this.netherNoiseGen4 = noiseGens[5];
this.netherNoiseGen5 = noiseGens[6];
this.netherNoiseGen1 = (NoiseGeneratorOctaves) noiseGens[0];
this.netherNoiseGen2 = (NoiseGeneratorOctaves) noiseGens[1];
this.netherNoiseGen3 = (NoiseGeneratorOctaves) noiseGens[2];
this.slowsandGravelNoiseGen = (NoiseGeneratorOctaves) noiseGens[3];
this.netherrackExculsivityNoiseGen = (NoiseGeneratorOctaves) noiseGens[4];
this.netherNoiseGen4 = (NoiseGeneratorOctaves) noiseGens[5];
this.netherNoiseGen5 = (NoiseGeneratorOctaves) noiseGens[6];
}

/**
Expand Down Expand Up @@ -175,7 +177,7 @@ public void generateNetherTerrain (int chunkX, int chunkZ, byte[] lowerIDs)
blockID = NContent.taintedSoil;
}

lowerIDs[layerPos] = (byte) blockID;
lowerIDs[layerPos] = (byte) Block.getIdFromBlock(blockID);
layerPos += amountPerLayer;
lValue += lOffset;
}
Expand All @@ -194,7 +196,8 @@ public void generateNetherTerrain (int chunkX, int chunkZ, byte[] lowerIDs)
}
}

public void replaceBlocksForBiome (int par1, int par2, byte[] lowerIDs)
// TODO 1.7 probably wrong. Gotta do something with the Block[]. This may or may not leave giant empty holes in the terain
public void replaceBlocksForBiome (int par1, int par2, Block[] blocks, byte[] lowerIDs)
{
//Lower nether
byte seaLevel = 64;
Expand All @@ -211,8 +214,8 @@ public void replaceBlocksForBiome (int par1, int par2, byte[] lowerIDs)
boolean flag1 = this.gravelNoise[iterX + iterZ * 16] + this.hellRNG.nextDouble() * 0.2D > 0.0D;
int i1 = (int) (this.netherrackExclusivityNoise[iterX + iterZ * 16] / 3.0D + 3.0D + this.hellRNG.nextDouble() * 0.25D);
int j1 = -1;
byte b1 = (byte) Blocks.netherrack;
byte b2 = (byte) NContent.taintedSoil;
byte b1 = (byte) Block.getIdFromBlock(Blocks.netherrack);
byte b2 = (byte) Block.getIdFromBlock(NContent.taintedSoil);

for (int k1 = 127; k1 >= 0; --k1)
{
Expand All @@ -226,44 +229,44 @@ public void replaceBlocksForBiome (int par1, int par2, byte[] lowerIDs)
{
j1 = -1;
}
else if (b3 == Blocks.netherrack)
else if (b3 == Block.getIdFromBlock(Blocks.netherrack))
{
if (j1 == -1)
{
if (i1 <= 0)
{
b1 = 0;
b2 = (byte) Blocks.netherrack;
b2 = (byte) Block.getIdFromBlock(Blocks.netherrack);
}
else if (k1 >= seaLevel - 4 && k1 <= seaLevel + 1)
{
b1 = (byte) Blocks.netherrack;
b2 = (byte) NContent.taintedSoil;
b1 = (byte) Block.getIdFromBlock(Blocks.netherrack);
b2 = (byte) Block.getIdFromBlock(NContent.taintedSoil);

if (flag1)
{
b1 = (byte) Blocks.gravel;
b1 = (byte) Block.getIdFromBlock(Blocks.gravel);
}

if (flag1)
{
b2 = (byte) Blocks.netherrack;
b2 = (byte) Block.getIdFromBlock(Blocks.netherrack);
}

if (flag)
{
b1 = (byte) Blocks.soul_sand;
b1 = (byte) Block.getIdFromBlock(Blocks.soul_sand);
}

if (flag)
{
b2 = (byte) NContent.heatSand;
b2 = (byte) Block.getIdFromBlock(NContent.heatSand);
}
}

if (k1 < seaLevel && b1 == 0)
{
b1 = (byte) Blocks.lava;
b1 = (byte) Block.getIdFromBlock(Blocks.lava);
}

j1 = i1;
Expand All @@ -286,7 +289,7 @@ else if (j1 > 0)
}
else
{
lowerIDs[l1] = (byte) Blocks.bedrock;
lowerIDs[l1] = (byte) Block.getIdFromBlock(Blocks.bedrock);
}
}
}
Expand All @@ -309,11 +312,12 @@ public Chunk provideChunk (int chunkX, int chunkZ)
{
this.hellRNG.setSeed((long) chunkX * 341873128712L + (long) chunkZ * 132897987541L);
byte[] lowerArray = new byte[32768];
Block[] aBlock = new Block[32768];
//byte[] upperArray = new byte[32768];
this.generateNetherTerrain(chunkX, chunkZ, lowerArray);
this.replaceBlocksForBiome(chunkX, chunkZ, lowerArray);
this.netherCaveGenerator.generate(this, this.worldObj, chunkX, chunkZ, lowerArray);
this.genNetherBridge.generate(this, this.worldObj, chunkX, chunkZ, lowerArray);
this.replaceBlocksForBiome(chunkX, chunkZ, aBlock, lowerArray);
this.netherCaveGenerator.func_151539_a(this, this.worldObj, chunkX, chunkZ, aBlock);
this.genNetherBridge.func_151539_a(this, this.worldObj, chunkX, chunkZ, aBlock);
Chunk chunk = new NetheriteChunk(this.worldObj, lowerArray, chunkX, chunkZ);
BiomeGenBase[] abiomegenbase = this.worldObj.getWorldChunkManager().loadBlockGeneratorData((BiomeGenBase[]) null, chunkX * 16, chunkZ * 16, 16, 16);
byte[] abyte1 = chunk.getBiomeArray();
Expand Down Expand Up @@ -657,7 +661,7 @@ public List getPossibleCreatures (EnumCreatureType par1EnumCreatureType, int par
/**
* Returns the location of the closest structure of the specified type. If not found returns null.
*/
public ChunkPosition findClosestStructure (World par1World, String par2Str, int par3, int par4, int par5)
public ChunkPosition func_147416_a (World par1World, String par2Str, int par3, int par4, int par5)
{
return null;
}
Expand All @@ -669,13 +673,12 @@ public int getLoadedChunkCount ()

public void recreateStructures (int par1, int par2)
{
this.genNetherBridge.generate(this, this.worldObj, par1, par2, (byte[]) null);
genNetherBridge.func_151539_a(this, this.worldObj, par1, par2, null);
}

@Override
public void saveExtraData ()
{
// TODO Auto-generated method stub

// NYI
}
}
17 changes: 11 additions & 6 deletions src/main/java/mods/natura/entity/BabyHeatscarSpider.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.EntitySpider;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.util.DamageSource;
Expand Down Expand Up @@ -103,6 +104,7 @@ protected void fall (float par1)
}
}

@Override
public boolean attackEntityAsMob (Entity par1Entity)
{
if (super.attackEntityAsMob(par1Entity))
Expand Down Expand Up @@ -142,21 +144,24 @@ public int getAttackStrength (Entity par1Entity)
return 4;
}

protected int getDropItemId ()
@Override
protected Item getDropItem()
{
return NContent.plantItem;
}

public EntityItem dropItemWithOffset (int par1, int par2, float par3)

@Override
// dropItemWithOffset
public EntityItem func_145778_a(Item item, int par2, float offset)
{
return this.entityDropItem(new ItemStack(par1, par2, 7), par3);
return this.entityDropItem(new ItemStack(item, par2, 7), offset);
}

protected void dropFewItems (boolean par1, int par2)
{
int j = this.getDropItemId();
Item j = this.getDropItem();

if (j > 0)
if (Item.getIdFromItem(j) > 0)
{
int k = this.rand.nextInt(3) + 2;

Expand Down
20 changes: 10 additions & 10 deletions src/main/java/mods/natura/entity/FusewoodArrow.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet70GameEvent;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
Expand Down Expand Up @@ -243,7 +241,8 @@ public void onUpdate ()
++this.ticksInAir;
Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks_do_do(vec3, vec31, false, true);
// TODO 1.7 May need to call overload with extra params
MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec3, vec31, false);
vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

Expand Down Expand Up @@ -335,11 +334,11 @@ public void onUpdate ()
{
if (movingobjectposition.entityHit instanceof EntityLivingBase)
{
EntityLivingBase entityliving = (EntityLivingBase) movingobjectposition.entityHit;
Entity entityliving = movingobjectposition.entityHit;

if (!this.worldObj.isRemote)
{
entityliving.setArrowCountInEntity(entityliving.getArrowCountInEntity() + 1);
((EntityLivingBase) entityliving).setArrowCountInEntity(((EntityLivingBase) entityliving).getArrowCountInEntity() + 1);
}

if (this.knockbackStrength > 0)
Expand All @@ -355,13 +354,14 @@ public void onUpdate ()

if (this.shootingEntity != null)
{
EnchantmentThorns.func_92096_a(this.shootingEntity, entityliving, this.rand);
// TODO 1.7 last arg is level of enchant (I think), confirm this is correct
EnchantmentThorns.thorns.func_151367_b((EntityLivingBase) this.shootingEntity, entityliving, 1);
}

if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer
&& this.shootingEntity instanceof EntityPlayerMP)
{
((EntityPlayerMP) this.shootingEntity).playerNetServerHandler.sendPacketToPlayer(new Packet70GameEvent(6, 0));
// TODO 1.7 What is Packet70 now? ((EntityPlayerMP) this.shootingEntity).playerNetServerHandler.sendPacketToPlayer(new Packet70GameEvent(6, 0));
}
}

Expand Down Expand Up @@ -466,7 +466,7 @@ public void onUpdate ()
this.motionZ *= (double) f4;
this.motionY -= (double) f1;
this.setPosition(this.posX, this.posY, this.posZ);
this.doBlockCollisions();
this.func_145775_I(); // doBlockCollisions
}
}

Expand All @@ -478,7 +478,7 @@ public void writeEntityToNBT (NBTTagCompound par1NBTTagCompound)
par1NBTTagCompound.setShort("xTile", (short) this.xTile);
par1NBTTagCompound.setShort("yTile", (short) this.yTile);
par1NBTTagCompound.setShort("zTile", (short) this.zTile);
par1NBTTagCompound.setByte("inTile", (byte) this.inTile);
par1NBTTagCompound.setByte("inTile", (byte) Block.getIdFromBlock(this.inTile));
par1NBTTagCompound.setByte("inData", (byte) this.inData);
par1NBTTagCompound.setByte("shake", (byte) this.arrowShake);
par1NBTTagCompound.setByte("inGround", (byte) (this.inGround ? 1 : 0));
Expand All @@ -494,7 +494,7 @@ public void readEntityFromNBT (NBTTagCompound par1NBTTagCompound)
this.xTile = par1NBTTagCompound.getShort("xTile");
this.yTile = par1NBTTagCompound.getShort("yTile");
this.zTile = par1NBTTagCompound.getShort("zTile");
this.inTile = par1NBTTagCompound.getByte("inTile") & 255;
this.inTile = Block.getBlockById(par1NBTTagCompound.getByte("inTile") & 255);
this.inData = par1NBTTagCompound.getByte("inData") & 255;
this.arrowShake = par1NBTTagCompound.getByte("shake") & 255;
this.inGround = par1NBTTagCompound.getByte("inGround") == 1;
Expand Down

0 comments on commit 09be750

Please sign in to comment.