update #21
|
@ -6,9 +6,9 @@ import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
|||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class modNetworkingClient { //Identifier werden eingeführt
|
||||
public static final Identifier request_respawn = new Identifier(REServerMod.MOD_ID, "request_respawn"); //alle Identifier muessen leider IMMER auf Client und Server (doppelt) eingefuehrt werden
|
||||
public static final Identifier start_sleeping_call_buttons = new Identifier(REServerMod.MOD_ID, "start_sleeping_call_buttons");
|
||||
public static final Identifier death_multi_respawn_buttons = new Identifier(REServerMod.MOD_ID, "death_call_respawn_buttons");
|
||||
public static final Identifier request_respawn = Identifier.of(REServerMod.MOD_ID, "request_respawn"); //alle Identifier muessen leider IMMER auf Client und Server (doppelt) eingefuehrt werden
|
||||
public static final Identifier start_sleeping_call_buttons = Identifier.of(REServerMod.MOD_ID, "start_sleeping_call_buttons");
|
||||
public static final Identifier death_multi_respawn_buttons = Identifier.of(REServerMod.MOD_ID, "death_call_respawn_buttons");
|
||||
public static void registerC2SPackets() { //Identifier fuer packets werden registriert (Identifier die der Server aufruft um beim CLient was auszufuehren)
|
||||
ClientPlayNetworking.registerGlobalReceiver(request_respawn, respawnRequestS2CPacket::receive); //was der Client dann machen soll steht in der receive Methode
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package modchest.block.custom;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import modchest.block.entity.modBlockEntities;
|
||||
import modchest.block.entity.steeringWheelEntity;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.BlockWithEntity;
|
||||
|
@ -20,11 +20,16 @@ import net.minecraft.world.World;
|
|||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
//gibt dem Block steering_wheel eigenschaften, wie z.B. das Interaktionsmenü, oder Grafiken
|
||||
public class steeringWheelBlock extends BlockWithEntity implements BlockEntityProvider {
|
||||
public class steeringWheelBlock extends BlockWithEntity {
|
||||
public steeringWheelBlock(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends BlockWithEntity> getCodec() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/* stuff benötigt um das Interaktionsmenü zu laden!*/
|
||||
@Override
|
||||
|
@ -43,7 +48,7 @@ public class steeringWheelBlock extends BlockWithEntity implements BlockEntityPr
|
|||
super.onStateReplaced(state, world, pos, newState, moved);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@Override //wird bei einem rechtsklick aufgerufen (ersellt das Blockentity)
|
||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||
if (!world.isClient) {
|
||||
|
@ -55,7 +60,7 @@ public class steeringWheelBlock extends BlockWithEntity implements BlockEntityPr
|
|||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
*/
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import modchest.REServerMod;
|
|||
import modchest.block.modBlocks;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
|
@ -12,8 +13,8 @@ public class modBlockEntities {
|
|||
public static BlockEntityType<steeringWheelEntity> steering_wheel_interface; // Interaktionsmenü wird erstellt
|
||||
|
||||
public static void registerBlockEntities() {
|
||||
steering_wheel_interface = Registry.register(Registry.BLOCK_ENTITY_TYPE,
|
||||
new Identifier(REServerMod.MOD_ID, "steering_wheel_interface"), // Interkationsmenü wird gerendert
|
||||
steering_wheel_interface = Registry.register(Registries.BLOCK_ENTITY_TYPE,
|
||||
Identifier.of(REServerMod.MOD_ID, "steering_wheel_interface"), // Interkationsmenü wird gerendert
|
||||
FabricBlockEntityTypeBuilder.create(steeringWheelEntity::new, modBlocks.steering_wheel).build(null));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,32 +3,32 @@ package modchest.block;
|
|||
import modchest.block.custom.steeringWheelBlock;
|
||||
import modchest.item.modItemGroup;
|
||||
import modchest.REServerMod;
|
||||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||||
import net.minecraft.item.Item;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
//setzt die blöcke auf
|
||||
public class modBlocks {
|
||||
public static Block steering_wheel; // Block wird erstellt
|
||||
public static Block steering_wheel; // Block wird erstellt; das entsprechende Item zum Block muss in "modItemGroup" getrennt zur mod Block Gruppe hinzugefügt werden"
|
||||
|
||||
public static void setBlocks() {// Block wird definiert
|
||||
steering_wheel = registerBlock("steering_wheel",
|
||||
new steeringWheelBlock(FabricBlockSettings.create(Material.WOOD).strength(1.0f).requiresTool()),
|
||||
modItemGroup.modchest);
|
||||
new steeringWheelBlock(FabricBlockSettings.create().strength(1.0f).requiresTool()),
|
||||
modItemGroup.item_group1);
|
||||
|
||||
}
|
||||
|
||||
private static Block registerBlock(String name, Block block, ItemGroup group) { // Nicht verändern! Fügt die oben
|
||||
// definierten Blöcke dem Register
|
||||
// hinzu
|
||||
Registry.register(Registry.ITEM, new Identifier(REServerMod.MOD_ID, name),
|
||||
new BlockItem(block, new FabricItemSettings().group(group)));
|
||||
return Registry.register(Registry.BLOCK, new Identifier(REServerMod.MOD_ID, name), block);
|
||||
Registry.register(Registries.ITEM, Identifier.of(REServerMod.MOD_ID, name),
|
||||
new BlockItem(block, new Item.Settings()));
|
||||
return Registry.register(Registries.BLOCK, Identifier.of(REServerMod.MOD_ID, name), block);
|
||||
}
|
||||
|
||||
public static void registerModBlocks() { // Error Logger halt...
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/*
|
||||
package modchest.data;
|
||||
|
||||
import modchest.item.modItems;
|
||||
|
@ -16,3 +17,4 @@ public class ModLootTableGenerator extends FabricBlockLootTableProvider {
|
|||
//oreDrops(modBlocks.steering_wheel, modItems.shipblock); mit silktouch würde steering_wheel gedroped werden, ohne würde shipblock gedroped werden
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -1,3 +1,4 @@
|
|||
/*
|
||||
package modchest.data;
|
||||
|
||||
import modchest.block.modBlocks;
|
||||
|
@ -23,4 +24,4 @@ public class ModModelProvider extends FabricModelProvider {
|
|||
public void generateItemModels(ItemModelGenerator itemModelGenerator) {
|
||||
//itemModelGenerator.register(modItems.shipblock, Models.GENERATED); //ergänzt die Texturen für die Items
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
/*
|
||||
package modchest.data;
|
||||
|
||||
import modchest.item.modItems;
|
||||
|
@ -19,3 +20,4 @@ public class ModRecipeGenerator extends FabricRecipeProvider {
|
|||
//offerSmelting(exporter, List.of(modItems.shipblock), , ); //generiert das rezept zum herstellen (hier mir braten)
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -1,19 +1,39 @@
|
|||
package modchest.item;
|
||||
|
||||
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
|
||||
import modchest.REServerMod;
|
||||
import modchest.block.modBlocks;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
//definiert eine neue Itemgruppe mit dem identifier itemlist1, wird in einer de .json files dann in "Malte's Mod" umbenannt fürs spiel; in der Liste sollen alle Items dieser Mod im Creative Inventar angezeigt werden
|
||||
public class modItemGroup {
|
||||
public static ItemGroup modchest;
|
||||
public static final RegistryKey<ItemGroup> item_group_key1 = RegistryKey.of(Registries.ITEM_GROUP.getKey(), Identifier.of(REServerMod.MOD_ID, "item_group_key1"));
|
||||
public static final ItemGroup item_group1 = FabricItemGroup.builder()
|
||||
.icon(() -> new ItemStack(Blocks.COBBLESTONE)) //Icon ist halt bisher noch ein Cobblestone, weil ich keine sprits erstellt habe... :(
|
||||
.displayName(Text.translatable("itemGroup.modchest.itemlist1"))
|
||||
.build();
|
||||
|
||||
|
||||
|
||||
public static void modchest() {
|
||||
modchest = FabricItemGroupBuilder.build(
|
||||
new Identifier("modchest", "itemlist1"),
|
||||
() -> new ItemStack(Blocks.COBBLESTONE)); //Icon ist halt bisher noch ein Cobblestone, weil ich keine sprits erstellt habe... :(
|
||||
//Registriert die Gruppe
|
||||
Registry.register(Registries.ITEM_GROUP, item_group_key1, item_group1);
|
||||
|
||||
//Registers the items to the group
|
||||
ItemGroupEvents.modifyEntriesEvent(item_group_key1).register(item_group1 -> {
|
||||
item_group1.add(modItems.pirates_coin);
|
||||
item_group1.add(modBlocks.steering_wheel);
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@ package modchest.item;
|
|||
|
||||
import modchest.REServerMod;
|
||||
import modchest.item.custom.piratesCoinItem;
|
||||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
//Liste der Items die hinzugefügt werden, ausgenommen Blöcke
|
||||
|
@ -14,15 +14,15 @@ public class modItems {
|
|||
public static Item pirates_coin; // pirates Coin wird erstellt; definition siehe ./custom/piratesCoinItem da ist
|
||||
// im detail erklärt was das Item machen soll
|
||||
|
||||
public static void setItems() { // Items werden beschrieben, bzw. dem Register hinzugefügt
|
||||
shipblock = registerItem("shipblock", new Item(new FabricItemSettings().group(modItemGroup.modchest)));
|
||||
public static void setItems() { // Items werden beschrieben, bzw. dem Register hinzugefügt; das entsprechende Item zum Block muss in "modItemGroup" getrennt zur mod Block Gruppe hinzugefügt werden"
|
||||
shipblock = registerItem("shipblock", new Item(new Item.Settings()));
|
||||
pirates_coin = registerItem("pirates_coin",
|
||||
new piratesCoinItem(new FabricItemSettings().group(modItemGroup.modchest).maxCount(16)));
|
||||
new piratesCoinItem(new Item.Settings().maxCount(16)));
|
||||
}
|
||||
|
||||
private static Item registerItem(String name, Item item) { // Methode, die die Items dann letztendlich hinzufügt;
|
||||
// nicht bearbeiten ist eine generische MEthode
|
||||
return Registry.register(Registry.ITEM, new Identifier(REServerMod.MOD_ID, name), item);
|
||||
return Registry.register(Registries.ITEM, Identifier.of(REServerMod.MOD_ID, name), item);
|
||||
}
|
||||
|
||||
public static void registerModItems() {
|
||||
|
|
|
@ -7,9 +7,9 @@ import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
|||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class modNetworkingServer { //Identifier werden eingeführt
|
||||
public static final Identifier request_respawn = new Identifier(REServerMod.MOD_ID, "request_respawn"); //alle Identifier muessen leider IMMER auf Client und Server (doppelt) eingefuehrt werden
|
||||
public static final Identifier start_sleeping_call_buttons = new Identifier(REServerMod.MOD_ID, "start_sleeping_call_buttons");
|
||||
public static final Identifier death_multi_respawn_buttons = new Identifier(REServerMod.MOD_ID, "death_call_respawn_buttons");
|
||||
public static final Identifier request_respawn = Identifier.of(REServerMod.MOD_ID, "request_respawn"); //alle Identifier muessen leider IMMER auf Client und Server (doppelt) eingefuehrt werden
|
||||
public static final Identifier start_sleeping_call_buttons = Identifier.of(REServerMod.MOD_ID, "start_sleeping_call_buttons");
|
||||
public static final Identifier death_multi_respawn_buttons = Identifier.of(REServerMod.MOD_ID, "death_call_respawn_buttons");
|
||||
|
||||
public static void registerS2CPackets() { //Identifier fuer packets werden registriert (Identifier die der Client aufruft um beim Server was auszufuehren)
|
||||
ServerPlayNetworking.registerGlobalReceiver(start_sleeping_call_buttons, setNewRespawnsC2SPacket::receive); //was der Server dann machen soll steht in der receive Methode
|
||||
|
|
Loading…
Reference in New Issue