mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 13:42:59 +00:00 
			
		
		
		
	Merge branch 'mc-1.20.x' into mc-1.21.x
Oh, I'm sure I missed something here. This was a nasty merge, has the docs have changed so much in each version.
This commit is contained in:
		| @@ -0,0 +1,41 @@ | ||||
| package com.example.examplemod; | ||||
| 
 | ||||
| import com.example.examplemod.peripheral.BrewingStandPeripheral; | ||||
| import dan200.computercraft.api.peripheral.PeripheralCapability; | ||||
| import dan200.computercraft.api.turtle.ITurtleUpgrade; | ||||
| import net.minecraft.resources.ResourceLocation; | ||||
| import net.minecraft.world.level.block.entity.BlockEntityType; | ||||
| import net.neoforged.bus.api.IEventBus; | ||||
| import net.neoforged.fml.common.Mod; | ||||
| import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; | ||||
| import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent; | ||||
| import net.neoforged.neoforge.registries.RegisterEvent; | ||||
| 
 | ||||
| /** | ||||
|  * The main entry point for the Forge version of our example mod. | ||||
|  */ | ||||
| @Mod(ExampleMod.MOD_ID) | ||||
| public class ForgeExampleMod { | ||||
|     public ForgeExampleMod(IEventBus modBus) { | ||||
|         // Register our turtle upgrade. If writing a Forge-only mod, you'd normally use DeferredRegister instead. | ||||
|         // However, this is an easy way to implement this in a multi-loader-compatible manner. | ||||
| 
 | ||||
|         // @start region=turtle_upgrades | ||||
|         modBus.addListener((RegisterEvent event) -> { | ||||
|             event.register( | ||||
|                 ITurtleUpgrade.typeRegistry(), | ||||
|                 ResourceLocation.fromNamespaceAndPath(ExampleMod.MOD_ID, "example_turtle_upgrade"), | ||||
|                 () -> ExampleMod.EXAMPLE_TURTLE_UPGRADE | ||||
|             ); | ||||
|         }); | ||||
|         // @end region=turtle_upgrades | ||||
| 
 | ||||
|         modBus.addListener((FMLCommonSetupEvent event) -> ExampleMod.registerComputerCraft()); | ||||
| 
 | ||||
|         // @start region=peripherals | ||||
|         modBus.addListener((RegisterCapabilitiesEvent event) -> { | ||||
|             event.registerBlockEntity(PeripheralCapability.get(), BlockEntityType.BREWING_STAND, (b, d) -> new BrewingStandPeripheral(b)); | ||||
|         }); | ||||
|         // @end region=peripherals | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,20 @@ | ||||
| package com.example.examplemod; | ||||
| 
 | ||||
| import dan200.computercraft.api.client.turtle.RegisterTurtleModellersEvent; | ||||
| import dan200.computercraft.api.client.turtle.TurtleUpgradeModeller; | ||||
| import net.neoforged.api.distmarker.Dist; | ||||
| import net.neoforged.bus.api.SubscribeEvent; | ||||
| import net.neoforged.fml.common.EventBusSubscriber; | ||||
| 
 | ||||
| /** | ||||
|  * The client-side entry point for the Forge version of our example mod. | ||||
|  */ | ||||
| @EventBusSubscriber(modid = ExampleMod.MOD_ID, value = Dist.CLIENT, bus = EventBusSubscriber.Bus.MOD) | ||||
| public class ForgeExampleModClient { | ||||
|     // @start region=turtle_modellers | ||||
|     @SubscribeEvent | ||||
|     public static void onRegisterTurtleModellers(RegisterTurtleModellersEvent event) { | ||||
|         event.register(ExampleMod.EXAMPLE_TURTLE_UPGRADE, TurtleUpgradeModeller.flatItem()); | ||||
|     } | ||||
|     // @end region=turtle_modellers | ||||
| } | ||||
| @@ -0,0 +1,31 @@ | ||||
| package com.example.examplemod; | ||||
| 
 | ||||
| import com.example.examplemod.data.TurtleUpgradeProvider; | ||||
| import net.minecraft.core.HolderLookup; | ||||
| import net.minecraft.data.DataGenerator; | ||||
| import net.neoforged.bus.api.SubscribeEvent; | ||||
| import net.neoforged.fml.common.EventBusSubscriber; | ||||
| import net.neoforged.neoforge.common.data.DatapackBuiltinEntriesProvider; | ||||
| import net.neoforged.neoforge.data.event.GatherDataEvent; | ||||
| 
 | ||||
| import java.util.Set; | ||||
| import java.util.concurrent.CompletableFuture; | ||||
| 
 | ||||
| /** | ||||
|  * Data generators for the Forge version of our example mod. | ||||
|  */ | ||||
| @EventBusSubscriber(bus = EventBusSubscriber.Bus.MOD) | ||||
| public class ForgeExampleModDataGenerator { | ||||
|     @SubscribeEvent | ||||
|     public static void gather(GatherDataEvent event) { | ||||
|         var pack = event.getGenerator().getVanillaPack(true); | ||||
|         addTurtleUpgrades(pack, event.getLookupProvider()); | ||||
|     } | ||||
| 
 | ||||
|     // @start region=turtle_upgrades | ||||
|     private static void addTurtleUpgrades(DataGenerator.PackGenerator pack, CompletableFuture<HolderLookup.Provider> registries) { | ||||
|         var fullRegistryPatch = TurtleUpgradeProvider.makeUpgradeRegistry(registries); | ||||
|         pack.addProvider(o -> new DatapackBuiltinEntriesProvider(o, fullRegistryPatch, Set.of(ExampleMod.MOD_ID))); | ||||
|     } | ||||
|     // @end region=turtle_upgrades | ||||
| } | ||||
| @@ -0,0 +1,14 @@ | ||||
| modLoader="javafml" | ||||
| loaderVersion="[1,)" | ||||
| license="CC0-1.0" | ||||
|  | ||||
| [[mods]] | ||||
| modId="examplemod" | ||||
| version="1.0.0" | ||||
|  | ||||
| [[dependencies.examplemod]] | ||||
| modId="computercraft" | ||||
| mandatory=true | ||||
| versionRange="[1.0,)" | ||||
| ordering="AFTER" | ||||
| side="BOTH" | ||||
							
								
								
									
										6
									
								
								projects/forge/src/examples/resources/pack.mcmeta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								projects/forge/src/examples/resources/pack.mcmeta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| { | ||||
|     "pack": { | ||||
|         "pack_format": 15, | ||||
|         "description": "Example Mod" | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Jonathan Coates
					Jonathan Coates