Skip to content

Commit

Permalink
SUUUPPPERRR
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsterner committed Feb 9, 2023
1 parent a5671ab commit 01ce40b
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 60 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs = -Xmx5G
org.gradle.parallel = true

# Mod Properties
version = 1.5.7
version = 1.5.8
maven_group = dev.sterner
archives_base_name = malum

Expand Down
7 changes: 5 additions & 2 deletions src/main/java/dev/sterner/malum/Malum.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@ public class Malum implements ModInitializer {

@Override
public void onInitialize(ModContainer mod) {
MalumObjects.init();
MalumSpiritTypeRegistry.init();

MalumAttributeRegistry.init();
MalumParticleRegistry.init();
MalumEnchantmentRegistry.init();
MalumSoundRegistry.init();


MalumEntityRegistry.init();
MalumObjects.init();
MalumBlockEntityRegistry.init();


Expand All @@ -52,7 +55,7 @@ public void onInitialize(ModContainer mod) {
MalumRecipeTypeRegistry.init();
MalumRecipeSerializerRegistry.init();
MalumScreenHandlerRegistry.init();
MalumSpiritTypeRegistry.init();

MalumRiteRegistry.init();
MalumTrinketEvents.init();
MalumItemGroupEvents.init();
Expand Down
50 changes: 50 additions & 0 deletions src/main/java/dev/sterner/malum/common/MalumMixinPlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package dev.sterner.malum.common;


import org.objectweb.asm.tree.ClassNode;
import org.quiltmc.loader.api.QuiltLoader;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;

import java.util.List;
import java.util.Set;

public class MalumMixinPlugin implements IMixinConfigPlugin {
@Override
public void onLoad(String mixinPackage) {

}

@Override
public String getRefMapperConfig() {
return null;
}

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
if (mixinClassName.startsWith("sterner.malum.mixin.plugin")) {
return QuiltLoader.isDevelopmentEnvironment();
}
return true;
}

@Override
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {

}

@Override
public List<String> getMixins() {
return null;
}

@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {

}

@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {

}
}
31 changes: 15 additions & 16 deletions src/main/java/dev/sterner/malum/common/registry/MalumObjects.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
public interface MalumObjects {
Map<Block, Identifier> BLOCKS = new LinkedHashMap<>();
Map<Item, Identifier> ITEMS = new LinkedHashMap<>();
Map<Supplier<MalumSpiritItem>, String> SPIRITS = new LinkedHashMap<>();
Set<MalumScytheItem> SCYTHES = new ReferenceOpenHashSet<>();
ArrayList<SignType> SIGN_TYPES = new ArrayList<>();

Expand All @@ -101,14 +102,14 @@ public interface MalumObjects {
//endregion

//region spirits
Item SACRED_SPIRIT = register("sacred_spirit", new MalumSpiritItem(settings(), MalumSpiritTypeRegistry.SACRED_SPIRIT));
Item WICKED_SPIRIT = register("wicked_spirit", new MalumSpiritItem(settings(), MalumSpiritTypeRegistry.WICKED_SPIRIT));
Item ARCANE_SPIRIT = register("arcane_spirit", new MalumSpiritItem(settings(), MalumSpiritTypeRegistry.ARCANE_SPIRIT));
Item ELDRITCH_SPIRIT = register("eldritch_spirit", new MalumSpiritItem(settings(), MalumSpiritTypeRegistry.ELDRITCH_SPIRIT));
Item EARTHEN_SPIRIT = register("earthen_spirit", new MalumSpiritItem(settings(), MalumSpiritTypeRegistry.EARTHEN_SPIRIT));
Item INFERNAL_SPIRIT = register("infernal_spirit", new MalumSpiritItem(settings(), MalumSpiritTypeRegistry.INFERNAL_SPIRIT));
Item AERIAL_SPIRIT = register("aerial_spirit", new MalumSpiritItem(settings(), MalumSpiritTypeRegistry.AERIAL_SPIRIT));
Item AQUEOUS_SPIRIT = register("aqueous_spirit", new MalumSpiritItem(settings(), MalumSpiritTypeRegistry.AQUEOUS_SPIRIT));
MalumSpiritItem SACRED_SPIRIT = registerSpirit("sacred_spirit", new MalumSpiritItem(settings(), MalumSpiritTypeRegistry.SACRED_SPIRIT));
MalumSpiritItem WICKED_SPIRIT = registerSpirit("wicked_spirit", new MalumSpiritItem(settings(), MalumSpiritTypeRegistry.WICKED_SPIRIT));
MalumSpiritItem ARCANE_SPIRIT = registerSpirit("arcane_spirit", new MalumSpiritItem(settings(), MalumSpiritTypeRegistry.ARCANE_SPIRIT));
MalumSpiritItem ELDRITCH_SPIRIT = registerSpirit("eldritch_spirit", new MalumSpiritItem(settings(), MalumSpiritTypeRegistry.ELDRITCH_SPIRIT));
MalumSpiritItem EARTHEN_SPIRIT = registerSpirit("earthen_spirit", new MalumSpiritItem(settings(), MalumSpiritTypeRegistry.EARTHEN_SPIRIT));
MalumSpiritItem INFERNAL_SPIRIT = registerSpirit("infernal_spirit", new MalumSpiritItem(settings(), MalumSpiritTypeRegistry.INFERNAL_SPIRIT));
MalumSpiritItem AERIAL_SPIRIT = registerSpirit("aerial_spirit", new MalumSpiritItem(settings(), MalumSpiritTypeRegistry.AERIAL_SPIRIT));
MalumSpiritItem AQUEOUS_SPIRIT = registerSpirit("aqueous_spirit", new MalumSpiritItem(settings(), MalumSpiritTypeRegistry.AQUEOUS_SPIRIT));
//endregion

//region ores
Expand Down Expand Up @@ -629,14 +630,6 @@ static <T extends Block> T register(String name, T block, boolean createItem) {
return block;
}

static <T extends Block> T registerS(String name, Supplier<T> block, boolean createItem) {
BLOCKS.put(block.get(), new Identifier(Malum.MODID, name));
if (createItem) {
ITEMS.put(new BlockItem(block.get(), settings()), BLOCKS.get(block));
}
return block.get();
}

static <T extends Block> T registerMultiBlock(String name, T block, Supplier<? extends MultiBlockStructure> structure, boolean createItem) {
BLOCKS.put(block, new Identifier(Malum.MODID, name));
if (createItem) {
Expand All @@ -650,6 +643,12 @@ static <T extends Item> T register(String name, T item) {
return item;
}

static MalumSpiritItem registerSpirit(String name, MalumSpiritItem item) {
ITEMS.put(item, new Identifier(Malum.MODID, name));
SPIRITS.put(() -> item, name);
return item;
}

static Item.Settings settings() {
return new Item.Settings();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.sterner.malum.common.registry;

import dev.sterner.malum.common.item.spirit.MalumSpiritItem;
import dev.sterner.malum.common.spirit.MalumSpiritType;
import dev.sterner.malum.common.spirit.SpiritTypeProperty;
import net.minecraft.item.Item;
Expand All @@ -12,25 +13,25 @@
public interface MalumSpiritTypeRegistry {
Map<String, MalumSpiritType> SPIRITS = new LinkedHashMap<>();

MalumSpiritType SACRED_SPIRIT = create("sacred", new Color(243, 40, 143), MalumObjects.SACRED_SPIRIT);
MalumSpiritType WICKED_SPIRIT = create("wicked", new Color(155, 62, 245), MalumObjects.WICKED_SPIRIT);
MalumSpiritType ARCANE_SPIRIT = create("arcane", new Color(212, 55, 255), MalumObjects.ARCANE_SPIRIT);
MalumSpiritType ELDRITCH_SPIRIT = create("eldritch", new Color(125, 29, 215), new Color(39, 201, 103), MalumObjects.ELDRITCH_SPIRIT);
MalumSpiritType AERIAL_SPIRIT = create("aerial", new Color(75, 243, 218), MalumObjects.AERIAL_SPIRIT);
MalumSpiritType AQUEOUS_SPIRIT = create("aqueous", new Color(29, 100, 232), MalumObjects.AQUEOUS_SPIRIT);
MalumSpiritType INFERNAL_SPIRIT = create("infernal", new Color(210, 134, 39), MalumObjects.INFERNAL_SPIRIT);
MalumSpiritType EARTHEN_SPIRIT = create("earthen", new Color(73, 234, 27), MalumObjects.EARTHEN_SPIRIT);
MalumSpiritType SACRED_SPIRIT = create("sacred", new Color(243, 40, 143));
MalumSpiritType WICKED_SPIRIT = create("wicked", new Color(155, 62, 245));
MalumSpiritType ARCANE_SPIRIT = create("arcane", new Color(212, 55, 255));
MalumSpiritType ELDRITCH_SPIRIT = create("eldritch", new Color(125, 29, 215), new Color(39, 201, 103));
MalumSpiritType AERIAL_SPIRIT = create("aerial", new Color(75, 243, 218));
MalumSpiritType AQUEOUS_SPIRIT = create("aqueous", new Color(29, 100, 232));
MalumSpiritType INFERNAL_SPIRIT = create("infernal", new Color(210, 134, 39));
MalumSpiritType EARTHEN_SPIRIT = create("earthen", new Color(73, 234, 27));

SpiritTypeProperty SPIRIT_TYPE_PROPERTY = new SpiritTypeProperty("spirit_type", SPIRITS.values());

static MalumSpiritType create(String identifier, Color color, Item splinterItem) {
MalumSpiritType spiritType = new MalumSpiritType(identifier, color, () -> splinterItem);
static MalumSpiritType create(String identifier, Color color) {
MalumSpiritType spiritType = new MalumSpiritType(identifier, color);
SPIRITS.put(identifier, spiritType);
return spiritType;
}

static MalumSpiritType create(String identifier, Color color, Color endColor, Item splinterItem) {
MalumSpiritType spiritType = new MalumSpiritType(identifier, color, endColor, () -> splinterItem);
static MalumSpiritType create(String identifier, Color color, Color endColor) {
MalumSpiritType spiritType = new MalumSpiritType(identifier, color, endColor);
SPIRITS.put(identifier, spiritType);
return spiritType;
}
Expand Down
58 changes: 29 additions & 29 deletions src/main/java/dev/sterner/malum/common/spirit/MalumSpiritType.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,45 @@
import net.minecraft.util.hit.BlockHitResult;

import java.awt.*;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.function.Supplier;
import java.util.stream.Stream;

public class MalumSpiritType {
private final Color color;
public Map<Supplier<MalumSpiritItem>, String> SPIRITS = new LinkedHashMap<>();

private final Color endColor;
public final Color color;

public final Color endColor;
public final String identifier;

public Supplier<Item> splinterItem;
public Supplier<MalumSpiritItem> splinterItem;

public MalumSpiritType(String identifier, Color color, Supplier<Item> splinterItem) {
this.identifier = identifier;
this.color = color;
this.endColor = createEndColor(color);
switch (identifier) {
case "wicked" -> this.splinterItem = () -> MalumObjects.WICKED_SPIRIT;
case "arcane" -> this.splinterItem = () -> MalumObjects.ARCANE_SPIRIT;
case "eldritch" -> this.splinterItem = () -> MalumObjects.ELDRITCH_SPIRIT;
case "aerial" -> this.splinterItem = () -> MalumObjects.AERIAL_SPIRIT;
case "aqueous" -> this.splinterItem = () -> MalumObjects.AQUEOUS_SPIRIT;
case "infernal" -> this.splinterItem = () -> MalumObjects.INFERNAL_SPIRIT;
case "earthen" -> this.splinterItem = () -> MalumObjects.EARTHEN_SPIRIT;
default -> this.splinterItem = () -> MalumObjects.SACRED_SPIRIT;
}
public MalumSpiritType(String identifier, Color color) {
this(identifier, color, createEndColor(color));
}

public MalumSpiritType(String identifier, Color color, Color endColor, Supplier<Item> splinterItem) {
public MalumSpiritType(String identifier, Color color, Color endColor) {
SPIRITS.put(() -> MalumObjects.WICKED_SPIRIT, "wicked");
SPIRITS.put(() -> MalumObjects.ARCANE_SPIRIT, "arcane");
SPIRITS.put(() -> MalumObjects.ELDRITCH_SPIRIT, "eldritch");
SPIRITS.put(() -> MalumObjects.AERIAL_SPIRIT, "aerial");
SPIRITS.put(() -> MalumObjects.AQUEOUS_SPIRIT, "aqueous");
SPIRITS.put(() -> MalumObjects.INFERNAL_SPIRIT, "infernal");
SPIRITS.put(() -> MalumObjects.EARTHEN_SPIRIT, "earthen");
SPIRITS.put(() -> MalumObjects.SACRED_SPIRIT, "sacred");


this.identifier = identifier;
this.color = color;
this.endColor = endColor;
switch (identifier) {
case "wicked" -> this.splinterItem = () -> MalumObjects.WICKED_SPIRIT;
case "arcane" -> this.splinterItem = () -> MalumObjects.ARCANE_SPIRIT;
case "eldritch" -> this.splinterItem = () -> MalumObjects.ELDRITCH_SPIRIT;
case "aerial" -> this.splinterItem = () -> MalumObjects.AERIAL_SPIRIT;
case "aqueous" -> this.splinterItem = () -> MalumObjects.AQUEOUS_SPIRIT;
case "infernal" -> this.splinterItem = () -> MalumObjects.INFERNAL_SPIRIT;
case "earthen" -> this.splinterItem = () -> MalumObjects.EARTHEN_SPIRIT;
default -> this.splinterItem = () -> MalumObjects.SACRED_SPIRIT;
for(Map.Entry<Supplier<MalumSpiritItem>, String> entry : SPIRITS.entrySet().stream().toList()){
String id = entry.getValue();
if(id.equals(identifier)){
this.splinterItem = () -> entry.getKey().get();
}
}
}

Expand Down Expand Up @@ -83,12 +83,12 @@ public String getFlavourText() {
return "malum.spirit.flavour." + identifier;
}

public Color createEndColor(Color color) {
public static Color createEndColor(Color color) {
return new Color(color.getGreen(), color.getBlue(), color.getRed());
}

public MalumSpiritItem getSplinterItem() {
return (MalumSpiritItem) splinterItem.get();
return splinterItem.get();
}

public Identifier getOverlayTexture() {
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/dev/sterner/malum/mixin/plugin/MojangWhy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package dev.sterner.malum.mixin.plugin;

import net.minecraft.util.Util;
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;

@Mixin(Util.class)
public class MojangWhy {
@Inject(at = @At("HEAD"), method = "getMaxBackgroundThreads", cancellable = true)
private static void stop(CallbackInfoReturnable<Integer> cir) {
cir.setReturnValue(6);
}
}
3 changes: 3 additions & 0 deletions src/main/resources/malum.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
"required": true,
"minVersion": "0.8",
"package": "dev.sterner.malum.mixin",
"plugin": "dev.sterner.malum.common.MalumMixinPlugin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"plugin.MojangWhy",

"common.ArmorMaterialsMixin",
"common.AxeItemMixin",
"common.CookingRecipeSerializerMixin",
Expand Down

0 comments on commit 01ce40b

Please sign in to comment.