Added Custom Particles for scripted entities that work on server and client sides.

This commit is contained in:
luisc committed 2021-09-06 01:24:38 -05:00
1 parent 9f4ab7f01e
commit fbc22fdef2
6 files changed
+295 -11

No files matched your search

@@ -6,12 +6,14 @@ 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;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
@@ -19,8 +21,10 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Util;
import net.minecraft.world.World;
import noppes.npcs.CustomNpcs;
import noppes.npcs.ModelPartData;
import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.Server;
import noppes.npcs.client.fx.EntityCustomFX;
import noppes.npcs.client.gui.player.GuiDialogInteract;
import noppes.npcs.client.gui.player.GuiQuestCompletion;
import noppes.npcs.client.gui.util.GuiContainerNPCInterface;
@@ -67,6 +71,71 @@ public class NoppesUtil {
}
}
public static void spawnScriptedParticle(ByteBuf buffer){
Minecraft minecraft = Minecraft.getMinecraft();
String directory = Server.readString(buffer);
int HEXcolor = buffer.readInt();
int amount = buffer.readInt();
int maxAge = buffer.readInt();
double x = buffer.readDouble();
double y = buffer.readDouble();
double z = buffer.readDouble();
double motionX = buffer.readDouble();
double motionY = buffer.readDouble();
double motionZ = buffer.readDouble();
float gravity = buffer.readFloat();
float scale1 = buffer.readFloat();
float scale2 = buffer.readFloat();
float scaleRate = buffer.readFloat();
int scaleRateStart = buffer.readInt();
float alpha1 = buffer.readFloat();
float alpha2 = buffer.readFloat();
float alphaRate = buffer.readFloat();
int alphaRateStart = buffer.readInt();
String playerName = Server.readString(buffer);
String UUID = Server.readString(buffer);
int entityID = buffer.readInt();
ModelPartData particle = new ModelPartData();
particle.setAttributes(
directory, HEXcolor, amount, maxAge,
x, y, z,
motionX, motionY, motionZ, gravity,
scale1, scale2, scaleRate, scaleRateStart,
alpha1, alpha2, alphaRate, alphaRateStart
);
World worldObj = Minecraft.getMinecraft().theWorld;
EntityPlayer player = worldObj.getPlayerEntityByName(playerName);
List<Entity> entities = player.worldObj.getEntitiesWithinAABB(Entity.class, player.boundingBox.expand(300, 300, 300));
for(Entity entity : entities){
if(UUID.equals(entity.getPersistentID().toString()) || (entity.getEntityId() == entityID)){
EntityCustomFX fx = new EntityCustomFX(
entity,
x, y, z,
motionX, motionY, motionZ, gravity,
scale1, scale2, scaleRate, scaleRateStart,
alpha1, alpha2, alphaRate, alphaRateStart,
particle.getMaxAge(),
particle
);
for(int i = 0; i < particle.getAmount(); i++){
minecraft.effectRenderer.addEffect(fx);
}
break;
}
}
}
public static void clickSound() {
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
}