generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 13
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
Showing
45 changed files
with
1,405 additions
and
374 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
97 changes: 97 additions & 0 deletions
97
remappedSrc/dev/sterner/culturaldelights/CulturalDelights.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,97 @@ | ||
package dev.sterner.culturaldelights; | ||
|
||
import com.mojang.serialization.Codec; | ||
import dev.sterner.culturaldelights.common.registry.CDObjects; | ||
import dev.sterner.culturaldelights.common.registry.CDConfiguredFeatures; | ||
import dev.sterner.culturaldelights.common.registry.CDWorldGenerators; | ||
import dev.sterner.culturaldelights.common.utils.Constants; | ||
import dev.sterner.culturaldelights.common.world.AvocadoBundleTreeDecorator; | ||
import net.fabricmc.api.ModInitializer; | ||
import net.fabricmc.fabric.api.biome.v1.BiomeModifications; | ||
import net.fabricmc.fabric.api.loot.v2.LootTableEvents; | ||
import net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper; | ||
import net.minecraft.core.Registry; | ||
import net.minecraft.core.registries.BuiltInRegistries; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.util.RandomSource; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.EntityType; | ||
import net.minecraft.world.entity.npc.VillagerProfession; | ||
import net.minecraft.world.entity.npc.VillagerTrades; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.Items; | ||
import net.minecraft.world.item.trading.MerchantOffer; | ||
import net.minecraft.world.level.biome.Biomes; | ||
import net.minecraft.world.level.levelgen.GenerationStep; | ||
import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecorator; | ||
import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType; | ||
import net.minecraft.world.level.storage.loot.LootPool; | ||
import net.minecraft.world.level.storage.loot.entries.LootItem; | ||
|
||
public class CulturalDelights implements ModInitializer { | ||
public static final String MOD_ID = "culturaldelights"; | ||
private static final ResourceLocation SQUID_LOOT_TABLE_ID = EntityType.SQUID.getDefaultLootTable(); | ||
private static final ResourceLocation GLOW_SQUID_LOOT_TABLE_ID = EntityType.GLOW_SQUID.getDefaultLootTable(); | ||
|
||
public static final TreeDecoratorType<AvocadoBundleTreeDecorator> AVOCADO_BUNDLE_TREE_DECORATOR_TYPE = register(Constants.id("avocado_bundle"), AvocadoBundleTreeDecorator.CODEC); | ||
|
||
private static <P extends TreeDecorator> TreeDecoratorType<P> register(ResourceLocation id, Codec<P> codec) { | ||
return Registry.register(BuiltInRegistries.TREE_DECORATOR_TYPE, id, new TreeDecoratorType<>(codec)); | ||
} | ||
|
||
@Override | ||
public void onInitialize() { | ||
CDObjects.init(); | ||
|
||
CDConfiguredFeatures.registerAll(); | ||
CDWorldGenerators.init(); | ||
|
||
BiomeModifications.addFeature(context -> context.getBiomeKey().equals(Biomes.PLAINS), GenerationStep.Decoration.VEGETAL_DECORATION, | ||
CDConfiguredFeatures.PATCH_WILD_CUCUMBERS.key()); | ||
BiomeModifications.addFeature(context -> context.getBiomeKey().equals(Biomes.SWAMP), GenerationStep.Decoration.VEGETAL_DECORATION, | ||
CDConfiguredFeatures.PATCH_WILD_EGGPLANTS.key()); | ||
BiomeModifications.addFeature(context -> context.getBiomeKey().equals(Biomes.SWAMP), GenerationStep.Decoration.VEGETAL_DECORATION, | ||
CDConfiguredFeatures.PATCH_WILD_CUCUMBERS.key()); | ||
BiomeModifications.addFeature(context -> context.getBiomeKey().equals(Biomes.JUNGLE), GenerationStep.Decoration.VEGETAL_DECORATION, | ||
CDConfiguredFeatures.PATCH_WILD_EGGPLANTS.key()); | ||
|
||
TradeOfferHelper.registerVillagerOffers(VillagerProfession.FARMER, 1, factories -> { | ||
factories.add(new EmeraldToItemOffer(new ItemStack(CDObjects.CUCUMBER), 1, 10, 2, 0.2F)); | ||
factories.add(new EmeraldToItemOffer(new ItemStack(CDObjects.EGGPLANT), 1, 10, 2, 0.2F)); | ||
factories.add(new EmeraldToItemOffer(new ItemStack(CDObjects.CORN_COB), 1, 10, 2, 0.2F)); | ||
factories.add(new EmeraldToItemOffer(new ItemStack(CDObjects.AVOCADO), 1, 10, 2, 0.2F)); | ||
}); | ||
|
||
LootTableEvents.MODIFY.register((resourceManager, lootManager, id, tableBuilder, source) -> { | ||
if(source.isBuiltin() && SQUID_LOOT_TABLE_ID.equals(id)){ | ||
LootPool.Builder poolBuilder = LootPool.lootPool().add(LootItem.lootTableItem(CDObjects.SQUID)); | ||
tableBuilder.withPool(poolBuilder); | ||
} | ||
if(source.isBuiltin() && GLOW_SQUID_LOOT_TABLE_ID.equals(id)){ | ||
LootPool.Builder poolBuilder = LootPool.lootPool().add(LootItem.lootTableItem(CDObjects.GLOW_SQUID)); | ||
tableBuilder.withPool(poolBuilder); | ||
} | ||
}); | ||
} | ||
|
||
public static class EmeraldToItemOffer implements VillagerTrades.ItemListing { | ||
|
||
private final ItemStack sell; | ||
private final int price; | ||
private final int maxUses; | ||
private final int experience; | ||
private final float multiplier; | ||
|
||
public EmeraldToItemOffer(ItemStack stack, int price, int maxUses, int experience, float multiplier) { | ||
this.sell = stack; | ||
this.price = price; | ||
this.maxUses = maxUses; | ||
this.experience = experience; | ||
this.multiplier = multiplier; | ||
} | ||
|
||
public MerchantOffer getOffer(Entity entity, RandomSource random) { | ||
return new MerchantOffer(new ItemStack(Items.EMERALD, this.price + random.nextInt(3)), sell, this.maxUses, this.experience, this.multiplier); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
remappedSrc/dev/sterner/culturaldelights/CulturalDelightsClient.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,24 @@ | ||
package dev.sterner.culturaldelights; | ||
|
||
import dev.sterner.culturaldelights.common.registry.CDObjects; | ||
import net.fabricmc.api.ClientModInitializer; | ||
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; | ||
import net.minecraft.client.renderer.RenderType; | ||
|
||
public class CulturalDelightsClient implements ClientModInitializer { | ||
@Override | ||
public void onInitializeClient() { | ||
BlockRenderLayerMap.INSTANCE.putBlocks(RenderType.cutout(), | ||
CDObjects.WILD_CUCUMBERS, | ||
CDObjects.WILD_CORN, | ||
CDObjects.WILD_EGGPLANTS, | ||
CDObjects.AVOCADO_LEAVES, | ||
CDObjects.AVOCADO_SAPLING, | ||
CDObjects.AVOCADO_PIT, | ||
CDObjects.CUCUMBER_CROP, | ||
CDObjects.EGGPLANT_CROP, | ||
CDObjects.CORN_CROP, | ||
CDObjects.CORN_UPPER | ||
); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
remappedSrc/dev/sterner/culturaldelights/common/block/AvocadoPitBlock.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,25 @@ | ||
package dev.sterner.culturaldelights.common.block; | ||
|
||
import net.minecraft.block.*; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.SaplingBlock; | ||
import net.minecraft.world.level.block.grower.AbstractTreeGrower; | ||
import net.minecraft.world.level.block.state.BlockBehaviour; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.phys.shapes.CollisionContext; | ||
import net.minecraft.world.phys.shapes.VoxelShape; | ||
|
||
public class AvocadoPitBlock extends SaplingBlock { | ||
private static final VoxelShape SHAPE_PIT = Block.box(6, 0, 6, 10, 3, 10); | ||
|
||
public AvocadoPitBlock(AbstractTreeGrower treeIn, BlockBehaviour.Properties properties) { | ||
super(treeIn, properties); | ||
} | ||
|
||
@Override | ||
public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { | ||
return SHAPE_PIT; | ||
} | ||
} |
Oops, something went wrong.