basic functions for replacing work

Es wird ein Block platziert wenn man auf einen Guardian rechtsklicked. Grafiken laden auch
This commit is contained in:
Malte Reents 2024-03-14 15:17:01 +01:00
parent 0c99c0b24e
commit e6acd9460d
14 changed files with 474 additions and 11 deletions

View File

@ -4,14 +4,16 @@ import modchest.networking.modNetworkingClient;
import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.ClientModInitializer;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import modchest.util.initializer;
public class REServerModClient implements ClientModInitializer { public class REServerModClient implements ClientModInitializer {
public static final Logger LOGGER = LoggerFactory.getLogger("modchest"); // Erster Error Logger public static final Logger LOGGER = LoggerFactory.getLogger("modchest"); // Erster Error Logger
@Override @Override
public void onInitializeClient() { public void onInitializeClient() {
// This entrypoint is suitable for setting up client-specific logic, such as rendering. // This entrypoint is suitable for setting up client-specific logic, such as rendering.
initializer.networking();
initializer.renderer();
modNetworkingClient.registerC2SPackets(); //Identifier unter denen der Client zuhoert werden registriert
LOGGER.info("Modchest-Client successfully loaded!"); LOGGER.info("Modchest-Client successfully loaded!");
} }

View File

@ -0,0 +1,33 @@
package modchest.util;
import modchest.block.entity.modBlockEntities;
import modchest.block.modBlocks;
import modchest.item.modItemGroup;
import modchest.item.modItems;
import modchest.networking.modNetworkingClient;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.minecraft.client.render.RenderLayer;
public class initializer {
public static void itemGroups() {
//modItemGroup.modchest(); // Item Gruppe fürs Creative-Inventar wird erstellt; In dieser Gruppe sollen
// dann alle Items und Blöcke dieser Mod angezeigt werden
}
public static void itemsAndBlocks() {
//modItems.setItems(); // die Items werden erstellt
//modBlocks.setBlocks(); // Hier werden die Blöcke erstellt
//modBlockEntities.registerBlockEntities(); // Die Interaktionsmenüs für die Blöcke werden erstellt
}
public static void events() { //Events, bei denen custom Code ausgefuehrt wird, werden eingefuehrt
}
public static void networking() { //Identifier unter denen der Server zuhoert werden registriert
modNetworkingClient.registerC2SPackets(); //Identifier unter denen der Client zuhoert werden registriert
}
public static void renderer() { //Grafikrenderer werden aufgerufen
BlockRenderLayerMap.INSTANCE.putBlock(modBlocks.denk_mal_block, RenderLayer.getTranslucent()); //denk_mal_block bekommt die Faehigkeit, transparente Grafiken zu haben
}
}

View File

@ -1,13 +1,17 @@
package modchest.block.custom; package modchest.block.custom;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.BlockWithEntity; import net.minecraft.block.BlockWithEntity;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion; import net.minecraft.world.explosion.Explosion;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -16,6 +20,17 @@ public class denkMalBlock extends BlockWithEntity { //Item soll nciht crafta
public denkMalBlock(FabricBlockSettings fabricBlockSettings) { public denkMalBlock(FabricBlockSettings fabricBlockSettings) {
super(fabricBlockSettings); super(fabricBlockSettings);
} }
@Override
public BlockRenderType getRenderType(BlockState state) { //ruft auf, die Grafik zu rendern
return BlockRenderType.MODEL;
}
private static VoxelShape SHAPE = BlockWithEntity.createCuboidShape(0, 0, 0, 16, 32, 16); //Erstellt eine approximation des Koerpers; braucht weniger Leistung als ein Volles Rendern
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { //Beschreibt die tatsaechlichen Konturen
return SHAPE;
}
@Nullable @Nullable
@Override //Später relevant für das Interface @Override //Später relevant für das Interface

View File

@ -25,10 +25,8 @@ public class steeringWheelBlock extends BlockWithEntity implements BlockEntityPr
super(settings); super(settings);
} }
/* stuff benötigt um das Interaktionsmenü zu laden!*/
@Override @Override
public BlockRenderType getRenderType(BlockState state) { public BlockRenderType getRenderType(BlockState state) {//ruft auf, die Grafik zu rendern
return BlockRenderType.MODEL; return BlockRenderType.MODEL;
} }
@ -44,6 +42,7 @@ public class steeringWheelBlock extends BlockWithEntity implements BlockEntityPr
} }
} }
/* stuff benötigt um das Interaktionsmenü zu laden!*/
@Override //wird bei einem rechtsklick aufgerufen (ersellt das Blockentity) @Override //wird bei einem rechtsklick aufgerufen (ersellt das Blockentity)
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (!world.isClient) { if (!world.isClient) {

View File

@ -7,6 +7,7 @@ import modchest.REServerMod;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings; import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
@ -24,7 +25,7 @@ public class modBlocks {
modItemGroup.modchest); modItemGroup.modchest);
denk_mal_block = registerBlock("denk_mal_block", denk_mal_block = registerBlock("denk_mal_block",
new denkMalBlock(FabricBlockSettings.of(Material.METAL).strength(1.0f).requiresTool()), new denkMalBlock(FabricBlockSettings.copyOf(Blocks.GLASS).nonOpaque()),
modItemGroup.modchest); modItemGroup.modchest);
} }

