mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-28 19:29:07 +00:00
Update feaure patches
This commit is contained in:
@@ -14,8 +14,6 @@ import net.minecraft.world.entity.item.PrimedTnt;
|
||||
import net.minecraft.world.level.ExplosionDamageCalculator;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.bukkit.craftbukkit.util.CraftVector;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
@@ -112,14 +110,13 @@ public final class TntExplosion extends SpecialisedExplosion<PrimedTnt> {
|
||||
}
|
||||
}
|
||||
|
||||
private Vector getCauseOrigin() {
|
||||
Vector origin = this.cause.getOriginVector();
|
||||
return origin == null ? CraftVector.toBukkit(this.center) : origin;
|
||||
private Vec3 getCauseOrigin() {
|
||||
return this.cause.origin == null ? this.center : this.cause.origin;
|
||||
}
|
||||
|
||||
private EntityState nextSourceVelocity() {
|
||||
Vector origin = this.getCauseOrigin(); // valid position to use while creating a temporary entity
|
||||
PrimedTnt tnt = new PrimedTnt(this.level(), origin.getX(), origin.getY(), origin.getZ(), null);
|
||||
Vec3 origin = this.getCauseOrigin(); // valid position to use while creating a temporary entity
|
||||
PrimedTnt tnt = new PrimedTnt(this.level(), origin.x(), origin.y(), origin.z(), null);
|
||||
this.cause.entityState().apply(tnt);
|
||||
this.impactCannonEntity(tnt, this.center, 1, this.radius() * 2.0f);
|
||||
return EntityState.of(tnt);
|
||||
@@ -166,7 +163,7 @@ public final class TntExplosion extends SpecialisedExplosion<PrimedTnt> {
|
||||
entities.createRawIterator();
|
||||
// iterate over the entityTickList to find entities that are exploding in the same position.
|
||||
while ((index = entities.advanceRawIterator(index)) != -1) {
|
||||
Entity foundEntity = entities.rawGet(index);
|
||||
Entity foundEntity = entities.getListRaw()[index];
|
||||
if (!(foundEntity instanceof MergeableEntity mergeEntity) || foundEntity.isRemoved() || !foundEntity.compareState(this.cause) || !mergeEntity.isSafeToMergeInto(this.cause, true))
|
||||
break;
|
||||
this.level().mergeHandler.mergeEntity(mergeEntity, this.cause);
|
||||
|
||||
@@ -2,8 +2,13 @@ package me.samsuik.sakura.player.combat;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Reference2DoubleMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2DoubleOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.item.component.ItemAttributeModifiers;
|
||||
@@ -18,14 +23,8 @@ public final class LegacyDamageMapping {
|
||||
return result == Double.MIN_VALUE ? OptionalDouble.empty() : OptionalDouble.of(result);
|
||||
}
|
||||
|
||||
private static double adjustDamageForItem(Item item, double attackDamage) {
|
||||
return switch (item) {
|
||||
case SwordItem i -> 1.0;
|
||||
case PickaxeItem i -> 1.0;
|
||||
case ShovelItem i -> -0.5;
|
||||
case HoeItem i -> -attackDamage;
|
||||
case null, default -> 0.0;
|
||||
};
|
||||
private interface ItemDamageRemapper {
|
||||
double apply(Item item, double attackDamage);
|
||||
}
|
||||
|
||||
static {
|
||||
@@ -39,6 +38,12 @@ public final class LegacyDamageMapping {
|
||||
LEGACY_ITEM_DAMAGE_MAP.put(Items.DIAMOND_AXE, 6.0);
|
||||
LEGACY_ITEM_DAMAGE_MAP.put(Items.NETHERITE_AXE, 7.0);
|
||||
|
||||
Reference2ObjectMap<TagKey<Item>, ItemDamageRemapper> remapUsingItemTags = new Reference2ObjectArrayMap<>();
|
||||
remapUsingItemTags.put(ItemTags.SWORDS, (item, attack) -> 1.0);
|
||||
remapUsingItemTags.put(ItemTags.PICKAXES, (item, attack) -> 1.0);
|
||||
remapUsingItemTags.put(ItemTags.SHOVELS, (item, attack) -> -0.5);
|
||||
remapUsingItemTags.put(ItemTags.HOES, (item, attack) -> -attack);
|
||||
|
||||
for (Item item : BuiltInRegistries.ITEM) {
|
||||
ItemAttributeModifiers modifiers = item.components().get(DataComponents.ATTRIBUTE_MODIFIERS);
|
||||
|
||||
@@ -46,7 +51,8 @@ public final class LegacyDamageMapping {
|
||||
continue;
|
||||
}
|
||||
|
||||
assert item instanceof AxeItem : "missing axe mapping";
|
||||
Holder.Reference<Item> itemHolder = item.builtInRegistryHolder();
|
||||
assert itemHolder.is(ItemTags.AXES) : "missing axe mapping";
|
||||
|
||||
double attackDamage = modifiers.modifiers().stream()
|
||||
.filter(e -> e.attribute().is(Attributes.ATTACK_DAMAGE))
|
||||
@@ -54,7 +60,14 @@ public final class LegacyDamageMapping {
|
||||
.sum();
|
||||
|
||||
if (attackDamage > 0.0) {
|
||||
double adjustment = adjustDamageForItem(item, attackDamage);
|
||||
double adjustment = 0.0;
|
||||
for (TagKey<Item> key : remapUsingItemTags.keySet()) {
|
||||
if (itemHolder.is(key)) {
|
||||
ItemDamageRemapper remapper = remapUsingItemTags.get(key);
|
||||
adjustment = remapper.apply(item, attackDamage);
|
||||
}
|
||||
}
|
||||
|
||||
LEGACY_ITEM_DAMAGE_MAP.put(item, attackDamage + adjustment);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public final class LegacyGoldenAppleItem extends Item {
|
||||
new ApplyStatusEffectsConsumeEffect(
|
||||
List.of(
|
||||
new MobEffectInstance(MobEffects.REGENERATION, 600, 4),
|
||||
new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 6000, 0),
|
||||
new MobEffectInstance(MobEffects.RESISTANCE, 6000, 0),
|
||||
new MobEffectInstance(MobEffects.FIRE_RESISTANCE, 6000, 0),
|
||||
new MobEffectInstance(MobEffects.ABSORPTION, 2400, 0)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user