-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cfbcf7f
commit 32813ab
Showing
23 changed files
with
174 additions
and
67 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
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
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 |
---|---|---|
@@ -1,18 +1,20 @@ | ||
package dev.spiritstudios.hollow; | ||
|
||
import dev.spiritstudios.specter.api.config.Config; | ||
import dev.spiritstudios.specter.api.config.annotations.Comment; | ||
import dev.spiritstudios.specter.api.config.annotations.Sync; | ||
import net.minecraft.util.Identifier; | ||
|
||
public class HollowConfig implements Config { | ||
public class HollowConfig extends Config<HollowConfig> { | ||
public static final HollowConfig INSTANCE = create(HollowConfig.class); | ||
|
||
@Override | ||
public Identifier getId() { return Identifier.of(Hollow.MODID, "config"); } | ||
public Identifier getId() { return Identifier.of(Hollow.MODID, "hollow"); } | ||
|
||
@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; | ||
public Value<Boolean> revertCopperBulb = booleanValue(true) | ||
.comment("Whether to revert the Copper Bulb to it's original 1-tick delay. If you aren't a redstoner, you can ignore this.") | ||
.sync() | ||
.build(); | ||
|
||
@Comment("Whether to enable Hollow's custom music.") | ||
public boolean music = true; | ||
public Value<Boolean> music = booleanValue(true) | ||
.comment("Whether to enable Hollow's custom music.") | ||
.build(); | ||
} |
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
16 changes: 14 additions & 2 deletions
16
.../hollow/HollowLootTableModifications.java → ...ow/loot/HollowLootTableModifications.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 |
---|---|---|
@@ -1,22 +1,34 @@ | ||
package dev.spiritstudios.hollow; | ||
package dev.spiritstudios.hollow.loot; | ||
|
||
import dev.spiritstudios.hollow.registry.HollowItemRegistrar; | ||
import net.fabricmc.fabric.api.loot.v3.LootTableEvents; | ||
import net.minecraft.loot.LootPool; | ||
import net.minecraft.loot.LootTables; | ||
import net.minecraft.loot.condition.RandomChanceLootCondition; | ||
import net.minecraft.loot.entry.ItemEntry; | ||
import net.minecraft.loot.provider.number.UniformLootNumberProvider; | ||
|
||
public class HollowLootTableModifications { | ||
public static void init() { | ||
LootTableEvents.MODIFY.register((key, tableBuilder, source, registries) -> { | ||
if (LootTables.ANCIENT_CITY_CHEST == key && source.isBuiltin()) { | ||
if (!source.isBuiltin()) return; | ||
|
||
if (LootTables.ANCIENT_CITY_CHEST == key) { | ||
LootPool.Builder lootPoolBuilder = LootPool.builder() | ||
.with(ItemEntry.builder(HollowItemRegistrar.MUSIC_DISC_POSTMORTEM)) | ||
.conditionally(RandomChanceLootCondition.builder(0.1F)); | ||
|
||
tableBuilder.pool(lootPoolBuilder); | ||
} | ||
|
||
if (LootTables.PILLAGER_OUTPOST_CHEST == key) { | ||
LootPool.Builder lootPoolBuilder = LootPool.builder() | ||
.rolls(UniformLootNumberProvider.create(0.0F, 1.0F)) | ||
.with(ItemEntry.builder(HollowItemRegistrar.COPPER_HORN)) | ||
.apply(SetCopperInstrumentFunction.builder()); | ||
|
||
tableBuilder.pool(lootPoolBuilder); | ||
} | ||
}); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/dev/spiritstudios/hollow/loot/SetCopperInstrumentFunction.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,48 @@ | ||
package dev.spiritstudios.hollow.loot; | ||
|
||
import com.mojang.serialization.MapCodec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import dev.spiritstudios.hollow.item.CopperHornItem; | ||
import dev.spiritstudios.hollow.registry.HollowDataComponentRegistrar; | ||
import net.minecraft.item.Instrument; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.loot.condition.LootCondition; | ||
import net.minecraft.loot.context.LootContext; | ||
import net.minecraft.loot.function.ConditionalLootFunction; | ||
import net.minecraft.loot.function.LootFunctionType; | ||
import net.minecraft.loot.function.LootFunctionTypes; | ||
import net.minecraft.loot.function.SetInstrumentLootFunction; | ||
import net.minecraft.registry.tag.TagKey; | ||
|
||
import java.util.List; | ||
|
||
public class SetCopperInstrumentFunction extends ConditionalLootFunction { | ||
public static final MapCodec<SetCopperInstrumentFunction> CODEC = RecordCodecBuilder.mapCodec( | ||
instance -> addConditionsField(instance).apply(instance, SetCopperInstrumentFunction::new) | ||
); | ||
|
||
private SetCopperInstrumentFunction(List<LootCondition> conditions) { | ||
super(conditions); | ||
} | ||
|
||
public static ConditionalLootFunction.Builder<?> builder() { | ||
return builder(SetCopperInstrumentFunction::new); | ||
} | ||
|
||
@Override | ||
public LootFunctionType<SetInstrumentLootFunction> getType() { | ||
return LootFunctionTypes.SET_INSTRUMENT; | ||
} | ||
|
||
@Override | ||
public ItemStack process(ItemStack stack, LootContext context) { | ||
if (stack.getItem() instanceof CopperHornItem) { | ||
HollowDataComponentRegistrar.CopperInstrument[] values = HollowDataComponentRegistrar.CopperInstrument.values(); | ||
stack.set( | ||
HollowDataComponentRegistrar.COPPER_INSTRUMENT, | ||
values[context.getRandom().nextInt(values.length)] | ||
); | ||
} | ||
return stack; | ||
} | ||
} |
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
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
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
Oops, something went wrong.