View File

@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "modchest:block/denk_mal_block_aus"}
}
}

View File

@ -0,0 +1,87 @@
{
"credit": "Made with Blockbench",
"texture_size": [64, 64],
"textures": {
"1": "modchest:block/denk_mal_block",
"3": "modchest:block/denk_mal_block_basis",
"particle": "modchest:block/denk_mal_block_kern_an"
},
"elements": [
{
"from": [0, 0, 0],
"to": [16, 16, 16],
"faces": {
"north": {"uv": [0, 0, 4, 4], "texture": "#3"},
"east": {"uv": [0, 4, 4, 8], "texture": "#3"},
"south": {"uv": [4, 0, 8, 4], "texture": "#3"},
"west": {"uv": [4, 4, 8, 8], "texture": "#3"},
"up": {"uv": [4, 12, 0, 8], "texture": "#3"},
"down": {"uv": [12, 0, 8, 4], "texture": "#3"}
}
},
{
"from": [0, 16, 0],
"to": [16, 32, 16],
"faces": {
"north": {"uv": [0, 0, 4, 4], "texture": "#1"},
"east": {"uv": [0, 4, 4, 8], "texture": "#1"},
"south": {"uv": [4, 0, 8, 4], "texture": "#1"},
"west": {"uv": [4, 4, 8, 8], "texture": "#1"},
"up": {"uv": [4, 12, 0, 8], "texture": "#1"},
"down": {"uv": [12, 0, 8, 4], "texture": "#1"}
}
},
{
"from": [3, 18, 3],
"to": [13, 29, 13],
"faces": {
"north": {"uv": [0, 0, 5, 5.5], "texture": "#missing"},
"east": {"uv": [5, 0, 10, 5.5], "texture": "#missing"},
"south": {"uv": [0, 5.5, 5, 11], "texture": "#missing"},
"west": {"uv": [5, 5.5, 10, 11], "texture": "#missing"},
"up": {"uv": [15, 5, 10, 0], "texture": "#missing"},
"down": {"uv": [15, 5, 10, 10], "texture": "#missing"}
}
}
],
"display": {
"thirdperson_righthand": {
"scale": [0.5, 0.5, 0.5]
},
"thirdperson_lefthand": {
"scale": [0.5, 0.5, 0.5]
},
"firstperson_righthand": {
"rotation": [1, 0, 0],
"translation": [2.5, -1.5, 0],
"scale": [0.5, 0.5, 0.5]
},
"firstperson_lefthand": {
"translation": [2.5, -1.5, 0],
"scale": [0.5, 0.5, 0.5]
},
"ground": {
"scale": [0.5, 0.5, 0.5]
},
"gui": {
"translation": [0, -3.25, 0],
"scale": [0.5, 0.5, 0.5]
},
"head": {
"translation": [0, 11.5, 0],
"scale": [0.5, 0.5, 0.5]
},
"fixed": {
"translation": [0, -1.75, 0],
"scale": [0.5, 0.5, 0.5]
}
},
"groups": [
{
"name": "VoxelShapes",
"origin": [8, 8, 8],
"color": 0,
"children": [0, 1, 2]
}
]
}

