Paint Balls.
This commit is contained in:
parent
9b8596dc7c
commit
8183becfd4
4 changed files with 299 additions and 119 deletions
90
block/misc/BlockPaint.java
Normal file
90
block/misc/BlockPaint.java
Normal file
|
@ -0,0 +1,90 @@
|
|||
package appeng.block.misc;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.tile.misc.TilePaint;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockPaint extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockPaint() {
|
||||
super( BlockPaint.class, Material.air );
|
||||
setfeature( EnumSet.of( AEFeature.PaintBalls ) );
|
||||
setTileEntiy( TilePaint.class );
|
||||
isFullSize = false;
|
||||
isOpaque = false;
|
||||
lightOpacity = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess w, int x, int y, int z)
|
||||
{
|
||||
TilePaint tp = getTileEntity( w, x, y, z );
|
||||
|
||||
if ( tp != null )
|
||||
{
|
||||
return tp.getLightLevel();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_)
|
||||
{
|
||||
// nothing..
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillWithRain(World w, int x, int y, int z)
|
||||
{
|
||||
w.setBlock( x, y, z, Platform.air, 0, 3 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBlockStay(World w, int x, int y, int z)
|
||||
{
|
||||
TilePaint tp = getTileEntity( w, x, y, z );
|
||||
|
||||
if ( tp != null )
|
||||
{
|
||||
return tp.canStay();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean canCollideCheck(int p_149678_1_, boolean p_149678_2_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_,
|
||||
int p_149690_7_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
34
client/render/blocks/RenderBlockPaint.java
Normal file
34
client/render/blocks/RenderBlockPaint.java
Normal file
|
@ -0,0 +1,34 @@
|
|||
package appeng.client.render.blocks;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
|
||||
public class RenderBlockPaint extends BaseBlockRender
|
||||
{
|
||||
|
||||
public RenderBlockPaint() {
|
||||
super( false, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj)
|
||||
{
|
||||
renderer.setRenderBounds( 0.25f, 0.0f, 0.25f, 0.75f, 0.5f, 0.75f );
|
||||
super.renderInventory( block, is, renderer, type, obj );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(AEBaseBlock imb, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
||||
{
|
||||
renderer.renderAllFaces = true;
|
||||
renderer.setRenderBounds( 0.25f, 0.0f, 0.25f, 0.75f, 0.5f, 0.75f );
|
||||
boolean out = super.renderInWorld( imb, world, x, y, z, renderer );
|
||||
renderer.renderAllFaces = false;
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
|
@ -10,6 +10,7 @@ import net.minecraft.entity.EntityLivingBase;
|
|||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
|
@ -41,6 +42,7 @@ import appeng.core.sync.packets.PacketMatterCannon;
|
|||
import appeng.hooks.DispenserMatterCannon;
|
||||
import appeng.items.contents.CellConfig;
|
||||
import appeng.items.contents.CellUpgrades;
|
||||
import appeng.items.misc.ItemPaintBall;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.me.storage.CellInventoryHandler;
|
||||
import appeng.util.Platform;
|
||||
|
@ -130,132 +132,28 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
|||
float f8 = f3 * f5;
|
||||
double d3 = 32.0D;
|
||||
|
||||
Vec3 vec31 = vec3.addVector( (double) f7 * d3, (double) f6 * d3, (double) f8 * d3 );
|
||||
Vec3 direction = w.getWorldVec3Pool().getVecFromPool( (double) f7 * d3, (double) f6 * d3, (double) f8 * d3 );
|
||||
|
||||
float penitration = AEApi.instance().registries().matterCannon().getPenetration( ammo ); // 196.96655f;
|
||||
boolean hasDestroyedSomething = true;
|
||||
while (penitration > 0 && hasDestroyedSomething)
|
||||
if ( penitration <= 0 )
|
||||
{
|
||||
hasDestroyedSomething = false;
|
||||
|
||||
Vec3 vec31 = vec3.addVector( (double) f7 * d3, (double) f6 * d3, (double) f8 * d3 );
|
||||
|
||||
AxisAlignedBB bb = AxisAlignedBB
|
||||
.getAABBPool()
|
||||
.getAABB( Math.min( vec3.xCoord, vec31.xCoord ), Math.min( vec3.yCoord, vec31.yCoord ),
|
||||
Math.min( vec3.zCoord, vec31.zCoord ), Math.max( vec3.xCoord, vec31.xCoord ),
|
||||
Math.max( vec3.yCoord, vec31.yCoord ), Math.max( vec3.zCoord, vec31.zCoord ) ).expand( 16, 16, 16 );
|
||||
|
||||
Entity entity = null;
|
||||
List list = w.getEntitiesWithinAABBExcludingEntity( p, bb );
|
||||
double Closeest = 9999999.0D;
|
||||
int l;
|
||||
|
||||
for (l = 0; l < list.size(); ++l)
|
||||
ItemStack type = ((IAEItemStack) aeammo).getItemStack();
|
||||
if ( type.getItem() instanceof ItemBlock )
|
||||
{
|
||||
Entity entity1 = (Entity) list.get( l );
|
||||
|
||||
if ( entity1.isDead == false && entity1 != p && !(entity1 instanceof EntityItem) )
|
||||
{
|
||||
if ( entity1.isEntityAlive() )
|
||||
{
|
||||
// prevent killing / flying of mounts.
|
||||
if ( entity1.riddenByEntity == p )
|
||||
continue;
|
||||
|
||||
f1 = 0.3F;
|
||||
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand( (double) f1, (double) f1, (double) f1 );
|
||||
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept( vec3, vec31 );
|
||||
|
||||
if ( movingobjectposition1 != null )
|
||||
{
|
||||
double nd = vec3.squareDistanceTo( movingobjectposition1.hitVec );
|
||||
|
||||
if ( nd < Closeest )
|
||||
{
|
||||
entity = entity1;
|
||||
Closeest = nd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vec3 Srec = w.getWorldVec3Pool().getVecFromPool( d0, d1, d2 );
|
||||
MovingObjectPosition pos = w.rayTraceBlocks( vec3, vec31, true );
|
||||
if ( entity != null && pos != null && pos.hitVec.squareDistanceTo( Srec ) > Closeest )
|
||||
{
|
||||
pos = new MovingObjectPosition( entity );
|
||||
}
|
||||
else if ( entity != null && pos == null )
|
||||
{
|
||||
pos = new MovingObjectPosition( entity );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
CommonHelper.proxy.sendToAllNearExcept( null, d0, d1, d2, 128, w, new PacketMatterCannon( d0, d1, d2, (float) (f7 * d3),
|
||||
(float) (f6 * d3), (float) (f8 * d3), (byte) (pos == null ? 32 : pos.hitVec.squareDistanceTo( Srec ) + 1) ) );
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
else if ( type.getItem() instanceof ItemPaintBall )
|
||||
{
|
||||
AELog.error( err );
|
||||
}
|
||||
|
||||
if ( pos != null )
|
||||
{
|
||||
DamageSource dmgSrc = DamageSource.causePlayerDamage( p );
|
||||
dmgSrc.damageType = "masscannon";
|
||||
|
||||
if ( pos.typeOfHit == MovingObjectType.ENTITY )
|
||||
{
|
||||
int dmg = (int) Math.ceil( penitration / 20.0f );
|
||||
if ( pos.entityHit instanceof EntityLivingBase )
|
||||
{
|
||||
EntityLivingBase el = (EntityLivingBase) pos.entityHit;
|
||||
penitration -= dmg;
|
||||
el.knockBack( p, 0, (double) -f7 * d3, (double) -f8 * d3 );
|
||||
// el.knockBack( p, 0, vec3.xCoord,
|
||||
// vec3.zCoord );
|
||||
el.attackEntityFrom( dmgSrc, dmg );
|
||||
if ( !el.isEntityAlive() )
|
||||
hasDestroyedSomething = true;
|
||||
}
|
||||
else if ( pos.entityHit instanceof EntityItem )
|
||||
{
|
||||
hasDestroyedSomething = true;
|
||||
pos.entityHit.setDead();
|
||||
}
|
||||
else if ( pos.entityHit.attackEntityFrom( dmgSrc, dmg ) )
|
||||
{
|
||||
hasDestroyedSomething = true;
|
||||
}
|
||||
}
|
||||
else if ( pos.typeOfHit == MovingObjectType.BLOCK )
|
||||
{
|
||||
if ( !AEConfig.instance.isFeatureEnabled( AEFeature.MassCannonBlockDamage ) )
|
||||
penitration = 0;
|
||||
else
|
||||
{
|
||||
Block b = w.getBlock( pos.blockX, pos.blockY, pos.blockZ );
|
||||
// int meta = w.getBlockMetadata(
|
||||
// pos.blockX, pos.blockY, pos.blockZ );
|
||||
|
||||
float hardness = b.getBlockHardness( w, pos.blockX, pos.blockY, pos.blockZ ) * 9.0f;
|
||||
if ( hardness >= 0.0 )
|
||||
{
|
||||
if ( penitration > hardness )
|
||||
{
|
||||
hasDestroyedSomething = true;
|
||||
penitration -= hardness;
|
||||
penitration *= 0.60;
|
||||
w.func_147480_a( pos.blockX, pos.blockY, pos.blockZ, true );
|
||||
// w.destroyBlock( pos.blockX, pos.blockY, pos.blockZ, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return item;
|
||||
}
|
||||
else
|
||||
{
|
||||
standardAmmo();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -269,6 +167,133 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
|||
return item;
|
||||
}
|
||||
|
||||
private void standardAmmo(float penitration, World w, EntityPlayer p, Vec3 vec3, Vec3 vec31, Vec3 direction, double d0, double d1, double d2)
|
||||
{
|
||||
boolean hasDestroyedSomething = true;
|
||||
while (penitration > 0 && hasDestroyedSomething)
|
||||
{
|
||||
hasDestroyedSomething = false;
|
||||
|
||||
AxisAlignedBB bb = AxisAlignedBB
|
||||
.getAABBPool()
|
||||
.getAABB( Math.min( vec3.xCoord, vec31.xCoord ), Math.min( vec3.yCoord, vec31.yCoord ), Math.min( vec3.zCoord, vec31.zCoord ),
|
||||
Math.max( vec3.xCoord, vec31.xCoord ), Math.max( vec3.yCoord, vec31.yCoord ), Math.max( vec3.zCoord, vec31.zCoord ) )
|
||||
.expand( 16, 16, 16 );
|
||||
|
||||
Entity entity = null;
|
||||
List list = w.getEntitiesWithinAABBExcludingEntity( p, bb );
|
||||
double Closeest = 9999999.0D;
|
||||
int l;
|
||||
|
||||
for (l = 0; l < list.size(); ++l)
|
||||
{
|
||||
Entity entity1 = (Entity) list.get( l );
|
||||
|
||||
if ( entity1.isDead == false && entity1 != p && !(entity1 instanceof EntityItem) )
|
||||
{
|
||||
if ( entity1.isEntityAlive() )
|
||||
{
|
||||
// prevent killing / flying of mounts.
|
||||
if ( entity1.riddenByEntity == p )
|
||||
continue;
|
||||
|
||||
float f1 = 0.3F;
|
||||
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand( (double) f1, (double) f1, (double) f1 );
|
||||
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept( vec3, vec31 );
|
||||
|
||||
if ( movingobjectposition1 != null )
|
||||
{
|
||||
double nd = vec3.squareDistanceTo( movingobjectposition1.hitVec );
|
||||
|
||||
if ( nd < Closeest )
|
||||
{
|
||||
entity = entity1;
|
||||
Closeest = nd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vec3 Srec = w.getWorldVec3Pool().getVecFromPool( d0, d1, d2 );
|
||||
MovingObjectPosition pos = w.rayTraceBlocks( vec3, vec31, true );
|
||||
if ( entity != null && pos != null && pos.hitVec.squareDistanceTo( Srec ) > Closeest )
|
||||
{
|
||||
pos = new MovingObjectPosition( entity );
|
||||
}
|
||||
else if ( entity != null && pos == null )
|
||||
{
|
||||
pos = new MovingObjectPosition( entity );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
CommonHelper.proxy.sendToAllNearExcept( null, d0, d1, d2, 128, w, new PacketMatterCannon( d0, d1, d2, (float) (f7 * d3), (float) (f6 * d3),
|
||||
(float) (f8 * d3), (byte) (pos == null ? 32 : pos.hitVec.squareDistanceTo( Srec ) + 1) ) );
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
AELog.error( err );
|
||||
}
|
||||
|
||||
if ( pos != null )
|
||||
{
|
||||
DamageSource dmgSrc = DamageSource.causePlayerDamage( p );
|
||||
dmgSrc.damageType = "masscannon";
|
||||
|
||||
if ( pos.typeOfHit == MovingObjectType.ENTITY )
|
||||
{
|
||||
int dmg = (int) Math.ceil( penitration / 20.0f );
|
||||
if ( pos.entityHit instanceof EntityLivingBase )
|
||||
{
|
||||
EntityLivingBase el = (EntityLivingBase) pos.entityHit;
|
||||
penitration -= dmg;
|
||||
el.knockBack( p, 0, (double) -f7 * d3, (double) -f8 * d3 );
|
||||
// el.knockBack( p, 0, vec3.xCoord,
|
||||
// vec3.zCoord );
|
||||
el.attackEntityFrom( dmgSrc, dmg );
|
||||
if ( !el.isEntityAlive() )
|
||||
hasDestroyedSomething = true;
|
||||
}
|
||||
else if ( pos.entityHit instanceof EntityItem )
|
||||
{
|
||||
hasDestroyedSomething = true;
|
||||
pos.entityHit.setDead();
|
||||
}
|
||||
else if ( pos.entityHit.attackEntityFrom( dmgSrc, dmg ) )
|
||||
{
|
||||
hasDestroyedSomething = true;
|
||||
}
|
||||
}
|
||||
else if ( pos.typeOfHit == MovingObjectType.BLOCK )
|
||||
{
|
||||
if ( !AEConfig.instance.isFeatureEnabled( AEFeature.MassCannonBlockDamage ) )
|
||||
penitration = 0;
|
||||
else
|
||||
{
|
||||
Block b = w.getBlock( pos.blockX, pos.blockY, pos.blockZ );
|
||||
// int meta = w.getBlockMetadata(
|
||||
// pos.blockX, pos.blockY, pos.blockZ );
|
||||
|
||||
float hardness = b.getBlockHardness( w, pos.blockX, pos.blockY, pos.blockZ ) * 9.0f;
|
||||
if ( hardness >= 0.0 )
|
||||
{
|
||||
if ( penitration > hardness )
|
||||
{
|
||||
hasDestroyedSomething = true;
|
||||
penitration -= hardness;
|
||||
penitration *= 0.60;
|
||||
w.func_147480_a( pos.blockX, pos.blockY, pos.blockZ, true );
|
||||
// w.destroyBlock( pos.blockX, pos.blockY, pos.blockZ, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean storableInStorageCell()
|
||||
{
|
||||
|
@ -346,6 +371,19 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
|||
@Override
|
||||
public boolean isBlackListed(ItemStack cellItem, IAEItemStack requsetedAddition)
|
||||
{
|
||||
return AEApi.instance().registries().matterCannon().getPenetration( requsetedAddition.getItemStack() ) == 0;
|
||||
float pen = AEApi.instance().registries().matterCannon().getPenetration( requsetedAddition.getItemStack() );
|
||||
if ( pen > 0 )
|
||||
return false;
|
||||
|
||||
if ( requsetedAddition.getItem() instanceof ItemPaintBall )
|
||||
return false;
|
||||
|
||||
if ( requsetedAddition.getItem() instanceof ItemBlock )
|
||||
{
|
||||
Block blk = Block.getBlockFromItem( requsetedAddition.getItem() );
|
||||
return blk == null;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
18
tile/misc/TilePaint.java
Normal file
18
tile/misc/TilePaint.java
Normal file
|
@ -0,0 +1,18 @@
|
|||
package appeng.tile.misc;
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
|
||||
public class TilePaint extends AEBaseTile
|
||||
{
|
||||
|
||||
public boolean canStay()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getLightLevel()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue