Skip to content

Commit

Permalink
Fixed Block Physics Overhaul mod mixin injection exception (Luohuayu#703
Browse files Browse the repository at this point in the history
)

* Fixed Block Physics Overhaul mod mixin injection exception

* Remove the Atomic class reference

* Remove unused imports
  • Loading branch information
Kotori0629 authored Feb 5, 2023
1 parent 2bf2eb6 commit c86cde4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
16 changes: 10 additions & 6 deletions patches/minecraft/net/minecraft/world/World.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,12 @@
public Chunk func_212866_a_(int p_212866_1_, int p_212866_2_) {
return (Chunk)this.func_217348_a(p_212866_1_, p_212866_2_, ChunkStatus.field_222617_m);
}
@@ -173,6 +_,17 @@
@@ -172,7 +_,20 @@
return this.func_241211_a_(p_180501_1_, p_180501_2_, p_180501_3_, 512);
}

+ // CatServer start - fix bpo mod mixin injection exception
+ private boolean catserver$captureBlockState; // CatServer - creating in the method body will affect mixin injection, so use global instead
public boolean func_241211_a_(BlockPos p_241211_1_, BlockState p_241211_2_, int p_241211_3_, int p_241211_4_) {
+ // CraftBukkit start - tree generation
+ if (this.captureTreeGeneration) {
Expand All @@ -297,17 +300,16 @@
if (func_189509_E(p_241211_1_)) {
return false;
} else if (!this.field_72995_K && this.func_234925_Z_()) {
@@ -180,17 +_,66 @@
@@ -180,17 +_,67 @@
} else {
Chunk chunk = this.func_175726_f(p_241211_1_);
Block block = p_241211_2_.func_177230_c();
- BlockState blockstate = chunk.func_177436_a(p_241211_1_, p_241211_2_, (p_241211_3_ & 64) != 0);
+ // CraftBukkit start - capture blockstates
+ boolean captured = false;
+ if (this.captureBlockStates && !this.capturedBlockStates.containsKey(p_241211_1_)) {
+ CapturedBlockState blockstate = CapturedBlockState.getBlockState(this, p_241211_1_, p_241211_3_);
+ this.capturedBlockStates.put(p_241211_1_.func_185334_h(), blockstate);
+ captured = true;
+ catserver$captureBlockState = true; // CatServer
+ }
+ // CraftBukkit end
+
Expand All @@ -322,10 +324,11 @@
+ int oldLight = old.getLightValue(this, p_241211_1_);
+ int oldOpacity = old.func_200016_a(this, p_241211_1_);
+
+ BlockState blockstate = chunk.setBlockState(p_241211_1_, p_241211_2_, (p_241211_3_ & 64) != 0, (p_241211_3_ & 1024) == 0);
+ chunk.catserver$doPlace = (p_241211_3_ & 1024) == 0; // CatServer
+ BlockState blockstate = chunk.func_177436_a(p_241211_1_, p_241211_2_, (p_241211_3_ & 64) != 0); // CatServer
if (blockstate == null) {
+ // CraftBukkit start - remove blockstate if failed (or the same)
+ if (this.captureBlockStates && captured) {
+ if (this.captureBlockStates && catserver$captureBlockState) { // CatServer
+ this.capturedBlockStates.remove(p_241211_1_);
+ }
+ // CraftBukkit end
Expand Down Expand Up @@ -355,6 +358,7 @@
+ }
+ }
+ }
+ // CatServer end
+
+ // Split off from original setBlockState(BlockPos, BlockState, int, int) method in order to directly send client and physic updates
+ public void markAndNotifyBlock(BlockPos p_241211_1_, @Nullable Chunk chunk, BlockState blockstate, BlockState p_241211_2_, int p_241211_3_, int p_241211_4_)
Expand Down
5 changes: 3 additions & 2 deletions patches/minecraft/net/minecraft/world/chunk/Chunk.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,18 @@
}

public Heightmap func_217303_b(Heightmap.Type p_217303_1_) {
@@ -231,14 +_,24 @@
@@ -231,14 +_,25 @@
}
}

+ // CraftBukkit start
+ public boolean catserver$doPlace = true;
@Nullable
public BlockState func_177436_a(BlockPos p_177436_1_, BlockState p_177436_2_, boolean p_177436_3_) {
- int i = p_177436_1_.func_177958_n() & 15;
- int j = p_177436_1_.func_177956_o();
- int k = p_177436_1_.func_177952_p() & 15;
+ return this.setBlockState(p_177436_1_, p_177436_2_, p_177436_3_, true);
+ return this.setBlockState(p_177436_1_, p_177436_2_, p_177436_3_, catserver$doPlace);
+ }
+
+ public BlockState setType(BlockPos pos, BlockState state, boolean isMoving, boolean doPlace) {
Expand Down

0 comments on commit c86cde4

Please sign in to comment.