-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated to 1.21 version changed to 0.0.1_1.21
- Loading branch information
1 parent
c1fdb47
commit b544fa7
Showing
10 changed files
with
123 additions
and
15 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
28 changes: 28 additions & 0 deletions
28
remappedSrc/net/skywalker8510/pocketsand/Item/ModItems.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,28 @@ | ||
package net.skywalker8510.pocketsand.Item; | ||
|
||
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroupEntries; | ||
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemGroups; | ||
import net.minecraft.registry.Registries; | ||
import net.minecraft.registry.Registry; | ||
import net.minecraft.util.Identifier; | ||
import net.skywalker8510.pocketsand.PocketSand; | ||
|
||
public class ModItems { | ||
|
||
public static final Item POCKET_SAND = registerItem("pocket_sand", new Item(new Item.Settings())); | ||
|
||
private static void addItemsToIngredientItemGroup(FabricItemGroupEntries entries) { | ||
entries.add(POCKET_SAND); | ||
} | ||
|
||
public static Item registerItem(String name, Item item) { | ||
return Registry.register(Registries.ITEM, new Identifier(PocketSand.MOD_ID, name), item); | ||
} | ||
public static void registerModItems() { | ||
PocketSand.LOGGER.info("Registering Mod Items for " + PocketSand.MOD_ID); | ||
|
||
ItemGroupEvents.modifyEntriesEvent(ItemGroups.INGREDIENTS).register(ModItems::addItemsToIngredientItemGroup); | ||
} | ||
} |
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,20 @@ | ||
package net.skywalker8510.pocketsand; | ||
|
||
import net.fabricmc.api.ModInitializer; | ||
|
||
import net.skywalker8510.pocketsand.Item.ModItems; | ||
import net.skywalker8510.pocketsand.util.ModLootTableModifiers; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class PocketSand implements ModInitializer { | ||
public static final String MOD_ID = "pocketsand"; | ||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); | ||
|
||
@Override | ||
public void onInitialize() { | ||
ModItems.registerModItems(); | ||
ModLootTableModifiers.modifyLootTables(); | ||
|
||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
remappedSrc/net/skywalker8510/pocketsand/PocketSandDataGenerator.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,11 @@ | ||
package net.skywalker8510.pocketsand; | ||
|
||
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint; | ||
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; | ||
|
||
public class PocketSandDataGenerator implements DataGeneratorEntrypoint { | ||
@Override | ||
public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { | ||
|
||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
remappedSrc/net/skywalker8510/pocketsand/mixin/ExampleMixin.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,15 @@ | ||
package net.skywalker8510.pocketsand.mixin; | ||
|
||
import net.minecraft.server.MinecraftServer; | ||
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.CallbackInfo; | ||
|
||
@Mixin(MinecraftServer.class) | ||
public class ExampleMixin { | ||
@Inject(at = @At("HEAD"), method = "loadWorld") | ||
private void init(CallbackInfo info) { | ||
// This code is injected into the start of MinecraftServer.loadWorld()V | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
remappedSrc/net/skywalker8510/pocketsand/util/ModLootTableModifiers.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,37 @@ | ||
package net.skywalker8510.pocketsand.util; | ||
|
||
import net.fabricmc.fabric.api.loot.v2.LootTableEvents; | ||
import net.minecraft.loot.LootPool; | ||
import net.minecraft.loot.condition.RandomChanceLootCondition; | ||
import net.minecraft.loot.entry.ItemEntry; | ||
import net.minecraft.loot.function.SetCountLootFunction; | ||
import net.minecraft.loot.provider.number.ConstantLootNumberProvider; | ||
import net.minecraft.loot.provider.number.UniformLootNumberProvider; | ||
import net.minecraft.util.Identifier; | ||
import net.skywalker8510.pocketsand.Item.ModItems; | ||
import net.skywalker8510.pocketsand.PocketSand; | ||
|
||
public class ModLootTableModifiers { | ||
|
||
private static final Identifier HUSK_LOOT_TABLE_ID = | ||
new Identifier("minecraft","entities/husk"); | ||
|
||
public static void modifyLootTables() { | ||
|
||
PocketSand.LOGGER.info("Registering Loot Tables for " + PocketSand.MOD_ID); | ||
|
||
LootTableEvents.MODIFY.register((key, tableBuilder, source) -> { | ||
// Let's only modify built-in loot tables and leave data pack loot tables untouched by checking the source. | ||
// We also check that the loot table ID is equal to the ID we want. | ||
if (source.isBuiltin() && HUSK_LOOT_TABLE_ID.equals(key.getValue())) { | ||
// We make the pool and add an item | ||
LootPool.Builder poolBuilder = LootPool.builder() | ||
.rolls(ConstantLootNumberProvider.create(1)) | ||
.conditionally(RandomChanceLootCondition.builder(1f)) | ||
.with(ItemEntry.builder(ModItems.POCKET_SAND)) | ||
.apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(2.0f, 5.0f)).build()); | ||
tableBuilder.pool(poolBuilder.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
File renamed without changes.
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