Skip to content

Commit

Permalink
Update upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
IzzelAliz committed Jul 7, 2024
1 parent 5bf8aaf commit ee68f94
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,14 @@ public abstract class WolfMixin extends TameableAnimalMixin {
var ret = instance.nextInt(i);
return ret == 0 && this.bridge$common$animalTameEvent(player) ? ret : 1;
}

@Inject(method = "mobInteract", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/animal/Wolf;spawnAtLocation(Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/entity/item/ItemEntity;"))
private void arclight$forceDropPre(Player player, InteractionHand interactionHand, CallbackInfoReturnable<InteractionResult> cir) {
this.forceDrops = true;
}

@Inject(method = "mobInteract", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/world/entity/animal/Wolf;spawnAtLocation(Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/entity/item/ItemEntity;"))
private void arclight$forceDropPost(Player player, InteractionHand interactionHand, CallbackInfoReturnable<InteractionResult> cir) {
this.forceDrops = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import net.minecraft.world.phys.Vec3;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRemoveEvent;
Expand Down Expand Up @@ -106,9 +107,7 @@ private boolean checkWalls(final AABB axisalignedbb) {
if (!flag2) {
return flag;
}
final org.bukkit.entity.Entity bukkitEntity = this.getBukkitEntity();
final EntityExplodeEvent event = new EntityExplodeEvent(bukkitEntity, bukkitEntity.getLocation(), destroyedBlocks, 0.0f);
bukkitEntity.getServer().getPluginManager().callEvent(event);
final EntityExplodeEvent event = CraftEventFactory.callEntityExplodeEvent((EnderDragon) (Object) this, destroyedBlocks, 0.0f, explosionSource.getBlockInteraction());
if (event.isCancelled()) {
return flag;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.izzel.arclight.common.mixin.core.world.entity.monster;

import io.izzel.arclight.common.bridge.core.network.datasync.SynchedEntityDataBridge;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.monster.Bogged;
import net.minecraft.world.entity.player.Player;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(Bogged.class)
public abstract class BoggedMixin extends AbstractSkeletonMixin {

@Shadow @Final private static EntityDataAccessor<Boolean> DATA_SHEARED;

@Inject(method = "mobInteract", cancellable = true, require = 0, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/monster/Bogged;shear(Lnet/minecraft/sounds/SoundSource;)V"))
private void arclight$shearEvent(Player player, InteractionHand interactionHand, CallbackInfoReturnable<InteractionResult> cir) {
if (!CraftEventFactory.handlePlayerShearEntityEvent(player, (Entity) (Object) this, player.getItemInHand(interactionHand), interactionHand)) {
((SynchedEntityDataBridge) this.getEntityData()).bridge$markDirty(DATA_SHEARED);
cir.setReturnValue(InteractionResult.PASS);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import net.minecraft.world.level.block.TntBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
Expand Down Expand Up @@ -60,6 +59,7 @@ public abstract class ExplosionMixin implements ExplosionBridge {
@Accessor("radius") public abstract void bridge$setSize(float size);
@Accessor("blockInteraction") public abstract Explosion.BlockInteraction bridge$getMode();
@Shadow @Final @Mutable private DamageSource damageSource;
@Shadow public abstract Explosion.BlockInteraction getBlockInteraction();
// @formatter:on

public float yield;
Expand Down Expand Up @@ -191,16 +191,14 @@ private boolean callBlockExplodeEvent() {
List<org.bukkit.block.Block> bukkitBlocks;

if (exploder != null) {
EntityExplodeEvent event = new EntityExplodeEvent(exploder, location, blockList, this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F);
Bukkit.getPluginManager().callEvent(event);
EntityExplodeEvent event = CraftEventFactory.callEntityExplodeEvent(this.source, blockList, this.yield, this.getBlockInteraction());
cancelled = event.isCancelled();
bukkitBlocks = event.blockList();
this.yield = event.getYield();
} else {
org.bukkit.block.Block block = location.getBlock();
org.bukkit.block.BlockState blockState = (((DamageSourceBridge) damageSource).bridge$directBlockState() != null) ? ((DamageSourceBridge) damageSource).bridge$directBlockState() : block.getState();
BlockExplodeEvent event = new BlockExplodeEvent(block, blockState, blockList, this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F);
Bukkit.getPluginManager().callEvent(event);
BlockExplodeEvent event = CraftEventFactory.callBlockExplodeEvent(block, blockState, blockList, this.yield, this.getBlockInteraction());
cancelled = event.isCancelled();
bukkitBlocks = event.blockList();
this.yield = event.getYield();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import net.minecraft.stats.Stats;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.entity.boss.enderdragon.phases.EnderDragonPhase;
import net.minecraft.world.entity.npc.VillagerProfession;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.CookingBookCategory;
Expand All @@ -48,7 +47,6 @@
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Pose;
import org.bukkit.entity.SpawnCategory;
import org.bukkit.entity.Villager;
import org.bukkit.potion.PotionType;

import java.lang.reflect.Field;
Expand Down Expand Up @@ -87,7 +85,6 @@ public static void registerAll(DedicatedServer console) {
loadPotions();
loadEnchantmentTargets();
loadEntities();
loadVillagerProfessions();
loadBiomes(console);
loadArts(console);
loadStats();
Expand Down Expand Up @@ -264,31 +261,6 @@ private static void loadBiomes(DedicatedServer console) {
ArclightServer.LOGGER.info("registry.biome", newTypes.size());
}

private static void loadVillagerProfessions() {
int i = Villager.Profession.values().length;
List<Villager.Profession> newTypes = new ArrayList<>();
Field key = Arrays.stream(Villager.Profession.class.getDeclaredFields()).filter(it -> it.getName().equals("key")).findAny().orElse(null);
long keyOffset = Unsafe.objectFieldOffset(key);
for (VillagerProfession villagerProfession : BuiltInRegistries.VILLAGER_PROFESSION) {
var location = BuiltInRegistries.VILLAGER_PROFESSION.getKey(villagerProfession);
String name = ResourceLocationUtil.standardize(location);
Villager.Profession profession;
try {
profession = Villager.Profession.valueOf(name);
} catch (Throwable t) {
profession = null;
}
if (profession == null) {
profession = EnumHelper.makeEnum(Villager.Profession.class, name, i++, ImmutableList.of(), ImmutableList.of());
newTypes.add(profession);
Unsafe.putObject(profession, keyOffset, CraftNamespacedKey.fromMinecraft(location));
ArclightServer.LOGGER.debug("Registered {} as villager profession {}", location, profession);
}
}
EnumHelper.addEnums(Villager.Profession.class, newTypes);
ArclightServer.LOGGER.info("registry.villager-profession", newTypes.size());
}

public static void registerEnvironments(Registry<LevelStem> registry) {
int i = World.Environment.values().length;
List<World.Environment> newTypes = new ArrayList<>();
Expand Down
5 changes: 5 additions & 0 deletions arclight-common/src/main/resources/arclight.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ accessible field net/minecraft/core/component/DataComponentPatch map Lit/unimi/d
accessible field net/minecraft/core/component/DataComponentPatch$Builder map Lit/unimi/dsi/fastutil/objects/Reference2ObjectMap;
accessible field net/minecraft/world/level/block/entity/HopperBlockEntity facing Lnet/minecraft/core/Direction;
accessible field net/minecraft/world/item/JukeboxSongPlayer ticksSinceSongStarted J
accessible field net/minecraft/world/level/block/entity/trialspawner/TrialSpawner normalConfig Lnet/minecraft/world/level/block/entity/trialspawner/TrialSpawnerConfig;
accessible field net/minecraft/world/level/block/entity/trialspawner/TrialSpawner ominousConfig Lnet/minecraft/world/level/block/entity/trialspawner/TrialSpawnerConfig;
accessible field net/minecraft/world/level/block/entity/trialspawner/TrialSpawner requiredPlayerRange I
accessible field net/minecraft/world/level/block/entity/trialspawner/TrialSpawner targetCooldownLength I
accessible field net/minecraft/world/level/block/entity/trialspawner/TrialSpawner isOminous Z
# Arclight 1.20.4
accessible method net/minecraft/world/level/block/entity/HopperBlockEntity setCooldown (I)V
accessible class net/minecraft/world/inventory/MenuType$MenuSupplier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@
"world.entity.item.ItemEntityMixin",
"world.entity.item.PrimedTntMixin",
"world.entity.monster.AbstractSkeletonMixin",
"world.entity.monster.BoggedMixin",
"world.entity.monster.CaveSpiderMixin",
"world.entity.monster.CreeperMixin",
"world.entity.monster.ElderGuardianMixin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public class EnumDefinalizer implements Implementer {
"org/bukkit/Material",
"org/bukkit/potion/PotionType",
"org/bukkit/entity/EntityType",
"org/bukkit/entity/Villager$Profession",
"org/bukkit/block/Biome",
"org/bukkit/Art",
"org/bukkit/Statistic",
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ dependencies {
implementation 'org.cadixdev:lorenz:0.5.8'
implementation 'org.cadixdev:at:0.1.0-rc1'
implementation 'net.fabricmc:lorenz-tiny:4.0.2'
implementation "dev.architectury:architectury-loom:1.6-SNAPSHOT"
implementation "dev.architectury:architectury-loom:1.7-SNAPSHOT"
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Sun Feb 09 15:27:43 CST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down

0 comments on commit ee68f94

Please sign in to comment.