2022-07-28 03:57:50 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2023-12-11 00:23:09 +00:00
|
|
|
From: Telesphoreo <me@telesphoreo.me>
|
|
|
|
Date: Sun, 10 Dec 2023 18:11:55 -0600
|
2022-07-28 03:57:50 +00:00
|
|
|
Subject: [PATCH] Add MasterBlockFireEvent
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/CommandBlock.java b/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
2023-12-11 00:23:09 +00:00
|
|
|
index 7ef14e4441a329c680a5dfe4bfb5033ffcb8f9d5..eff5bdf00b0aa7a9925ff59a62ead72509dc67b8 100644
|
2022-07-28 03:57:50 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
2023-12-11 00:23:09 +00:00
|
|
|
@@ -4,6 +4,7 @@ import com.mojang.logging.LogUtils;
|
|
|
|
import com.mojang.serialization.Codec;
|
|
|
|
import com.mojang.serialization.MapCodec;
|
|
|
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
|
|
|
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
|
2022-07-28 03:57:50 +00:00
|
|
|
import net.minecraft.core.BlockPos;
|
|
|
|
import net.minecraft.core.Direction;
|
2023-12-11 00:23:09 +00:00
|
|
|
import net.minecraft.server.level.ServerLevel;
|
|
|
|
@@ -28,6 +29,7 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
2022-07-28 03:57:50 +00:00
|
|
|
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
|
|
|
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
|
|
|
import net.minecraft.world.phys.BlockHitResult;
|
2023-12-11 00:23:09 +00:00
|
|
|
+import org.bukkit.Location;
|
2022-07-28 03:57:50 +00:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
2023-07-01 20:21:13 +00:00
|
|
|
import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
2023-12-11 00:23:09 +00:00
|
|
|
@@ -130,6 +132,14 @@ public class CommandBlock extends BaseEntityBlock implements GameMasterBlock {
|
2022-07-28 03:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void execute(BlockState state, Level world, BlockPos pos, BaseCommandBlock executor, boolean hasCommand) {
|
2023-07-01 20:21:13 +00:00
|
|
|
+ // Scissors start - Add master block fire event
|
2022-07-28 03:57:50 +00:00
|
|
|
+ final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ()));
|
|
|
|
+ if (!event.callEvent())
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // Scissors end
|
|
|
|
+
|
|
|
|
if (hasCommand) {
|
|
|
|
executor.performCommand(world);
|
|
|
|
} else {
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java
|
2023-12-11 00:23:09 +00:00
|
|
|
index 3a210e138b6ae065fd32e1b1e0e49999e20c4667..183c47a6fbf5201c38d5eb182049643862ca0964 100644
|
2022-07-28 03:57:50 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java
|
2023-12-11 00:23:09 +00:00
|
|
|
@@ -2,6 +2,8 @@ package net.minecraft.world.level.block.entity;
|
2022-07-28 03:57:50 +00:00
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Optional;
|
2023-12-11 00:23:09 +00:00
|
|
|
+
|
|
|
|
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
|
2022-07-28 03:57:50 +00:00
|
|
|
import net.minecraft.core.BlockPos;
|
|
|
|
import net.minecraft.core.Holder;
|
|
|
|
import net.minecraft.core.Registry;
|
2023-12-11 00:23:09 +00:00
|
|
|
@@ -17,6 +19,7 @@ import net.minecraft.world.level.block.JigsawBlock;
|
2022-07-28 03:57:50 +00:00
|
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
|
|
import net.minecraft.world.level.levelgen.structure.pools.JigsawPlacement;
|
|
|
|
import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool;
|
2023-12-11 00:23:09 +00:00
|
|
|
+import org.bukkit.Location;
|
2022-07-28 03:57:50 +00:00
|
|
|
|
|
|
|
public class JigsawBlockEntity extends BlockEntity {
|
|
|
|
public static final String TARGET = "target";
|
2023-12-11 00:23:09 +00:00
|
|
|
@@ -131,6 +134,16 @@ public class JigsawBlockEntity extends BlockEntity {
|
2022-07-28 03:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void generate(ServerLevel world, int maxDepth, boolean keepJigsaws) {
|
2023-07-01 20:21:13 +00:00
|
|
|
+ // Scissors start - Add master block fire event
|
2022-07-28 03:57:50 +00:00
|
|
|
+ final BlockPos pos = this.getBlockPos();
|
|
|
|
+ final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), pos.getX(), pos.getY(), pos.getZ()));
|
|
|
|
+
|
|
|
|
+ if (!event.callEvent())
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // Scissors end
|
|
|
|
+
|
|
|
|
BlockPos blockPos = this.getBlockPos().relative(this.getBlockState().getValue(JigsawBlock.ORIENTATION).front());
|
2022-12-11 06:04:11 +00:00
|
|
|
Registry<StructureTemplatePool> registry = world.registryAccess().registryOrThrow(Registries.TEMPLATE_POOL);
|
2022-10-02 22:14:40 +00:00
|
|
|
// Paper start - Replace getHolderOrThrow with a null check
|
2022-07-28 03:57:50 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java
|
2023-12-11 00:23:09 +00:00
|
|
|
index 60c941bd67dc899ea923f8ee49412de01ce199db..9bcd07f8b5d266c39034e5c021da9ffb7262b474 100644
|
2022-07-28 03:57:50 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java
|
2023-12-11 00:23:09 +00:00
|
|
|
@@ -5,6 +5,8 @@ import java.util.Objects;
|
2022-07-28 03:57:50 +00:00
|
|
|
import java.util.Optional;
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
import javax.annotation.Nullable;
|
2023-12-11 00:23:09 +00:00
|
|
|
+
|
|
|
|
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
|
2022-07-28 03:57:50 +00:00
|
|
|
import net.minecraft.ResourceLocationException;
|
|
|
|
import net.minecraft.Util;
|
|
|
|
import net.minecraft.core.BlockPos;
|
2023-12-11 00:23:09 +00:00
|
|
|
@@ -29,6 +31,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.BlockRotProce
|
2022-07-28 03:57:50 +00:00
|
|
|
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
|
|
|
|
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
|
|
|
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager;
|
2023-12-11 00:23:09 +00:00
|
|
|
+import org.bukkit.Location;
|
2022-07-28 03:57:50 +00:00
|
|
|
|
|
|
|
public class StructureBlockEntity extends BlockEntity {
|
|
|
|
private static final int SCAN_CORNER_BLOCKS_RANGE = 5;
|
2023-12-11 00:23:09 +00:00
|
|
|
@@ -261,7 +264,7 @@ public class StructureBlockEntity extends BlockEntity {
|
2022-07-28 03:57:50 +00:00
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
BlockPos blockPos = this.getBlockPos();
|
|
|
|
- int i = 80;
|
2023-07-01 20:21:13 +00:00
|
|
|
+ // Scissors - Obfuscation fixes
|
2022-07-28 03:57:50 +00:00
|
|
|
BlockPos blockPos2 = new BlockPos(blockPos.getX() - 80, this.level.getMinBuildHeight(), blockPos.getZ() - 80);
|
|
|
|
BlockPos blockPos3 = new BlockPos(blockPos.getX() + 80, this.level.getMaxBuildHeight() - 1, blockPos.getZ() + 80);
|
|
|
|
Stream<BlockPos> stream = this.getRelatedCorners(blockPos2, blockPos3);
|
2023-12-11 00:23:09 +00:00
|
|
|
@@ -320,6 +323,16 @@ public class StructureBlockEntity extends BlockEntity {
|
|
|
|
if (this.structureName == null) {
|
|
|
|
return false;
|
|
|
|
} else {
|
2023-07-01 20:21:13 +00:00
|
|
|
+ // Scissors start - Add master block fire event
|
2022-07-28 03:57:50 +00:00
|
|
|
+ final BlockPos pos = this.getBlockPos();
|
|
|
|
+ final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), pos.getX(), pos.getY(), pos.getZ()));
|
|
|
|
+
|
|
|
|
+ if (!event.callEvent())
|
|
|
|
+ {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ // Scissors end
|
|
|
|
+
|
|
|
|
BlockPos blockPos = this.getBlockPos().offset(this.structurePos);
|
|
|
|
ServerLevel serverLevel = (ServerLevel)this.level;
|
|
|
|
StructureTemplateManager structureTemplateManager = serverLevel.getStructureManager();
|
2023-12-11 00:23:09 +00:00
|
|
|
@@ -371,6 +384,16 @@ public class StructureBlockEntity extends BlockEntity {
|
|
|
|
if (structureTemplate == null) {
|
|
|
|
return false;
|
|
|
|
} else {
|
2023-07-01 20:21:13 +00:00
|
|
|
+ // Scissors start - Add master block fire event
|
2022-07-28 03:57:50 +00:00
|
|
|
+ final BlockPos blockPos = this.getBlockPos();
|
|
|
|
+ final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), blockPos.getX(), blockPos.getY(), blockPos.getZ()));
|
|
|
|
+
|
|
|
|
+ if (!event.callEvent())
|
|
|
|
+ {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ // Scissors end
|
|
|
|
+
|
2023-12-11 00:23:09 +00:00
|
|
|
this.loadStructureInfo(structureTemplate);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
@@ -407,6 +430,15 @@ public class StructureBlockEntity extends BlockEntity {
|
2022-07-28 03:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void unloadStructure() {
|
2023-07-01 20:21:13 +00:00
|
|
|
+ // Scissors start - Add master block fire event
|
2022-07-28 03:57:50 +00:00
|
|
|
+ final BlockPos blockPos = this.getBlockPos();
|
|
|
|
+ final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), blockPos.getX(), blockPos.getY(), blockPos.getZ()));
|
|
|
|
+
|
|
|
|
+ if (!event.callEvent())
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // Scissors end
|
|
|
|
if (this.structureName != null) {
|
|
|
|
ServerLevel serverLevel = (ServerLevel)this.level;
|
|
|
|
StructureTemplateManager structureTemplateManager = serverLevel.getStructureManager();
|