mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
More Phantom Device particles that make them look awesome
This commit is contained in:
parent
31bffd7076
commit
6d0e88220b
6 changed files with 69 additions and 34 deletions
|
@ -14,6 +14,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import ellpeck.actuallyadditions.items.base.ItemBase;
|
import ellpeck.actuallyadditions.items.base.ItemBase;
|
||||||
import ellpeck.actuallyadditions.tile.IPhantomTile;
|
import ellpeck.actuallyadditions.tile.IPhantomTile;
|
||||||
|
import ellpeck.actuallyadditions.tile.TileEntityBase;
|
||||||
import ellpeck.actuallyadditions.util.ModUtil;
|
import ellpeck.actuallyadditions.util.ModUtil;
|
||||||
import ellpeck.actuallyadditions.util.StringUtil;
|
import ellpeck.actuallyadditions.util.StringUtil;
|
||||||
import ellpeck.actuallyadditions.util.WorldPos;
|
import ellpeck.actuallyadditions.util.WorldPos;
|
||||||
|
@ -48,6 +49,9 @@ public class ItemPhantomConnector extends ItemBase{
|
||||||
if(tile instanceof IPhantomTile){
|
if(tile instanceof IPhantomTile){
|
||||||
if(this.checkHasConnection(stack, player, tile)){
|
if(this.checkHasConnection(stack, player, tile)){
|
||||||
((IPhantomTile)tile).setBoundPosition(getStoredPosition(stack));
|
((IPhantomTile)tile).setBoundPosition(getStoredPosition(stack));
|
||||||
|
if(tile instanceof TileEntityBase){
|
||||||
|
((TileEntityBase)tile).sendUpdate();
|
||||||
|
}
|
||||||
clearStorage(stack);
|
clearStorage(stack);
|
||||||
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connected.desc")));
|
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connected.desc")));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* This file ("EntityColoredParticleFX.java") is part of the Actually Additions Mod for Minecraft.
|
||||||
|
* It is created and owned by Ellpeck and distributed
|
||||||
|
* under the Actually Additions License to be found at
|
||||||
|
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||||
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||||
|
*
|
||||||
|
* © 2015 Ellpeck
|
||||||
|
*/
|
||||||
|
|
||||||
|
package ellpeck.actuallyadditions.misc;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraft.client.particle.EntityReddustFX;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public class EntityColoredParticleFX extends EntityReddustFX{
|
||||||
|
|
||||||
|
public EntityColoredParticleFX(World world, double x, double y, double z, float size, float r, float g, float b, int ageMulti){
|
||||||
|
super(world, x, y, z, size, r, g, b);
|
||||||
|
//To work around Reddust particles resetting the color to red if it's 0 (which is really stupid to be honest)
|
||||||
|
this.particleRed = ((float)(Math.random()*0.20000000298023224D)+0.8F)*r*(float)Math.random()*0.4F+0.6F;
|
||||||
|
this.particleMaxAge = (int)(8.0D/(Math.random()*0.8D+0.2D))*ageMulti;
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,9 +15,9 @@ import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import ellpeck.actuallyadditions.misc.EntityColoredParticleFX;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.particle.EntityReddustFX;
|
|
||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.Vec3;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
@ -88,22 +88,26 @@ public class PacketParticle implements IMessage{
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public IMessage onMessage(PacketParticle message, MessageContext ctx){
|
public IMessage onMessage(PacketParticle message, MessageContext ctx){
|
||||||
World world = Minecraft.getMinecraft().theWorld;
|
renderParticlesFromAToB(message.startX, message.startY, message.startZ, message.endX, message.endY, message.endZ, message.particleAmount, message.particleSize, message.color, 1);
|
||||||
|
|
||||||
if(Minecraft.getMinecraft().thePlayer.getDistance(message.startX, message.startY, message.startZ) <= 64){
|
|
||||||
int difX = message.startX-message.endX;
|
|
||||||
int difY = message.startY-message.endY;
|
|
||||||
int difZ = message.startZ-message.endZ;
|
|
||||||
double distance = Vec3.createVectorHelper(message.startX, message.startY, message.startZ).distanceTo(Vec3.createVectorHelper(message.endX, message.endY, message.endZ));
|
|
||||||
|
|
||||||
for(int times = 0; times < message.particleAmount/2; times++){
|
|
||||||
for(double i = 0; i <= 1; i += 1/(distance*message.particleAmount)){
|
|
||||||
Minecraft.getMinecraft().effectRenderer.addEffect(new EntityReddustFX(world, (difX*i)+message.endX+0.5, (difY*i)+message.endY+0.5, (difZ*i)+message.endZ+0.5, message.particleSize, message.color[0], message.color[1], message.color[2]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void renderParticlesFromAToB(int startX, int startY, int startZ, int endX, int endY, int endZ, int particleAmount, float particleSize, float[] color, int ageMultiplier){
|
||||||
|
World world = Minecraft.getMinecraft().theWorld;
|
||||||
|
|
||||||
|
if(Minecraft.getMinecraft().thePlayer.getDistance(startX, startY, startZ) <= 64){
|
||||||
|
int difX = startX-endX;
|
||||||
|
int difY = startY-endY;
|
||||||
|
int difZ = startZ-endZ;
|
||||||
|
double distance = Vec3.createVectorHelper(startX, startY, startZ).distanceTo(Vec3.createVectorHelper(endX, endY, endZ));
|
||||||
|
|
||||||
|
for(int times = 0; times < particleAmount/2; times++){
|
||||||
|
for(double i = 0; i <= 1; i += 1/(distance*particleAmount)){
|
||||||
|
EntityColoredParticleFX fx = new EntityColoredParticleFX(world, (difX*i)+endX+0.5, (difY*i)+endY+0.5, (difZ*i)+endZ+0.5, particleSize, color[0], color[1], color[2], ageMultiplier);
|
||||||
|
Minecraft.getMinecraft().effectRenderer.addEffect(fx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,11 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import ellpeck.actuallyadditions.config.values.ConfigBoolValues;
|
import ellpeck.actuallyadditions.config.values.ConfigBoolValues;
|
||||||
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
||||||
import ellpeck.actuallyadditions.misc.LaserRelayConnectionHandler;
|
import ellpeck.actuallyadditions.misc.LaserRelayConnectionHandler;
|
||||||
|
import ellpeck.actuallyadditions.network.PacketParticle;
|
||||||
import ellpeck.actuallyadditions.util.Util;
|
import ellpeck.actuallyadditions.util.Util;
|
||||||
import ellpeck.actuallyadditions.util.WorldPos;
|
import ellpeck.actuallyadditions.util.WorldPos;
|
||||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||||
import io.netty.util.internal.ConcurrentSet;
|
import io.netty.util.internal.ConcurrentSet;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.particle.EntityReddustFX;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
|
@ -32,6 +31,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||||
public class TileEntityLaserRelay extends TileEntityBase implements IEnergyReceiver{
|
public class TileEntityLaserRelay extends TileEntityBase implements IEnergyReceiver{
|
||||||
|
|
||||||
public static final int MAX_DISTANCE = 15;
|
public static final int MAX_DISTANCE = 15;
|
||||||
|
private static final float[] COLOR = new float[]{1F, 0F, 0F};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity(){
|
public void updateEntity(){
|
||||||
|
@ -49,16 +49,7 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
|
||||||
if(network != null){
|
if(network != null){
|
||||||
for(LaserRelayConnectionHandler.ConnectionPair aPair : network.connections){
|
for(LaserRelayConnectionHandler.ConnectionPair aPair : network.connections){
|
||||||
if(aPair.contains(thisPos) && thisPos.isEqual(aPair.firstRelay)){
|
if(aPair.contains(thisPos) && thisPos.isEqual(aPair.firstRelay)){
|
||||||
if(Minecraft.getMinecraft().thePlayer.getDistance(aPair.firstRelay.getX(), aPair.firstRelay.getY(), aPair.firstRelay.getZ()) <= 64){
|
PacketParticle.renderParticlesFromAToB(aPair.firstRelay.getX(), aPair.firstRelay.getY(), aPair.firstRelay.getZ(), aPair.secondRelay.getX(), aPair.secondRelay.getY(), aPair.secondRelay.getZ(), ConfigBoolValues.LESS_LASER_RELAY_PARTICLES.isEnabled() ? 1 : 5, 0.75F, COLOR, 1);
|
||||||
int difX = aPair.firstRelay.getX()-aPair.secondRelay.getX();
|
|
||||||
int difY = aPair.firstRelay.getY()-aPair.secondRelay.getY();
|
|
||||||
int difZ = aPair.firstRelay.getZ()-aPair.secondRelay.getZ();
|
|
||||||
|
|
||||||
double distance = aPair.firstRelay.toVec().distanceTo(aPair.secondRelay.toVec());
|
|
||||||
for(double i = 0; i <= 1; i += 1/(distance*(ConfigBoolValues.LESS_LASER_RELAY_PARTICLES.isEnabled() ? 1 : 5))){
|
|
||||||
Minecraft.getMinecraft().effectRenderer.addEffect(new EntityReddustFX(this.worldObj, (difX*i)+aPair.secondRelay.getX()+0.5, (difY*i)+aPair.secondRelay.getY()+0.5, (difZ*i)+aPair.secondRelay.getZ()+0.5, 0.75F, 0, 0, 0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ package ellpeck.actuallyadditions.tile;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import ellpeck.actuallyadditions.inventory.GuiHandler;
|
import ellpeck.actuallyadditions.inventory.GuiHandler;
|
||||||
|
import ellpeck.actuallyadditions.network.PacketParticle;
|
||||||
import ellpeck.actuallyadditions.util.Util;
|
import ellpeck.actuallyadditions.util.Util;
|
||||||
import ellpeck.actuallyadditions.util.WorldPos;
|
import ellpeck.actuallyadditions.util.WorldPos;
|
||||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||||
|
@ -20,8 +21,6 @@ import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.Vec3;
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.DimensionManager;
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -110,6 +109,10 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
||||||
double d3 = (double)(Util.RANDOM.nextFloat()*1.0F*(float)i1);
|
double d3 = (double)(Util.RANDOM.nextFloat()*1.0F*(float)i1);
|
||||||
worldObj.spawnParticle("portal", d0, d1, d2, d3, d4, d5);
|
worldObj.spawnParticle("portal", d0, d1, d2, d3, d4, d5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this.ticksElapsed%80 == 0){
|
||||||
|
PacketParticle.renderParticlesFromAToB(xCoord, yCoord, zCoord, boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), 2, 0.35F, TileEntityPhantomface.COLORS, 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -152,8 +155,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
||||||
@Override
|
@Override
|
||||||
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
|
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
|
||||||
super.writeSyncableNBT(compound, sync);
|
super.writeSyncableNBT(compound, sync);
|
||||||
compound.setInteger("Time", currentTime);
|
if(this.boundPosition != null){
|
||||||
if(this.hasBoundPosition()){
|
|
||||||
compound.setInteger("XCoordOfTileStored", boundPosition.getX());
|
compound.setInteger("XCoordOfTileStored", boundPosition.getX());
|
||||||
compound.setInteger("YCoordOfTileStored", boundPosition.getY());
|
compound.setInteger("YCoordOfTileStored", boundPosition.getY());
|
||||||
compound.setInteger("ZCoordOfTileStored", boundPosition.getZ());
|
compound.setInteger("ZCoordOfTileStored", boundPosition.getZ());
|
||||||
|
@ -167,8 +169,8 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
||||||
int x = compound.getInteger("XCoordOfTileStored");
|
int x = compound.getInteger("XCoordOfTileStored");
|
||||||
int y = compound.getInteger("YCoordOfTileStored");
|
int y = compound.getInteger("YCoordOfTileStored");
|
||||||
int z = compound.getInteger("ZCoordOfTileStored");
|
int z = compound.getInteger("ZCoordOfTileStored");
|
||||||
World world = DimensionManager.getWorld(compound.getInteger("WorldOfTileStored"));
|
int world = compound.getInteger("WorldOfTileStored");
|
||||||
if(x != 0 && y != 0 && z != 0 && world != null){
|
if(!(x == 0 && y == 0 && z == 0)){
|
||||||
this.boundPosition = new WorldPos(world, x, y, z);
|
this.boundPosition = new WorldPos(world, x, y, z);
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import ellpeck.actuallyadditions.blocks.BlockPhantom;
|
import ellpeck.actuallyadditions.blocks.BlockPhantom;
|
||||||
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
||||||
|
import ellpeck.actuallyadditions.network.PacketParticle;
|
||||||
import ellpeck.actuallyadditions.util.Util;
|
import ellpeck.actuallyadditions.util.Util;
|
||||||
import ellpeck.actuallyadditions.util.WorldPos;
|
import ellpeck.actuallyadditions.util.WorldPos;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -32,6 +33,8 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
||||||
private WorldPos boundPosBefore;
|
private WorldPos boundPosBefore;
|
||||||
private Block boundBlockBefore;
|
private Block boundBlockBefore;
|
||||||
|
|
||||||
|
public static final float[] COLORS = new float[]{93F/255F, 43F/255F, 181F/255F};
|
||||||
|
|
||||||
public TileEntityPhantomface(String name){
|
public TileEntityPhantomface(String name){
|
||||||
super(0, name);
|
super(0, name);
|
||||||
}
|
}
|
||||||
|
@ -131,6 +134,10 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
||||||
double d3 = (double)(Util.RANDOM.nextFloat()*1.0F*(float)i1);
|
double d3 = (double)(Util.RANDOM.nextFloat()*1.0F*(float)i1);
|
||||||
worldObj.spawnParticle("portal", d0, d1, d2, d3, d4, d5);
|
worldObj.spawnParticle("portal", d0, d1, d2, d3, d4, d5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this.ticksElapsed%80 == 0){
|
||||||
|
PacketParticle.renderParticlesFromAToB(xCoord, yCoord, zCoord, boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), 2, 0.35F, COLORS, 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue