Skip to content

Commit

Permalink
feat: Wood set completed? I think?
Browse files Browse the repository at this point in the history
  • Loading branch information
Zepalesque committed May 25, 2024
1 parent e9bb0b3 commit fe440b0
Show file tree
Hide file tree
Showing 26 changed files with 883 additions and 45 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ aether_version=1.20.4-1.4.1-neoforge
nitrogen_version=1.20.4-1.1.4-neoforge
cumulus_version=1.20.4-1.0.1-neoforge
curios_version=7.3.4
zenith_version=1.20.4-1.0.11-neoforge
zenith_version=1.20.4-1.0.12-neoforge
aeroblender_version=5271794
terrablender_version=1.20.4-3.3.0.12
terrablender_version_minimum=1.20.4-3.3.0.0
Expand Down
33 changes: 29 additions & 4 deletions src/main/java/net/zepalesque/redux/Redux.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package net.zepalesque.redux;

import com.aetherteam.aether.data.generators.AetherBlockStateData;
import com.aetherteam.aether.data.generators.AetherItemModelData;
import com.aetherteam.aether.data.generators.AetherLanguageData;
import com.aetherteam.aether.data.generators.AetherRecipeData;
import com.mojang.logging.LogUtils;
import net.minecraft.DetectedVersion;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.PackOutput;
import net.minecraft.data.metadata.PackMetadataGenerator;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.metadata.pack.PackMetadataSection;
import net.minecraft.util.InclusiveRange;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.common.Mod;
Expand All @@ -17,29 +19,41 @@
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import net.neoforged.neoforge.data.event.GatherDataEvent;
import net.zepalesque.redux.block.ReduxBlocks;
import net.zepalesque.redux.blockset.ReduxWoodSets;
import net.zepalesque.redux.config.ReduxConfig;
import net.zepalesque.redux.data.gen.ReduxBlockStateGen;
import net.zepalesque.redux.data.gen.ReduxItemModelGen;
import net.zepalesque.redux.data.gen.ReduxLanguageGen;
import net.zepalesque.redux.data.gen.ReduxLootGen;
import net.zepalesque.redux.data.gen.ReduxRecipeGen;
import net.zepalesque.redux.data.gen.tags.ReduxBlockTagsGen;
import net.zepalesque.redux.data.gen.tags.ReduxItemTagsGen;
import net.zepalesque.redux.entity.ReduxEntities;
import net.zepalesque.redux.item.ReduxItems;
import net.zepalesque.redux.tile.ReduxTiles;
import net.zepalesque.zenith.api.blockset.AbstractWoodSet;
import net.zepalesque.zenith.api.condition.ConfigCondition;
import net.zepalesque.zenith.api.condition.config.ConfigSerializer;
import org.slf4j.Logger;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;

