Paint balls now color entities their color when they get hit for 30 or so seconds ( mostly works ).
Paint balls now color sheep. The Color Applicator can now accept snow balls. Snowballs can be used to clean paint balls, and to clean cables ( restore fluix ) Tweaks to Color API.
This commit is contained in:
parent
f355fc1643
commit
3f29590fad
22 changed files with 382 additions and 49 deletions
block
client
core
fmp
helpers
hooks
items/tools/powered
parts
tile
crafting
misc
networking
storage
|
@ -779,7 +779,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
|||
|
||||
if ( c != newColor )
|
||||
{
|
||||
ct.setColor( newColor );
|
||||
ct.recolourBlock( side, newColor, null );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -28,6 +28,7 @@ import appeng.api.parts.IPart;
|
|||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.PartItemStack;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.BusRenderHelper;
|
||||
|
@ -224,7 +225,7 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection
|
|||
{
|
||||
try
|
||||
{
|
||||
return cb( world, x, y, z ).recolourBlock( side, colour, who );
|
||||
return cb( world, x, y, z ).recolourBlock( side, AEColor.values()[colour], who );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
|
|
|
@ -27,11 +27,13 @@ import net.minecraftforge.client.ForgeHooksClient;
|
|||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.client.event.MouseEvent;
|
||||
import net.minecraftforge.client.event.RenderLivingEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.TESRWrapper;
|
||||
|
@ -56,6 +58,8 @@ import appeng.entity.EntityTinyTNTPrimed;
|
|||
import appeng.entity.RenderFloatingItem;
|
||||
import appeng.entity.RenderTinyTNTPrimed;
|
||||
import appeng.helpers.IMouseWheelItem;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.hooks.TickHandler.PlayerColor;
|
||||
import appeng.server.ServerHelper;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
|
@ -68,6 +72,21 @@ public class ClientHelper extends ServerHelper
|
|||
private static RenderItem itemRenderer = new RenderItem();
|
||||
private static RenderBlocks blockRenderer = new RenderBlocks();
|
||||
|
||||
@SubscribeEvent
|
||||
public void postPlayerRender(RenderLivingEvent.Pre p)
|
||||
{
|
||||
PlayerColor player = TickHandler.instance.getPlayerColors().get( p.entity.getEntityId() );
|
||||
if ( player != null )
|
||||
{
|
||||
AEColor col = player.myColor;
|
||||
|
||||
float r = (float) (0xff & (col.mediumVariant >> 16));
|
||||
float g = (float) (0xff & (col.mediumVariant >> 8));
|
||||
float b = (float) (0xff & (col.mediumVariant));
|
||||
GL11.glColor3f( r / 255.0f, g / 255.0f, b / 255.0f );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRenderItem(ItemStack itemstack, World w)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package appeng.client.render.blocks;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -44,8 +46,19 @@ public class RenderBlockPaint extends BaseBlockRender
|
|||
|
||||
double offoff = 0.001;
|
||||
|
||||
EnumSet<ForgeDirection> validSides = EnumSet.noneOf( ForgeDirection.class );
|
||||
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if ( tp.isSideValid( side ) )
|
||||
validSides.add( side );
|
||||
}
|
||||
|
||||
for (Splot s : tp.getDots())
|
||||
{
|
||||
if ( !validSides.contains( s.side ) )
|
||||
continue;
|
||||
|
||||
if ( s.lumen )
|
||||
{
|
||||
tess.setColorOpaque_I( s.color.whiteVariant );
|
||||
|
|
|
@ -2,6 +2,7 @@ package appeng.client.render.items;
|
|||
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemSnowball;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
@ -84,12 +85,20 @@ public class ToolColorApplicatorRender implements IItemRenderer
|
|||
GL11.glTranslatef( 4, 6, 0 );
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
|
||||
AEColor col = null;
|
||||
|
||||
ItemStack is = ((ToolColorApplicator) item.getItem()).getColor( item );
|
||||
if ( is != null && is.getItem() instanceof ItemPaintBall )
|
||||
{
|
||||
ItemPaintBall ipb = (ItemPaintBall) is.getItem();
|
||||
col = ipb.getColor( is );
|
||||
}
|
||||
|
||||
AEColor col = ipb.getColor( is );
|
||||
if ( is != null && is.getItem() instanceof ItemSnowball )
|
||||
col = AEColor.Transparent;
|
||||
|
||||
if ( col != null )
|
||||
{
|
||||
tessellator.startDrawingQuads();
|
||||
float z = 0;
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@ import net.minecraftforge.common.config.Property;
|
|||
import appeng.api.util.WorldCoord;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketNewStorageDimension;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.hooks.TickHandler.PlayerColor;
|
||||
import appeng.me.GridStorage;
|
||||
import appeng.me.GridStorageSearch;
|
||||
import appeng.services.CompassService;
|
||||
|
@ -130,6 +132,9 @@ public class WorldSettings extends Configuration
|
|||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
for (PlayerColor pc : TickHandler.instance.getPlayerColors().values())
|
||||
NetworkHandler.instance.sendToAll( pc.getPacket() );
|
||||
}
|
||||
|
||||
public void init()
|
||||
|
|
|
@ -32,7 +32,7 @@ public enum GuiText
|
|||
|
||||
OfSecondOutput, NoSecondOutput, RFTunnel, Stores, Next, SelectAmount, Lumen, Empty, ConfirmCrafting,
|
||||
|
||||
Stored, Crafting, Scheduled, CraftingStatus, Cancel, FromStorage, ToCraft, CraftingPlan, CalculatingWait, Start, Bytes, CraftingCPU, Automatic, CoProcessors, Simulation, Missing, InterfaceTerminal, NoCraftingCPUs, LightTunnel;
|
||||
Stored, Crafting, Scheduled, CraftingStatus, Cancel, FromStorage, ToCraft, CraftingPlan, CalculatingWait, Start, Bytes, CraftingCPU, Automatic, CoProcessors, Simulation, Missing, InterfaceTerminal, NoCraftingCPUs, LightTunnel, Clean;
|
||||
|
||||
String root;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import appeng.core.sync.packets.PacketMockExplosion;
|
|||
import appeng.core.sync.packets.PacketMultiPart;
|
||||
import appeng.core.sync.packets.PacketNEIRecipe;
|
||||
import appeng.core.sync.packets.PacketNewStorageDimension;
|
||||
import appeng.core.sync.packets.PacketPaintedEntity;
|
||||
import appeng.core.sync.packets.PacketPartPlacement;
|
||||
import appeng.core.sync.packets.PacketPartialItem;
|
||||
import appeng.core.sync.packets.PacketPatternSlot;
|
||||
|
@ -82,7 +83,9 @@ public class AppEngPacketHandlerBase
|
|||
|
||||
PACKET_ASSEMBLER_ANIMATION(PacketAssemblerAnimation.class),
|
||||
|
||||
PACKET_COMPRESSED_NBT(PacketCompressedNBT.class);
|
||||
PACKET_COMPRESSED_NBT(PacketCompressedNBT.class),
|
||||
|
||||
PACKET_PAINTED_ENTITY(PacketPaintedEntity.class);
|
||||
|
||||
final public Class pc;
|
||||
final public Constructor con;
|
||||
|
|
48
core/sync/packets/PacketPaintedEntity.java
Normal file
48
core/sync/packets/PacketPaintedEntity.java
Normal file
|
@ -0,0 +1,48 @@
|
|||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.hooks.TickHandler.PlayerColor;
|
||||
|
||||
public class PacketPaintedEntity extends AppEngPacket
|
||||
{
|
||||
|
||||
private AEColor myColor;
|
||||
private int entityId;
|
||||
private int ticks;
|
||||
|
||||
// automatic.
|
||||
public PacketPaintedEntity(ByteBuf stream) throws IOException {
|
||||
entityId = stream.readInt();
|
||||
myColor = AEColor.values()[stream.readByte()];
|
||||
ticks = stream.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
PlayerColor pc = new PlayerColor( entityId, myColor, ticks );
|
||||
TickHandler.instance.getPlayerColors().put( entityId, pc );
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketPaintedEntity(int myEntity, AEColor myColor, int ticksLeft) {
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeInt( this.entityId = myEntity );
|
||||
data.writeByte( (this.myColor = myColor).ordinal() );
|
||||
data.writeInt( ticksLeft );
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
}
|
|
@ -96,6 +96,12 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds
|
|||
return cb.getCableConnectionType( dir );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recolourBlock(ForgeDirection side, AEColor colour, EntityPlayer who)
|
||||
{
|
||||
return cb.recolourBlock( side, colour, who );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEColor getColor()
|
||||
{
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package appeng.helpers;
|
||||
|
||||
import appeng.api.implementations.tiles.IColorableTile;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.parts.IPartHost;
|
||||
|
||||
public interface AEMultiTile extends IGridHost, IPartHost
|
||||
public interface AEMultiTile extends IGridHost, IPartHost, IColorableTile
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package appeng.hooks;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
|
@ -11,7 +12,9 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.event.world.ChunkEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.packets.PacketPaintedEntity;
|
||||
import appeng.crafting.CraftingJob;
|
||||
import appeng.entity.EntityFloatingItem;
|
||||
import appeng.me.Grid;
|
||||
|
@ -54,6 +57,47 @@ public class TickHandler
|
|||
final private HandlerRep server = new HandlerRep();
|
||||
final private HandlerRep client = new HandlerRep();
|
||||
|
||||
static public class PlayerColor
|
||||
{
|
||||
|
||||
public final AEColor myColor;
|
||||
protected final int myEntity;
|
||||
protected int ticksLeft;
|
||||
|
||||
public PacketPaintedEntity getPacket()
|
||||
{
|
||||
return new PacketPaintedEntity( myEntity, myColor, ticksLeft );
|
||||
}
|
||||
|
||||
public PlayerColor(int id, AEColor col, int ticks) {
|
||||
myEntity = id;
|
||||
myColor = col;
|
||||
ticksLeft = ticks;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
final private HashMap<Integer, PlayerColor> cliPlayerColors = new HashMap();
|
||||
final private HashMap<Integer, PlayerColor> srvPlayerColors = new HashMap();
|
||||
|
||||
public HashMap<Integer, PlayerColor> getPlayerColors()
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
return srvPlayerColors;
|
||||
return cliPlayerColors;
|
||||
}
|
||||
|
||||
private void tickColors(HashMap<Integer, PlayerColor> playerSet)
|
||||
{
|
||||
Iterator<PlayerColor> i = playerSet.values().iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
PlayerColor pc = i.next();
|
||||
if ( pc.ticksLeft-- <= 0 )
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
|
||||
HandlerRep getRepo()
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
|
@ -143,6 +187,7 @@ public class TickHandler
|
|||
|
||||
if ( ev.type == Type.CLIENT && ev.phase == Phase.START )
|
||||
{
|
||||
tickColors( cliPlayerColors );
|
||||
EntityFloatingItem.ageStatic = (EntityFloatingItem.ageStatic + 1) % 60000;
|
||||
}
|
||||
|
||||
|
@ -165,12 +210,13 @@ public class TickHandler
|
|||
// for no there is no reason to care about this on the client...
|
||||
else if ( ev.type == Type.SERVER && ev.phase == Phase.END )
|
||||
{
|
||||
tickColors( srvPlayerColors );
|
||||
// ready tiles.
|
||||
HandlerRep repo = getRepo();
|
||||
while (!repo.tiles.isEmpty())
|
||||
{
|
||||
AEBaseTile bt = repo.tiles.poll();
|
||||
if (! bt.isInvalid() )
|
||||
if ( !bt.isInvalid() )
|
||||
bt.onReady();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,10 @@ import net.minecraft.block.BlockDispenser;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemSnowball;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
@ -22,6 +24,7 @@ import appeng.api.config.FuzzyMode;
|
|||
import appeng.api.config.SortDir;
|
||||
import appeng.api.implementations.items.IItemGroup;
|
||||
import appeng.api.implementations.items.IStorageCell;
|
||||
import appeng.api.implementations.tiles.IColorableTile;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.ICellInventory;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
|
@ -30,6 +33,7 @@ import appeng.api.storage.StorageChannel;
|
|||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.block.misc.BlockPaint;
|
||||
import appeng.client.render.items.ToolColorApplicatorRender;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
@ -42,6 +46,7 @@ import appeng.items.contents.CellUpgrades;
|
|||
import appeng.items.misc.ItemPaintBall;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.me.storage.CellInventoryHandler;
|
||||
import appeng.tile.misc.TilePaint;
|
||||
import appeng.util.ItemSorters;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
@ -166,7 +171,36 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
|
|||
else
|
||||
paintBall = null;
|
||||
|
||||
if ( paintBall != null && paintBall.getItem() instanceof ItemPaintBall )
|
||||
if ( paintBall != null && paintBall.getItem() instanceof ItemSnowball )
|
||||
{
|
||||
ForgeDirection oside = ForgeDirection.getOrientation( side );
|
||||
TileEntity te = w.getTileEntity( x, y, z );
|
||||
// clean cables.
|
||||
if ( te instanceof IColorableTile )
|
||||
{
|
||||
if ( getAECurrentPower( is ) > powerPerUse && ((IColorableTile) te).getColor() != AEColor.Transparent )
|
||||
{
|
||||
if ( ((IColorableTile) te).recolourBlock( oside, AEColor.Transparent, p ) )
|
||||
{
|
||||
inv.extractItems( AEItemStack.create( paintBall ), Actionable.MODULATE, new BaseActionSource() );
|
||||
extractAEPower( is, powerPerUse );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// clean paint balls..
|
||||
Block testBlk = w.getBlock( x + oside.offsetX, y + oside.offsetY, z + oside.offsetZ );
|
||||
TileEntity painte = w.getTileEntity( x + oside.offsetX, y + oside.offsetY, z + oside.offsetZ );
|
||||
if ( getAECurrentPower( is ) > powerPerUse && testBlk instanceof BlockPaint && painte instanceof TilePaint )
|
||||
{
|
||||
inv.extractItems( AEItemStack.create( paintBall ), Actionable.MODULATE, new BaseActionSource() );
|
||||
extractAEPower( is, powerPerUse );
|
||||
((TilePaint) painte).cleanSide( oside.getOpposite() );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if ( paintBall != null && paintBall.getItem() instanceof ItemPaintBall )
|
||||
{
|
||||
ItemPaintBall ipb = (ItemPaintBall) paintBall.getItem();
|
||||
AEColor color = ipb.getColor( paintBall );
|
||||
|
@ -264,6 +298,9 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
|
|||
|
||||
ItemStack selected = getColor( par1ItemStack );
|
||||
|
||||
if ( selected != null && selected.getItem() instanceof ItemSnowball )
|
||||
extra = GuiText.Clean.getLocal();
|
||||
|
||||
if ( selected != null && selected.getItem() instanceof ItemPaintBall )
|
||||
extra = ((ItemPaintBall) selected.getItem()).getExtraName( selected );
|
||||
|
||||
|
@ -309,7 +346,14 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
|
|||
@Override
|
||||
public boolean isBlackListed(ItemStack cellItem, IAEItemStack requsetedAddition)
|
||||
{
|
||||
return requsetedAddition == null || !(requsetedAddition.getItem() instanceof ItemPaintBall && requsetedAddition.getItemDamage() < 20);
|
||||
if ( requsetedAddition != null )
|
||||
{
|
||||
if ( requsetedAddition.getItem() instanceof ItemSnowball )
|
||||
return false;
|
||||
|
||||
return !(requsetedAddition.getItem() instanceof ItemPaintBall && requsetedAddition.getItemDamage() < 20);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.block.BlockDispenser;
|
|||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.passive.EntitySheep;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -33,14 +34,18 @@ import appeng.api.storage.StorageChannel;
|
|||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketMatterCannon;
|
||||
import appeng.hooks.DispenserMatterCannon;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.hooks.TickHandler.PlayerColor;
|
||||
import appeng.items.contents.CellConfig;
|
||||
import appeng.items.contents.CellUpgrades;
|
||||
import appeng.items.misc.ItemPaintBall;
|
||||
|
@ -144,34 +149,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
|||
ItemStack type = ((IAEItemStack) aeammo).getItemStack();
|
||||
if ( type.getItem() instanceof ItemPaintBall )
|
||||
{
|
||||
MovingObjectPosition pos = w.rayTraceBlocks( vec3, vec31, false );
|
||||
if ( pos != null && pos.typeOfHit == MovingObjectType.BLOCK )
|
||||
{
|
||||
ForgeDirection side = ForgeDirection.getOrientation( pos.sideHit );
|
||||
|
||||
int x = pos.blockX + side.offsetX;
|
||||
int y = pos.blockY + side.offsetY;
|
||||
int z = pos.blockZ + side.offsetZ;
|
||||
|
||||
Block whatsThere = w.getBlock( x, y, z );
|
||||
if ( whatsThere == AEApi.instance().blocks().blockPaint.block() )
|
||||
{
|
||||
|
||||
}
|
||||
else if ( whatsThere.isReplaceable( w, x, y, z ) && w.isAirBlock( x, y, z ) )
|
||||
{
|
||||
w.setBlock( x, y, z, AEApi.instance().blocks().blockPaint.block(), 0, 3 );
|
||||
}
|
||||
|
||||
TileEntity te = w.getTileEntity( x, y, z );
|
||||
if ( te instanceof TilePaint )
|
||||
{
|
||||
pos.hitVec.xCoord -= x;
|
||||
pos.hitVec.yCoord -= y;
|
||||
pos.hitVec.zCoord -= z;
|
||||
((TilePaint) te).addBlot( type, side.getOpposite(), pos.hitVec );
|
||||
}
|
||||
}
|
||||
shootPaintBalls( type, w, p, vec3, vec31, direction, d0, d1, d2 );
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
@ -193,6 +171,123 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
|||
return item;
|
||||
}
|
||||
|
||||
private void shootPaintBalls(ItemStack type, World w, EntityPlayer p, Vec3 vec3, Vec3 vec31, Vec3 direction, double d0, double d1, double d2)
|
||||
{
|
||||
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox( 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MovingObjectPosition pos = w.rayTraceBlocks( vec3, vec31, false );
|
||||
|
||||
Vec3 Srec = Vec3.createVectorHelper( d0, d1, d2 );
|
||||
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) direction.xCoord,
|
||||
(float) direction.yCoord, (float) direction.zCoord, (byte) (pos == null ? 32 : pos.hitVec.squareDistanceTo( Srec ) + 1) ) );
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
AELog.error( err );
|
||||
}
|
||||
|
||||
if ( pos != null && type != null && type.getItem() instanceof ItemPaintBall )
|
||||
{
|
||||
ItemPaintBall ipb = (ItemPaintBall) type.getItem();
|
||||
|
||||
AEColor col = ipb.getColor( type );
|
||||
// boolean lit = ipb.isLumen( type );
|
||||
|
||||
if ( pos.typeOfHit == MovingObjectType.ENTITY )
|
||||
{
|
||||
int id = pos.entityHit.getEntityId();
|
||||
PlayerColor marker = new PlayerColor( id, col, 20 * 30 );
|
||||
TickHandler.instance.getPlayerColors().put( id, marker );
|
||||
|
||||
if ( pos.entityHit instanceof EntitySheep )
|
||||
{
|
||||
EntitySheep sh = (EntitySheep) pos.entityHit;
|
||||
sh.setFleeceColor( col.ordinal() );
|
||||
}
|
||||
|
||||
pos.entityHit.attackEntityFrom( DamageSource.causePlayerDamage( p ), (float) 0 );
|
||||
NetworkHandler.instance.sendToAll( marker.getPacket() );
|
||||
}
|
||||
else if ( pos.typeOfHit == MovingObjectType.BLOCK )
|
||||
{
|
||||
ForgeDirection side = ForgeDirection.getOrientation( pos.sideHit );
|
||||
|
||||
int x = pos.blockX + side.offsetX;
|
||||
int y = pos.blockY + side.offsetY;
|
||||
int z = pos.blockZ + side.offsetZ;
|
||||
|
||||
Block whatsThere = w.getBlock( x, y, z );
|
||||
if ( whatsThere == AEApi.instance().blocks().blockPaint.block() )
|
||||
{
|
||||
|
||||
}
|
||||
else if ( whatsThere.isReplaceable( w, x, y, z ) && w.isAirBlock( x, y, z ) )
|
||||
{
|
||||
w.setBlock( x, y, z, AEApi.instance().blocks().blockPaint.block(), 0, 3 );
|
||||
}
|
||||
|
||||
TileEntity te = w.getTileEntity( x, y, z );
|
||||
if ( te instanceof TilePaint )
|
||||
{
|
||||
pos.hitVec.xCoord -= x;
|
||||
pos.hitVec.yCoord -= y;
|
||||
pos.hitVec.zCoord -= z;
|
||||
((TilePaint) te).addBlot( type, side.getOpposite(), pos.hitVec );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void standardAmmo(float penitration, World w, EntityPlayer p, Vec3 vec3, Vec3 vec31, Vec3 direction, double d0, double d1, double d2)
|
||||
{
|
||||
boolean hasDestroyedSomething = true;
|
||||
|
|
|
@ -799,16 +799,13 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean recolourBlock(ForgeDirection side, int colour, EntityPlayer who)
|
||||
public boolean recolourBlock(ForgeDirection side, AEColor colour, EntityPlayer who)
|
||||
{
|
||||
IPart cable = getPart( ForgeDirection.UNKNOWN );
|
||||
if ( cable != null )
|
||||
{
|
||||
IPartCable pc = (IPartCable) cable;
|
||||
|
||||
AEColor colors[] = AEColor.values();
|
||||
if ( colors.length > colour )
|
||||
return pc.changeColor( colors[colour], who );
|
||||
return pc.changeColor( colour, who );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.util.Vec3;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import appeng.api.util.AEColor;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -34,7 +35,7 @@ public interface ICableBusContainer
|
|||
|
||||
SelectedPart selectPart(Vec3 v3);
|
||||
|
||||
boolean recolourBlock(ForgeDirection side, int colour, EntityPlayer who);
|
||||
boolean recolourBlock(ForgeDirection side, AEColor colour, EntityPlayer who);
|
||||
|
||||
boolean isLadder(EntityLivingBase entity);
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.util.Vec3;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import appeng.api.util.AEColor;
|
||||
|
||||
public class NullCableBusContainer implements ICableBusContainer
|
||||
{
|
||||
|
@ -69,7 +70,7 @@ public class NullCableBusContainer implements ICableBusContainer
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean recolourBlock(ForgeDirection side, int colour, EntityPlayer who)
|
||||
public boolean recolourBlock(ForgeDirection side, AEColor colour, EntityPlayer who)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,9 @@ import io.netty.buffer.ByteBuf;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.implementations.tiles.IColorableTile;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AEColor;
|
||||
|
@ -126,10 +128,15 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
|
|||
return paintedColor;
|
||||
}
|
||||
|
||||
public void setColor(AEColor newPaintedColor)
|
||||
@Override
|
||||
public boolean recolourBlock(ForgeDirection side, AEColor newPaintedColor, EntityPlayer who)
|
||||
{
|
||||
if ( paintedColor == newPaintedColor )
|
||||
return false;
|
||||
|
||||
paintedColor = newPaintedColor;
|
||||
markDirty();
|
||||
markForUpdate();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,11 +121,15 @@ public class TilePaint extends AEBaseTile
|
|||
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
Block blk = worldObj.getBlock( xCoord + side.offsetX, yCoord + side.offsetY, zCoord + side.offsetZ );
|
||||
if ( !blk.isSideSolid( worldObj, xCoord + side.offsetX, yCoord + side.offsetY, zCoord + side.offsetZ, side.getOpposite() ) )
|
||||
if ( !isSideValid( side ) )
|
||||
removeSide( side );
|
||||
}
|
||||
|
||||
updateData();
|
||||
}
|
||||
|
||||
private void updateData()
|
||||
{
|
||||
isLit = 0;
|
||||
for (Splot s : dots)
|
||||
{
|
||||
|
@ -144,6 +148,22 @@ public class TilePaint extends AEBaseTile
|
|||
worldObj.setBlock( xCoord, yCoord, zCoord, Blocks.air );
|
||||
}
|
||||
|
||||
public void cleanSide(ForgeDirection side)
|
||||
{
|
||||
if ( dots == null )
|
||||
return;
|
||||
|
||||
removeSide( side );
|
||||
|
||||
updateData();
|
||||
}
|
||||
|
||||
public boolean isSideValid(ForgeDirection side)
|
||||
{
|
||||
Block blk = worldObj.getBlock( xCoord + side.offsetX, yCoord + side.offsetY, zCoord + side.offsetZ );
|
||||
return blk.isSideSolid( worldObj, xCoord + side.offsetX, yCoord + side.offsetY, zCoord + side.offsetZ, side.getOpposite() );
|
||||
}
|
||||
|
||||
private void removeSide(ForgeDirection side)
|
||||
{
|
||||
Iterator<Splot> i = dots.iterator();
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.ArrayList;
|
|||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -328,11 +329,16 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
|||
return paintedColor;
|
||||
}
|
||||
|
||||
public void setColor(AEColor newPaintedColor)
|
||||
@Override
|
||||
public boolean recolourBlock(ForgeDirection side, AEColor newPaintedColor, EntityPlayer who)
|
||||
{
|
||||
if ( paintedColor == newPaintedColor )
|
||||
return false;
|
||||
|
||||
paintedColor = newPaintedColor;
|
||||
markDirty();
|
||||
markForUpdate();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -345,4 +345,10 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
|||
cb.updateConnections();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recolourBlock(ForgeDirection side, AEColor colour, EntityPlayer who)
|
||||
{
|
||||
return cb.recolourBlock( side, colour, who );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -827,10 +827,15 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
|||
return paintedColor;
|
||||
}
|
||||
|
||||
public void setColor(AEColor newPaintedColor)
|
||||
@Override
|
||||
public boolean recolourBlock(ForgeDirection side, AEColor newPaintedColor, EntityPlayer who)
|
||||
{
|
||||
if ( paintedColor == newPaintedColor )
|
||||
return false;
|
||||
|
||||
paintedColor = newPaintedColor;
|
||||
markDirty();
|
||||
markForUpdate();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue