-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fabric: Make FastMap state holders "compatible" with Hydrogen
Implicitely fixes #7
- Loading branch information
Showing
5 changed files
with
57 additions
and
7 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
23 changes: 23 additions & 0 deletions
23
fabric/src/main/java/malte0811/ferritecore/mixin/fabric/Config.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,23 @@ | ||
package malte0811.ferritecore.mixin.fabric; | ||
|
||
import malte0811.ferritecore.mixin.config.FerriteConfig; | ||
import malte0811.ferritecore.mixin.config.FerriteMixinConfig; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class Config extends FerriteMixinConfig { | ||
public Config() { | ||
super(null, false); | ||
} | ||
|
||
@Override | ||
public List<String> getMixins() { | ||
if (HAS_HYDROGEN && FerriteConfig.NEIGHBOR_LOOKUP.isEnabled()) { | ||
LOGGER.warn("Adding Mixin to disable Hydrogen's MixinState#postCreateWithTable"); | ||
return Collections.singletonList("HydrogenStateholderMixin"); | ||
} else { | ||
return super.getMixins(); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
fabric/src/main/java/malte0811/ferritecore/mixin/fabric/HydrogenStateholderMixin.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,26 @@ | ||
package malte0811.ferritecore.mixin.fabric; | ||
|
||
import net.minecraft.state.Property; | ||
import net.minecraft.state.StateHolder; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import java.util.Map; | ||
|
||
// This mixin is conditionally added by the Mixin config | ||
@SuppressWarnings("UnusedMixin") | ||
@Mixin(value = StateHolder.class, priority = 900) | ||
public class HydrogenStateholderMixin<S> { | ||
/** | ||
* Disable the callback injected by Hydrogen, since it relies on the neighbor table being present, which is not the | ||
* case after this method is called with FASTMAP enabled.<br> | ||
* This is a massive hack, but is currently probably the cleanest approach. If H gets the system for | ||
* disabling Mixins already implemented in Na/Li that system should be used instead! | ||
*/ | ||
@Inject(method = "func_235899_a_", at = @At("RETURN"), cancellable = true) | ||
public void postPopulateNeighbors(Map<Map<Property<?>, Comparable<?>>, S> map, CallbackInfo ci) { | ||
ci.cancel(); | ||
} | ||
} |
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