Skip to content

Commit

Permalink
Move Compostables and Fuels to Items where they Belong.
Browse files Browse the repository at this point in the history
- Fix Creative tab crash in latest release
* Resolves #99
  • Loading branch information
gniftygnome committed Jun 16, 2023
1 parent a917fa1 commit 4860c0a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@
import com.terraformersmc.traverse.feature.TraverseConfiguredFeatures;
import com.terraformersmc.traverse.init.helpers.TraverseRegistry;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.registry.CompostingChanceRegistry;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.fabricmc.fabric.api.registry.StrippableBlockRegistry;
import net.minecraft.block.*;
import net.minecraft.entity.EntityType;
import net.minecraft.item.Items;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
Expand Down Expand Up @@ -100,29 +97,10 @@ public static void register() {
POTTED_YELLOW_AUTUMNAL_SAPLING = TraverseRegistry.register("potted_yellow_autumnal_sapling", new FlowerPotBlock(YELLOW_AUTUMNAL_SAPLING, FabricBlockSettings.copyOf(Blocks.POTTED_OAK_SAPLING)));
POTTED_FIR_SAPLING = TraverseRegistry.register("potted_fir_sapling", new FlowerPotBlock(FIR_SAPLING, FabricBlockSettings.copyOf(Blocks.POTTED_OAK_SAPLING)));

addCompostables();
addFlammables();
addFuels();
addStrippables();
}

private static void addCompostables() {
CompostingChanceRegistry compostingRegistry = CompostingChanceRegistry.INSTANCE;
float LEAVES_CHANCE = compostingRegistry.get(Items.OAK_LEAVES);
float SAPLING_CHANCE = compostingRegistry.get(Items.OAK_SAPLING);

compostingRegistry.add(FIR_LEAVES, LEAVES_CHANCE);
compostingRegistry.add(FIR_SAPLING, SAPLING_CHANCE);
compostingRegistry.add(BROWN_AUTUMNAL_LEAVES, LEAVES_CHANCE);
compostingRegistry.add(BROWN_AUTUMNAL_SAPLING, SAPLING_CHANCE);
compostingRegistry.add(ORANGE_AUTUMNAL_LEAVES, LEAVES_CHANCE);
compostingRegistry.add(ORANGE_AUTUMNAL_SAPLING, SAPLING_CHANCE);
compostingRegistry.add(RED_AUTUMNAL_LEAVES, LEAVES_CHANCE);
compostingRegistry.add(RED_AUTUMNAL_SAPLING, SAPLING_CHANCE);
compostingRegistry.add(YELLOW_AUTUMNAL_LEAVES, LEAVES_CHANCE);
compostingRegistry.add(YELLOW_AUTUMNAL_SAPLING, SAPLING_CHANCE);
}

private static void addFlammables() {
FlammableBlockRegistry flammableRegistry = FlammableBlockRegistry.getDefaultInstance();

Expand All @@ -142,13 +120,6 @@ private static void addFlammables() {
flammableRegistry.add(YELLOW_AUTUMNAL_LEAVES, 30, 60);
}

private static void addFuels() {
FuelRegistry fuelRegistry = FuelRegistry.INSTANCE;

fuelRegistry.add(FIR_FENCE, 300);
fuelRegistry.add(FIR_FENCE_GATE, 300);
}

private static void addStrippables() {
StrippableBlockRegistry.register(FIR_LOG, STRIPPED_FIR_LOG);
StrippableBlockRegistry.register(FIR_WOOD, STRIPPED_FIR_WOOD);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public class TraverseItemGroups {
// Target the end of the Item Group
content.addAll(entries.getCollection());
} else {
//Traverse.LOGGER.warn("About to add to Vanilla Item Group '{}' after Item '{}': '{}'", group.getId(), relative, entries.getCollection().stream().map(ItemStack::getItem).collect(Collectors.toList()));
//Traverse.LOGGER.warn("About to add to Vanilla Item Group '{}' after Item '{}': '{}'", group.getValue(), relative, entries.getCollection().stream().map(ItemStack::getItem).collect(Collectors.toList()));
content.addAfter(relative, entries.getCollection());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import com.terraformersmc.traverse.block.TraverseBlocks;
import com.terraformersmc.traverse.init.helpers.TraverseRegistry;
import net.fabricmc.fabric.api.registry.CompostingChanceRegistry;
import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.minecraft.item.HangingSignItem;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.item.SignItem;

public class TraverseItems {
Expand Down Expand Up @@ -65,5 +68,32 @@ public static void register() {

FIR_SIGN = TraverseRegistry.register("fir_sign", new SignItem(new Item.Settings().maxCount(16), TraverseBlocks.FIR_SIGN, TraverseBlocks.FIR_WALL_SIGN));
FIR_HANGING_SIGN = TraverseRegistry.register("fir_hanging_sign", new HangingSignItem(TraverseBlocks.FIR_HANGING_SIGN, TraverseBlocks.FIR_WALL_HANGING_SIGN, new Item.Settings().maxCount(16)));

addCompostables();
addFuels();
}

private static void addCompostables() {
CompostingChanceRegistry compostingRegistry = CompostingChanceRegistry.INSTANCE;
float LEAVES_CHANCE = compostingRegistry.get(Items.OAK_LEAVES);
float SAPLING_CHANCE = compostingRegistry.get(Items.OAK_SAPLING);

compostingRegistry.add(FIR_LEAVES, LEAVES_CHANCE);
compostingRegistry.add(FIR_SAPLING, SAPLING_CHANCE);
compostingRegistry.add(BROWN_AUTUMNAL_LEAVES, LEAVES_CHANCE);
compostingRegistry.add(BROWN_AUTUMNAL_SAPLING, SAPLING_CHANCE);
compostingRegistry.add(ORANGE_AUTUMNAL_LEAVES, LEAVES_CHANCE);
compostingRegistry.add(ORANGE_AUTUMNAL_SAPLING, SAPLING_CHANCE);
compostingRegistry.add(RED_AUTUMNAL_LEAVES, LEAVES_CHANCE);
compostingRegistry.add(RED_AUTUMNAL_SAPLING, SAPLING_CHANCE);
compostingRegistry.add(YELLOW_AUTUMNAL_LEAVES, LEAVES_CHANCE);
compostingRegistry.add(YELLOW_AUTUMNAL_SAPLING, SAPLING_CHANCE);
}

private static void addFuels() {
FuelRegistry fuelRegistry = FuelRegistry.INSTANCE;

fuelRegistry.add(FIR_FENCE, 300);
fuelRegistry.add(FIR_FENCE_GATE, 300);
}
}

0 comments on commit 4860c0a

Please sign in to comment.