mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-30 20:39:13 +00:00
latest work
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.entities.MEGEntity;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||
import com.ticxo.modelengine.api.generator.model.ModelBlueprint;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -39,8 +35,8 @@ public class CosmeticBalloonType extends Cosmetic {
|
||||
user.getBalloonEntity().setVelocity(actual.clone().subtract(previous.clone()).toVector());
|
||||
user.getBalloonEntity().updateModel();
|
||||
|
||||
PacketManager.sendTeleportPacket(user.getBalloonEntity().getBalloonID(), actual, false, PlayerUtils.getNearbyPlayers(player));
|
||||
PacketManager.sendLeashPacket(user.getBalloonEntity().getBalloonID(), player.getEntityId(), PlayerUtils.getNearbyPlayers(player));
|
||||
PacketManager.sendTeleportPacket(user.getBalloonEntity().getPufferfishBalloonId(), actual, false, PlayerUtils.getNearbyPlayers(player));
|
||||
PacketManager.sendLeashPacket(user.getBalloonEntity().getPufferfishBalloonId(), player.getEntityId(), PlayerUtils.getNearbyPlayers(player));
|
||||
}
|
||||
|
||||
public String getModelName() {
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
@@ -17,13 +18,15 @@ public class BalloonEntity {
|
||||
private final UUID uniqueID;
|
||||
private final MEGEntity megEntity;
|
||||
|
||||
public BalloonEntity(int balloonID, Location location) {
|
||||
public BalloonEntity(Location location) {
|
||||
this.uniqueID = UUID.randomUUID();
|
||||
this.balloonID = balloonID;
|
||||
this.megEntity = new MEGEntity(UUID.randomUUID(), balloonID, new Vector(0, 0, 0), location, false);
|
||||
this.balloonID = Entity.nextEntityId();
|
||||
this.megEntity = new MEGEntity(UUID.randomUUID(), Entity.nextEntityId(), new Vector(0, 0, 0), location, false);
|
||||
}
|
||||
|
||||
public void updateModel() {
|
||||
this.megEntity.update();
|
||||
/*
|
||||
final ModeledEntity model = ModelEngineAPI.api.getModeledEntity(megEntity.getUniqueId());
|
||||
|
||||
if (model == null) return;
|
||||
@@ -32,6 +35,7 @@ public class BalloonEntity {
|
||||
//HMCCosmeticsPlugin.getInstance().getLogger().info("Updated Model");
|
||||
e.update(this);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public void spawnModel(final String id) {
|
||||
@@ -69,6 +73,15 @@ public class BalloonEntity {
|
||||
model.showToPlayer(player);
|
||||
}
|
||||
|
||||
public void addPlayerToModel(final Player player) {
|
||||
final ModeledEntity model = ModelEngineAPI.api.getModeledEntity(megEntity.getUniqueId());
|
||||
if (model == null) {
|
||||
return;
|
||||
}
|
||||
//if (megEntity.getRangeManager().getPlayerInRange().contains(player)) return;
|
||||
model.showToPlayer(player);
|
||||
}
|
||||
|
||||
public void removePlayerFromModel(final Player player) {
|
||||
final ModeledEntity model = ModelEngineAPI.api.getModeledEntity(megEntity.getUniqueId());
|
||||
|
||||
@@ -78,17 +91,21 @@ public class BalloonEntity {
|
||||
}
|
||||
|
||||
|
||||
public int getBalloonID() {
|
||||
public int getPufferfishBalloonId() {
|
||||
return balloonID;
|
||||
}
|
||||
public UUID getBalloonUUID() {
|
||||
public UUID getPufferfishBalloonUniqueId() {
|
||||
return uniqueID;
|
||||
}
|
||||
|
||||
public UUID getUniqueID() {
|
||||
public UUID getModelUnqiueId() {
|
||||
return megEntity.getUniqueId();
|
||||
}
|
||||
|
||||
public int getModelId() {
|
||||
return megEntity.getEntityId();
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return this.megEntity.getLocation();
|
||||
}
|
||||
|
||||
@@ -57,10 +57,10 @@ public class MEGEntity implements BaseEntity {
|
||||
this.alive = false;
|
||||
}
|
||||
|
||||
public void update(BalloonEntity entity) {
|
||||
this.velocity = entity.getLocation().toVector();
|
||||
this.location = entity.getLocation();
|
||||
this.alive = entity.isAlive();
|
||||
public void update() {
|
||||
for (Player player : rangeManager.getPlayerInRange()) {
|
||||
rangeManager.updatePlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
public void setVelocity(final Vector velocity) {
|
||||
|
||||
@@ -9,13 +9,8 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||
import com.hibiscusmc.hmccosmetics.entities.BalloonEntity;
|
||||
import com.hibiscusmc.hmccosmetics.entities.InvisibleArmorstand;
|
||||
import com.hibiscusmc.hmccosmetics.entities.MEGEntity;
|
||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@@ -24,7 +19,6 @@ import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -173,15 +167,15 @@ public class CosmeticUser {
|
||||
Location newLoc = player.getLocation().clone().add(Settings.getBalloonOffset());
|
||||
|
||||
if (this.balloonEntity != null) return;
|
||||
BalloonEntity balloonEntity1 = new BalloonEntity(Entity.nextEntityId(), player.getLocation());
|
||||
BalloonEntity balloonEntity1 = new BalloonEntity(player.getLocation());
|
||||
|
||||
balloonEntity1.spawnModel(cosmeticBalloonType.getModelName());
|
||||
balloonEntity1.addPlayerToModel(player, cosmeticBalloonType.getModelName());
|
||||
balloonEntity1.updateModel();
|
||||
|
||||
PacketManager.sendEntitySpawnPacket(newLoc, balloonEntity1.getBalloonID(), EntityType.PUFFERFISH, balloonEntity1.getBalloonUUID(), sentTo);
|
||||
PacketManager.sendInvisibilityPacket(balloonEntity1.getBalloonID(), sentTo);
|
||||
PacketManager.sendLeashPacket(balloonEntity1.getBalloonID(), player.getEntityId(), sentTo);
|
||||
PacketManager.sendEntitySpawnPacket(newLoc, balloonEntity1.getPufferfishBalloonId(), EntityType.PUFFERFISH, balloonEntity1.getPufferfishBalloonUniqueId(), sentTo);
|
||||
PacketManager.sendInvisibilityPacket(balloonEntity1.getPufferfishBalloonId(), sentTo);
|
||||
PacketManager.sendLeashPacket(balloonEntity1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
|
||||
|
||||
this.balloonEntity = balloonEntity1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user