Skip to content

Commit

Permalink
more sapling tree gen
Browse files Browse the repository at this point in the history
  • Loading branch information
Uraneptus committed Feb 12, 2024
1 parent a8aaf0e commit d487354
Show file tree
Hide file tree
Showing 15 changed files with 114 additions and 47 deletions.
2 changes: 2 additions & 0 deletions src/generated/resources/assets/sullysmod/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@
"item.sullysmod.tortoise_shell": "Tortoise Shell",
"item.sullysmod.tortoise_spawn_egg": "Tortoise Spawn Egg",
"item.sullysmod.venom_vial": "Vial of Jungle Venom",
"painting.sullysmod.amber.author": "Graus",
"painting.sullysmod.amber.title": "Amber",
"painting.sullysmod.unnerving_night.author": "RealSpidey",
"painting.sullysmod.unnerving_night.title": "Unnerving Night",
"subtitles.block.flinger_totem.add_honey": "Honey applied",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"sullysmod:unnerving_night",
"sullysmod:amber"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"type": "minecraft:archaeology",
"pools": [
{
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"name": "sullysmod:amber"
}
],
"rolls": 1.0
}
],
"random_sequence": "sullysmod:archaeology/petrified_sapling_tree"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,7 @@
"config": {
"decorators": [
{
"type": "minecraft:alter_ground",
"provider": {
"type": "minecraft:weighted_state_provider",
"entries": [
{
"data": {
"Name": "minecraft:gravel"
},
"weight": 5
},
{
"data": {
"Name": "minecraft:suspicious_gravel",
"Properties": {
"dusted": "0"
}
},
"weight": 3
}
]
}
"type": "sullysmod:petrified_gravel_decorator"
}
],
"dirt_provider": {
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/com/uraneptus/sullysmod/SullysMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
import com.uraneptus.sullysmod.core.data.server.loot.SMLootTableProvider;
import com.uraneptus.sullysmod.core.data.server.modifiers.SMAdvancementModifiersProvider;
import com.uraneptus.sullysmod.core.data.server.modifiers.SMLootModifierProvider;
import com.uraneptus.sullysmod.core.data.server.tags.SMBiomeTagsProvider;
import com.uraneptus.sullysmod.core.data.server.tags.SMBlockTagsProvider;
import com.uraneptus.sullysmod.core.data.server.tags.SMEntityTagsProvider;
import com.uraneptus.sullysmod.core.data.server.tags.SMItemTagsProvider;
import com.uraneptus.sullysmod.core.data.server.tags.*;
import com.uraneptus.sullysmod.core.other.SMTextDefinitions;
import com.uraneptus.sullysmod.core.registry.*;
import net.minecraft.core.HolderLookup;
Expand Down Expand Up @@ -63,6 +60,7 @@ public SullysMod() {
SMRecipeTypes.RECIPE_TYPES.register(bus);
SMRecipeSerializer.SERIALIZERS.register(bus);
SMPaintingVariants.PAINTINGS.register(bus);
SMTreeDecoratorTypes.TREE_DECORATORS.register(bus);

DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> SMItems::buildCreativeTabContents);

Expand Down Expand Up @@ -113,6 +111,7 @@ public void gatherData(GatherDataEvent event) {
generator.addProvider(includeServer, blockTagProvider);
generator.addProvider(includeServer, new SMItemTagsProvider(packOutput, lookupProvider, blockTagProvider.contentsGetter(), fileHelper));
generator.addProvider(includeServer, new SMBiomeTagsProvider(packOutput, lookupProvider, fileHelper));
generator.addProvider(includeServer, new SMPaintingVariantTagsProvider(packOutput, lookupProvider, fileHelper));
generator.addProvider(includeServer, new SMAdvancementModifiersProvider(packOutput, lookupProvider));
generator.addProvider(includeServer, new SMLootTableProvider(packOutput));
generator.addProvider(includeServer, new SMAdvancementProvider(packOutput, lookupProvider, fileHelper));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.uraneptus.sullysmod.common.levelgen;

import com.google.common.collect.Lists;
import com.mojang.serialization.Codec;
import com.uraneptus.sullysmod.SullysMod;
import com.uraneptus.sullysmod.core.registry.SMTreeDecoratorTypes;
import net.minecraft.core.BlockPos;
import net.minecraft.util.random.SimpleWeightedRandomList;
import net.minecraft.world.level.block.Blocks;
Expand All @@ -13,18 +16,27 @@
import net.minecraft.world.level.levelgen.feature.stateproviders.WeightedStateProvider;
import net.minecraft.world.level.levelgen.feature.treedecorators.AlterGroundDecorator;
import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecorator;
import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType;
import net.minecraft.world.level.levelgen.feature.treedecorators.TrunkVineDecorator;
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
import net.minecraftforge.event.ForgeEventFactory;

import java.util.List;

public class PetrifiedTreeGravelDecorator extends AlterGroundDecorator {
public class PetrifiedTreeGravelDecorator extends TreeDecorator {
public static final Codec<PetrifiedTreeGravelDecorator> CODEC = Codec.unit(() -> PetrifiedTreeGravelDecorator.INSTANCE);
public static final PetrifiedTreeGravelDecorator INSTANCE = new PetrifiedTreeGravelDecorator();
public final BlockStateProvider provider;

public PetrifiedTreeGravelDecorator() {
super(new WeightedStateProvider(SimpleWeightedRandomList.<BlockState>builder()
.add(Blocks.GRAVEL.defaultBlockState(), 5)
.add(Blocks.SUSPICIOUS_GRAVEL.defaultBlockState(), 3))
);
this.provider = new WeightedStateProvider(SimpleWeightedRandomList.<BlockState>builder()
.add(Blocks.GRAVEL.defaultBlockState(), 75)
.add(Blocks.SUSPICIOUS_GRAVEL.defaultBlockState(), 25));
}

@Override
protected TreeDecoratorType<?> type() {
return SMTreeDecoratorTypes.GRAVEL_DECORATOR.get();
}

@Override
Expand All @@ -45,19 +57,18 @@ public void place(TreeDecorator.Context pContext) {
int i = list.get(0).getY();
list.stream().filter((p_69310_) -> p_69310_.getY() == i).forEach((p_225978_) -> {
this.placeCircle(pContext, p_225978_.west().north());
this.placeCircle(pContext, p_225978_.east(2).north());
this.placeCircle(pContext, p_225978_.west().south(2));
this.placeCircle(pContext, p_225978_.east(2).south(2));
this.placeCircle(pContext, p_225978_.east(1).north());
this.placeCircle(pContext, p_225978_.west().south(1));
this.placeCircle(pContext, p_225978_.east(1).south(1));

for(int j = 0; j < 5; ++j) {
for(int j = 0; j < 1; ++j) {
int k = pContext.random().nextInt(64);
int l = k % 8;
int i1 = k / 8;
if (l == 0 || l == 7 || i1 == 0 || i1 == 7) {
this.placeCircle(pContext, p_225978_.offset(-3 + l, 0, -3 + i1));
}
}

});
}
}
Expand All @@ -79,13 +90,11 @@ private void placeBlockAt(TreeDecorator.Context pContext, BlockPos pPos) {
if (Feature.isGrassOrDirt(pContext.level(), blockpos)) {
BlockState state = this.provider.getState(pContext.random(), pPos);
pContext.level().getBlockEntity(pPos, BlockEntityType.BRUSHABLE_BLOCK).ifPresent(brushableBlockEntity -> {
brushableBlockEntity.setLootTable(BuiltInLootTables.END_CITY_TREASURE, pPos.asLong());
brushableBlockEntity.setLootTable(SullysMod.modPrefix("archaeology/petrified_sapling_tree"), pPos.asLong());
});
pContext.setBlock(blockpos, ForgeEventFactory.alterGround(pContext.level(), pContext.random(), blockpos, state));

break;
}

if (!pContext.isAir(blockpos) && i < 0) {
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import static com.uraneptus.sullysmod.core.data.SMDatagenUtil.*;

//TODO add wood recipes
@SuppressWarnings("SameParameterValue")
public class SMRecipeProvider extends RecipeProvider {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.uraneptus.sullysmod.core.data.server.loot;

import com.uraneptus.sullysmod.SullysMod;
import com.uraneptus.sullysmod.core.registry.SMBlocks;
import net.minecraft.data.loot.LootTableSubProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.storage.loot.LootPool;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.entries.LootItem;
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;

import java.util.function.BiConsumer;

public class SMArchaeologyLoot implements LootTableSubProvider {

@Override
public void generate(BiConsumer<ResourceLocation, LootTable.Builder> pOutput) {
//TODO wait for sully to decide on loot
pOutput.accept(SullysMod.modPrefix("archaeology/petrified_sapling_tree"), LootTable.lootTable().withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1.0F)).add(LootItem.lootTableItem(SMBlocks.AMBER.get()))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public class SMLootTableProvider extends LootTableProvider {
public SMLootTableProvider(PackOutput packOutput) {
super(packOutput, Collections.emptySet(), List.of(
new LootTableProvider.SubProviderEntry(SMBlockLoot::new, LootContextParamSets.BLOCK),
new LootTableProvider.SubProviderEntry(SMEntityLoot::new, LootContextParamSets.ENTITY)
new LootTableProvider.SubProviderEntry(SMEntityLoot::new, LootContextParamSets.ENTITY),
new LootTableProvider.SubProviderEntry(SMArchaeologyLoot::new, LootContextParamSets.ARCHAEOLOGY)
));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.uraneptus.sullysmod.core.data.server.tags;

import com.uraneptus.sullysmod.SullysMod;
import com.uraneptus.sullysmod.core.registry.SMPaintingVariants;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.data.tags.PaintingVariantTagsProvider;
import net.minecraft.tags.PaintingVariantTags;
import net.minecraftforge.common.data.ExistingFileHelper;
import org.jetbrains.annotations.Nullable;

import java.util.concurrent.CompletableFuture;

public class SMPaintingVariantTagsProvider extends PaintingVariantTagsProvider {

public SMPaintingVariantTagsProvider(PackOutput pOutput, CompletableFuture<HolderLookup.Provider> pProvider, @Nullable ExistingFileHelper existingFileHelper) {
super(pOutput, pProvider, SullysMod.MOD_ID, existingFileHelper);
}

protected void addTags(HolderLookup.Provider pProvider) {
SMPaintingVariants.PAINTINGS.getEntries().forEach(painting -> tag(PaintingVariantTags.PLACEABLE).add(painting.getKey()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class SMPaintingVariants {
public static Map<String, String> PAINTING_TRANSLATIONS = new HashMap<>();

public static final RegistryObject<PaintingVariant> UNNERVING_NIGHT = registerPainting("unnerving_night", "RealSpidey", 16, 32);
public static final RegistryObject<PaintingVariant> AMBER = registerPainting("amber", "Graus", 16, 32);

public static RegistryObject<PaintingVariant> registerPainting(String name, String author, int width, int height) {
PAINTING_TRANSLATIONS.put(name, author);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.uraneptus.sullysmod.core.registry;

import com.uraneptus.sullysmod.SullysMod;
import com.uraneptus.sullysmod.common.levelgen.PetrifiedTreeGravelDecorator;
import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

public class SMTreeDecoratorTypes {
public static final DeferredRegister<TreeDecoratorType<?>> TREE_DECORATORS = DeferredRegister.create(ForgeRegistries.TREE_DECORATOR_TYPES, SullysMod.MOD_ID);

public static final RegistryObject<TreeDecoratorType<PetrifiedTreeGravelDecorator>> GRAVEL_DECORATOR = TREE_DECORATORS.register("petrified_gravel_decorator", () -> new TreeDecoratorType<>(PetrifiedTreeGravelDecorator.CODEC));
}
3 changes: 1 addition & 2 deletions src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ public net.minecraft.world.level.block.ButtonBlock m_51115_()I # getPressDuratio
public net.minecraft.world.damagesource.DamageSources m_269079_(Lnet/minecraft/resources/ResourceKey;)Lnet/minecraft/world/damagesource/DamageSource; # source # SOURCE FOR DAMAGESOURCE
public net.minecraft.world.damagesource.DamageSources m_268998_(Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/entity/Entity;)Lnet/minecraft/world/damagesource/DamageSource; # source
public net.minecraft.world.entity.projectile.AbstractArrow f_36703_ # inGround
public net.minecraft.world.entity.projectile.AbstractArrow f_36696_ # lastState
public net.minecraft.world.level.levelgen.feature.treedecorators.AlterGroundDecorator f_69303_ # provider
public net.minecraft.world.entity.projectile.AbstractArrow f_36696_ # lastState
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

0 comments on commit d487354

Please sign in to comment.