Skip to content

Commit

Permalink
🔧 Add a config
Browse files Browse the repository at this point in the history
  • Loading branch information
CallMeEchoCodes committed Jul 23, 2024
1 parent 841d91f commit bc2b641
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 14 deletions.
5 changes: 5 additions & 0 deletions src/main/java/dev/callmeecho/hollow/client/HollowClient.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package dev.callmeecho.hollow.client;

import dev.callmeecho.cabinetapi.client.ModMenuHelper;
import dev.callmeecho.cabinetapi.util.ReflectionHelper;
import dev.callmeecho.hollow.client.render.entity.FireflyEntityRenderer;
import dev.callmeecho.hollow.client.render.entity.JarBlockEntityRenderer;
import dev.callmeecho.hollow.main.Hollow;
import dev.callmeecho.hollow.main.HollowConfig;
import dev.callmeecho.hollow.main.block.HollowLogBlock;
import dev.callmeecho.hollow.main.particle.FireflyJarParticle;
import dev.callmeecho.hollow.main.registry.*;
Expand Down Expand Up @@ -44,5 +47,7 @@ public void onInitializeClient() {
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex == 0 ? 0x71C35C : -1, HollowItemRegistrar.GIANT_LILYPAD);

ParticleFactoryRegistry.getInstance().register(HollowParticleRegistrar.FIREFLY_JAR, FireflyJarParticle.Factory::new);

ModMenuHelper.addConfig(Hollow.MODID, HollowConfig.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.passive.SheepEntity;
import net.minecraft.util.DyeColor;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ColorHelper;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RotationAxis;
import org.joml.Matrix3f;
import org.joml.Matrix4f;

import static dev.callmeecho.hollow.main.Hollow.MODID;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
package dev.callmeecho.hollow.client.render.entity;

import dev.callmeecho.hollow.main.block.entity.JarBlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.render.model.json.ModelTransformationMode;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RotationAxis;
import net.minecraft.world.World;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import dev.callmeecho.hollow.main.registry.HollowBlockRegistrar;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.data.server.recipe.RecipeExporter;
import net.minecraft.data.server.recipe.ShapedRecipeJsonBuilder;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/dev/callmeecho/hollow/main/Hollow.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.callmeecho.hollow.main;

import dev.callmeecho.cabinetapi.config.ConfigHandler;
import dev.callmeecho.cabinetapi.item.CabinetItemGroup;
import dev.callmeecho.cabinetapi.registry.RegistrarHandler;
import dev.callmeecho.hollow.main.entity.FireflyEntity;
Expand All @@ -19,6 +20,7 @@
public class Hollow implements ModInitializer {
public static final String MODID = "hollow";
public static final Logger LOGGER = LoggerFactory.getLogger(MODID);
public static final HollowConfig CONFIG = ConfigHandler.getConfig(HollowConfig.class);

public static final CabinetItemGroup GROUP = new CabinetItemGroup(Identifier.of(MODID, "item_group"), HollowBlockRegistrar.BIRCH_HOLLOW_LOG);

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/dev/callmeecho/hollow/main/HollowConfig.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package dev.callmeecho.hollow.main;

import dev.callmeecho.cabinetapi.config.Config;
import dev.callmeecho.cabinetapi.config.annotations.Comment;
import dev.callmeecho.cabinetapi.config.annotations.Sync;
import net.minecraft.util.Identifier;

public class HollowConfig implements Config {
@Override
public Identifier getName() { return Identifier.of(Hollow.MODID, "config"); }

@Sync
@Comment("Whether to revert the Copper Bulb to it's original 1-tick delay. If you aren't a redstoner, you can ignore this.")
public boolean revertCopperBulb = true;
}
12 changes: 9 additions & 3 deletions src/main/java/dev/callmeecho/hollow/mixin/BulbBlockMixin.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package dev.callmeecho.hollow.mixin;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import dev.callmeecho.hollow.main.Hollow;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.BulbBlock;
Expand All @@ -19,9 +22,12 @@ public BulbBlockMixin(Settings settings) {
super(settings);
}

@Redirect(method = "neighborUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BulbBlock;update(Lnet/minecraft/block/BlockState;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/util/math/BlockPos;)V"))
private void updateRedirect(BulbBlock instance, BlockState state, ServerWorld world, BlockPos pos) {
world.scheduleBlockTick(pos, instance, 1);
@WrapOperation(method = "neighborUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BulbBlock;update(Lnet/minecraft/block/BlockState;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/util/math/BlockPos;)V"))
private void updateRedirect(BulbBlock instance, BlockState state, ServerWorld world, BlockPos pos, Operation<Void> original) {
if (Hollow.CONFIG.revertCopperBulb)
world.scheduleBlockTick(pos, instance, 1);
else
original.call(instance, state, world, pos);
}

@Override
Expand Down
6 changes: 5 additions & 1 deletion src/main/resources/assets/hollow/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,9 @@
"advancements.adventure.diversity_win.title": "Diversity Win",
"advancements.adventure.diversity_win.description": "Get one of every dye.",

"resourcepack.hollow_music": "Hollow Music"
"resourcepack.hollow_music": "Hollow Music",

"config.hollow:config.title": "Hollow",
"config.hollow:config.revertCopperBulb": "Revert Copper Bulb",
"config.hollow:config.revertCopperBulb.tooltip": "Whether to revert the Copper Bulb to it's original 1-tick delay. If you aren't a redstoner, you can ignore this."
}

0 comments on commit bc2b641

Please sign in to comment.