-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issues on client and block id desync
- Loading branch information
Showing
11 changed files
with
107 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/eu/pb4/polymer/mixin/other/SimpleRegistryMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package eu.pb4.polymer.mixin.other; | ||
|
||
import com.mojang.serialization.Lifecycle; | ||
import eu.pb4.polymer.interfaces.VirtualObject; | ||
import net.minecraft.util.registry.RegistryKey; | ||
import net.minecraft.util.registry.SimpleRegistry; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
|
||
@Mixin(SimpleRegistry.class) | ||
public abstract class SimpleRegistryMixin<T> { | ||
@Shadow private int nextId; | ||
|
||
@Shadow public abstract <V extends T> V set(int rawId, RegistryKey<T> key, V entry, Lifecycle lifecycle); | ||
|
||
@Inject(method = "add", at = @At("HEAD"), cancellable = true) | ||
private <V extends T> void moveVirtualObjectToTheEnd(RegistryKey<T> key, V entry, Lifecycle lifecycle, CallbackInfoReturnable<V> cir) { | ||
if (entry instanceof VirtualObject) { | ||
int current = this.nextId; | ||
this.set(current + 1000000, key, entry, lifecycle); | ||
this.nextId = current + 1; | ||
cir.setReturnValue(entry); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package eu.pb4.polymer.other; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class Event<T> { | ||
private List<EventHandler<T>> handlers = new ArrayList<>(); | ||
|
||
public void register(EventHandler<T> event) { | ||
this.handlers.add(event); | ||
} | ||
|
||
public void invoke(T obj) { | ||
for (EventHandler<T> consumer : this.handlers) { | ||
consumer.call(obj); | ||
} | ||
} | ||
|
||
|
||
public interface EventHandler<T> { | ||
void call(T obj); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters