mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 18:49:39 +00:00
Scripted particles can now spawn anywhere in the world, not just attached to an entity.
ScriptEntityParticle renamed to ScriptParticle, and EntityCustomFX renamed to CustomFX. Re-enabled OpenGL blending for custom particles.
This commit is contained in:
1 parent
dbc9754b43
commit
c3b9096295
8 files changed
+50
-48
No files matched your search
@@ -6,7 +6,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Vector;
|
||||
|
||||
@@ -23,7 +22,7 @@ import net.minecraft.world.World;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.NoppesUtilPlayer;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.client.fx.EntityCustomFX;
|
||||
import noppes.npcs.client.fx.CustomFX;
|
||||
import noppes.npcs.client.gui.player.GuiDialogInteract;
|
||||
import noppes.npcs.client.gui.player.GuiQuestCompletion;
|
||||
import noppes.npcs.client.gui.util.GuiContainerNPCInterface;
|
||||
@@ -130,11 +129,8 @@ public class NoppesUtil {
|
||||
World worldObj = Minecraft.getMinecraft().theWorld;
|
||||
Entity entity = worldObj.getEntityByID(entityID);
|
||||
|
||||
if(entity == null)
|
||||
return;
|
||||
|
||||
EntityCustomFX fx = new EntityCustomFX(
|
||||
entity,
|
||||
CustomFX fx = new CustomFX(
|
||||
worldObj, entity,
|
||||
directory, HEXcolor,
|
||||
x, y, z,
|
||||
motionX, motionY, motionZ, gravity,
|
||||
|
||||
+17
-23
@@ -12,6 +12,7 @@ import net.minecraft.client.resources.data.TextureMetadataSection;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.client.ClientProxy;
|
||||
import noppes.npcs.client.ImageDownloadAlt;
|
||||
import noppes.npcs.client.renderer.ImageBufferDownloadAlt;
|
||||
@@ -22,8 +23,8 @@ import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class EntityCustomFX extends EntityFX {
|
||||
private Entity entity;
|
||||
public class CustomFX extends EntityFX {
|
||||
private Entity entity = null;
|
||||
private final ResourceLocation location;
|
||||
private static final ResourceLocation resource = new ResourceLocation("textures/particle/particles.png");
|
||||
private boolean move = true;
|
||||
@@ -74,17 +75,17 @@ public class EntityCustomFX extends EntityFX {
|
||||
private boolean isUrl = false;
|
||||
private boolean gotWidthHeight = false;
|
||||
|
||||
public EntityCustomFX(Entity entity, String directory, int HEXColor, double x, double y, double z,
|
||||
double motionX, double motionY, double motionZ, float gravity,
|
||||
float scale1, float scale2, float scaleRate, int scaleRateStart,
|
||||
float alpha1, float alpha2, float alphaRate, int alphaRateStart,
|
||||
float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart,
|
||||
float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart,
|
||||
float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart,
|
||||
int age, boolean facePlayer, int width, int height, int offsetX, int offsetY,
|
||||
int animRate, boolean animLoop, int animStart, int animEnd
|
||||
public CustomFX(World worldObj, Entity entity, String directory, int HEXColor, double x, double y, double z,
|
||||
double motionX, double motionY, double motionZ, float gravity,
|
||||
float scale1, float scale2, float scaleRate, int scaleRateStart,
|
||||
float alpha1, float alpha2, float alphaRate, int alphaRateStart,
|
||||
float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart,
|
||||
float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart,
|
||||
float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart,
|
||||
int age, boolean facePlayer, int width, int height, int offsetX, int offsetY,
|
||||
int animRate, boolean animLoop, int animStart, int animEnd
|
||||
) {
|
||||
super(entity.worldObj, x, y, z, motionX, motionY, motionZ);
|
||||
super(worldObj, x, y, z, motionX, motionY, motionZ);
|
||||
|
||||
this.scale1 = scale1;
|
||||
this.scale2 = scale2;
|
||||
@@ -139,13 +140,6 @@ public class EntityCustomFX extends EntityFX {
|
||||
particleRed = (HEXColor >> 16 & 255) / 255f;
|
||||
particleGreen = (HEXColor >> 8 & 255) / 255f;
|
||||
particleBlue = (HEXColor & 255) / 255f;
|
||||
|
||||
if(Math.floor(Math.random()*3) == 1){
|
||||
move = false;
|
||||
this.startX = (float) entity.posX;
|
||||
this.startY = (float) entity.posY;
|
||||
this.startZ = (float) entity.posZ;
|
||||
}
|
||||
|
||||
location = new ResourceLocation(directory);
|
||||
|
||||
@@ -215,7 +209,7 @@ public class EntityCustomFX extends EntityFX {
|
||||
getURLWidthHeight();
|
||||
}
|
||||
|
||||
if(move){
|
||||
if(move && entity != null){
|
||||
startX = (float)(entity.prevPosX + (entity.posX - entity.prevPosX) * (double)partialTick);
|
||||
startY = (float)(entity.prevPosY + (entity.posY - entity.prevPosY) * (double)partialTick);
|
||||
startZ = (float)(entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)partialTick);
|
||||
@@ -267,9 +261,9 @@ public class EntityCustomFX extends EntityFX {
|
||||
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
float renderScale = 0.1F * particleScale;
|
||||
float posX = (float)(((prevPosX + (this.posX - prevPosX) * (double)partialTick) - interpPosX) + startX);
|
||||
float posY = (float)(((prevPosY + (this.posY - prevPosY) * (double)partialTick) - interpPosY) + startY);
|
||||
float posZ = (float)(((prevPosZ + (this.posZ - prevPosZ) * (double)partialTick) - interpPosZ) + startZ);
|
||||
float posX = (float)((prevPosX + (this.posX - prevPosX) * (double)partialTick) - interpPosX) + startX;
|
||||
float posY = (float)((prevPosY + (this.posY - prevPosY) * (double)partialTick) - interpPosY) + startY;
|
||||
float posZ = (float)((prevPosZ + (this.posZ - prevPosZ) * (double)partialTick) - interpPosZ) + startZ;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(posX,posY,posZ);
|
||||
@@ -10,11 +10,8 @@ import java.io.File;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.eventhandler.EventBus;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.DamageSource;
|
||||
@@ -91,7 +88,9 @@ public abstract class NpcAPI {
|
||||
|
||||
public abstract ScriptItemStack createItem(String id, int damage, int size);
|
||||
|
||||
public abstract ScriptEntityParticle createEntityParticle(String directory);
|
||||
public abstract ScriptParticle createParticle(String directory);
|
||||
|
||||
public abstract ScriptParticle createEntityParticle(String directory);
|
||||
|
||||
public abstract int getServerTime();
|
||||
}
|
||||
+17
-2
@@ -6,7 +6,7 @@ import noppes.npcs.scripted.entity.ScriptEntity;
|
||||
/**
|
||||
* Created by luisc on 9/8/2021.
|
||||
*/
|
||||
public class ScriptEntityParticle {
|
||||
public class ScriptParticle {
|
||||
private String directory;
|
||||
private int HEXcolor = 0xFFFFFF;
|
||||
private int amount = 1;
|
||||
@@ -42,7 +42,7 @@ public class ScriptEntityParticle {
|
||||
|
||||
public boolean facePlayer = true;
|
||||
|
||||
public ScriptEntityParticle(String directory){
|
||||
public ScriptParticle(String directory){
|
||||
this.directory = directory;
|
||||
}
|
||||
|
||||
@@ -62,6 +62,21 @@ public class ScriptEntityParticle {
|
||||
);
|
||||
}
|
||||
|
||||
public void spawnInWorld(double x, double y, double z){
|
||||
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||
x, y, z,
|
||||
motionX, motionY, motionZ, gravity,
|
||||
scale1, scale2, scaleRate, scaleRateStart,
|
||||
alpha1, alpha2, alphaRate, alphaRateStart,
|
||||
rotationX1, rotationX2, rotationXRate, rotationXRateStart,
|
||||
rotationY1, rotationY2, rotationYRate, rotationYRateStart,
|
||||
rotationZ1, rotationZ2, rotationZRate, rotationZRateStart,
|
||||
facePlayer, width, height, offsetX, offsetY,
|
||||
animRate, animLoop, animStart, animEnd,
|
||||
-1
|
||||
);
|
||||
}
|
||||
|
||||
public void setSize(int width, int height){
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
@@ -21,7 +21,6 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntitySign;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.blocks.tiles.TileBigSign;
|
||||
@@ -31,7 +30,6 @@ import noppes.npcs.scripted.entity.ScriptEntity;
|
||||
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||
import noppes.npcs.scripted.interfaces.IBlock;
|
||||
import noppes.npcs.scripted.interfaces.IWorld;
|
||||
import sun.font.Script;
|
||||
|
||||
public class ScriptWorld implements IWorld {
|
||||
private static Map<String,Object> tempData = new HashMap<String,Object>();
|
||||
@@ -335,8 +333,8 @@ public class ScriptWorld implements IWorld {
|
||||
* @param directory The particle's texture directory. Use only forward slashes when writing a directory. Example: "customnpcs:textures/particle/tail.png"
|
||||
* @return Returns ScriptEntityParticle object
|
||||
*/
|
||||
public ScriptEntityParticle createEntityParticle(String directory){
|
||||
return new ScriptEntityParticle(directory);
|
||||
public ScriptParticle createEntityParticle(String directory){
|
||||
return new ScriptParticle(directory);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,6 @@ import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTBase.NBTPrimitive;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldServer;
|
||||
@@ -177,7 +176,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
entityID
|
||||
);
|
||||
}
|
||||
public void spawnParticle(ScriptEntityParticle entityParticle) { entityParticle.spawnOnEntity(this); }
|
||||
public void spawnParticle(ScriptParticle entityParticle) { entityParticle.spawnOnEntity(this); }
|
||||
|
||||
public int getEntityId(){
|
||||
return entity.getEntityId();
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package noppes.npcs.scripted.interfaces;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import noppes.npcs.scripted.*;
|
||||
import noppes.npcs.scripted.entity.ScriptEntity;
|
||||
@@ -175,7 +172,7 @@ public interface IWorld {
|
||||
* @param directory The particle's texture directory. Use only forward slashes when writing a directory. Example: "customnpcs:textures/particle/tail.png"
|
||||
* @return Returns ScriptEntityParticle object
|
||||
*/
|
||||
public ScriptEntityParticle createEntityParticle(String directory);
|
||||
public ScriptParticle createEntityParticle(String directory);
|
||||
|
||||
/**
|
||||
* @param key Get temp data for this key
|
||||
|
||||
@@ -283,8 +283,12 @@ public class WrapperNpcAPI extends NpcAPI {
|
||||
MinecraftServer.getServer().setMOTD(motd);
|
||||
}
|
||||
|
||||
public ScriptEntityParticle createEntityParticle(String directory){
|
||||
return new ScriptEntityParticle(directory);
|
||||
public ScriptParticle createParticle(String directory){
|
||||
return new ScriptParticle(directory);
|
||||
}
|
||||
|
||||
public ScriptParticle createEntityParticle(String directory){
|
||||
return new ScriptParticle(directory);
|
||||
}
|
||||
|
||||
public int getServerTime() {
|
||||
|
||||
Reference in new issue
Block a user