Skip to content

Commit

Permalink
refabricated
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsterner committed Apr 13, 2024
1 parent 7f9f3ce commit 6c21f1c
Show file tree
Hide file tree
Showing 45 changed files with 1,405 additions and 374 deletions.
26 changes: 23 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.0-SNAPSHOT'
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'maven-publish'
}

Expand All @@ -11,6 +11,21 @@ version = project.mod_version
group = project.maven_group

repositories {
maven {
name = "Greenhouse Maven"
url = 'https://maven.greenhouseteam.dev/releases/'
}
maven { url = "https://mvn.devos.one/snapshots/" } // Porting Lib
maven {
url "https://maven.jamieswhiteshirt.com/libs-release" // Reach Entity Attributes (Required by Porting Lib)
content {
includeGroup "com.jamieswhiteshirt"
}
}
maven {
name = "Jitpack, ASM, MixinExtras"
url = "https://jitpack.io"
}
maven {
name "cloth config, rei"
url "https://maven.shedaniel.me"
Expand All @@ -24,13 +39,18 @@ repositories {

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "curse.maven:farmersdelightfabric-482834:${project.delight_version}"
modImplementation("vectorwing:FarmersDelight:${fdrf_version}") {
exclude(group: "net.fabricmc")
}

modImplementation include("com.terraformersmc.terraform-api:terraform-wood-api-v1:${project.terraform_wood_api_version}")

//Fabric ASM
modImplementation include ("com.github.Chocohead:Fabric-ASM:v2.3")
}

processResources {
Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ org.gradle.parallel=true
# Fabric Properties
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.9
loader_version=0.14.21
loader_version=0.15.9

# Mod Properties
mod_version = 0.14.11+1.20.1
mod_version = 1.0.0+1.20.1
maven_group = dev.sterner
archives_base_name = cultural-delights-fabric

# Dependencies
fabric_version=0.85.0+1.20.1
delight_version=4640640
fdrf_version=1.20.1-2.0.16+refabricated
rei_version=4644023
terraform_wood_api_version=7.0.1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
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 remappedSrc/dev/sterner/culturaldelights/CulturalDelights.java
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);
}
}
}
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
);
}
}
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;
}
}
Loading

0 comments on commit 6c21f1c

Please sign in to comment.