Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Generation #419

Open
wants to merge 23 commits into
base: 1.18
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
cdd70b9
Data Generation!
caelwarner Feb 20, 2023
39e44c0
Added documentation
caelwarner Feb 20, 2023
b0e05ff
Added data gen for layered blocks like Shimmer sheets
caelwarner Feb 21, 2023
746c840
Added data gen for paths, panes, carpets, torches, lanterns, campfire…
caelwarner Feb 21, 2023
91d9a69
Added data gen for luminous fungus, shroomlight tears, planted quartz…
caelwarner Feb 22, 2023
344ca9f
Added data gen for item models
caelwarner Feb 22, 2023
b860be4
Moved one-off block providers from IEBlocks to IEBlockProviders
caelwarner Feb 22, 2023
cbd013d
Added data gen for glowsilk bow and whips
caelwarner Feb 23, 2023
84dbb0f
Added data gen for tags
caelwarner Feb 28, 2023
a16f91f
Updated copyright notice
caelwarner Feb 28, 2023
f60ec41
Refactored IETagProviders
caelwarner Mar 1, 2023
d2d57f0
Added datagen for recipes
caelwarner Mar 2, 2023
b029bdf
Added datagen for stonecutting recipes
caelwarner Mar 2, 2023
bd7d414
Added datagen for custom recipe types
caelwarner Mar 3, 2023
d9fc5af
Moved recipes over to main resources folder
caelwarner Mar 3, 2023
80ccae1
Added data gen for all tag overrides
caelwarner Mar 3, 2023
18d6ddd
Added data gen for lang files
caelwarner Mar 6, 2023
11c286a
Don't add lang entries for untranslated entries to lang JSON files
caelwarner Mar 8, 2023
fbaa8a2
Added datagen for all block loot tables
caelwarner Jul 16, 2023
98501af
Added datagen for entity loot tables
caelwarner Jul 16, 2023
ae7918c
Added datagen for chest loot tables
caelwarner Jul 17, 2023
cb59d1d
Replaced loot tables JSON files with generated JSON files
caelwarner Jul 17, 2023
5e32f10
Removed DataProviderCollection
caelwarner Jul 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 16 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ minecraft {
workingDirectory project.file('run')
property 'forge.logging.markers', 'SCAN,REGISTRIES'
property 'forge.logging.console.level', 'debug'
args '--mod', 'infernalexp', '--all', '--output', file('src/generated/resources/')
property 'file.encoding', 'UTF-8'
args '--mod', 'infernalexp', '--all', '--output', file('src/generated/resources/'), '--existing', sourceSets.main.resources.srcDirs[0]
mods {
infernalexp {
source sourceSets.main
Expand All @@ -86,6 +87,12 @@ mixin {

repositories {
maven { url = 'https://repo.spongepowered.org/maven/' }
maven {
url "https://cursemaven.com"
content {
includeGroup "curse.maven"
}
}

jcenter()
mavenCentral()
Expand All @@ -94,6 +101,14 @@ repositories {
dependencies {
minecraft "net.minecraftforge:forge:${config.MINECRAFT_VERSION}-${config.FORGE_VERSION}"
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'

// implementation fg.deobf("curse.maven:jei-238222:4352925")
// implementation fg.deobf("curse.maven:quark-243121:3840125")
// implementation fg.deobf("curse.maven:autoreglib-250363:3642382")
// implementation fg.deobf("curse.maven:create-328085:4371807")
// implementation fg.deobf("curse.maven:flywheel-486392:4341461")
// implementation fg.deobf("curse.maven:farmersdelight-398521:3999153")
// implementation fg.deobf("curse.maven:miningmaster-534956:4041438")
}

jar {
Expand Down
378 changes: 378 additions & 0 deletions scripts/lang/base.json

Large diffs are not rendered by default.

84 changes: 84 additions & 0 deletions scripts/lang/convert_lang.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Copyright 2023 Infernal Studios
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#
# This script is a bit of a cobbled together mess.
# It converts JSON lang files into the Java code that is then used to generate the JSON lang files.
# A bit ironic, isn't it?
#

import json

with open("base.json", "r", encoding="utf-8") as f:
base = json.load(f)

with open("zh_tw.json", "r", encoding="utf-8") as f:
lang = json.load(f)

f = open("output.txt", "w", encoding="utf-8")

for key in lang:
if lang[key] == base[key]:
lang[key] = "null"
else:
lang[key] = f"\"{lang[key]}\""

for key in lang:
if key.endswith(".desc") or key.endswith(".hurt") or key.endswith(".death"):
continue

if "potion" in key or "tipped" in key:
continue

if key.startswith("itemGroup."):
f.write(f"add(InfernalExpansion.TAB, {lang[key]});\n")
continue

name = key.split(".")[2]

if key.startswith("block."):
f.write(f"add(IEBlocks.{name.upper()}.get(), {lang[key]});\n")

elif "music_disc" in key:
f.write(f"addMusicDisc(IEItems.{name.upper()}.get(), {lang[key]}, {lang[key + '.desc']});\n")

elif key.startswith("item."):
f.write(f"add(IEItems.{name.upper()}.get(), {lang[key]});\n")

elif key.startswith("entity."):
f.write(f"add(IEEntityTypes.{name.upper()}.get(), {lang[key]});\n")

elif key.startswith("subtitles."):
if key.endswith(".ambient"):
key = key.replace(".ambient", "")
f.write(f"addEntitySubtitles(IEEntityTypes.{name.upper()}.get(), {lang.get(key + '.ambient', 'null')}, {lang.get(key + '.hurt', 'null')}, {lang.get(key + '.death', 'null')});\n")
else:
f.write(f"add(\"subtitles.entity.\" + ForgeRegistries.ENTITIES.getKey(IEEntityTypes.{name.upper()}.get()).getPath() + \".{key.split('.')[-1]}\", {lang[key]});\n")

elif key.startswith("biome."):
f.write(f"add(IEBiomes.{name.upper()}, {lang[key]});\n")

elif key.startswith("effect."):
f.write(f"addEffect(IEEffects.{name.upper()}.get(), {lang[key]});\n")

elif key.startswith("generator."):
f.write(f"add(\"generator.\" + InfernalExpansion.MOD_ID + \".{name}\", {lang[key]});\n")

elif "config" in key:
f.write(f"addConfig(\"{key.split('.', 2)[-1]}\", {lang[key]});\n")

elif "commands" in key:
f.write(f"add(InfernalExpansion.MOD_ID + \".{key.split('.', 1)[1]}\", {lang[key]});\n")

f.close()
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import net.minecraft.world.level.levelgen.carver.WorldCarver;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.crafting.CraftingHelper;
import net.minecraftforge.event.server.ServerStartingEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
Expand Down Expand Up @@ -74,7 +73,6 @@
import org.infernalstudios.infernalexp.init.IESurfaceRules;
import org.infernalstudios.infernalexp.mixin.common.WorldCarverAccessor;
import org.infernalstudios.infernalexp.network.IENetworkHandler;
import org.infernalstudios.infernalexp.util.CompatibilityQuark;
import org.infernalstudios.infernalexp.world.gen.ModEntityPlacement;

import java.util.HashSet;
Expand Down Expand Up @@ -148,9 +146,6 @@ private void commonSetup(final FMLCommonSetupEvent event) {
((WorldCarverAccessor) WorldCarver.NETHER_CAVE).setReplaceableBlocks(newCarvableBlocks);
});

// Register for Quark Compatibility in recipe
CraftingHelper.register(new CompatibilityQuark.Serializer());

// Places entity spawn locations on the ground
ModEntityPlacement.spawnPlacement();

Expand Down Expand Up @@ -196,6 +191,6 @@ public ItemStack makeIcon() {
return new ItemStack(IEItems.TAB_ITEM.get());
}

};
}.setRecipeFolderName(InfernalExpansion.MOD_ID);

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.infernalstudios.infernalexp.init.IEBlockTags;
import org.infernalstudios.infernalexp.init.IEBlocks;
import org.infernalstudios.infernalexp.init.IETags;

import javax.annotation.CheckForNull;

Expand Down Expand Up @@ -72,7 +72,7 @@ public BlockState getPlaceableState(Level world, BlockPos pos, Direction placeSi

@Override
protected boolean isValidGround(BlockState state, BlockGetter worldIn, BlockPos pos) {
return state.is(IETags.Blocks.BURIED_BONE_BASE_BLOCKS);
return state.is(IEBlockTags.BURIED_BONE_BASE_BLOCKS);
}

public boolean canAttachToSurface(LevelReader reader, BlockPos pos, Direction direction) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.BushBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
Expand All @@ -43,10 +42,10 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.common.IForgeShearable;
import org.infernalstudios.infernalexp.entities.BlindsightEntity;
import org.infernalstudios.infernalexp.init.IEBlockTags;
import org.infernalstudios.infernalexp.init.IEBlocks;
import org.infernalstudios.infernalexp.init.IEEffects;
import org.infernalstudios.infernalexp.init.IEItems;
import org.infernalstudios.infernalexp.init.IETags;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand All @@ -57,7 +56,7 @@
public class DullthornsBlock extends BushBlock implements IForgeShearable {
public static final IntegerProperty AGE = BlockStateProperties.AGE_15;
public static final BooleanProperty TIP = BooleanProperty.create("tip");
protected static final VoxelShape SHAPE = Block.box(5.0D, 0.0D, 5.0D, 11.0D, 15.0D, 11.0D);
protected static final VoxelShape SHAPE = net.minecraft.world.level.block.Block.box(5.0D, 0.0D, 5.0D, 11.0D, 15.0D, 11.0D);

public DullthornsBlock(Properties properties) {
super(properties);
Expand All @@ -77,7 +76,7 @@ public List<ItemStack> onSheared(@Nullable Player player, @Nonnull ItemStack ite

@Override
protected boolean mayPlaceOn(BlockState state, BlockGetter worldIn, BlockPos pos) {
return state.is(IETags.Blocks.DULLTHORNS_GROUND);
return state.is(IEBlockTags.DULLTHORNS_GROUND);
}

@Override
Expand Down Expand Up @@ -169,13 +168,13 @@ public BlockState updateShape(BlockState stateIn, Direction facing, BlockState f
boolean aboveIsDullthorns = aboveBlockState.is(IEBlocks.DULLTHORNS.get());

if (!stateIn.canSurvive(worldIn, currentPos)) {
return Blocks.AIR.defaultBlockState();
return net.minecraft.world.level.block.Blocks.AIR.defaultBlockState();
}

if (!aboveIsDullthorns && !stateIn.getValue(TIP)) {
return !stateIn.canSurvive(worldIn, currentPos) ? Blocks.AIR.defaultBlockState() : stateIn.setValue(TIP, true);
return !stateIn.canSurvive(worldIn, currentPos) ? net.minecraft.world.level.block.Blocks.AIR.defaultBlockState() : stateIn.setValue(TIP, true);
} else if (aboveIsDullthorns && stateIn.getValue(TIP)) {
return !stateIn.canSurvive(worldIn, currentPos) ? Blocks.AIR.defaultBlockState() : stateIn.setValue(TIP, false);
return !stateIn.canSurvive(worldIn, currentPos) ? net.minecraft.world.level.block.Blocks.AIR.defaultBlockState() : stateIn.setValue(TIP, false);
} else {
return stateIn;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.BaseFireBlock;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import org.infernalstudios.infernalexp.config.InfernalExpansionConfig;
import org.infernalstudios.infernalexp.init.IEBlockTags;
import org.infernalstudios.infernalexp.init.IEEffects;
import org.infernalstudios.infernalexp.init.IETags;

public class GlowFireBlock extends BaseFireBlock {

Expand All @@ -38,15 +37,15 @@ public GlowFireBlock(Properties builder) {
}

public BlockState updateShape(BlockState stateIn, Direction facing, BlockState facingState, LevelAccessor worldIn, BlockPos currentPos, BlockPos facingPos) {
return this.canSurvive(stateIn, worldIn, currentPos) ? this.defaultBlockState() : Blocks.AIR.defaultBlockState();
return this.canSurvive(stateIn, worldIn, currentPos) ? this.defaultBlockState() : net.minecraft.world.level.block.Blocks.AIR.defaultBlockState();
}

public boolean canSurvive(BlockState state, LevelReader worldIn, BlockPos pos) {
return isGlowFireBase(worldIn.getBlockState(pos.below()));
}

public static boolean isGlowFireBase(BlockState block) {
return block.is(IETags.Blocks.GLOW_FIRE_BASE_BLOCKS);
return block.is(IEBlockTags.GLOW_FIRE_BASE_BLOCKS);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
import org.infernalstudios.infernalexp.blockentities.LuminousFungusBlockEntity;
import org.infernalstudios.infernalexp.config.InfernalExpansionConfig;
import org.infernalstudios.infernalexp.init.IEBlockEntityTypes;
import org.infernalstudios.infernalexp.init.IEBlockTags;
import org.infernalstudios.infernalexp.init.IEConfiguredFeatures;
import org.infernalstudios.infernalexp.init.IEEffects;
import org.infernalstudios.infernalexp.init.IETags;

import javax.annotation.Nullable;
import java.util.Random;
Expand All @@ -62,7 +62,7 @@ public LuminousFungusBlock(Properties properties) {

@Override
protected boolean isValidGround(BlockState state, BlockGetter worldIn, BlockPos pos) {
return state.is(IETags.Blocks.LUMINOUS_FUNGUS_BASE_BLOCKS);
return state.is(IEBlockTags.LUMINOUS_FUNGUS_BASE_BLOCKS);
}

public boolean canAttachToSurface(LevelReader reader, BlockPos pos, Direction direction) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import net.minecraft.world.level.block.state.properties.AttachFace;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.infernalstudios.infernalexp.init.IEBlockTags;
import org.infernalstudios.infernalexp.init.IEBlocks;
import org.infernalstudios.infernalexp.init.IETags;

import javax.annotation.CheckForNull;

Expand All @@ -49,7 +49,7 @@ public PlantedQuartzBlock(Properties builder) {

@Override
protected boolean isValidGround(BlockState state, BlockGetter worldIn, BlockPos pos) {
return state.is(IETags.Blocks.PLANTED_QUARTZ_BASE_BLOCKS);
return state.is(IEBlockTags.PLANTED_QUARTZ_BASE_BLOCKS);
}

@CheckForNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,27 @@ public static void init(Consumer<Runnable> enqueueWorkConsumer) {
}

private static void threadSafeInit() {
ItemProperties.register(IEItems.GLOWSILK_BOW.get(), new ResourceLocation("pull"), (itemStack, clientWorld, livingEntity, ticks) -> {
ItemProperties.register(IEItems.GLOWSILK_BOW.get(), new ResourceLocation(InfernalExpansion.MOD_ID, "pull"), (itemStack, clientWorld, livingEntity, ticks) -> {
if (livingEntity == null) {
return 0.0F;
} else {
return livingEntity.getUseItem() != itemStack ? 0.0F : (float) (itemStack.getUseDuration() - livingEntity.getUseItemRemainingTicks()) / 20.0F;
}
});
ItemProperties.register(IEItems.GLOWSILK_BOW.get(), new ResourceLocation(InfernalExpansion.MOD_ID, "pulling"), (itemStack, clientWorld, livingEntity, entityId) -> livingEntity != null && livingEntity.isUsingItem() && livingEntity.getUseItem() == itemStack ? 1.0F : 0.0F);

ItemProperties.register(IEItems.GLOWSILK_BOW.get(), new ResourceLocation("pulling"), (itemStack, clientWorld, livingEntity, entityId) -> livingEntity != null && livingEntity.isUsingItem() && livingEntity.getUseItem() == itemStack ? 1.0F : 0.0F);

ItemProperties.register(IEItems.BLINDSIGHT_TONGUE_WHIP.get(), new ResourceLocation("attack_frame"), (itemStack, clientWorld, livingEntity, entityId) ->
ItemProperties.register(IEItems.BLINDSIGHT_TONGUE_WHIP.get(), new ResourceLocation(InfernalExpansion.MOD_ID, "attack_frame"), (itemStack, clientWorld, livingEntity, entityId) ->
livingEntity == null || (livingEntity.getMainHandItem() != itemStack && livingEntity.getOffhandItem() != itemStack) ?
0 : (int) (((WhipItem) itemStack.getItem()).getTicksSinceAttack(itemStack) / 3.0F)
);
ItemProperties.register(IEItems.BLINDSIGHT_TONGUE_WHIP.get(), new ResourceLocation("attacking"), (itemStack, clientWorld, livingEntity, entityId) -> livingEntity != null && (((WhipItem) itemStack.getItem()).getAttacking(itemStack) || ((WhipItem) itemStack.getItem()).getCharging(itemStack)) && (livingEntity.getMainHandItem() == itemStack || livingEntity.getOffhandItem() == itemStack) ? 1.0F : 0.0F);
ItemProperties.register(IEItems.BLINDSIGHT_TONGUE_WHIP.get(), new ResourceLocation(InfernalExpansion.MOD_ID, "attacking"), (itemStack, clientWorld, livingEntity, entityId) -> livingEntity != null && (((WhipItem) itemStack.getItem()).getAttacking(itemStack) || ((WhipItem) itemStack.getItem()).getCharging(itemStack)) && (livingEntity.getMainHandItem() == itemStack || livingEntity.getOffhandItem() == itemStack) ? 1.0F : 0.0F);


ItemProperties.register(IEItems.KINETIC_TONGUE_WHIP.get(), new ResourceLocation("attack_frame"), (itemStack, clientWorld, livingEntity, entityId) ->
ItemProperties.register(IEItems.KINETIC_TONGUE_WHIP.get(), new ResourceLocation(InfernalExpansion.MOD_ID, "attack_frame"), (itemStack, clientWorld, livingEntity, entityId) ->
livingEntity == null || (livingEntity.getMainHandItem() != itemStack && livingEntity.getOffhandItem() != itemStack) ?
0 : (int) (((WhipItem) itemStack.getItem()).getTicksSinceAttack(itemStack) / 3.0F)
);
ItemProperties.register(IEItems.KINETIC_TONGUE_WHIP.get(), new ResourceLocation("attacking"), (itemStack, clientWorld, livingEntity, entityId) -> livingEntity != null && (((WhipItem) itemStack.getItem()).getAttacking(itemStack) || ((WhipItem) itemStack.getItem()).getCharging(itemStack)) && (livingEntity.getMainHandItem() == itemStack || livingEntity.getOffhandItem() == itemStack) ? 1.0F : 0.0F);
ItemProperties.register(IEItems.KINETIC_TONGUE_WHIP.get(), new ResourceLocation(InfernalExpansion.MOD_ID, "attacking"), (itemStack, clientWorld, livingEntity, entityId) -> livingEntity != null && (((WhipItem) itemStack.getItem()).getAttacking(itemStack) || ((WhipItem) itemStack.getItem()).getCharging(itemStack)) && (livingEntity.getMainHandItem() == itemStack || livingEntity.getOffhandItem() == itemStack) ? 1.0F : 0.0F);

InfernalExpansionClient.loadInfernalResources();
}
Expand Down
Loading