AE2 First Commit, the dawn of 1.7 hast arrived.

This commit is contained in:
algorithmx2
2013-12-27 16:59:59 -06:00
commit e9acdcbee2
468 changed files with 47440 additions and 0 deletions
+118
View File
@@ -0,0 +1,118 @@
package appeng.entity;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.client.render.effects.LightningEffect;
import appeng.core.Configuration;
import appeng.util.Platform;
final public class EntityChargedQuartz extends EntityItem
{
int delay = 0;
int transformTime = 0;
public EntityChargedQuartz(World w) {
super( w );
}
public EntityChargedQuartz(World w, double x, double y, double z, ItemStack is) {
super( w, x, y, z, is );
}
@Override
public void onUpdate()
{
super.onUpdate();
if ( Platform.isClient() && delay++ > 30 && Configuration.instance.enableEffects )
{
delay = 0;
LightningEffect fx = new LightningEffect( worldObj, posX, posY + 0.3f, posZ, 0.0f, 0.0f, 0.0f );
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
int j = MathHelper.floor_double( this.posX );
int i = MathHelper.floor_double( this.posY );
int k = MathHelper.floor_double( this.posZ );
Material mat = worldObj.getBlockMaterial( j, i, k );
if ( Platform.isServer() && mat.isLiquid() )
{
transformTime++;
if ( transformTime > 60 )
{
if ( !transform() )
transformTime = 0;
}
}
else
transformTime = 0;
};
public boolean transform()
{
ItemStack item = getEntityItem();
if ( AEApi.instance().materials().materialCertusQuartzCrystalCharged.sameAs( item ) )
{
AxisAlignedBB region = AxisAlignedBB.getBoundingBox( posX - 1, posY - 1, posZ - 1, posX + 1, posY + 1, posZ + 1 );
List<Entity> l = worldObj.getEntitiesWithinAABBExcludingEntity( this, region );
EntityItem redstone = null;
EntityItem netherQuartz = null;
for (Entity e : l)
{
if ( e instanceof EntityItem && !e.isDead )
{
ItemStack other = ((EntityItem) e).getEntityItem();
if ( other != null && other.stackSize > 0 )
{
if ( Platform.isSameItem( other, new ItemStack( Item.redstone ) ) )
redstone = (EntityItem) e;
if ( Platform.isSameItem( other, new ItemStack( Item.netherQuartz ) ) )
netherQuartz = (EntityItem) e;
}
}
}
if ( redstone != null && netherQuartz != null )
{
getEntityItem().stackSize--;
redstone.getEntityItem().stackSize--;
netherQuartz.getEntityItem().stackSize--;
if ( getEntityItem().stackSize <= 0 )
setDead();
if ( redstone.getEntityItem().stackSize <= 0 )
redstone.setDead();
if ( netherQuartz.getEntityItem().stackSize <= 0 )
netherQuartz.setDead();
List<ItemStack> i = new ArrayList();
i.add( AEApi.instance().materials().materialFluixCrystal.stack( 1 ) );
ItemStack Output = AEApi.instance().materials().materialFluixCrystal.stack( 2 );
worldObj.spawnEntityInWorld( new EntityItem( worldObj, posX, posY, posZ, Output ) );
return true;
}
}
return false;
}
}
+108
View File
@@ -0,0 +1,108 @@
package appeng.entity;
import java.util.Date;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import appeng.api.AEApi;
import appeng.util.Platform;
final public class EntitySingularity extends EntityItem
{
static private int randTickSeed = 0;
public EntitySingularity(World w) {
super( w );
}
public EntitySingularity(World w, double x, double y, double z, ItemStack is) {
super( w, x, y, z, is );
}
@Override
public boolean attackEntityFrom(DamageSource src, float dmg)
{
if ( src.isExplosion() )
{
doExplosion();
return false;
}
return super.attackEntityFrom( src, dmg );
}
public void doExplosion()
{
if ( Platform.isClient() )
return;
ItemStack item = getEntityItem();
if ( AEApi.instance().materials().materialSingularity.sameAs( item ) )
{
AxisAlignedBB region = AxisAlignedBB.getBoundingBox( posX - 4, posY - 4, posZ - 4, posX + 4, posY + 4, posZ + 4 );
List<Entity> l = worldObj.getEntitiesWithinAABBExcludingEntity( this, region );
for (Entity e : l)
{
if ( e instanceof EntityItem )
{
ItemStack other = ((EntityItem) e).getEntityItem();
if ( other != null )
{
boolean matches = false;
for (ItemStack is : OreDictionary.getOres( "dustEnder" ))
{
if ( OreDictionary.itemMatches( other, is, false ) )
{
matches = true;
break;
}
}
// check... other name.
if ( matches == false )
{
for (ItemStack is : OreDictionary.getOres( "dustEnderPearl" ))
{
if ( OreDictionary.itemMatches( other, is, false ) )
{
matches = true;
break;
}
}
}
if ( matches )
{
while (item.stackSize > 0 && other.stackSize > 0)
{
other.stackSize--;
if ( other.stackSize == 0 )
e.setDead();
ItemStack Output = AEApi.instance().materials().materialQESingularity.stack( 2 );
NBTTagCompound cmp = Platform.openNbtData( Output );
cmp.setLong( "freq", (new Date()).getTime() * 100 + (randTickSeed++) % 100 );
item.stackSize--;
worldObj.spawnEntityInWorld( new EntitySingularity( worldObj, posX, posY, posZ, Output ) );
}
if ( item.stackSize <= 0 )
setDead();
}
}
}
}
}
}
}
+162
View File
@@ -0,0 +1,162 @@
package appeng.entity;
import java.io.IOException;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityTNTPrimed;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.core.CommonHelper;
import appeng.core.Configuration;
import appeng.core.features.AEFeature;
import appeng.core.sync.packets.PacketMockExplosion;
import appeng.util.Platform;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
final public class EntityTinyTNTPrimed extends EntityTNTPrimed implements IEntityAdditionalSpawnData
{
public EntityTinyTNTPrimed(World w) {
super( w );
this.setSize( 0.35F, 0.35F );
}
public EntityTinyTNTPrimed(World w, double x, double y, double z, EntityLivingBase ignitor) {
super( w, x, y, z, ignitor );
this.setSize( 0.55F, 0.55F );
this.yOffset = this.height / 2.0F;
}
/**
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate()
{
this.handleWaterMovement();
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.motionY -= 0.03999999910593033D;
this.moveEntity( this.motionX, this.motionY, this.motionZ );
this.motionX *= 0.9800000190734863D;
this.motionY *= 0.9800000190734863D;
this.motionZ *= 0.9800000190734863D;
if ( this.onGround )
{
this.motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D;
this.motionY *= -0.5D;
}
if ( this.isInWater() && Platform.isServer() ) // put out the fuse.
{
EntityItem item = new EntityItem( worldObj, this.posX, this.posY, this.posZ, AEApi.instance().blocks().blockTinyTNT.stack( 1 ) );
item.motionX = motionX;
item.motionY = motionY;
item.motionZ = motionZ;
item.prevPosX = this.prevPosX;
item.prevPosY = this.prevPosY;
item.prevPosZ = this.prevPosZ;
worldObj.spawnEntityInWorld( item );
this.setDead();
}
if ( this.fuse-- <= 0 )
{
this.setDead();
if ( !this.worldObj.isRemote )
{
this.explode();
}
}
else
{
this.worldObj.spawnParticle( "smoke", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D );
}
}
// override :P
void explode()
{
this.worldObj.playSoundEffect( this.posX, this.posY, this.posZ, "random.explode", 4.0F,
(1.0F + (this.worldObj.rand.nextFloat() - this.worldObj.rand.nextFloat()) * 0.2F) * 32.9F );
if ( this.isInWater() )
{
return;
}
if ( Configuration.instance.isFeatureEnabled( AEFeature.TinyTNTBlockDamage ) )
{
posY -= 0.25;
for (int x = (int) (posX - 2); x <= posX + 2; x++)
{
for (int y = (int) (posY - 2); y <= posY + 2; y++)
{
for (int z = (int) (posZ - 2); z <= posZ + 2; z++)
{
int l = worldObj.getBlockId( x, y, z );
Block block = Block.blocksList[l];
if ( block != null && !block.isAirBlock( worldObj, x, y, z ) )
{
float strength = (float) (2.3f - (((x + 0.5f) - posX) * ((x + 0.5f) - posX) + ((y + 0.5f) - posY) * ((y + 0.5f) - posY) + ((z + 0.5f) - posZ)
* ((z + 0.5f) - posZ)));
float resistance = block.getExplosionResistance( this, worldObj, x, y, z, posX, posY, posZ );
strength -= (resistance + 0.3F) * 0.11f;
if ( strength > 0.01 )
{
worldObj.destroyBlock( x, y, z, true );
}
}
}
}
}
}
try
{
CommonHelper.proxy.sendToAllNearExcept( null, posX, posY, posZ, 64, this.worldObj, (new PacketMockExplosion( posX, posY, posZ )).getPacket() );
}
catch (IOException e1)
{
}
for (Object e : this.worldObj.getEntitiesWithinAABBExcludingEntity( this,
AxisAlignedBB.getBoundingBox( this.posX - 1.5, this.posY - 1.5f, this.posZ - 1.5, this.posX + 1.5, this.posY + 1.5, this.posZ + 1.5 ) ))
{
if ( e instanceof Entity )
{
((Entity) e).attackEntityFrom( DamageSource.setExplosionSource( null ), 6 );
}
}
}
@Override
public void writeSpawnData(ByteArrayDataOutput data)
{
data.writeByte( fuse );
}
@Override
public void readSpawnData(ByteArrayDataInput data)
{
fuse = data.readByte();
}
}