Skip to content

Commit

Permalink
Initial commit for 1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
TimLee9024 committed Jul 6, 2022
1 parent 89f6d61 commit 58172ca
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 124 deletions.
34 changes: 6 additions & 28 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
buildscript {
repositories {
// These repositories are only for Gradle plugins, put any other repositories in the repository block further below
maven { url = 'https://maven.minecraftforge.net' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
}
}
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
plugins {
id 'eclipse'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '5.1.+'
}
apply plugin: 'net.minecraftforge.gradle'


version = '1.18.2-Forge-1.0.0.2'
version = '1.19-Forge-1.0.0.0'
group = 'com.timlee9024.mcgltf.example' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'MCglTF-Example'

Expand All @@ -38,7 +26,7 @@ minecraft {
//
// Use non-default mappings at your own risk. They may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: 'official', version: '1.18.2'
mappings channel: 'official', version: '1.19'

// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.

Expand Down Expand Up @@ -77,7 +65,6 @@ minecraft {

property 'forge.logging.console.level', 'debug'

// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
property 'forge.enabledGameTestNamespaces', 'example_mcgltf_usage'

mods {
Expand All @@ -93,19 +80,10 @@ minecraft {
gameTestServer {
workingDirectory project.file('run')

// Recommended logging data for a userdev environment
// The markers can be added/remove as needed separated by commas.
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
property 'forge.logging.markers', 'REGISTRIES'

// Recommended logging level for the console
// You can set various levels here.
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
property 'forge.logging.console.level', 'debug'

// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
property 'forge.enabledGameTestNamespaces', 'example_mcgltf_usage'

mods {
Expand Down Expand Up @@ -151,7 +129,7 @@ dependencies {
// Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed
// that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft 'net.minecraftforge:forge:1.18.2-40.1.14'
minecraft 'net.minecraftforge:forge:1.19-41.0.63'

// Real mod deobf dependency examples - these get remapped to your current mappings
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
Expand All @@ -164,8 +142,8 @@ dependencies {
// For more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
implementation fileTree(dir: 'libs', include: '*.jar')
implementation fileTree(dir: 'libs', include: '*.jar')
}

// Example for how to get properties into the manifest for reading at runtime.
Expand Down
152 changes: 65 additions & 87 deletions src/main/java/com/timlee9024/mcgltf/example/Example.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockBehaviour;
Expand All @@ -41,10 +40,11 @@
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.common.ForgeSpawnEggItem;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegisterEvent;

@Mod("example_mcgltf_usage")
public class Example {
Expand All @@ -57,46 +57,34 @@ public class Example {
public static class Server {

@SubscribeEvent
public static void onBlockRegistryEvent(final RegistryEvent.Register<Block> event) {
EXAMPLE_BLOCK = new ExampleBlock(BlockBehaviour.Properties.of(Material.STONE).strength(0.3F).sound(SoundType.STONE).noOcclusion().isValidSpawn((a, b, c, d) -> false).isRedstoneConductor((a, b, c) -> false).isSuffocating((a, b, c) -> false).isViewBlocking((a, b, c) -> false));
EXAMPLE_BLOCK.setRegistryName(new ResourceLocation("mcgltf", "example_block"));
event.getRegistry().register(EXAMPLE_BLOCK);
}

@SubscribeEvent
public static void onBlockEntityTypeRegistryEvent(final RegistryEvent.Register<BlockEntityType<?>> event) {
EXAMPLE_BLOCK_ENTITY_TYPE = BlockEntityType.Builder.of(ExampleBlockEntity::new, EXAMPLE_BLOCK).build(null);
EXAMPLE_BLOCK_ENTITY_TYPE.setRegistryName(new ResourceLocation("mcgltf", "example_blockentity"));
event.getRegistry().register(EXAMPLE_BLOCK_ENTITY_TYPE);
}

@SubscribeEvent
public static void onEntityTypeRegistryEvent(final RegistryEvent.Register<EntityType<?>> event) {
EXAMPLE_ENTITY_TYPE = EntityType.Builder.of(ExampleEntity::new, MobCategory.MISC)
.sized(0.6F, 1.95F)
.clientTrackingRange(10)
.build("mcgltf:example_entity");
EXAMPLE_ENTITY_TYPE.setRegistryName(new ResourceLocation("mcgltf", "example_entity"));
event.getRegistry().register(EXAMPLE_ENTITY_TYPE);
}

@SubscribeEvent
public static void onItemRegistryEvent(final RegistryEvent.Register<Item> event) {
Item item = new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC));
item.setRegistryName(new ResourceLocation("mcgltf", "example_item"));
event.getRegistry().register(item);
public static void onEvent(RegisterEvent event) {
event.register(ForgeRegistries.Keys.BLOCKS, helper -> {
EXAMPLE_BLOCK = new ExampleBlock(BlockBehaviour.Properties.of(Material.STONE).strength(0.3F).sound(SoundType.STONE).noOcclusion().isValidSpawn((a, b, c, d) -> false).isRedstoneConductor((a, b, c) -> false).isSuffocating((a, b, c) -> false).isViewBlocking((a, b, c) -> false));
helper.register(new ResourceLocation("mcgltf", "example_block"), EXAMPLE_BLOCK);
});

event.register(ForgeRegistries.Keys.BLOCK_ENTITY_TYPES, helper -> {
EXAMPLE_BLOCK_ENTITY_TYPE = BlockEntityType.Builder.of(ExampleBlockEntity::new, EXAMPLE_BLOCK).build(null);
helper.register(new ResourceLocation("mcgltf", "example_blockentity"), EXAMPLE_BLOCK_ENTITY_TYPE);
});

BlockItem blockItem = new BlockItem(EXAMPLE_BLOCK, new Item.Properties().tab(CreativeModeTab.TAB_MISC));
item.setRegistryName(EXAMPLE_BLOCK.getRegistryName());
event.getRegistry().register(blockItem);
event.register(ForgeRegistries.Keys.ENTITY_TYPES, helper -> {
EXAMPLE_ENTITY_TYPE = EntityType.Builder.of(ExampleEntity::new, MobCategory.MISC)
.sized(0.6F, 1.95F)
.clientTrackingRange(10)
.build("mcgltf:example_entity");
helper.register(new ResourceLocation("mcgltf", "example_entity"), EXAMPLE_ENTITY_TYPE);
});

ForgeSpawnEggItem spawnEggItem = new ForgeSpawnEggItem(() -> EXAMPLE_ENTITY_TYPE, 12422002, 5651507, new Item.Properties().tab(CreativeModeTab.TAB_MISC));
spawnEggItem.setRegistryName(new ResourceLocation("mcgltf", "example_entity_spawn_egg"));
event.getRegistry().register(spawnEggItem);
event.register(ForgeRegistries.Keys.ITEMS, helper -> {
helper.register(new ResourceLocation("mcgltf", "example_item"), new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC)));
helper.register(new ResourceLocation("mcgltf", "example_block"), new BlockItem(EXAMPLE_BLOCK, new Item.Properties().tab(CreativeModeTab.TAB_MISC)));
helper.register(new ResourceLocation("mcgltf", "example_entity_spawn_egg"), new ForgeSpawnEggItem(() -> EXAMPLE_ENTITY_TYPE, 12422002, 5651507, new Item.Properties().tab(CreativeModeTab.TAB_MISC)));
});
}

@SubscribeEvent
public static void onEvent(final EntityAttributeCreationEvent event) {
public static void onEvent(EntityAttributeCreationEvent event) {
event.put(EXAMPLE_ENTITY_TYPE, ExampleEntity.createAttributes().build());
}
}
Expand All @@ -108,31 +96,25 @@ public static class Client {
private static BlockItem blockItem;

@SubscribeEvent
public static void onBlockRegistryEvent(final RegistryEvent.Register<Block> event) {
EXAMPLE_BLOCK = new ExampleBlock(BlockBehaviour.Properties.of(Material.STONE).strength(0.3F).sound(SoundType.STONE).noOcclusion().isValidSpawn((a, b, c, d) -> false).isRedstoneConductor((a, b, c) -> false).isSuffocating((a, b, c) -> false).isViewBlocking((a, b, c) -> false));
EXAMPLE_BLOCK.setRegistryName(new ResourceLocation("mcgltf", "example_block"));
event.getRegistry().register(EXAMPLE_BLOCK);
}

@SubscribeEvent
public static void onBlockEntityTypeRegistryEvent(final RegistryEvent.Register<BlockEntityType<?>> event) {
EXAMPLE_BLOCK_ENTITY_TYPE = BlockEntityType.Builder.of(ExampleBlockEntity::new, EXAMPLE_BLOCK).build(null);
EXAMPLE_BLOCK_ENTITY_TYPE.setRegistryName(new ResourceLocation("mcgltf", "example_blockentity"));
event.getRegistry().register(EXAMPLE_BLOCK_ENTITY_TYPE);
}

@SubscribeEvent
public static void onEntityTypeRegistryEvent(final RegistryEvent.Register<EntityType<?>> event) {
EXAMPLE_ENTITY_TYPE = EntityType.Builder.of(ExampleEntity::new, MobCategory.MISC)
.sized(0.6F, 1.95F)
.clientTrackingRange(10)
.build("mcgltf:example_entity");
EXAMPLE_ENTITY_TYPE.setRegistryName(new ResourceLocation("mcgltf", "example_entity"));
event.getRegistry().register(EXAMPLE_ENTITY_TYPE);
}

@SubscribeEvent
public static void onItemRegistryEvent(final RegistryEvent.Register<Item> event) {
public static void onEvent(RegisterEvent event) {
event.register(ForgeRegistries.Keys.BLOCKS, helper -> {
EXAMPLE_BLOCK = new ExampleBlock(BlockBehaviour.Properties.of(Material.STONE).strength(0.3F).sound(SoundType.STONE).noOcclusion().isValidSpawn((a, b, c, d) -> false).isRedstoneConductor((a, b, c) -> false).isSuffocating((a, b, c) -> false).isViewBlocking((a, b, c) -> false));
helper.register(new ResourceLocation("mcgltf", "example_block"), EXAMPLE_BLOCK);
});

event.register(ForgeRegistries.Keys.BLOCK_ENTITY_TYPES, helper -> {
EXAMPLE_BLOCK_ENTITY_TYPE = BlockEntityType.Builder.of(ExampleBlockEntity::new, EXAMPLE_BLOCK).build(null);
helper.register(new ResourceLocation("mcgltf", "example_blockentity"), EXAMPLE_BLOCK_ENTITY_TYPE);
});

event.register(ForgeRegistries.Keys.ENTITY_TYPES, helper -> {
EXAMPLE_ENTITY_TYPE = EntityType.Builder.of(ExampleEntity::new, MobCategory.MISC)
.sized(0.6F, 1.95F)
.clientTrackingRange(10)
.build("mcgltf:example_entity");
helper.register(new ResourceLocation("mcgltf", "example_entity"), EXAMPLE_ENTITY_TYPE);
});

AbstractItemGltfModelReceiver itemModelReceiver = new AbstractItemGltfModelReceiver() {

@Override
Expand Down Expand Up @@ -440,40 +422,36 @@ public BlockEntityWithoutLevelRenderer getItemStackRenderer() {

};

item = new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC)) {
event.register(ForgeRegistries.Keys.ITEMS, helper -> {
item = new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC)) {

@Override
public void initializeClient(Consumer<IItemRenderProperties> consumer) {
consumer.accept(renderProperties);
}

};
item.setRegistryName(new ResourceLocation("mcgltf", "example_item"));
event.getRegistry().register(item);

blockItem = new BlockItem(EXAMPLE_BLOCK, new Item.Properties().tab(CreativeModeTab.TAB_MISC)) {
@Override
public void initializeClient(Consumer<IItemRenderProperties> consumer) {
consumer.accept(renderProperties);
}

};;
helper.register(new ResourceLocation("mcgltf", "example_item"), item);
blockItem = new BlockItem(EXAMPLE_BLOCK, new Item.Properties().tab(CreativeModeTab.TAB_MISC)) {

@Override
public void initializeClient(Consumer<IItemRenderProperties> consumer) {
consumer.accept(renderProperties);
}

};
blockItem.setRegistryName(EXAMPLE_BLOCK.getRegistryName());
event.getRegistry().register(blockItem);

ForgeSpawnEggItem spawnEggItem = new ForgeSpawnEggItem(() -> EXAMPLE_ENTITY_TYPE, 12422002, 5651507, new Item.Properties().tab(CreativeModeTab.TAB_MISC));
spawnEggItem.setRegistryName(new ResourceLocation("mcgltf", "example_entity_spawn_egg"));
event.getRegistry().register(spawnEggItem);
@Override
public void initializeClient(Consumer<IItemRenderProperties> consumer) {
consumer.accept(renderProperties);
}

};
helper.register(new ResourceLocation("mcgltf", "example_block"), blockItem);
helper.register(new ResourceLocation("mcgltf", "example_entity_spawn_egg"), new ForgeSpawnEggItem(() -> EXAMPLE_ENTITY_TYPE, 12422002, 5651507, new Item.Properties().tab(CreativeModeTab.TAB_MISC)));
});
}

@SubscribeEvent
public static void onEvent(final EntityAttributeCreationEvent event) {
public static void onEvent(EntityAttributeCreationEvent event) {
event.put(EXAMPLE_ENTITY_TYPE, ExampleEntity.createAttributes().build());
}

@SubscribeEvent
public static void onEvent(final EntityRenderersEvent.RegisterRenderers event) {
public static void onEvent(EntityRenderersEvent.RegisterRenderers event) {
event.registerBlockEntityRenderer(EXAMPLE_BLOCK_ENTITY_TYPE, (context) -> {
ExampleBlockEntityRenderer ber = new ExampleBlockEntityRenderer();
MCglTF.getInstance().addGltfModelReceiver(ber);
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ version="${file.jarVersion}" #mandatory
# A display name for the mod
displayName="Example MCglTF Usage" #mandatory
# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/
updateJSONURL="https://raw.githubusercontent.com/TimLee9024/MCglTF-Example/1.18.2-Forge/updates.json" #optional
updateJSONURL="https://raw.githubusercontent.com/TimLee9024/MCglTF-Example/1.19-Forge/updates.json" #optional
# A URL for the "homepage" for this mod, displayed in the mod UI
displayURL="https://github.com/TimLee9024/MCglTF-Example/tree/1.18.2-Forge/" #optional
displayURL="https://github.com/TimLee9024/MCglTF-Example/tree/1.19-Forge/" #optional
# A file name (in the root of the mod JAR) containing a logo for display
logoFile="examplemod.png" #optional
# A text field displayed in the mod UI
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"pack": {
"description": "MCglTF Example resources",
"pack_format": 9
"pack_format": 9,
"forge:resource_pack_format": 9,
"forge:data_pack_format": 10
}
}
10 changes: 4 additions & 6 deletions updates.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"homepage": "https://github.com/TimLee9024/MCglTF-Example/releases",
"1.18.2": {
"1.18.2-Forge-1.0.0.2": "Fix registry name of block item is incorrect on server",
"1.18.2-Forge-1.0.0.1": "Fix depth test sometime not enable on GUI Item",
"1.18.2-Forge-1.0.0.0": "Initial release"
"1.19": {
"1.19-Forge-1.0.0.0": "Initial release"
},
"promos": {
"1.18.2-latest": "1.18.2-Forge-1.0.0.2",
"1.18.2-recommended": "1.18.2-Forge-1.0.0.2"
"1.19-latest": "1.19-Forge-1.0.0.0",
"1.19-recommended": "1.19-Forge-1.0.0.0"
}
}

0 comments on commit 58172ca

Please sign in to comment.