@Mod(Redux.MODID)
public class Redux {
public static final String MODID = "aether_redux";
private static final Logger LOGGER = LogUtils.getLogger();

public static final Collection<AbstractWoodSet> WOOD_SETS = new ArrayList<>();

public Redux(IEventBus bus) {
bus.addListener(this::commonSetup);
bus.addListener(this::dataSetup);

ReduxWoodSets.init();

ReduxBlocks.BLOCKS.register(bus);
ReduxItems.ITEMS.register(bus);
ReduxEntities.ENTITIES.register(bus);
Expand All @@ -66,7 +80,18 @@ private void dataSetup(GatherDataEvent event) {

// Server Data
generator.addProvider(event.includeServer(), new ReduxRecipeGen(packOutput, lookupProvider));
generator.addProvider(event.includeServer(), ReduxLootGen.create(packOutput));

// Tags
ReduxBlockTagsGen blockTags = new ReduxBlockTagsGen(packOutput, lookupProvider, fileHelper);
generator.addProvider(event.includeServer(), blockTags);
generator.addProvider(event.includeServer(), new ReduxItemTagsGen(packOutput, lookupProvider, blockTags.contentsGetter(), fileHelper));

// pack.mcmeta
generator.addProvider(true, new PackMetadataGenerator(packOutput).add(PackMetadataSection.TYPE, new PackMetadataSection(
Component.translatable("pack.aether_redux.mod.description"),
DetectedVersion.BUILT_IN.getPackVersion(PackType.SERVER_DATA),
Optional.of(new InclusiveRange<>(0, Integer.MAX_VALUE)))));
}

public static ResourceLocation loc(String path) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package net.zepalesque.redux.block.natural;

import com.aetherteam.aether.block.AetherBlockStateProperties;
import com.google.common.collect.ImmutableMap;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.WallBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.zepalesque.redux.mixin.mixins.common.accessor.WallBlockAccessor;

import java.util.Map;

// TODO: Replace with Nitrogen version
public class ReduxDoubleDropsWall extends WallBlock {
public ReduxDoubleDropsWall(Properties properties) {
super(properties);
this.registerDefaultState(this.defaultBlockState().setValue(AetherBlockStateProperties.DOUBLE_DROPS, false));
this.fixShapeMaps();
}

@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
super.createBlockStateDefinition(builder);
builder.add(AetherBlockStateProperties.DOUBLE_DROPS);
}

/**
* Based on the Framed Blocks mod's shape map fix for implementing a wall with additional block properties.
*/
protected void fixShapeMaps() {
WallBlockAccessor wallBlockAccessor = (WallBlockAccessor) this;
Map<BlockState, VoxelShape> shapeByIndex = wallBlockAccessor.redux$getShapeByIndex();
shapeByIndex = fixShapeMap(shapeByIndex).build();
wallBlockAccessor.redux$setShapeByIndex(shapeByIndex);

Map<BlockState, VoxelShape> collisionShapeByIndex = wallBlockAccessor.redux$getCollisionShapeByIndex();
collisionShapeByIndex = fixShapeMap(collisionShapeByIndex).build();
wallBlockAccessor.redux$setCollisionShapeByIndex(collisionShapeByIndex);
}

protected ImmutableMap.Builder<BlockState, VoxelShape> fixShapeMap(Map<BlockState, VoxelShape> map) {
ImmutableMap.Builder<BlockState, VoxelShape> builder = ImmutableMap.builder();
builder.putAll(map);
for (BlockState state : map.keySet()) {
builder.put(state.cycle(AetherBlockStateProperties.DOUBLE_DROPS), map.get(state));
}
return builder;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package net.zepalesque.redux.block.natural;

import com.google.common.collect.ImmutableMap;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.zepalesque.redux.block.state.ReduxStates;

import java.util.Map;

public class ReduxNaturalWall extends ReduxDoubleDropsWall {
public ReduxNaturalWall(Properties properties) {
super(properties);
this.registerDefaultState(this.defaultBlockState().setValue(ReduxStates.NATURAL_GEN, false));
this.fixShapeMaps();
}

@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
super.createBlockStateDefinition(builder);
builder.add(ReduxStates.NATURAL_GEN);
}

@Override
protected ImmutableMap.Builder<BlockState, VoxelShape> fixShapeMap(Map<BlockState, VoxelShape> map) {
ImmutableMap.Builder<BlockState, VoxelShape> builder = super.fixShapeMap(map);
for (BlockState state : map.keySet()) {
builder.put(state.cycle(ReduxStates.NATURAL_GEN), map.get(state));
}
return builder;
}
}
219 changes: 219 additions & 0 deletions src/main/java/net/zepalesque/redux/blockset/AetherWoodSet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
package net.zepalesque.redux.blockset;

import com.aetherteam.aether.mixin.mixins.common.accessor.FireBlockAccessor;
import net.minecraft.data.recipes.RecipeCategory;
import net.minecraft.data.recipes.RecipeOutput;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour.Properties;
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
import net.minecraft.world.level.material.MapColor;
import net.neoforged.neoforge.client.model.generators.ModelBuilder;
import net.neoforged.neoforge.client.model.generators.ModelFile;
import net.neoforged.neoforge.registries.DeferredBlock;
import net.neoforged.neoforge.registries.DeferredRegister;
import net.zepalesque.redux.Redux;
import net.zepalesque.redux.block.ReduxBlocks;
import net.zepalesque.redux.block.natural.ReduxNaturalWall;
import net.zepalesque.redux.data.prov.ReduxBlockStateProvider;
import net.zepalesque.redux.data.prov.ReduxItemModelProvider;
import net.zepalesque.redux.data.prov.ReduxLanguageProvider;
import net.zepalesque.redux.data.prov.ReduxRecipeProvider;
import net.zepalesque.redux.data.prov.loot.ReduxBlockLootProvider;
import net.zepalesque.redux.data.prov.tags.ReduxBlockTagsProvider;
import net.zepalesque.redux.item.ReduxItems;
import net.zepalesque.zenith.util.DatagenUtil;

public class AetherWoodSet extends BaseWoodSet {

protected final DeferredBlock<ReduxNaturalWall> log_wall;
protected final DeferredBlock<ReduxNaturalWall> wood_wall;
protected final DeferredBlock<ReduxNaturalWall> stripped_log_wall;
protected final DeferredBlock<ReduxNaturalWall> stripped_wood_wall;

public AetherWoodSet(String id, MapColor woodColor, MapColor barkColor, SoundType sound) {
super(id, woodColor, barkColor, sound);
DeferredRegister.Blocks blocks = ReduxBlocks.BLOCKS;
DeferredRegister.Items items = ReduxItems.ITEMS;

this.log_wall = this.logWall(blocks, items, id, woodColor, sound);
this.wood_wall = this.woodWall(blocks, items, id, woodColor, sound);
this.stripped_log_wall = this.strippedLogWall(blocks, items, id, woodColor, sound);
this.stripped_wood_wall = this.strippedWoodWall(blocks, items, id, woodColor, sound);
}

protected DeferredBlock<ReduxNaturalWall> logWall(DeferredRegister.Blocks registry, DeferredRegister.Items items, String id, MapColor color, SoundType soundType) {
var block = registry.register(id + this.logSuffix(LangType.ID) + "_wall", () -> new ReduxNaturalWall(Properties.of()
.mapColor(MapColor.WOOD)
.instrument(NoteBlockInstrument.BASS)
.ignitedByLava()
.strength(2.0F)
.sound(SoundType.WOOD)
));
items.register(block.getId().getPath(), () -> new BlockItem(block.get(), new Item.Properties()));
return block;
}

public DeferredBlock<ReduxNaturalWall> logWall() {
return this.log_wall;
}

protected DeferredBlock<ReduxNaturalWall> woodWall(DeferredRegister.Blocks registry, DeferredRegister.Items items, String id, MapColor color, SoundType soundType) {
var block = registry.register(id + this.woodSuffix(LangType.ID) + "_wall", () -> new ReduxNaturalWall(Properties.of()
.mapColor(MapColor.WOOD)
.instrument(NoteBlockInstrument.BASS)
.ignitedByLava()
.strength(2.0F)
.sound(SoundType.WOOD)
));
items.register(block.getId().getPath(), () -> new BlockItem(block.get(), new Item.Properties()));
return block;
}

public DeferredBlock<ReduxNaturalWall> woodWall() {
return this.wood_wall;
}

protected DeferredBlock<ReduxNaturalWall> strippedLogWall(DeferredRegister.Blocks registry, DeferredRegister.Items items, String id, MapColor color, SoundType soundType) {
var block = registry.register(id + this.logSuffix(LangType.ID) + "_wall", () -> new ReduxNaturalWall(Properties.of()
.mapColor(MapColor.WOOD)
.instrument(NoteBlockInstrument.BASS)
.ignitedByLava()
.strength(2.0F)
.sound(SoundType.WOOD)
));
items.register(block.getId().getPath(), () -> new BlockItem(block.get(), new Item.Properties()));
return block;
}

public DeferredBlock<ReduxNaturalWall> strippedLogWall() {
return this.stripped_log_wall;
}

protected DeferredBlock<ReduxNaturalWall> strippedWoodWall(DeferredRegister.Blocks registry, DeferredRegister.Items items, String id, MapColor color, SoundType soundType) {
var block = registry.register(id + this.logSuffix(LangType.ID) + "_wall", () -> new ReduxNaturalWall(Properties.of()
.mapColor(MapColor.WOOD)
.instrument(NoteBlockInstrument.BASS)
.ignitedByLava()
.strength(2.0F)
.sound(SoundType.WOOD)
));
items.register(block.getId().getPath(), () -> new BlockItem(block.get(), new Item.Properties()));
return block;
}

public DeferredBlock<ReduxNaturalWall> strippedWoodWall() {
return this.stripped_wood_wall;
}


@Override
protected void blockData(ReduxBlockStateProvider data) {
super.blockData(data);
ModelFile postBig = data.makeWallPostModel(4, 16, "wooden_post_big");
ModelFile postShort = data.makeWallPostModel(3, 14, "wooden_post_short");
ModelFile postTall = data.makeWallPostModel(3, 16, "wooden_post_tall");
ModelFile side = data.makeWallSideModel(5, 14, "wooden_side", ModelBuilder.FaceRotation.CLOCKWISE_90, 0, 5);
ModelFile sideAlt = data.makeWallSideModel(5, 14, "wooden_side_alt", ModelBuilder.FaceRotation.COUNTERCLOCKWISE_90, 11, 16);
ModelFile sideTall = data.makeWallSideModel(5, 16, "wooden_side_tall", ModelBuilder.FaceRotation.CLOCKWISE_90, 0, 5);
ModelFile sideTallAlt = data.makeWallSideModel(5, 16, "wooden_side_tall_alt", ModelBuilder.FaceRotation.COUNTERCLOCKWISE_90, 11, 16);
ModelFile sideShort = data.makeWallSideModel(4, 14, "wooden_side_short", ModelBuilder.FaceRotation.CLOCKWISE_90, 0, 4);
ModelFile sideAltShort = data.makeWallSideModel(4, 14, "wooden_side_alt_short", ModelBuilder.FaceRotation.COUNTERCLOCKWISE_90, 12, 16);
ModelFile sideTallShort = data.makeWallSideModel(4, 16, "wooden_side_tall_short", ModelBuilder.FaceRotation.CLOCKWISE_90, 0, 4);
ModelFile sideTallAltShort = data.makeWallSideModel(4, 16, "wooden_side_tall_alt_short", ModelBuilder.FaceRotation.COUNTERCLOCKWISE_90, 12, 16);

data.logWallBlock(this.logWall().get(), this.log().get(), "natural/",
Redux.MODID, true, postBig, postShort, postTall, side, sideAlt, sideTall, sideTallAlt, sideShort, sideAltShort, sideTallShort, sideTallAltShort);

data.logWallBlock(this.strippedLogWall().get(), this.strippedLog().get(), "natural/",
Redux.MODID, true, postBig, postShort, postTall, side, sideAlt, sideTall, sideTallAlt, sideShort, sideAltShort, sideTallShort, sideTallAltShort);

data.logWallBlock(this.woodWall().get(), this.log().get(), "natural/",
Redux.MODID, false, postBig, postShort, postTall, side, sideAlt, sideTall, sideTallAlt, sideShort, sideAltShort, sideTallShort, sideTallAltShort);

data.logWallBlock(this.strippedWoodWall().get(), this.strippedLog().get(), "natural/",
Redux.MODID, false, postBig, postShort, postTall, side, sideAlt, sideTall, sideTallAlt, sideShort, sideAltShort, sideTallShort, sideTallAltShort);

}

@Override
protected void itemData(ReduxItemModelProvider data) {
super.itemData(data);
data.itemLogWallBlock(this.logWall().get(), this.log().get(), "natural/", Redux.MODID);
data.itemLogWallBlock(this.strippedLogWall().get(), this.strippedLog().get(), "natural/", Redux.MODID);
data.itemWoodWallBlock(this.woodWall().get(), this.log().get(), "natural/", Redux.MODID);
data.itemWoodWallBlock(this.strippedWoodWall().get(), this.strippedLog().get(), "natural/", Redux.MODID);
}

@Override
protected void langData(ReduxLanguageProvider data) {
super.langData(data);
String name = DatagenUtil.getNameLocalized(this.id);

data.add(this.logWall());
data.addLore(this.logWall(), "Crafted from " + name + " " + this.logSuffix(LangType.LANG_PLURAL) + ". Can be used for decorative enclosures and defences. Great for keeping nasty intruders away!");

data.add(this.strippedLogWall());
data.addLore(this.strippedLogWall(), "Crafted from Stripped " + name + " " + this.logSuffix(LangType.LANG_PLURAL) + ". Can be used for decorative enclosures and defences. Great for keeping nasty intruders away!");

data.add(this.woodWall());
data.addLore(this.woodWall(), "Crafted from " + name + " " + this.woodSuffix(LangType.LANG_PLURAL) + ". Can be used for decorative enclosures and defences. Great for keeping nasty intruders away!");

data.add(this.strippedWoodWall());
data.addLore(this.strippedWoodWall(), "Crafted from Stripped " + name + " " + this.woodSuffix(LangType.LANG_PLURAL) + ". Can be used for decorative enclosures and defences. Great for keeping nasty intruders away!");
}

@Override
protected void recipeData(ReduxRecipeProvider data, RecipeOutput consumer) {
super.recipeData(data, consumer);
ReduxRecipeProvider.wall(consumer, RecipeCategory.BUILDING_BLOCKS, this.logWall().get(), this.log().get());
ReduxRecipeProvider.wall(consumer, RecipeCategory.BUILDING_BLOCKS, this.strippedLogWall().get(), this.strippedLog().get());
ReduxRecipeProvider.wall(consumer, RecipeCategory.BUILDING_BLOCKS, this.woodWall().get(), this.wood().get());
ReduxRecipeProvider.wall(consumer, RecipeCategory.BUILDING_BLOCKS, this.strippedWoodWall().get(), this.strippedWood().get());
}

@Override
protected void blockTagData(ReduxBlockTagsProvider data) {
super.blockTagData(data);
data.tag(BlockTags.MINEABLE_WITH_AXE).add(
this.logWall().get(),
this.strippedLogWall().get(),
this.woodWall().get(),
this.strippedWoodWall().get()
);
data.tag(BlockTags.LOGS).add(
this.logWall().get(),
this.strippedLogWall().get(),
this.woodWall().get(),
this.strippedWoodWall().get()
);
data.tag(BlockTags.WALLS).add(
this.logWall().get(),
this.strippedLogWall().get(),
this.woodWall().get(),
this.strippedWoodWall().get()
);
}

@Override
protected void lootData(ReduxBlockLootProvider data) {
super.lootData(data);
data.naturalDrop(this.logWall().get(), this.log().get());
data.naturalDrop(this.woodWall().get(), this.log().get());
data.naturalDrop(this.strippedLogWall().get(), this.strippedLog().get());
data.naturalDrop(this.strippedWoodWall().get(), this.strippedLog().get());
}

@Override
public void flammables() {
super.flammables();
FireBlockAccessor accessor = (FireBlockAccessor) Blocks.FIRE;
accessor.callSetFlammable(this.logWall().get(), 5, 5);
accessor.callSetFlammable(this.woodWall().get(), 5, 5);
accessor.callSetFlammable(this.strippedLogWall().get(), 5, 5);
accessor.callSetFlammable(this.strippedWoodWall().get(), 5, 5);
}
}
Loading

0 comments on commit fe440b0

Please sign in to comment.