Skip to content

Commit

Permalink
Merge pull request #21 from vrglab/dev/qol/Test-system
Browse files Browse the repository at this point in the history
Dev/qol/test system
  • Loading branch information
vrglab authored Jun 28, 2024
2 parents a5f630b + 8017772 commit d914b5c
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 2 deletions.
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(){

}
}
4 changes: 2 additions & 2 deletions 1.19.2/common/src/main/java/org/Vrglab/Utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public class Utils {

public static Object convertToMcSafeType(Object registry_result){
return TypeTransformer.ObjectToType.accept(registry_result);
public static <T> T convertToMcSafeType(Object registry_result){
return (T)TypeTransformer.ObjectToType.accept(registry_result);
}
}
2 changes: 2 additions & 0 deletions 1.19.2/common/src/main/java/org/Vrglab/VrglabsLib.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.Vrglab;


import org.TestSystem.TestMod;

public final class VrglabsLib {

public static void init() {
Expand Down

0 comments on commit d914b5c

Please sign in to comment.