this mixin blows up the Koumakan (implemented 0045-lithium-cached-hashcode.patch)

This commit is contained in:
DoggySazHi
2024-03-06 15:30:53 -08:00
parent 0233863cc4
commit 2394106531
4 changed files with 67 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
group=net.gensokyoreimagined.nitori
version=1.0.1
version=1.0.2
description=Converting patches into mixins, for the Ignite Framework
org.gradle.parallel=true

View File

@@ -0,0 +1,63 @@
// Nitori Copyright (C) 2024 Gensokyo Reimagined
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package net.gensokyoreimagined.nitori.core;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
/*
* Originally from CaffeineMC, licensed under GNU Lesser General Public License v3.0
* See https://github.com/CaffeineMC/lithium-fabric for more information/sources
*/
@Mixin(Block.BlockStatePairKey.class)
public class MixinBlock {
@Unique
private int gensouHacks$hash;
@Shadow
@Final
private BlockState first;
@Shadow
@Final
private BlockState second;
@Shadow
@Final
private Direction direction;
@Inject(method = "<init>", at = @At("RETURN"))
private void init(CallbackInfo info) {
int hash = first.hashCode();
hash = 31 * hash + second.hashCode();
hash = 31 * hash + direction.hashCode();
this.gensouHacks$hash = hash;
}
/**
* @author DoggySazHi
* @reason Implementation of 0045-lithium-cached-hashcode.patch
*/
@Overwrite
public int hashCode() {
return this.gensouHacks$hash;
}
}

View File

@@ -1,6 +1,6 @@
{
"id": "Nitori",
"version": "1.0.1",
"version": "1.0.2",
"mixins": [
"mixins.core.json"
]

View File

@@ -12,6 +12,7 @@
"MixinDirection",
"MixinLevel",
"MixinEntitySectionStorage",
"MixinMth"
"MixinMth",
"MixinBlock"
]
}