View File

@ -0,0 +1,324 @@
{
"parent": "block/cube_all",
"credit": "Made with Blockbench",
"texture_size": [
64,
64
],
"textures": {
"1": "modchest:block/denk_mal_block",
"2": "modchest:block/denk_mal_block_kern_aus",
"3": "modchest:block/denk_mal_block_basis",
"particles": "modchest:block/denk_mal_block_basis"
},
"elements": [
{
"from": [
0,
0,
0
],
"to": [
16,
16,
16
],
"faces": {
"north": {
"uv": [
0,
0,
4,
4
],
"texture": "#3"
},
"east": {
"uv": [
0,
4,
4,
8
],
"texture": "#3"
},
"south": {
"uv": [
4,
0,
8,
4
],
"texture": "#3"
},
"west": {
"uv": [
4,
4,
8,
8
],
"texture": "#3"
},
"up": {
"uv": [
4,
12,
0,
8
],
"texture": "#3"
},
"down": {
"uv": [
12,
0,
8,
4
],
"texture": "#3"
}
}
},
{
"from": [
0,
16,
0
],
"to": [
16,
32,
16
],
"faces": {
"north": {
"uv": [
0,
0,
4,
4
],
"texture": "#1"
},
"east": {
"uv": [
0,
4,
4,
8
],
"texture": "#1"
},
"south": {
"uv": [
4,
0,
8,
4
],
"texture": "#1"
},
"west": {
"uv": [
4,
4,
8,
8
],
"texture": "#1"
},
"up": {
"uv": [
4,
12,
0,
8
],
"texture": "#1"
},
"down": {
"uv": [
12,
0,
8,
4
],
"texture": "#1"
}
}
},
{
"from": [
3,
18,
3
],
"to": [
13,
29,
13
],
"faces": {
"north": {
"uv": [
0,
0,
5,
5.5
],
"texture": "#2"
},
"east": {
"uv": [
5,
0,
10,
5.5
],
"texture": "#2"
},
"south": {
"uv": [
0,
5.5,
5,
11
],
"texture": "#2"
},
"west": {
"uv": [
5,
5.5,
10,
11
],
"texture": "#2"
},
"up": {
"uv": [
15,
5,
10,
0
],
"texture": "#2"
},
"down": {
"uv": [
15,
5,
10,
10
],
"texture": "#2"
}
}
}
],
"display": {
"thirdperson_righthand": {
"scale": [
0.5,
0.5,
0.5
]
},
"thirdperson_lefthand": {
"scale": [
0.5,
0.5,
0.5
]
},
"firstperson_righthand": {
"rotation": [
1,
0,
0
],
"translation": [
2.5,
-1.5,
0
],
"scale": [
0.5,
0.5,
0.5
]
},
"firstperson_lefthand": {
"translation": [
2.5,
-1.5,
0
],
"scale": [
0.5,
0.5,
0.5
]
},
"ground": {
"scale": [
0.5,
0.5,
0.5
]
},
"gui": {
"translation": [
0,
-3.25,
0
],
"scale": [
0.5,
0.5,
0.5
]
},
"head": {
"translation": [
0,
11.5,
0
],
"scale": [
0.5,
0.5,
0.5
]
},
"fixed": {
"translation": [
0,
-1.75,
0
],
"scale": [
0.5,
0.5,
0.5
]
}
},
"groups": [
{
"name": "VoxelShapes",
"origin": [
8,
8,
8
],
"color": 0,
"children": [
0,
1,
2
]
}
]
}

View File

@ -1,6 +0,0 @@
{
"parent": "block/cube_all",
"textures": {
"all": "modchest:block/denk_mal_block"
}
}

View File

@ -0,0 +1,3 @@
{
"parent": "modchest:block/denk_mal_block"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB