Skip to content

Commit

Permalink
Fix unsafe usage of FakePlayer in Infusion Claw (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
reobf authored Nov 25, 2024
1 parent a9bdebf commit f72630c
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.management.ItemInWorldManager;
import net.minecraft.world.World;
Expand Down Expand Up @@ -275,6 +278,14 @@ private void performClickBlock() {
}

AdvancedFakePlayer fakePlayer = new AdvancedFakePlayer((WorldServer) world, TileInfusionClaw.FAKE_UUID);
fakePlayer.playerNetServerHandler = new NetHandlerPlayServer(
MinecraftServer.getServer(),
new NetworkManager(false),
fakePlayer) {

@Override
public void sendPacket(Packet discard) {}
};
this.loadResearch(fakePlayer);

if (behavior.hasVisCost()) {
Expand All @@ -287,6 +298,7 @@ private void performClickBlock() {

if (this.im == null) {
this.im = new ItemInWorldManager(world);
this.im.thisPlayerMP = fakePlayer;
} else {
this.im.setWorld((WorldServer) world);
}
Expand Down Expand Up @@ -465,4 +477,5 @@ public boolean canInsertItem(int slot, ItemStack stack, int side) {
public boolean canExtractItem(int slot, ItemStack stack, int side) {
return (!this.isLocked() || !this.hasSufficientVis()) && this.canInsertItem(slot, stack, side);
}

}

0 comments on commit f72630c

Please sign in to comment.