Skip to content

Commit

Permalink
Made the block data exporter class more generic.
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSVK12 committed Nov 6, 2023
1 parent e791b1b commit 3fa2e6a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ public SignalIndustries(){
EntityHelper.createEntity(EntityInfernal.class,new MobRenderer<EntityInfernal>(new ModelZombie(), 0.5F),config.getInt("EntityIDs.infernalId"),"Infernal");
//crafting recipes in RecipeHandlerCraftingSI

BlockDataExporter.export();
BlockDataExporter.export(SignalIndustries.class);
}

public static <K,V> Map<K,V> mapOf(K[] keys, V[] values){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import net.minecraft.core.block.Block;
import net.minecraft.core.block.BlockTileEntity;
import net.minecraft.core.util.helper.Side;
import sunsetsatellite.signalindustries.SignalIndustries;
import turniplabs.halplibe.helper.TextureHelper;

import java.io.DataOutputStream;
Expand All @@ -19,8 +18,8 @@
import java.util.Map;

public class BlockDataExporter {
public static void export() {
List<Field> fields = new ArrayList<>(Arrays.asList(SignalIndustries.class.getDeclaredFields()));
public static void export(Class<?> clazz) {
List<Field> fields = new ArrayList<>(Arrays.asList(clazz.getDeclaredFields()));
fields.removeIf((F)->F.getType() != Block.class);
CompoundTag data = new CompoundTag();
for (Field field : fields) {
Expand All @@ -32,7 +31,7 @@ public static void export() {
}
CompoundTag tag = new CompoundTag();
tag.putString("name",field.getName());
tag.putString("mod",SignalIndustries.class.getName());
tag.putString("mod", clazz.getName());
CompoundTag uv = new CompoundTag();
for (Side side : Side.values()) {
if(side == Side.NONE) continue;
Expand All @@ -59,7 +58,6 @@ public static void export() {
try {
try (DataOutputStream output = new DataOutputStream(Files.newOutputStream(file.toPath()))) {
NbtIo.write(data, output);
SignalIndustries.LOGGER.info("exported block data");
}
} catch (Exception e){
throw new RuntimeException(e);
Expand Down

0 comments on commit 3fa2e6a

Please sign in to comment.