Update upstream

This commit is contained in:
IzzelAliz 2023-09-17 11:25:27 +08:00
parent 6bfebdb9d7
commit f7bf687d4e
8 changed files with 95 additions and 0 deletions

View File

@ -0,0 +1,8 @@
package io.izzel.arclight.common.bridge.core.block;
import net.minecraft.world.level.Level;
public interface SculkSpreaderBridge {
void bridge$setLevel(Level level);
}

View File

@ -0,0 +1,8 @@
package io.izzel.arclight.common.bridge.core.tileentity;
import net.minecraft.world.level.Level;
public interface SculkCatalystListenerBridge {
void bridge$setLevel(Level level);
}

View File

@ -0,0 +1,41 @@
package io.izzel.arclight.common.mixin.core.world.level.block;
import io.izzel.arclight.common.bridge.core.block.SculkSpreaderBridge;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.SculkSpreader;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.event.block.SculkBloomEvent;
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.CallbackInfo;
@Mixin(SculkSpreader.class)
public abstract class SculkSpreaderMixin implements SculkSpreaderBridge {
// @formatter:off
@Shadow public abstract boolean isWorldGeneration();
// @formatter:on
private transient Level arclight$level;
@Override
public void bridge$setLevel(Level level) {
this.arclight$level = level;
}
@Inject(method = "addCursor", cancellable = true, at = @At(value = "INVOKE", remap = false, target = "Ljava/util/List;add(Ljava/lang/Object;)Z"))
private void arclight$bloomEvent(SculkSpreader.ChargeCursor cursor, CallbackInfo ci) {
if (!isWorldGeneration() && arclight$level != null) {
var bukkitBlock = CraftBlock.at(arclight$level, cursor.pos);
var event = new SculkBloomEvent(bukkitBlock, cursor.getCharge());
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
ci.cancel();
}
cursor.charge = event.getCharge();
}
}
}

View File

@ -37,6 +37,7 @@ public abstract class BlockEntityMixin implements TileEntityBridge {
@Shadow protected static void setChanged(Level p_155233_, BlockPos p_155234_, BlockState p_155235_) { }
@Shadow public abstract BlockEntityType<?> getType();
@Shadow public void load(CompoundTag p_155245_) {}
@Shadow public void setLevel(Level p_155231_) {}
// @formatter:on
@Inject(method = "load", at = @At("RETURN"))

View File

@ -1,12 +1,15 @@
package io.izzel.arclight.common.mixin.core.world.level.block.entity;
import io.izzel.arclight.common.bridge.core.tileentity.SculkCatalystListenerBridge;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.SculkCatalystBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
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.CallbackInfo;
@ -14,6 +17,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(SculkCatalystBlockEntity.class)
public abstract class SculkCatalystBlockEntityMixin extends BlockEntityMixin {
@Shadow @Final private SculkCatalystBlockEntity.CatalystListener catalystListener;
@Override
public void setLevel(Level p_155231_) {
super.setLevel(p_155231_);
((SculkCatalystListenerBridge) this.catalystListener).bridge$setLevel(p_155231_);
}
@Inject(method = "serverTick", at = @At("HEAD"))
private static void arclight$overrideSource(Level p_222780_, BlockPos p_222781_, BlockState p_222782_, SculkCatalystBlockEntity blockEntity, CallbackInfo ci) {
CraftEventFactory.sourceBlockOverride = blockEntity.getBlockPos();

View File

@ -0,0 +1,21 @@
package io.izzel.arclight.common.mixin.core.world.level.block.entity;
import io.izzel.arclight.common.bridge.core.block.SculkSpreaderBridge;
import io.izzel.arclight.common.bridge.core.tileentity.SculkCatalystListenerBridge;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.SculkSpreader;
import net.minecraft.world.level.block.entity.SculkCatalystBlockEntity;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(SculkCatalystBlockEntity.CatalystListener.class)
public class SculkCatalystBlockEntity_CatalystListenerMixin implements SculkCatalystListenerBridge {
@Shadow @Final SculkSpreader sculkSpreader;
@Override
public void bridge$setLevel(Level level) {
((SculkSpreaderBridge) this.sculkSpreader).bridge$setLevel(level);
}
}

View File

@ -4,6 +4,9 @@ public net.minecraft.server.dedicated.DedicatedServerProperties$WorldDimensionDa
public net.minecraft.world.entity.projectile.Arrow f_36855_ # potion
public net.minecraft.world.entity.Display$TextDisplay f_268476_ # DATA_LINE_WIDTH_ID
public net.minecraft.world.entity.Display$TextDisplay f_268494_ # DATA_BACKGROUND_COLOR_ID
public net.minecraft.world.level.block.entity.SculkCatalystBlockEntity$CatalystListener m_280309_(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/util/RandomSource;)V # bloom
public net.minecraft.world.level.block.SculkSpreader$ChargeCursor f_222288_ # pos
public net.minecraft.world.level.block.SculkSpreader$ChargeCursor f_222289_ # charge
# Arclight 1.19.4
public net.minecraft.world.item.DebugStickItem m_150802_(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;ZLnet/minecraft/world/item/ItemStack;)Z # handleInteraction
public net.minecraft.world.level.block.ComposterBlock m_269590_(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState; # empty

View File

@ -417,6 +417,7 @@
"world.level.block.SculkBlockMixin",
"world.level.block.SculkSensorBlockMixin",
"world.level.block.SculkShriekerBlockMixin",
"world.level.block.SculkSpreaderMixin",
"world.level.block.SculkVeinBlockMixin",
"world.level.block.SignBlockMixin",
"world.level.block.SnowBlockMixin",
@ -457,6 +458,7 @@
"world.level.block.entity.LecternBlockEntityMixin",
"world.level.block.entity.LecternTileEntity1Mixin",
"world.level.block.entity.LockableBlockEntityMixin",
"world.level.block.entity.SculkCatalystBlockEntity_CatalystListenerMixin",
"world.level.block.entity.SculkCatalystBlockEntityMixin",
"world.level.block.entity.ShulkerBoxBlockEntityMixin",
"world.level.block.entity.SignBlockEntityMixin",