mirror of
https://github.com/HibiscusMC/HibiscusCommons.git
synced 2025-12-19 15:09:26 +00:00
feat: attribute modifiers now included in scale
This commit is contained in:
@@ -8,9 +8,12 @@ public class PlayerScaleWrapper {
|
|||||||
private final int entityId;
|
private final int entityId;
|
||||||
@Getter
|
@Getter
|
||||||
private final double scale;
|
private final double scale;
|
||||||
|
@Getter
|
||||||
|
private final double base;
|
||||||
|
|
||||||
public PlayerScaleWrapper(int entityId, double scale) {
|
public PlayerScaleWrapper(int entityId, double base, double scale) {
|
||||||
this.entityId = entityId;
|
this.entityId = entityId;
|
||||||
this.scale = scale;
|
this.scale = scale;
|
||||||
|
this.base = base;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import me.lojosho.hibiscuscommons.util.MessagesUtil;
|
|||||||
import net.minecraft.core.NonNullList;
|
import net.minecraft.core.NonNullList;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.*;
|
import net.minecraft.network.protocol.game.*;
|
||||||
|
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
||||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||||
import net.minecraft.world.inventory.ClickType;
|
import net.minecraft.world.inventory.ClickType;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
@@ -183,7 +184,18 @@ public class NMSPacketChannel extends ChannelDuplexHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AtomicReference<PacketAction> action = new AtomicReference<>(PacketAction.NOTHING);
|
AtomicReference<PacketAction> action = new AtomicReference<>(PacketAction.NOTHING);
|
||||||
PlayerScaleWrapper wrapper = new PlayerScaleWrapper(packet.getEntityId(), nmsScaleAttribute.base());
|
|
||||||
|
final double base = nmsScaleAttribute.base();
|
||||||
|
double total = base;
|
||||||
|
|
||||||
|
for (AttributeModifier modifier : nmsScaleAttribute.modifiers()) {
|
||||||
|
switch (modifier.operation()) {
|
||||||
|
case ADD_VALUE -> total += modifier.amount();
|
||||||
|
case ADD_MULTIPLIED_BASE -> total += modifier.amount() * nmsScaleAttribute.base();
|
||||||
|
case ADD_MULTIPLIED_TOTAL -> total += modifier.amount() * total;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlayerScaleWrapper wrapper = new PlayerScaleWrapper(packet.getEntityId(), base, total);
|
||||||
|
|
||||||
SubPlugins.getSubPlugins().forEach(plugin -> {
|
SubPlugins.getSubPlugins().forEach(plugin -> {
|
||||||
PacketAction pluginAction = plugin.getPacketInterface().readPlayerScale(player, wrapper);
|
PacketAction pluginAction = plugin.getPacketInterface().readPlayerScale(player, wrapper);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import me.lojosho.hibiscuscommons.util.MessagesUtil;
|
|||||||
import net.minecraft.core.NonNullList;
|
import net.minecraft.core.NonNullList;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.*;
|
import net.minecraft.network.protocol.game.*;
|
||||||
|
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
||||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||||
import net.minecraft.world.inventory.ClickType;
|
import net.minecraft.world.inventory.ClickType;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
@@ -183,7 +184,18 @@ public class NMSPacketChannel extends ChannelDuplexHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AtomicReference<PacketAction> action = new AtomicReference<>(PacketAction.NOTHING);
|
AtomicReference<PacketAction> action = new AtomicReference<>(PacketAction.NOTHING);
|
||||||
PlayerScaleWrapper wrapper = new PlayerScaleWrapper(packet.getEntityId(), nmsScaleAttribute.base());
|
|
||||||
|
final double base = nmsScaleAttribute.base();
|
||||||
|
double total = base;
|
||||||
|
|
||||||
|
for (AttributeModifier modifier : nmsScaleAttribute.modifiers()) {
|
||||||
|
switch (modifier.operation()) {
|
||||||
|
case ADD_VALUE -> total += modifier.amount();
|
||||||
|
case ADD_MULTIPLIED_BASE -> total += modifier.amount() * nmsScaleAttribute.base();
|
||||||
|
case ADD_MULTIPLIED_TOTAL -> total += modifier.amount() * total;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlayerScaleWrapper wrapper = new PlayerScaleWrapper(packet.getEntityId(), base, total);
|
||||||
|
|
||||||
SubPlugins.getSubPlugins().forEach(plugin -> {
|
SubPlugins.getSubPlugins().forEach(plugin -> {
|
||||||
PacketAction pluginAction = plugin.getPacketInterface().readPlayerScale(player, wrapper);
|
PacketAction pluginAction = plugin.getPacketInterface().readPlayerScale(player, wrapper);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import me.lojosho.hibiscuscommons.util.MessagesUtil;
|
|||||||
import net.minecraft.core.NonNullList;
|
import net.minecraft.core.NonNullList;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.*;
|
import net.minecraft.network.protocol.game.*;
|
||||||
|
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
||||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||||
import net.minecraft.world.inventory.ClickType;
|
import net.minecraft.world.inventory.ClickType;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
@@ -183,7 +184,18 @@ public class NMSPacketChannel extends ChannelDuplexHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AtomicReference<PacketAction> action = new AtomicReference<>(PacketAction.NOTHING);
|
AtomicReference<PacketAction> action = new AtomicReference<>(PacketAction.NOTHING);
|
||||||
PlayerScaleWrapper wrapper = new PlayerScaleWrapper(packet.getEntityId(), nmsScaleAttribute.base());
|
|
||||||
|
final double base = nmsScaleAttribute.base();
|
||||||
|
double total = base;
|
||||||
|
|
||||||
|
for (AttributeModifier modifier : nmsScaleAttribute.modifiers()) {
|
||||||
|
switch (modifier.operation()) {
|
||||||
|
case ADD_VALUE -> total += modifier.amount();
|
||||||
|
case ADD_MULTIPLIED_BASE -> total += modifier.amount() * nmsScaleAttribute.base();
|
||||||
|
case ADD_MULTIPLIED_TOTAL -> total += modifier.amount() * total;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlayerScaleWrapper wrapper = new PlayerScaleWrapper(packet.getEntityId(), base, total);
|
||||||
|
|
||||||
SubPlugins.getSubPlugins().forEach(plugin -> {
|
SubPlugins.getSubPlugins().forEach(plugin -> {
|
||||||
PacketAction pluginAction = plugin.getPacketInterface().readPlayerScale(player, wrapper);
|
PacketAction pluginAction = plugin.getPacketInterface().readPlayerScale(player, wrapper);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import me.lojosho.hibiscuscommons.util.MessagesUtil;
|
|||||||
import net.minecraft.core.NonNullList;
|
import net.minecraft.core.NonNullList;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.*;
|
import net.minecraft.network.protocol.game.*;
|
||||||
|
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
||||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||||
import net.minecraft.world.inventory.ClickType;
|
import net.minecraft.world.inventory.ClickType;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
@@ -183,7 +184,18 @@ public class NMSPacketChannel extends ChannelDuplexHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AtomicReference<PacketAction> action = new AtomicReference<>(PacketAction.NOTHING);
|
AtomicReference<PacketAction> action = new AtomicReference<>(PacketAction.NOTHING);
|
||||||
PlayerScaleWrapper wrapper = new PlayerScaleWrapper(packet.getEntityId(), nmsScaleAttribute.base());
|
|
||||||
|
final double base = nmsScaleAttribute.base();
|
||||||
|
double total = base;
|
||||||
|
|
||||||
|
for (AttributeModifier modifier : nmsScaleAttribute.modifiers()) {
|
||||||
|
switch (modifier.operation()) {
|
||||||
|
case ADD_VALUE -> total += modifier.amount();
|
||||||
|
case ADD_MULTIPLIED_BASE -> total += modifier.amount() * nmsScaleAttribute.base();
|
||||||
|
case ADD_MULTIPLIED_TOTAL -> total += modifier.amount() * total;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlayerScaleWrapper wrapper = new PlayerScaleWrapper(packet.getEntityId(), base, total);
|
||||||
|
|
||||||
SubPlugins.getSubPlugins().forEach(plugin -> {
|
SubPlugins.getSubPlugins().forEach(plugin -> {
|
||||||
PacketAction pluginAction = plugin.getPacketInterface().readPlayerScale(player, wrapper);
|
PacketAction pluginAction = plugin.getPacketInterface().readPlayerScale(player, wrapper);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import me.lojosho.hibiscuscommons.plugins.SubPlugins;
|
|||||||
import me.lojosho.hibiscuscommons.util.MessagesUtil;
|
import me.lojosho.hibiscuscommons.util.MessagesUtil;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.*;
|
import net.minecraft.network.protocol.game.*;
|
||||||
|
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
||||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||||
import net.minecraft.world.inventory.ClickType;
|
import net.minecraft.world.inventory.ClickType;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
@@ -182,7 +183,18 @@ public class NMSPacketChannel extends ChannelDuplexHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AtomicReference<PacketAction> action = new AtomicReference<>(PacketAction.NOTHING);
|
AtomicReference<PacketAction> action = new AtomicReference<>(PacketAction.NOTHING);
|
||||||
PlayerScaleWrapper wrapper = new PlayerScaleWrapper(packet.getEntityId(), nmsScaleAttribute.base());
|
|
||||||
|
final double base = nmsScaleAttribute.base();
|
||||||
|
double total = base;
|
||||||
|
|
||||||
|
for (AttributeModifier modifier : nmsScaleAttribute.modifiers()) {
|
||||||
|
switch (modifier.operation()) {
|
||||||
|
case ADD_VALUE -> total += modifier.amount();
|
||||||
|
case ADD_MULTIPLIED_BASE -> total += modifier.amount() * nmsScaleAttribute.base();
|
||||||
|
case ADD_MULTIPLIED_TOTAL -> total += modifier.amount() * total;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlayerScaleWrapper wrapper = new PlayerScaleWrapper(packet.getEntityId(), base, total);
|
||||||
|
|
||||||
SubPlugins.getSubPlugins().forEach(plugin -> {
|
SubPlugins.getSubPlugins().forEach(plugin -> {
|
||||||
PacketAction pluginAction = plugin.getPacketInterface().readPlayerScale(player, wrapper);
|
PacketAction pluginAction = plugin.getPacketInterface().readPlayerScale(player, wrapper);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import me.lojosho.hibiscuscommons.plugins.SubPlugins;
|
|||||||
import me.lojosho.hibiscuscommons.util.MessagesUtil;
|
import me.lojosho.hibiscuscommons.util.MessagesUtil;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.*;
|
import net.minecraft.network.protocol.game.*;
|
||||||
|
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
||||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||||
import net.minecraft.world.inventory.ClickType;
|
import net.minecraft.world.inventory.ClickType;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
@@ -182,7 +183,18 @@ public class NMSPacketChannel extends ChannelDuplexHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AtomicReference<PacketAction> action = new AtomicReference<>(PacketAction.NOTHING);
|
AtomicReference<PacketAction> action = new AtomicReference<>(PacketAction.NOTHING);
|
||||||
PlayerScaleWrapper wrapper = new PlayerScaleWrapper(packet.getEntityId(), nmsScaleAttribute.base());
|
|
||||||
|
final double base = nmsScaleAttribute.base();
|
||||||
|
double total = base;
|
||||||
|
|
||||||
|
for (AttributeModifier modifier : nmsScaleAttribute.modifiers()) {
|
||||||
|
switch (modifier.operation()) {
|
||||||
|
case ADD_VALUE -> total += modifier.amount();
|
||||||
|
case ADD_MULTIPLIED_BASE -> total += modifier.amount() * nmsScaleAttribute.base();
|
||||||
|
case ADD_MULTIPLIED_TOTAL -> total += modifier.amount() * total;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlayerScaleWrapper wrapper = new PlayerScaleWrapper(packet.getEntityId(), base, total);
|
||||||
|
|
||||||
SubPlugins.getSubPlugins().forEach(plugin -> {
|
SubPlugins.getSubPlugins().forEach(plugin -> {
|
||||||
PacketAction pluginAction = plugin.getPacketInterface().readPlayerScale(player, wrapper);
|
PacketAction pluginAction = plugin.getPacketInterface().readPlayerScale(player, wrapper);
|
||||||
|
|||||||
Reference in New Issue
Block a user