Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some fixes #18

Merged
merged 5 commits into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
--- a/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java
+++ b/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java
@@ -46,6 +_,7 @@
import net.minecraft.world.item.TooltipFlag;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
+import org.bukkit.inventory.InventoryView;

@OnlyIn(Dist.CLIENT)
public class CreativeModeInventoryScreen extends EffectRenderingInventoryScreen<CreativeModeInventoryScreen.ItemPickerMenu> {
@@ -79,6 +_,8 @@
private boolean hasClickedOutside;
private final Set<TagKey<Item>> visibleTags = new HashSet<>();
Expand Down Expand Up @@ -263,6 +271,20 @@
@OnlyIn(Dist.CLIENT)
static class CustomCreativeSlot extends Slot {
public CustomCreativeSlot(Container p_98633_, int p_98634_, int p_98635_, int p_98636_) {
@@ -838,6 +_,13 @@
return this.items.size() > 45;
}

+ //Ketting start - Bogus client implementation, because it will never get called anyways
+ @Override
+ public InventoryView getBukkitView() {
+ return null;
+ }
+ //Ketting end
+
public ItemStack quickMoveStack(Player p_98650_, int p_98651_) {
if (p_98651_ >= this.slots.size() - 9 && p_98651_ < this.slots.size()) {
Slot slot = this.slots.get(p_98651_);
@@ -926,6 +_,22 @@

public boolean mayPickup(Player p_98665_) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/net/minecraft/client/server/IntegratedPlayerList.java
+++ b/net/minecraft/client/server/IntegratedPlayerList.java
@@ -30,7 +_,7 @@
}

public Component canPlayerLogin(SocketAddress p_120007_, GameProfile p_120008_) {
- return (Component)(this.getServer().isSingleplayerOwner(p_120008_) && this.getPlayerByName(p_120008_.getName()) != null ? Component.translatable("multiplayer.disconnect.name_taken") : super.canPlayerLogin(p_120007_, p_120008_));
+ return (Component)(this.getServer().isSingleplayerOwner(p_120008_) && this.getPlayerByName(p_120008_.getName()) != null ? Component.translatable("multiplayer.disconnect.name_taken") : super.canPlayerLogin(null, p_120008_)); //Ketting - bogus fix, because client stuff will never get called anyways
}

public IntegratedServer getServer() {
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--- a/net/minecraft/server/commands/DebugCommand.java
+++ b/net/minecraft/server/commands/DebugCommand.java
@@ -118,11 +_,18 @@
return i;
}

- static class Tracer implements ServerFunctionManager.TraceCallbacks, CommandSource {
+ public static class Tracer implements ServerFunctionManager.TraceCallbacks, CommandSource {
public static final int INDENT_OFFSET = 1;
private final PrintWriter output;
private int lastIndent;
private boolean waitingForResult;
+
+ //Ketting start
+ @Override
+ public org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) {
+ return new org.bukkit.craftbukkit.v1_20_R2.command.DebugCommandCommandSender(wrapper, Tracer.this);
+ }
+ //Ketting end

Tracer(PrintWriter p_180079_) {
this.output = p_180079_;
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
+ result = player.teleportTo(p_139017_, p_139018_, p_139019_, p_139020_, p_139021_, f, f1, PlayerTeleportEvent.TeleportCause.COMMAND);
+ } else {
+ Location to = new Location(p_139017_.getWorld(), p_139018_, p_139019_, p_139020_, f, f1);
+ EntityTeleportEvent event = new EntityTeleportEvent(p_139016_.getBukkitEntity(), p_139016_.getBukkitEntity().getLocation(), to);
+ p_139017_.getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ EntityTeleportEvent bevent = new EntityTeleportEvent(p_139016_.getBukkitEntity(), p_139016_.getBukkitEntity().getLocation(), to);
+ p_139017_.getCraftServer().getPluginManager().callEvent(bevent);
+ if (bevent.isCancelled()) {
+ return;
+ }
+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
int k = ChunkStorage.getVersion(compoundtag);
ChunkGenerator chunkgenerator = this.dimensions.getOrThrow(Registries.levelToLevelStem(resourcekey2)).generator();
- CompoundTag compoundtag1 = chunkstorage.upgradeChunkTag(resourcekey2, () -> {
+ CompoundTag compoundtag1 = chunkstorage.upgradeChunkTag(Registries.levelStemToLevel(resourcekey2), () -> { // CraftBukkit
+ CompoundTag compoundtag1 = chunkstorage.upgradeChunkTag(Registries.levelToLevelStem(resourcekey2), () -> { // CraftBukkit
return this.overworldDataStorage;
- }, compoundtag, chunkgenerator.getTypeNameForDataFixer());
+ }, compoundtag, chunkgenerator.getTypeNameForDataFixer(), chunkpos, null); // CraftBukkit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
--- a/net/minecraft/world/level/block/RedStoneOreBlock.java
+++ b/net/minecraft/world/level/block/RedStoneOreBlock.java
@@ -20,6 +_,8 @@
@@ -20,6 +_,10 @@
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.phys.BlockHitResult;
+import org.bukkit.craftbukkit.v1_20_R2.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityInteractEvent;
+
+import javax.annotation.Nullable;

public class RedStoneOreBlock extends Block {
public static final BooleanProperty LIT = RedstoneTorchBlock.LIT;
Expand All @@ -20,7 +22,8 @@

public void stepOn(Level p_154299_, BlockPos p_154300_, BlockState p_154301_, Entity p_154302_) {
if (!p_154302_.isSteppingCarefully()) {
interact(p_154301_, p_154299_, p_154300_);
- interact(p_154301_, p_154299_, p_154300_);
+ interact(p_154301_, p_154299_, p_154300_, p_154302_);
+ // CraftBukkit start
+ if (p_154302_ instanceof Player) {
+ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.v1_20_R2.event.CraftEventFactory.callPlayerInteractEvent((Player) p_154302_, org.bukkit.event.block.Action.PHYSICAL, p_154300_, null, null, null);
Expand All @@ -38,7 +41,7 @@
}

super.stepOn(p_154299_, p_154300_, p_154301_, p_154302_);
@@ -46,16 +_,21 @@
@@ -46,16 +_,26 @@
if (p_55473_.isClientSide) {
spawnParticles(p_55473_, p_55474_);
} else {
Expand All @@ -51,11 +54,16 @@
}

- private static void interact(BlockState p_55493_, Level p_55494_, BlockPos p_55495_) {
+ private static void interact(BlockState p_55493_, Level p_55494_, BlockPos p_55495_, Entity entity) { // CraftBukkit - add Entity
+ //Ketting start - keep original method head
+ private static void interact(BlockState p_55493_, Level p_55494_, BlockPos p_55495_){
+ interact(p_55493_,p_55494_,p_55495_, null);
+ }
+ //Ketting end
+ private static void interact(BlockState p_55493_, Level p_55494_, BlockPos p_55495_, @Nullable Entity entity) { // CraftBukkit - add Entity
spawnParticles(p_55494_, p_55495_);
if (!p_55493_.getValue(LIT)) {
+ // CraftBukkit start
+ if (!CraftEventFactory.callEntityChangeBlockEvent(entity, p_55495_, p_55493_.setValue(RedStoneOreBlock.LIT, true))) {
+ if (entity != null && !CraftEventFactory.callEntityChangeBlockEvent(entity, p_55495_, p_55493_.setValue(RedStoneOreBlock.LIT, true))) {
+ return;
+ }
+ // CraftBukkit end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,12 @@
if (!Files.isDirectory(this.generatedDir)) {
return Optional.empty();
} else {
@@ -227,7 +_,7 @@
}
}

- private StructureTemplate readStructure(InputStream p_230378_) throws IOException {
+ public StructureTemplate readStructure(InputStream p_230378_) throws IOException {
CompoundTag compoundtag = NbtIo.readCompressed(p_230378_);
return this.readStructure(compoundtag);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.bukkit.craftbukkit.v1_20_R2.command;

import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component;
import org.bukkit.craftbukkit.v1_20_R2.util.CraftChatMessage;
import org.jetbrains.annotations.NotNull;

public class DebugCommandCommandSender extends ServerCommandSender {
private CommandSourceStack stack;
private net.minecraft.server.commands.DebugCommand.Tracer tracer;
public DebugCommandCommandSender(CommandSourceStack stack, net.minecraft.server.commands.DebugCommand.Tracer tracer){
this.stack = stack;
this.tracer = tracer;
}
@Override
public void sendMessage(@NotNull String message) {
for (Component component : CraftChatMessage.fromString(message)) {
tracer.sendSystemMessage(component);
}
}

@Override
public void sendMessage(String... messages) {
for (String message : messages) {
sendMessage(message);
}
}

@Override
public @NotNull String getName() {
return "DebugCommandCommandSender";
}

@Override
public boolean isOp() {
return true;
}

@Override
public void setOp(boolean value) {
throw new UnsupportedOperationException("Cannot change operator status of a DebugCommand CommandSender");
}
}