Skip to content

Commit

Permalink
updated to 1.21 version changed to 0.0.1_1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
Skywalker8510 committed Aug 2, 2024
1 parent c1fdb47 commit b544fa7
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 15 deletions.
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.3
loader_version=0.15.11
minecraft_version=1.21
yarn_mappings=1.21+build.9
loader_version=0.16.0

# Mod Properties
mod_version=0.0.1
mod_version=0.0.1_1.21
maven_group=net.skywalker8510.pocketsand
archives_base_name=pocketsand

# Dependencies
fabric_version=0.100.4+1.20.6
fabric_version=0.100.8+1.21
28 changes: 28 additions & 0 deletions remappedSrc/net/skywalker8510/pocketsand/Item/ModItems.java
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);
}
}
20 changes: 20 additions & 0 deletions remappedSrc/net/skywalker8510/pocketsand/PocketSand.java
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();

}
}
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 remappedSrc/net/skywalker8510/pocketsand/mixin/ExampleMixin.java
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
}
}
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());
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ private static void addItemsToIngredientItemGroup(FabricItemGroupEntries entries
}

public static Item registerItem(String name, Item item) {
return Registry.register(Registries.ITEM, new Identifier(PocketSand.MOD_ID, name), item);
return Registry.register(Registries.ITEM, Identifier.of(PocketSand.MOD_ID, name), item);
}
public static void registerModItems() {
PocketSand.LOGGER.info("Registering Mod Items for " + PocketSand.MOD_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public class ModLootTableModifiers {

private static final Identifier HUSK_LOOT_TABLE_ID =
new Identifier("minecraft","entities/husk");
Identifier.of("minecraft","entities/husk");

public static void modifyLootTables() {

Expand Down
13 changes: 5 additions & 8 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"id": "pocketsand",
"version": "${version}",
"name": "PocketSand",
"description": "This is an example description! Tell everyone what your mod is about!",
"description": "Make Husks drop sandy bits from their pockets when you kill them to make sand a renewable resource.",
"authors": [
"Skywalker8510"
],
"contact": {
"homepage": "https://fabricmc.net/",
"sources": "https://github.com/FabricMC/fabric-example-mod"
"homepage": "https://github.com/Skywalker8510/PocketSand/",
"sources": "https://github.com/Skywalker8510/PocketSand/"
},
"license": "MIT",
"icon": "assets/pocketsand/icon.png",
Expand All @@ -26,12 +26,9 @@
"pocketsand.mixins.json"
],
"depends": {
"fabricloader": ">=0.15.11",
"minecraft": "~1.20.6",
"fabricloader": ">=0.16.0",
"minecraft": ">=1.21.0",
"java": ">=21",
"fabric-api": "*"
},
"suggests": {
"another-mod": "*"
}
}

0 comments on commit b544fa7

Please sign in to comment.