mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-11-01 04:37:09 +00:00
171 lines
8.4 KiB
Diff
171 lines
8.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Allink <arclicious@vivaldi.net>
|
|
Date: Mon, 4 Jul 2022 21:43:40 +0100
|
|
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
|
|
index 1a48c5ea1f2f755abfa85469e26f37ea5f02d6da..d6ed6b04792c4766ed5111fb83d52b76967d6856 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
|
@@ -1,7 +1,7 @@
|
|
package net.minecraft.world.level.block;
|
|
|
|
import com.mojang.logging.LogUtils;
|
|
-import java.util.Random;
|
|
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.core.Direction;
|
|
import net.minecraft.server.level.ServerLevel;
|
|
@@ -25,9 +25,11 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
|
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
|
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
|
import net.minecraft.world.phys.BlockHitResult;
|
|
+import org.bukkit.event.block.BlockRedstoneEvent;
|
|
+import org.bukkit.Location;
|
|
import org.slf4j.Logger;
|
|
|
|
-import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
|
+import java.util.Random;
|
|
|
|
public class CommandBlock extends BaseEntityBlock implements GameMasterBlock {
|
|
|
|
@@ -117,6 +119,15 @@ public class CommandBlock extends BaseEntityBlock implements GameMasterBlock {
|
|
}
|
|
|
|
private void execute(BlockState state, Level world, BlockPos pos, BaseCommandBlock executor, boolean hasCommand) {
|
|
+ // Scissors - Add master block fire event
|
|
+ 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
|
|
index 4bed3a1f353ada478c93e3e6f94aa7ea9d228730..02a9c902a2ec8994ebc8c639864aa0d231aab61a 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java
|
|
@@ -1,5 +1,6 @@
|
|
package net.minecraft.world.level.block.entity;
|
|
|
|
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
|
|
import com.google.common.collect.Lists;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
@@ -27,6 +28,7 @@ import net.minecraft.world.level.levelgen.structure.pools.SinglePoolElement;
|
|
import net.minecraft.world.level.levelgen.structure.pools.StructurePoolElement;
|
|
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
|
|
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
|
+import org.bukkit.Location;
|
|
|
|
public class JigsawBlockEntity extends BlockEntity {
|
|
public static final String TARGET = "target";
|
|
@@ -117,11 +119,21 @@ public class JigsawBlockEntity extends BlockEntity {
|
|
}
|
|
|
|
public void generate(ServerLevel world, int maxDepth, boolean keepJigsaws) {
|
|
+ // Scissors - Add master block fire event
|
|
+ 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
|
|
+
|
|
ChunkGenerator chunkGenerator = world.getChunkSource().getGenerator();
|
|
StructureManager structureManager = world.getStructureManager();
|
|
StructureFeatureManager structureFeatureManager = world.structureFeatureManager();
|
|
Random random = world.getRandom();
|
|
- BlockPos blockPos = this.getBlockPos();
|
|
+ // BlockPos blockPos = this.getBlockPos(); // Scissors - We've already defined this in the scope
|
|
List<PoolElementStructurePiece> list = Lists.newArrayList();
|
|
StructureTemplate structureTemplate = new StructureTemplate();
|
|
structureTemplate.fillFromWorld(world, blockPos, new Vec3i(1, 1, 1), false, (Block)null);
|
|
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
|
|
index 9a65ed7e5ed76a320c8602b0a4edeff6615d9e0b..e46727ee13550d4ab5473dc5ac28abddf822c9ee 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java
|
|
@@ -6,6 +6,8 @@ import java.util.Optional;
|
|
import java.util.Random;
|
|
import java.util.stream.Stream;
|
|
import javax.annotation.Nullable;
|
|
+
|
|
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
|
|
import net.minecraft.ResourceLocationException;
|
|
import net.minecraft.Util;
|
|
import net.minecraft.core.BlockPos;
|
|
@@ -29,6 +31,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.BlockRotProce
|
|
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
|
|
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
|
|
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
|
+import org.bukkit.Location;
|
|
|
|
public class StructureBlockEntity extends BlockEntity {
|
|
private static final int SCAN_CORNER_BLOCKS_RANGE = 5;
|
|
@@ -264,7 +267,6 @@ public class StructureBlockEntity extends BlockEntity {
|
|
return false;
|
|
} else {
|
|
BlockPos blockPos = this.getBlockPos();
|
|
- int i = 80;
|
|
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);
|
|
@@ -321,6 +323,16 @@ public class StructureBlockEntity extends BlockEntity {
|
|
|
|
public boolean saveStructure(boolean bl) {
|
|
if (this.mode == StructureMode.SAVE && !this.level.isClientSide && this.structureName != null) {
|
|
+ // Scissors - Add master block fire event
|
|
+ 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;
|
|
StructureManager structureManager = serverLevel.getStructureManager();
|
|
@@ -358,6 +370,16 @@ public class StructureBlockEntity extends BlockEntity {
|
|
|
|
public boolean loadStructure(ServerLevel world, boolean bl) {
|
|
if (this.mode == StructureMode.LOAD && this.structureName != null) {
|
|
+ // Scissors - Add master block fire event
|
|
+ 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
|
|
+
|
|
StructureManager structureManager = world.getStructureManager();
|
|
|
|
Optional<StructureTemplate> optional;
|
|
@@ -403,6 +425,16 @@ public class StructureBlockEntity extends BlockEntity {
|
|
}
|
|
|
|
public void unloadStructure() {
|
|
+ // Scissors - Add master block fire event
|
|
+ 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;
|
|
StructureManager structureManager = serverLevel.getStructureManager();
|