Code cleanup and refactoring before porting

This commit is contained in:
2023-05-10 21:21:16 +02:00
parent 1dec8d130c
commit 8e72212bf6
134 changed files with 975 additions and 755 deletions

View File

@@ -0,0 +1,27 @@
package com.hypherionmc.craterlib.mixin.colors;
import com.hypherionmc.craterlib.api.event.client.ColorRegistrationEvent;
import com.hypherionmc.craterlib.core.event.CraterEventBus;
import net.minecraft.client.color.block.BlockColors;
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.CallbackInfoReturnable;
/**
* @author HypherionSA
* Mixin to accommodate Block Color Registration across multiple Modloaders
*/
@Mixin(BlockColors.class)
public class BlockColorsMixin {
/**
* Inject into Vanilla code to fire off our event
*/
@Inject(method = "createDefault", at = @At("RETURN"))
private static void injectBlockColors(CallbackInfoReturnable<BlockColors> cir) {
ColorRegistrationEvent.Blocks blockEvent = new ColorRegistrationEvent.Blocks(cir.getReturnValue());
CraterEventBus.INSTANCE.postEvent(blockEvent);
}
}

View File

@@ -0,0 +1,29 @@
package com.hypherionmc.craterlib.mixin.colors;
import com.hypherionmc.craterlib.api.event.client.ColorRegistrationEvent;
import com.hypherionmc.craterlib.core.event.CraterEventBus;
import net.minecraft.client.color.block.BlockColors;
import net.minecraft.client.color.item.ItemColors;
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.CallbackInfoReturnable;
/**
* @author HypherionSA
* Mixin to accommodate Item Color Registration across multiple Modloaders
*/
@Mixin(ItemColors.class)
public class ItemColorsMixin {
/**
* Inject into Vanilla code to fire off our event
* @param cir
*/
@Inject(method = "createDefault", at = @At("RETURN"))
private static void injectItemColors(BlockColors $$0, CallbackInfoReturnable<ItemColors> cir) {
ColorRegistrationEvent.Items itemColorEvent = new ColorRegistrationEvent.Items(cir.getReturnValue());
CraterEventBus.INSTANCE.postEvent(itemColorEvent);
}
}