Paint Balls.
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraft.util.DamageSource;
|
import net.minecraft.util.DamageSource;
|
||||||
@@ -41,6 +42,7 @@ import appeng.core.sync.packets.PacketMatterCannon;
|
|||||||
import appeng.hooks.DispenserMatterCannon;
|
import appeng.hooks.DispenserMatterCannon;
|
||||||
import appeng.items.contents.CellConfig;
|
import appeng.items.contents.CellConfig;
|
||||||
import appeng.items.contents.CellUpgrades;
|
import appeng.items.contents.CellUpgrades;
|
||||||
|
import appeng.items.misc.ItemPaintBall;
|
||||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||||
import appeng.me.storage.CellInventoryHandler;
|
import appeng.me.storage.CellInventoryHandler;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
@@ -130,19 +132,53 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
|||||||
float f8 = f3 * f5;
|
float f8 = f3 * f5;
|
||||||
double d3 = 32.0D;
|
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;
|
float penitration = AEApi.instance().registries().matterCannon().getPenetration( ammo ); // 196.96655f;
|
||||||
|
if ( penitration <= 0 )
|
||||||
|
{
|
||||||
|
ItemStack type = ((IAEItemStack) aeammo).getItemStack();
|
||||||
|
if ( type.getItem() instanceof ItemBlock )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else if ( type.getItem() instanceof ItemPaintBall )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
standardAmmo();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( Platform.isServer() )
|
||||||
|
p.addChatMessage( PlayerMessages.AmmoDepleted.get() );
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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;
|
boolean hasDestroyedSomething = true;
|
||||||
while (penitration > 0 && hasDestroyedSomething)
|
while (penitration > 0 && hasDestroyedSomething)
|
||||||
{
|
{
|
||||||
hasDestroyedSomething = false;
|
hasDestroyedSomething = false;
|
||||||
|
|
||||||
Vec3 vec31 = vec3.addVector( (double) f7 * d3, (double) f6 * d3, (double) f8 * d3 );
|
|
||||||
|
|
||||||
AxisAlignedBB bb = AxisAlignedBB
|
AxisAlignedBB bb = AxisAlignedBB
|
||||||
.getAABBPool()
|
.getAABBPool()
|
||||||
.getAABB( Math.min( vec3.xCoord, vec31.xCoord ), Math.min( vec3.yCoord, vec31.yCoord ),
|
.getAABB( Math.min( vec3.xCoord, vec31.xCoord ), Math.min( vec3.yCoord, vec31.yCoord ), Math.min( vec3.zCoord, vec31.zCoord ),
|
||||||
Math.min( vec3.zCoord, vec31.zCoord ), Math.max( vec3.xCoord, vec31.xCoord ),
|
Math.max( vec3.xCoord, vec31.xCoord ), Math.max( vec3.yCoord, vec31.yCoord ), Math.max( vec3.zCoord, vec31.zCoord ) )
|
||||||
Math.max( vec3.yCoord, vec31.yCoord ), Math.max( vec3.zCoord, vec31.zCoord ) ).expand( 16, 16, 16 );
|
.expand( 16, 16, 16 );
|
||||||
|
|
||||||
Entity entity = null;
|
Entity entity = null;
|
||||||
List list = w.getEntitiesWithinAABBExcludingEntity( p, bb );
|
List list = w.getEntitiesWithinAABBExcludingEntity( p, bb );
|
||||||
@@ -161,7 +197,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
|||||||
if ( entity1.riddenByEntity == p )
|
if ( entity1.riddenByEntity == p )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
f1 = 0.3F;
|
float f1 = 0.3F;
|
||||||
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand( (double) f1, (double) f1, (double) f1 );
|
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand( (double) f1, (double) f1, (double) f1 );
|
||||||
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept( vec3, vec31 );
|
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept( vec3, vec31 );
|
||||||
|
|
||||||
@@ -192,8 +228,8 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CommonHelper.proxy.sendToAllNearExcept( null, d0, d1, d2, 128, w, new PacketMatterCannon( d0, d1, d2, (float) (f7 * d3),
|
CommonHelper.proxy.sendToAllNearExcept( null, d0, d1, d2, 128, w, new PacketMatterCannon( d0, d1, d2, (float) (f7 * d3), (float) (f6 * d3),
|
||||||
(float) (f6 * d3), (float) (f8 * d3), (byte) (pos == null ? 32 : pos.hitVec.squareDistanceTo( Srec ) + 1) ) );
|
(float) (f8 * d3), (byte) (pos == null ? 32 : pos.hitVec.squareDistanceTo( Srec ) + 1) ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception err)
|
catch (Exception err)
|
||||||
@@ -257,17 +293,6 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( Platform.isServer() )
|
|
||||||
p.addChatMessage( PlayerMessages.AmmoDepleted.get() );
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean storableInStorageCell()
|
public boolean storableInStorageCell()
|
||||||
@@ -346,6 +371,19 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
|||||||
@Override
|
@Override
|
||||||
public boolean isBlackListed(ItemStack cellItem, IAEItemStack requsetedAddition)
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user