diff --git a/TODO b/TODO.md similarity index 51% rename from TODO rename to TODO.md index d35572a..5f2ff0d 100644 --- a/TODO +++ b/TODO.md @@ -1,3 +1,19 @@ +# Блоки и функционал +## Высокий приоритет +Это критично прямо сейчас +* Добавить коричневые, жёлтые, красные и зелёные блоки. +* Сделать datagen для ступеней и полублоков, затем добавить их + +## Средний приоритет +Нужно до 1.0, но не полностью ломает мод +* Механика окон +* Двери с ключами +* Духовка + +## Низкий приоритет +* Терминал + + === ADD BLOCKS/FEATURES === * Add brown+yellow+red+green blocks * Add slab and stair variations @@ -17,4 +33,6 @@ * Good README.md and icon, assets, screenshots etc. === ACHIEVEMENTS === -Kolkhoz warrior - kill a zombie, skeleton, creeper and spider with a sickle \ No newline at end of file +Kolkhoz warrior - kill a zombie, skeleton, creeper and spider with a sickle + +=== Блоки и функционал === diff --git a/media/NSElogo.png b/media/NSElogo.png new file mode 100644 index 0000000..0260f1d Binary files /dev/null and b/media/NSElogo.png differ diff --git a/media/nse_scr1.png b/media/nse_scr1.png new file mode 100644 index 0000000..6ff6d2d Binary files /dev/null and b/media/nse_scr1.png differ diff --git a/media/nse_scr2.png b/media/nse_scr2.png new file mode 100644 index 0000000..2e615d0 Binary files /dev/null and b/media/nse_scr2.png differ diff --git a/media/nse_scr3.png b/media/nse_scr3.png new file mode 100644 index 0000000..c2d596d Binary files /dev/null and b/media/nse_scr3.png differ diff --git a/src/client/java/su/a71/new_soviet/NewSovietClient.java b/src/client/java/su/a71/new_soviet/NewSovietClient.java index 8891aa0..d9f090f 100644 --- a/src/client/java/su/a71/new_soviet/NewSovietClient.java +++ b/src/client/java/su/a71/new_soviet/NewSovietClient.java @@ -4,7 +4,9 @@ import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; +import net.fabricmc.fabric.api.client.rendering.v1.BlockEntityRendererRegistry; import net.minecraft.client.render.RenderLayer; +import su.a71.new_soviet.entity.TVBlockEntity; import su.a71.new_soviet.registration.NSE_Blocks; import su.a71.new_soviet.registration.NSE_Custom; @@ -17,5 +19,7 @@ public class NewSovietClient implements ClientModInitializer { BlockRenderLayerMap.INSTANCE.putBlock(NSE_Custom.LAMP, RenderLayer.getCutout()); BlockRenderLayerMap.INSTANCE.putBlock(NSE_Custom.CEILING_FAN, RenderLayer.getCutout()); BlockRenderLayerMap.INSTANCE.putBlock(NSE_Custom.SIREN, RenderLayer.getCutout()); + + BlockEntityRendererRegistry.register(NSE_Custom.TV_BLOCK_ENTITY, TVBlockEntityRenderer::new); } } \ No newline at end of file diff --git a/src/client/java/su/a71/new_soviet/TVBlockEntityRenderer.java b/src/client/java/su/a71/new_soviet/TVBlockEntityRenderer.java new file mode 100644 index 0000000..4ce9e74 --- /dev/null +++ b/src/client/java/su/a71/new_soviet/TVBlockEntityRenderer.java @@ -0,0 +1,22 @@ +package su.a71.new_soviet; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.block.entity.BlockEntityRenderer; +import net.minecraft.client.render.block.entity.BlockEntityRendererFactory; +import net.minecraft.client.util.math.MatrixStack; +import su.a71.new_soviet.entity.TVBlockEntity; + +@Environment(EnvType.CLIENT) +public class TVBlockEntityRenderer implements BlockEntityRenderer { + public TVBlockEntityRenderer(BlockEntityRendererFactory.Context ctx) {} + + @Override + public void render(TVBlockEntity blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) { + matrices.push(); +// Rendering stuff here + matrices.pop(); + } +} \ No newline at end of file diff --git a/src/main/java/su/a71/new_soviet/DataGeneration.java b/src/main/java/su/a71/new_soviet/DataGeneration.java index 56ce225..7bbcf1b 100644 --- a/src/main/java/su/a71/new_soviet/DataGeneration.java +++ b/src/main/java/su/a71/new_soviet/DataGeneration.java @@ -24,7 +24,6 @@ import net.minecraft.registry.RegistryWrapper; import net.minecraft.registry.tag.BlockTags; import net.minecraft.util.Util; import su.a71.new_soviet.registration.NSE_Blocks; -import su.a71.new_soviet.registration.NSE_Combat; import su.a71.new_soviet.registration.NSE_Custom; import su.a71.new_soviet.registration.NSE_Items; @@ -689,6 +688,7 @@ public class DataGeneration implements DataGeneratorEntrypoint { @Override public void generateBlockStateModels(BlockStateModelGenerator blockStateModelGenerator) { +// BlockStateModelGenerator.createStairsBlockState(NSE_Blocks.SAND_TILES_STAIRS, new Identifier(NewSoviet.MOD_ID, "sand_tiles_stairs")); } @Override diff --git a/src/main/java/su/a71/new_soviet/NewSoviet.java b/src/main/java/su/a71/new_soviet/NewSoviet.java index f376093..9cbc39a 100644 --- a/src/main/java/su/a71/new_soviet/NewSoviet.java +++ b/src/main/java/su/a71/new_soviet/NewSoviet.java @@ -8,7 +8,6 @@ import net.minecraft.util.math.random.Random; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import su.a71.new_soviet.registration.NSE_Blocks; -import su.a71.new_soviet.registration.NSE_Combat; import su.a71.new_soviet.registration.NSE_Custom; import su.a71.new_soviet.registration.NSE_Items; @@ -31,6 +30,5 @@ public class NewSoviet implements ModInitializer { NSE_Blocks.initFlame(); NSE_Items.init(); NSE_Custom.init(); - NSE_Combat.init(); } } \ No newline at end of file diff --git a/src/main/java/su/a71/new_soviet/blocks/TVBlock.java b/src/main/java/su/a71/new_soviet/blocks/TVBlock.java index a35c639..13976c1 100644 --- a/src/main/java/su/a71/new_soviet/blocks/TVBlock.java +++ b/src/main/java/su/a71/new_soviet/blocks/TVBlock.java @@ -1,7 +1,7 @@ package su.a71.new_soviet.blocks; -import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.block.*; +import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.piston.PistonBehavior; import net.minecraft.item.ItemPlacementContext; import net.minecraft.sound.BlockSoundGroup; @@ -12,14 +12,14 @@ import net.minecraft.util.math.Direction; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; import net.minecraft.world.BlockView; +import su.a71.new_soviet.entity.TVBlockEntity; -public class TVBlock extends HorizontalFacingBlock { +public class TVBlock extends HorizontalFacingBlock implements BlockEntityProvider { public TVBlock(AbstractBlock.Settings settings) { - super(settings.sounds(BlockSoundGroup.METAL).pistonBehavior(PistonBehavior.DESTROY).strength(1f, 2f)); + super(settings.sounds(BlockSoundGroup.METAL).pistonBehavior(PistonBehavior.BLOCK).strength(1f, 2f)); setDefaultState(getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH)); } - @Override protected void appendProperties(StateManager.Builder builder) { builder.add(Properties.HORIZONTAL_FACING); @@ -39,4 +39,9 @@ public class TVBlock extends HorizontalFacingBlock { public BlockState getPlacementState(ItemPlacementContext ctx) { return super.getPlacementState(ctx).with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite()); } + + @Override + public BlockEntity createBlockEntity(BlockPos pos, BlockState state) { + return new TVBlockEntity(pos, state); + } } \ No newline at end of file diff --git a/src/main/java/su/a71/new_soviet/entity/TVBlockEntity.java b/src/main/java/su/a71/new_soviet/entity/TVBlockEntity.java new file mode 100644 index 0000000..1d27136 --- /dev/null +++ b/src/main/java/su/a71/new_soviet/entity/TVBlockEntity.java @@ -0,0 +1,71 @@ +package su.a71.new_soviet.entity; + +import io.netty.channel.unix.Errors; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.network.listener.ClientPlayPacketListener; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; +import net.minecraft.util.math.BlockPos; +import org.jetbrains.annotations.Nullable; +import su.a71.new_soviet.registration.NSE_Custom; + +import java.util.Arrays; + +public class TVBlockEntity extends BlockEntity { + /* + Digit Color + 0 black + 1 red + 2 green + 3 yellow + 4 blue + 5 magenta + 6 cyan + 7 white + */ + public int[][] display; + public int DISPLAY_SIZE = 8; // The monitor is 8x8 + public TVBlockEntity(BlockPos pos, BlockState state) { + super(NSE_Custom.TV_BLOCK_ENTITY, pos, state); + display = new int[8][8]; + Arrays.fill(display, new int[]{0, 0, 0, 0, 0, 0, 0, 0}); + } + + public int getPixel(int x, int y) { + if (x > 7 || y > 7 || x < 0 || y < 0) { + throw new IndexOutOfBoundsException("Coordinates must be within 0-7 range"); + } + return display[x][y]; + } + + @Override + protected void writeNbt(NbtCompound nbt) { + for (int i = 0; i < DISPLAY_SIZE; i++) { + nbt.putIntArray("display_row_" + i, display[i]); + } + super.writeNbt(nbt); + } + + @Override + public void readNbt(NbtCompound nbt) { + super.readNbt(nbt); + display = new int[8][8]; + for (int i = 0; i < DISPLAY_SIZE; i++) { + display[i] = nbt.getIntArray("display_row_" + i); + } + } + + @Nullable + @Override + public Packet toUpdatePacket() { + return BlockEntityUpdateS2CPacket.create(this); + } + + @Override + public NbtCompound toInitialChunkDataNbt() { + return createNbt(); + } +} diff --git a/src/main/java/su/a71/new_soviet/registration/NSE_Combat.java b/src/main/java/su/a71/new_soviet/registration/NSE_Combat.java deleted file mode 100644 index ec8ff8e..0000000 --- a/src/main/java/su/a71/new_soviet/registration/NSE_Combat.java +++ /dev/null @@ -1,48 +0,0 @@ -package su.a71.new_soviet.registration; - -import net.fabricmc.fabric.api.item.v1.FabricItemSettings; -import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; -import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; -import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.minecraft.block.Block; -import net.minecraft.block.MapColor; -import net.minecraft.item.*; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; -import net.minecraft.registry.RegistryKey; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.text.Text; -import net.minecraft.util.Identifier; -import su.a71.new_soviet.NewSoviet; -import su.a71.new_soviet.blocks.*; - -import java.util.Optional; -import java.util.function.Supplier; - -public class NSE_Combat { - - public static final LandMineBlock LANDMINE = new LandMineBlock(FabricBlockSettings.create().mapColor(MapColor.LIGHT_GRAY)); - - private static final ItemGroup NSE_COMBAT_TAB = FabricItemGroup.builder() - .icon(() -> new ItemStack(LANDMINE)) - .displayName(Text.translatable("itemGroup.new_soviet.combat")) - .build(); - - - private static void register(String name, Supplier supplier, ItemGroup tab) { - Registry.register(Registries.BLOCK, new Identifier(NewSoviet.MOD_ID, name), supplier.get()); - BlockItem blockItem = new BlockItem(supplier.get(), new FabricItemSettings()); - Registry.register(Registries.ITEM, new Identifier(NewSoviet.MOD_ID, name), blockItem); - - Optional> key = Registries.ITEM_GROUP.getKey(tab); - key.ifPresent(itemGroupRegistryKey -> ItemGroupEvents.modifyEntriesEvent(itemGroupRegistryKey).register(content -> { - content.add(blockItem); - })); - } - - public static void init() { - Registry.register(Registries.ITEM_GROUP, new Identifier("new_soviet", "combat"), NSE_COMBAT_TAB); - register("landmine", () -> LANDMINE, NSE_COMBAT_TAB); - - } -} diff --git a/src/main/java/su/a71/new_soviet/registration/NSE_Custom.java b/src/main/java/su/a71/new_soviet/registration/NSE_Custom.java index 22a08de..31edb3a 100644 --- a/src/main/java/su/a71/new_soviet/registration/NSE_Custom.java +++ b/src/main/java/su/a71/new_soviet/registration/NSE_Custom.java @@ -4,8 +4,10 @@ import net.fabricmc.fabric.api.item.v1.FabricItemSettings; import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; +import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder; import net.minecraft.block.Block; import net.minecraft.block.MapColor; +import net.minecraft.block.entity.BlockEntityType; import net.minecraft.item.BlockItem; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; @@ -18,24 +20,31 @@ import net.minecraft.text.Text; import net.minecraft.util.Identifier; import su.a71.new_soviet.NewSoviet; import su.a71.new_soviet.blocks.*; +import su.a71.new_soviet.entity.TVBlockEntity; import java.util.Optional; import java.util.function.Supplier; public class NSE_Custom { - public static final TVBlock TV = new TVBlock(FabricBlockSettings.create().mapColor(MapColor.TERRACOTTA_YELLOW)); public static final TVBlock RED_TV = new TVBlock(FabricBlockSettings.create().mapColor(MapColor.TERRACOTTA_RED)); public static final TVBlock BROWN_TV = new TVBlock(FabricBlockSettings.create().mapColor(MapColor.TERRACOTTA_BROWN)); + public static final BlockEntityType TV_BLOCK_ENTITY = Registry.register( + Registries.BLOCK_ENTITY_TYPE, + new Identifier(NewSoviet.MOD_ID, "tv_block_entity"), + FabricBlockEntityTypeBuilder.create(TVBlockEntity::new, TV, RED_TV, BROWN_TV).build() + ); public static final RadioBlock RADIO = new RadioBlock(); public static final LampBlock LAMP = new LampBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.LANTERN).strength(1f, 1.5f).mapColor(MapColor.WHITE)); public static final LightBulbBlock LIGHT_BULB = new LightBulbBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.GLASS).strength(1f, 1.5f).mapColor(MapColor.WHITE)); - public static final SoundEvent LIGHT_BULB_BROKEN_SOUND = SoundEvent.of(new Identifier("new_soviet", "light_bulb_broken_sound")); + public static final SoundEvent LIGHT_BULB_BROKEN_SOUND = SoundEvent.of(new Identifier(NewSoviet.MOD_ID, "light_bulb_broken_sound")); public static final CeilingFanBlock CEILING_FAN = new CeilingFanBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).strength(1f, 1.5f).mapColor(MapColor.WHITE)); public static final SirenBlock SIREN = new SirenBlock(); - public static final SoundEvent SIREN_SOUND = SoundEvent.of(new Identifier("new_soviet", "siren_sound")); + public static final SoundEvent SIREN_SOUND = SoundEvent.of(new Identifier(NewSoviet.MOD_ID, "siren_sound")); + + public static final LandMineBlock LANDMINE = new LandMineBlock(FabricBlockSettings.create().mapColor(MapColor.LIGHT_GRAY)); private static final ItemGroup NSE_CUSTOM_TAB = FabricItemGroup.builder() .icon(() -> new ItemStack(TV)) @@ -55,7 +64,7 @@ public class NSE_Custom { } public static void init() { - Registry.register(Registries.ITEM_GROUP, new Identifier("new_soviet", "custom"), NSE_CUSTOM_TAB); + Registry.register(Registries.ITEM_GROUP, new Identifier(NewSoviet.MOD_ID, "custom"), NSE_CUSTOM_TAB); register("tv", () -> TV, NSE_CUSTOM_TAB); register("red_tv", () -> RED_TV, NSE_CUSTOM_TAB); register("brown_tv", () -> BROWN_TV, NSE_CUSTOM_TAB); @@ -64,8 +73,9 @@ public class NSE_Custom { register("light_bulb", () -> LIGHT_BULB, NSE_CUSTOM_TAB); register("ceiling_fan", () -> CEILING_FAN, NSE_CUSTOM_TAB); register("siren", () -> SIREN, NSE_CUSTOM_TAB); + register("landmine", () -> LANDMINE, NSE_CUSTOM_TAB); - Registry.register(Registries.SOUND_EVENT, new Identifier("new_soviet", "siren_sound"), SIREN_SOUND); - Registry.register(Registries.SOUND_EVENT, new Identifier("new_soviet", "light_bulb_broken_sound"), LIGHT_BULB_BROKEN_SOUND); + Registry.register(Registries.SOUND_EVENT, new Identifier(NewSoviet.MOD_ID, "siren_sound"), SIREN_SOUND); + Registry.register(Registries.SOUND_EVENT, new Identifier(NewSoviet.MOD_ID, "light_bulb_broken_sound"), LIGHT_BULB_BROKEN_SOUND); } } \ No newline at end of file diff --git a/src/main/resources/assets/new_soviet/lang/en_us.json b/src/main/resources/assets/new_soviet/lang/en_us.json index 47ad64c..a23fb45 100644 --- a/src/main/resources/assets/new_soviet/lang/en_us.json +++ b/src/main/resources/assets/new_soviet/lang/en_us.json @@ -2,7 +2,6 @@ "itemGroup.new_soviet.building_blocks": "Soviet Building Blocks", "itemGroup.new_soviet.items": "Soviet Items", "itemGroup.new_soviet.custom": "Soviet Additions", - "itemGroup.new_soviet.combat": "Soviet Combat", "block.new_soviet.sand_tiles": "Sand Tiles", "block.new_soviet.cracked_sand_tiles": "Cracked Sand Tiles", "block.new_soviet.mossy_sand_tiles": "Mossy Sand Tiles", diff --git a/src/main/resources/assets/new_soviet/textures/item/keys/personal_key_1.png b/src/main/resources/assets/new_soviet/textures/item/keys/personal_key_1.png new file mode 100644 index 0000000..2873d27 Binary files /dev/null and b/src/main/resources/assets/new_soviet/textures/item/keys/personal_key_1.png differ diff --git a/src/main/resources/assets/new_soviet/textures/item/keys/personal_key_2.png b/src/main/resources/assets/new_soviet/textures/item/keys/personal_key_2.png new file mode 100644 index 0000000..2ad5f21 Binary files /dev/null and b/src/main/resources/assets/new_soviet/textures/item/keys/personal_key_2.png differ diff --git a/src/main/resources/assets/new_soviet/textures/item/keys/personal_key_3.png b/src/main/resources/assets/new_soviet/textures/item/keys/personal_key_3.png new file mode 100644 index 0000000..0abe18c Binary files /dev/null and b/src/main/resources/assets/new_soviet/textures/item/keys/personal_key_3.png differ diff --git a/src/main/resources/assets/new_soviet/textures/item/keys/personal_key_4.png b/src/main/resources/assets/new_soviet/textures/item/keys/personal_key_4.png new file mode 100644 index 0000000..4602412 Binary files /dev/null and b/src/main/resources/assets/new_soviet/textures/item/keys/personal_key_4.png differ diff --git a/src/main/resources/assets/new_soviet/textures/item/keys/personal_key_5.png b/src/main/resources/assets/new_soviet/textures/item/keys/personal_key_5.png new file mode 100644 index 0000000..a49f6bc Binary files /dev/null and b/src/main/resources/assets/new_soviet/textures/item/keys/personal_key_5.png differ