Skip to content

Commit

Permalink
Merge pull request #23 from vrglab/dev/1.20.4
Browse files Browse the repository at this point in the history
Dev/1.20.4
  • Loading branch information
vrglab authored Jun 29, 2024
2 parents fb1ac35 + 0e02b8a commit f9c78ea
Show file tree
Hide file tree
Showing 122 changed files with 3,683 additions and 586 deletions.
2 changes: 1 addition & 1 deletion 1.19.2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ architectury {

allprojects {
group = rootProject.maven_group
version = "$project.name-$rootProject.mod_version"
version = "$project.name-$rootProject.loader_safe_version-mc$rootProject.minecraft_version"

}

Expand Down
2 changes: 2 additions & 0 deletions 1.19.2/common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ dependencies {

// Architectury API. This is optional, and you can comment it out if you don't need it.
modImplementation "dev.architectury:architectury:$rootProject.architectury_api_version"


}
21 changes: 21 additions & 0 deletions 1.19.2/common/src/main/java/org/TestSystem/TestMod.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.TestSystem;

import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import org.TestSystem.world.Blocks.TestBlocks;
import org.TestSystem.world.Items.CreativeModeTabs;
import org.TestSystem.world.Items.TestItems;

public class TestMod {
public static final String MODID = "vrglabslib";

public static void init(){
CreativeModeTabs.init();
TestItems.init();
TestBlocks.init();
}

public static Item.Settings basicItemSettings() {
return new Item.Settings().group(ItemGroup.DECORATIONS);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.TestSystem.world.Blocks;

import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.util.math.BlockPos;
import org.Vrglab.Utils.Utils;

public class TestBlockEntity extends BlockEntity {
public TestBlockEntity(BlockPos pos, BlockState state) {
super(Utils.convertToMcSafeType(TestBlocks.TEST_ENTITY_BLOCK_TYPE), pos, state);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.TestSystem.world.Blocks;

import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.Material;
import org.TestSystem.TestMod;
import org.Vrglab.Modloader.Registration.Registry;

public class TestBlocks {

public static Object TEST_BLOCK = Registry.RegisterBlock("test_block", TestMod.MODID, ()->new Block(AbstractBlock.Settings.of(Material.METAL)), TestMod.basicItemSettings());
public static Object TEST_ITEMLESS_BLOCK = Registry.RegisterItemlessBlock("test_itemless_block", TestMod.MODID, ()->new Block(AbstractBlock.Settings.of(Material.METAL)));

public static Object TEST_POI_BLOCK = Registry.RegisterBlock("test_poi_block", TestMod.MODID, ()->new Block(AbstractBlock.Settings.of(Material.METAL)), TestMod.basicItemSettings());
public static Object TEST_ENTITY_BLOCK = Registry.RegisterBlock("test_entity_block", TestMod.MODID, ()->new TestEntityBlockHolder(AbstractBlock.Settings.of(Material.METAL)), TestMod.basicItemSettings());

public static Object TEST_ENTITY_BLOCK_TYPE = Registry.RegisterBlockEntityType("test_entity_block_type", TestMod.MODID, TestBlockEntity::new, TEST_ENTITY_BLOCK);

public static void init() {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.TestSystem.world.Blocks;

import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.BlockWithEntity;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.math.BlockPos;
import org.jetbrains.annotations.Nullable;

public class TestEntityBlockHolder extends BlockWithEntity implements BlockEntityProvider {

protected TestEntityBlockHolder(Settings settings) {
super(settings);
}

@Nullable
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new TestBlockEntity(pos, state);
}

@Override
public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.MODEL;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.TestSystem.world.Items;

public class CreativeModeTabs {

public static void init(){

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.TestSystem.world.Items;

import net.minecraft.item.Item;
import org.TestSystem.TestMod;
import org.Vrglab.Modloader.Registration.Registry;

public class TestItems {

public static Object TEST_ITEM = Registry.RegisterItem("test_item", TestMod.MODID, ()->new Item(TestMod.basicItemSettings()));


public static void init(){

}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.Vrglab.Modloader.CreationHelpers;

import net.minecraft.block.entity.BlockEntityType;
import org.Vrglab.Modloader.Types.ICallBack;
import org.jetbrains.annotations.ApiStatus;

@ApiStatus.Internal
public class TypeTransformer {
public static ICallBack ObjectToType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import net.minecraft.item.Item;
import net.minecraft.recipe.RecipeSerializer;
import net.minecraft.recipe.RecipeType;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.sound.SoundEvent;
import net.minecraft.village.TradeOffer;
import net.minecraft.world.gen.GenerationStep;
Expand All @@ -16,6 +15,7 @@
import org.Vrglab.Modloader.Types.ICallBack;
import org.Vrglab.Modloader.Types.IScreenHandledCreationFunction;
import org.Vrglab.Modloader.Types.IScreenHandlerTypeCreationFunction;
import org.Vrglab.Modloader.enumTypes.IRegistryType;
import org.Vrglab.Modloader.enumTypes.RegistryTypes;
import org.Vrglab.Modloader.enumTypes.VinillaBiomeTypes;
import org.Vrglab.Screen.ScreenHandler;
Expand All @@ -32,7 +32,7 @@
*/
public class Registry {
private static class UnregisteredData{
public UnregisteredData(int registry_type, Object... args) {
public UnregisteredData(UUID registry_type, Object... args) {
this.registry_type = registry_type;
this.args = new ArrayList<>();
for (Object argdata: args) {
Expand All @@ -41,26 +41,26 @@ public UnregisteredData(int registry_type, Object... args) {
}

public List<Object> args;
public int registry_type;
public UUID registry_type;
public boolean resolved;

public Object Obj = null;
}

private static Map<String, Map<Integer, ICallBack>> open_registeries = new HashMap<>();
private static Map<String, Map<UUID, ICallBack>> open_registeries = new HashMap<>();
private static Map<String, Set<UnregisteredData>> ready_to_load_registeries = new HashMap<>();

/**
* Initializes a Modloader's Registry to be used for loading of objects
* <div><i>(Using this function is extremely not recommended, unless you trully know what you are really doing, instead use {@link #initRegistry(ICallBack, RegistryTypes, String)})</i></div>
* <div><i>(Using this function is extremely not recommended, unless you trully know what you are really doing, instead use {@link #initRegistry(ICallBack, IRegistryType, String)})</i></div>
* @param _registery The registry code
* @param _currentRegistryTypes the type of registry
* @param modid the Mod ID
*
* @author Arad Bozorgmehr
* @since 1.1.0
*/
public static void initRegistry(ICallBack _registery, int _currentRegistryTypes, String modid){
public static void initRegistry(ICallBack _registery, UUID _currentRegistryTypes, String modid){
if(open_registeries.containsKey(modid)){
open_registeries.get(modid).put(_currentRegistryTypes, _registery);
} else{
Expand All @@ -86,21 +86,8 @@ public static void initRegistry(ICallBack _registery, int _currentRegistryTypes,
* @author Arad Bozorgmehr
* @since 1.0.0
*/
public static void initRegistry(ICallBack _registery, RegistryTypes _currentRegistryTypes, String modid){
if(open_registeries.containsKey(modid)){
open_registeries.get(modid).put(_currentRegistryTypes.getTypeId(), _registery);
} else{
open_registeries.put(modid, new HashMap());
open_registeries.get(modid).put(_currentRegistryTypes.getTypeId(), _registery);
}
if(ready_to_load_registeries.containsKey(modid) && ready_to_load_registeries.get(modid).size() > 0) {
for (UnregisteredData data: ready_to_load_registeries.get(modid)) {
if(!data.resolved && data.registry_type == _currentRegistryTypes.getTypeId()){
data.Obj = _registery.accept(data.args.toArray());
data.resolved = true;
}
}
}
public static void initRegistry(ICallBack _registery, IRegistryType _currentRegistryTypes, String modid){
initRegistry(_registery, _currentRegistryTypes.getTypeId(), modid);
}

/**
Expand All @@ -113,19 +100,13 @@ public static void initRegistry(ICallBack _registery, RegistryTypes _currentRegi
* @author Arad Bozorgmehr
* @since 1.0.0
*/
public static void ForgeEventResolver(Object eventData, ICallBack resolver, RegistryTypes ResolveTypeOf, String modid){
if(ready_to_load_registeries.containsKey(modid) && ready_to_load_registeries.get(modid).size() > 0) {
for (UnregisteredData data: ready_to_load_registeries.get(modid)) {
if(!data.resolved && data.registry_type == ResolveTypeOf.getTypeId()){
data.Obj = resolver.accept(data.args.toArray(), eventData);
}
}
}
public static void ForgeEventResolver(Object eventData, ICallBack resolver, IRegistryType ResolveTypeOf, String modid){
ForgeEventResolver(eventData, resolver, ResolveTypeOf.getTypeId(), modid);
}

/**
* Creates an Event resolver for forge
* <div><i>(Using this function is extremely not recommended, unless you trully know what you are really doing, instead use {@link #ForgeEventResolver(Object, ICallBack, RegistryTypes, String)})</i></div>
* <div><i>(Using this function is extremely not recommended, unless you truly know what you are really doing, instead use {@link #ForgeEventResolver(Object, ICallBack, IRegistryType, String)})</i></div>
* @param eventData The event data
* @param resolver The resolver code
* @param ResolveTypeOf The type of Object this event resolves
Expand All @@ -134,7 +115,7 @@ public static void ForgeEventResolver(Object eventData, ICallBack resolver, Regi
* @author Arad Bozorgmehr
* @since 1.1.0
*/
public static void ForgeEventResolver(Object eventData, ICallBack resolver, int ResolveTypeOf, String modid){
public static void ForgeEventResolver(Object eventData, ICallBack resolver, UUID ResolveTypeOf, String modid){
if(ready_to_load_registeries.containsKey(modid) && ready_to_load_registeries.get(modid).size() > 0) {
for (UnregisteredData data: ready_to_load_registeries.get(modid)) {
if(!data.resolved && data.registry_type == ResolveTypeOf){
Expand All @@ -147,7 +128,7 @@ public static void ForgeEventResolver(Object eventData, ICallBack resolver, int
/**
* Register's a new Item for MC. Based on what Mod loader we are on, We either receive the Object itself or a
* RegistryObject of the Object, to safely use the Object in other pieces of
* code use {@link org.Vrglab.Modloader.CreationHelpers.TypeTransformer#ObjectToType}
* code use {@link org.Vrglab.Utils.Utils#convertToMcSafeType(Object)}
* @param name The Item name (aka ID)
* @param Modid The Mod Id of the Registerar
* @param aNew The supplier which gives us the Item Instance
Expand All @@ -163,7 +144,7 @@ public static Object RegisterItem(String name, String Modid, Supplier aNew) {
/**
* Register's a new Block for MC. Based on what Mod loader we are on, We either receive the Object itself or a
* RegistryObject of the Object, to safely use the Object in other pieces of
* code use {@link org.Vrglab.Modloader.CreationHelpers.TypeTransformer#ObjectToType}
* code use {@link org.Vrglab.Utils.Utils#convertToMcSafeType(Object)}
* @param name The Block name (aka ID)
* @param Modid The Mod Id of the Registerar
* @param aNew The supplier which gives us the Block Instance
Expand All @@ -180,11 +161,11 @@ public static Object RegisterBlock(String name, String Modid, Supplier aNew, Ite
/**
* Register's a new Block Entity for MC. Based on what Mod loader we are on, We either receive the Object itself or a
* RegistryObject of the Object, to safely use the Object in other pieces of
* code use {@link org.Vrglab.Modloader.CreationHelpers.TypeTransformer#ObjectToType}
* code use {@link org.Vrglab.Utils.Utils#convertToMcSafeType(Object)}
* @param name The Block Entity name (aka ID)
* @param Modid The Mod Id of the Registerar
* @param aNew The ::new which gives us the Block Entity Instance
* @param block The block to attach the entity to (NOT converted using {@link org.Vrglab.Modloader.CreationHelpers.TypeTransformer#ObjectToType})
* @param block The block to attach the entity to (NOT converted using {@link org.Vrglab.Utils.Utils#convertToMcSafeType(Object)})
* @return The registered data
*
* @author Arad Bozorgmehr
Expand All @@ -199,7 +180,7 @@ public static Object RegisterBlockEntityType(String name, String Modid, IBlockEn
* @param name The Screen Handler name (aka ID)
* @param Modid The Mod Id of the Registerar
* @param aNew The ::new which gives us the Screen Handler Instance
* @return The registered data (The return value of this Function CAN NOT be converted using {@link org.Vrglab.Modloader.CreationHelpers.TypeTransformer#ObjectToType})
* @return The registered data (The return value of this Function CAN NOT be converted using {@link org.Vrglab.Utils.Utils#convertToMcSafeType(Object)})
*
* @author Arad Bozorgmehr
* @since 1.0.0
Expand All @@ -225,7 +206,7 @@ public static <T extends ScreenHandler, U extends Screen & ScreenHandlerProvide
/**
* Register's a new Itemless Block for MC. Based on what Mod loader we are on, We either receive the Object itself or a
* RegistryObject of the Object, to safely use the Object in other pieces of
* code use {@link org.Vrglab.Modloader.CreationHelpers.TypeTransformer#ObjectToType}
* code use {@link org.Vrglab.Utils.Utils#convertToMcSafeType(Object)}
* @param name The Block name (aka ID)
* @param Modid The Mod Id of the Registerar
* @param aNew The supplier which gives us the Block Instance
Expand All @@ -241,10 +222,10 @@ public static Object RegisterItemlessBlock(String name, String Modid, Supplier a
/**
* Register's a new POI (Point of Interest) for MC. Based on what Mod loader we are on, We either receive the Object itself or a
* RegistryObject of the Object, to safely use the Object in other pieces of
* code use {@link org.Vrglab.Modloader.CreationHelpers.TypeTransformer#ObjectToType}
* code use {@link org.Vrglab.Utils.Utils#convertToMcSafeType(Object)}
* @param name The POI name (aka ID)
* @param Modid The Mod Id of the Registerar
* @param block The block to attach the entity to (NOT converted using {@link org.Vrglab.Modloader.CreationHelpers.TypeTransformer#ObjectToType})
* @param block The block to attach the entity to (NOT converted using {@link org.Vrglab.Utils.Utils#convertToMcSafeType(Object)})
* @param tickcount The POI tick count
* @param searchdistance The Search distance for the POI
* @return The registered data
Expand All @@ -259,7 +240,7 @@ public static Object RegisterPOI(String name, String Modid, Object block, int ti
/**
* Register's a new Villager Profession for MC. Based on what Mod loader we are on, We either receive the Object itself or a
* RegistryObject of the Object, to safely use the Object in other pieces of
* code use {@link org.Vrglab.Modloader.CreationHelpers.TypeTransformer#ObjectToType}
* code use {@link org.Vrglab.Utils.Utils#convertToMcSafeType(Object)}
* @param name The Villager Profession name (aka ID)
* @param Modid The Mod Id of the Registerar
* @param aNew The POI name (aka ID)
Expand Down Expand Up @@ -332,26 +313,14 @@ public static Object RegisterRecipeType(String name, String Modid, RecipeType ty
* @author Arad Bozorgmehr
* @since 1.0.0
*/
public static Object SimpleRegister(RegistryTypes type, String Modid, Object... args){
VLModInfo.LOGGER.info("Registering "+type.toString().toLowerCase() +" " + args[0] + " for " + Modid);
if(open_registeries.containsKey(Modid) && open_registeries.get(Modid).containsKey(type.getTypeId()))
return open_registeries.get(Modid).get(type.getTypeId()).accept(args);
else {
UnregisteredData data = new UnregisteredData(type.getTypeId(), args);
if(!ready_to_load_registeries.containsKey(Modid)) {
ready_to_load_registeries.put(Modid, new HashSet<>());
ready_to_load_registeries.get(Modid).add(data);
}
else
ready_to_load_registeries.get(Modid).add(data);
return data.Obj;
}
public static Object SimpleRegister(IRegistryType type, String Modid, Object... args){
return SimpleRegister(type.getTypeId(), Modid, args);
}


/**
* Sends data to the modloader for something to be registered for MC
* <div><i>(Using this function is extremely not recommended, unless you trully know what you are really doing, instead use {@link #SimpleRegister(RegistryTypes, String, Object...)})</i></div>
* <div><i>(Using this function is extremely not recommended, unless you trully know what you are really doing, instead use {@link #SimpleRegister(IRegistryType, String, Object...)})</i></div>
* @param type The type to use for registeration
* @param Modid The Mod Id of the Registerar
* @param args All the arguments needed to register the Object (On the callback end of this interaction the arguments are fed in the EXACT same order)
Expand All @@ -360,8 +329,8 @@ public static Object SimpleRegister(RegistryTypes type, String Modid, Object...
* @author Arad Bozorgmehr
* @since 1.1.0
*/
public static Object SimpleRegister(int type, String Modid, Object... args){
VLModInfo.LOGGER.info("Registering "+String.valueOf(type).toLowerCase() +" " + args[0] + " for " + Modid);
public static Object SimpleRegister(UUID type, String Modid, Object... args){
VLModInfo.LOGGER.info("Registry "+String.valueOf(type).toLowerCase() +" Registering " + args[0] + " for " + Modid);
if(open_registeries.containsKey(Modid) && open_registeries.get(Modid).containsKey(type))
return open_registeries.get(Modid).get(type).accept(args);
else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.Vrglab.Modloader.enumTypes;

import java.util.UUID;

public interface IRegistryType {
UUID getTypeId();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.Vrglab.Modloader.enumTypes;

public interface RegistryType {
public int getTypeId();

}
Loading

0 comments on commit f9c78ea

Please sign in to comment.