From ffc40b123d351978c6f2ab31cd8fa150a9023feb Mon Sep 17 00:00:00 2001 From: Vedvod <68318644+Vedvod@users.noreply.github.com> Date: Sun, 28 Dec 2025 02:32:59 +1100 Subject: [PATCH 1/5] modify gradle.properties to use mediawater version var --- build.gradle | 4 ++-- gradle.properties | 3 ++- gradle/wrapper/gradle-wrapper.properties | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 14e6e02..33ebae4 100644 --- a/build.gradle +++ b/build.gradle @@ -39,7 +39,7 @@ dependencies { modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - implementation 'com.github.WaterMediaTeam:watermedia:2.1.19' + implementation "com.github.WaterMediaTeam:watermedia:${watermedia_version}" } @@ -71,4 +71,4 @@ jar { from("LICENSE") { rename { "${it}_${base.archivesName.get()}"} } -} +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 5483cc6..fffe3d7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,4 +15,5 @@ maven_group = com.github.ngoedix archives_base_name = VideoPlayer-3.0.5-FABRIC-1.21.X # Dependencies -fabric_version=0.115.0+1.21.1 \ No newline at end of file +fabric_version=0.115.0+1.21.1 +watermedia_version=2.1.37 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 18362b7..ff23a68 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From a6686578cbf0c23d6c2b9caf9b388411872ddfc4 Mon Sep 17 00:00:00 2001 From: Vedvod <68318644+Vedvod@users.noreply.github.com> Date: Sun, 28 Dec 2025 02:59:08 +1100 Subject: [PATCH 2/5] fix scrolling menu recursion bug --- .../videoplayer/client/gui/components/ScrollingList.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/github/NGoedix/videoplayer/client/gui/components/ScrollingList.java b/src/main/java/com/github/NGoedix/videoplayer/client/gui/components/ScrollingList.java index 1391389..9a818df 100644 --- a/src/main/java/com/github/NGoedix/videoplayer/client/gui/components/ScrollingList.java +++ b/src/main/java/com/github/NGoedix/videoplayer/client/gui/components/ScrollingList.java @@ -22,7 +22,7 @@ public void renderWidget(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, flo GL11.glScissor((int)(this.getX() * scale), (int)(Minecraft.getInstance().getWindow().getHeight() - ((this.getY() + this.height) * scale)), (int)(this.width * scale), (int)(this.height * scale)); - super.render(pGuiGraphics, pMouseX, pMouseY, pPartialTick); + super.renderWidget(pGuiGraphics, pMouseX, pMouseY, pPartialTick); GL11.glDisable(GL11.GL_SCISSOR_TEST); } From cbd21a150bd890b0da6f5199fdb9b6e0d9ec01e2 Mon Sep 17 00:00:00 2001 From: Vedvod <68318644+Vedvod@users.noreply.github.com> Date: Sun, 28 Dec 2025 03:00:10 +1100 Subject: [PATCH 3/5] update deprecated function calls --- .../block/entity/ModBlockEntities.java | 29 ++++++++++--------- .../videoplayer/client/ClientHandler.java | 4 +-- .../util/displayers/VideoDisplayer.java | 14 ++++----- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/github/NGoedix/videoplayer/block/entity/ModBlockEntities.java b/src/main/java/com/github/NGoedix/videoplayer/block/entity/ModBlockEntities.java index 9831726..1a99f58 100644 --- a/src/main/java/com/github/NGoedix/videoplayer/block/entity/ModBlockEntities.java +++ b/src/main/java/com/github/NGoedix/videoplayer/block/entity/ModBlockEntities.java @@ -3,26 +3,29 @@ import com.github.NGoedix.videoplayer.Reference; import com.github.NGoedix.videoplayer.block.ModBlocks; import com.github.NGoedix.videoplayer.block.entity.custom.TVBlockEntity; -import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.entity.BlockEntityType; + public class ModBlockEntities { - public static BlockEntityType TV_BLOCK_ENTITY; - public static BlockEntityType RADIO_BLOCK_ENTITY; - public static BlockEntityType HAND_RADIO_BLOCK_ENTITY; + public static final BlockEntityType TV_BLOCK_ENTITY = registerBlockEntity("radio_block_entity"); + public static final BlockEntityType RADIO_BLOCK_ENTITY = registerBlockEntity("tv_block_entity"); + // public static BlockEntityType HAND_RADIO_BLOCK_ENTITY; - public static void registerAllBlockEntities() { - TV_BLOCK_ENTITY = Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, - ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "tv_block_entity"), - FabricBlockEntityTypeBuilder.create(TVBlockEntity::new, - ModBlocks.TV_BLOCK).build(null)); + private static BlockEntityType registerBlockEntity(String name) { + return Registry.register( + BuiltInRegistries.BLOCK_ENTITY_TYPE, + ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, name), + BlockEntityType.Builder.of( + TVBlockEntity::new, + ModBlocks.RADIO_BLOCK + ).build() + ); + } - RADIO_BLOCK_ENTITY = Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, - ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "radio_block_entity"), - FabricBlockEntityTypeBuilder.create(TVBlockEntity::new, - ModBlocks.RADIO_BLOCK).build(null)); + public static void registerAllBlockEntities() { + // init } } diff --git a/src/main/java/com/github/NGoedix/videoplayer/client/ClientHandler.java b/src/main/java/com/github/NGoedix/videoplayer/client/ClientHandler.java index bf909ed..175e5fb 100644 --- a/src/main/java/com/github/NGoedix/videoplayer/client/ClientHandler.java +++ b/src/main/java/com/github/NGoedix/videoplayer/client/ClientHandler.java @@ -14,8 +14,8 @@ import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.client.rendering.v1.BlockEntityRendererRegistry; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; import net.minecraft.core.BlockPos; import net.minecraft.world.level.block.entity.BlockEntity; import org.watermedia.api.image.ImageAPI; @@ -61,7 +61,7 @@ public void onInitializeClient() { RadioStreams.prepareRadios(); PacketHandler.registerS2CPackets(); - BlockEntityRendererRegistry.register(ModBlockEntities.TV_BLOCK_ENTITY, TVBlockRenderer::new); + BlockEntityRenderers.register(ModBlockEntities.TV_BLOCK_ENTITY, TVBlockRenderer::new); IMG_PAUSED = ImageAPI.renderer(JarTool.readImage("/pictures/paused.png"), true); IMG_STEP10 = ImageAPI.renderer(JarTool.readImage("/pictures/step10.png"), true); diff --git a/src/main/java/com/github/NGoedix/videoplayer/util/displayers/VideoDisplayer.java b/src/main/java/com/github/NGoedix/videoplayer/util/displayers/VideoDisplayer.java index f5364b0..95762bb 100644 --- a/src/main/java/com/github/NGoedix/videoplayer/util/displayers/VideoDisplayer.java +++ b/src/main/java/com/github/NGoedix/videoplayer/util/displayers/VideoDisplayer.java @@ -50,7 +50,7 @@ public static IDisplay createVideoDisplay(Vec3d pos, String url, float volume, f return TryCore.withReturn((defaultVar) -> { VideoDisplayer display = new VideoDisplayer(pos, url, volume, minDistance, maxDistance, loop, isOnlyMusic); - if (display.player.raw() == null) throw new IllegalStateException("VideoDisplayer uses a broken player"); + if (display.player.isBroken()) throw new IllegalStateException("VideoDisplayer uses a broken player"); OPEN_DISPLAYS.add(display); return display; }, cache.ready() ? (IDisplay) new ImageDisplayer(cache.getPicture()) : null); @@ -158,16 +158,16 @@ public int maxTick() { public int prepare(String url, boolean playing, boolean loop, int tick) { if (player == null) return -1; this.url = url; - if (player instanceof VideoPlayer) - return ((VideoPlayer) player).preRender(); + if (player instanceof VideoPlayer videoplayer) + return videoplayer.texture(); return 0; } @Override public int getRenderTexture() { - if (player instanceof VideoPlayer) - return ((VideoPlayer) player).preRender(); + if (player instanceof VideoPlayer videoplayer) + return videoplayer.texture(); return 0; } @@ -212,8 +212,8 @@ public void resume(int tick) { @Override public Dimension getDimensions() { if (player == null) return null; - if (player instanceof VideoPlayer) - return ((VideoPlayer) player).dimension(); + if (player instanceof VideoPlayer videoplayer) + return videoplayer.dimension(); return null; } From fa649768bbf2b5a71399aa8bbd847bf519a1f401 Mon Sep 17 00:00:00 2001 From: Vedvod <68318644+Vedvod@users.noreply.github.com> Date: Sun, 28 Dec 2025 03:00:28 +1100 Subject: [PATCH 4/5] register radio message packet --- .../com/github/NGoedix/videoplayer/network/PacketHandler.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/github/NGoedix/videoplayer/network/PacketHandler.java b/src/main/java/com/github/NGoedix/videoplayer/network/PacketHandler.java index daf4b0c..a8829d2 100644 --- a/src/main/java/com/github/NGoedix/videoplayer/network/PacketHandler.java +++ b/src/main/java/com/github/NGoedix/videoplayer/network/PacketHandler.java @@ -24,6 +24,7 @@ public static void registerPackets() { PayloadTypeRegistry.playS2C().register(StopCustomVideoMessage.TYPE, StopCustomVideoMessage.CODEC); PayloadTypeRegistry.playS2C().register(StartMusicMessage.TYPE, StartMusicMessage.CODEC); PayloadTypeRegistry.playS2C().register(StopMusicMessage.TYPE, StopMusicMessage.CODEC); + PayloadTypeRegistry.playS2C().register(RadioMessage.TYPE, RadioMessage.CODEC); } public static void registerC2SPackets() { @@ -41,6 +42,7 @@ public static void registerS2CPackets() { ClientPlayNetworking.registerGlobalReceiver(StopVideoMessage.TYPE, StopVideoMessage::handle); ClientPlayNetworking.registerGlobalReceiver(StopCustomVideoMessage.TYPE, StopCustomVideoMessage::handle); ClientPlayNetworking.registerGlobalReceiver(StopMusicMessage.TYPE, StopMusicMessage::handle); + ClientPlayNetworking.registerGlobalReceiver(RadioMessage.TYPE, RadioMessage::handle); } // SEND MESSAGES S2C From 78aae461d6f1641ff1ceb2c744fb8262faab7592 Mon Sep 17 00:00:00 2001 From: Vedvod <68318644+Vedvod@users.noreply.github.com> Date: Sun, 28 Dec 2025 03:00:34 +1100 Subject: [PATCH 5/5] general refactor --- .../videoplayer/block/custom/TVBlock.java | 14 +++++++++---- .../block/entity/custom/TVBlockEntity.java | 1 + .../videoplayer/client/gui/RadioScreen.java | 20 +++++++++---------- .../videoplayer/client/gui/TVVideoScreen.java | 13 ++++++------ .../gui/components/ScrollingStringList.java | 1 + .../commands/StopVideoCommand.java | 1 + .../videoplayer/util/math/geo/VecNd.java | 4 ++-- .../videoplayer/util/math/geo/VecNf.java | 4 ++-- 8 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/github/NGoedix/videoplayer/block/custom/TVBlock.java b/src/main/java/com/github/NGoedix/videoplayer/block/custom/TVBlock.java index e98036a..f156a76 100644 --- a/src/main/java/com/github/NGoedix/videoplayer/block/custom/TVBlock.java +++ b/src/main/java/com/github/NGoedix/videoplayer/block/custom/TVBlock.java @@ -3,6 +3,7 @@ import com.github.NGoedix.videoplayer.block.entity.custom.TVBlockEntity; import com.github.NGoedix.videoplayer.util.math.geo.AlignedBox; import com.github.NGoedix.videoplayer.util.math.geo.Facing; + import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.InteractionResult; @@ -12,7 +13,12 @@ import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.*; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.EntityBlock; +import net.minecraft.world.level.block.HorizontalDirectionalBlock; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.RedstoneTorchBlock; +import net.minecraft.world.level.block.Rotation; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; @@ -24,6 +30,7 @@ import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; + import org.jetbrains.annotations.Nullable; public class TVBlock extends Block implements EntityBlock { @@ -87,11 +94,10 @@ public boolean useShapeForLightOcclusion(BlockState state) { @Override protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hitResult) { BlockEntity blockEntity = world.getBlockEntity(pos); - if (!world.isClientSide) { - if (blockEntity instanceof TVBlockEntity tvBlockEntity) { + if (!world.isClientSide && blockEntity instanceof TVBlockEntity tvBlockEntity) { tvBlockEntity.tryOpen(world, pos, player); } - } + return InteractionResult.SUCCESS; } diff --git a/src/main/java/com/github/NGoedix/videoplayer/block/entity/custom/TVBlockEntity.java b/src/main/java/com/github/NGoedix/videoplayer/block/entity/custom/TVBlockEntity.java index 7d29f42..b3da145 100644 --- a/src/main/java/com/github/NGoedix/videoplayer/block/entity/custom/TVBlockEntity.java +++ b/src/main/java/com/github/NGoedix/videoplayer/block/entity/custom/TVBlockEntity.java @@ -6,6 +6,7 @@ import com.github.NGoedix.videoplayer.util.math.geo.AlignedBox; import com.github.NGoedix.videoplayer.util.math.geo.Axis; import com.github.NGoedix.videoplayer.util.math.geo.Facing; + import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.HolderLookup; diff --git a/src/main/java/com/github/NGoedix/videoplayer/client/gui/RadioScreen.java b/src/main/java/com/github/NGoedix/videoplayer/client/gui/RadioScreen.java index d69268d..efece93 100644 --- a/src/main/java/com/github/NGoedix/videoplayer/client/gui/RadioScreen.java +++ b/src/main/java/com/github/NGoedix/videoplayer/client/gui/RadioScreen.java @@ -32,22 +32,23 @@ public class RadioScreen extends Screen { private static final ResourceLocation PAUSE_BUTTON_TEXTURE = ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "textures/gui/pause_button.png"); private static final ResourceLocation PAUSE_HOVER_BUTTON_TEXTURE = ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "textures/gui/pause_button_hover.png"); - private ScrollingStringList countryList, stationList; - private EditBox urlField; - private CustomSlider volumeSlider; + + private ScrollingStringList stationList; private ImageButtonHoverable playButton; + private CustomSlider volumeSlider; + private ScrollingStringList countryList; + private EditBox urlField; private ImageButtonHoverable pauseButton; // Control private final RadioBlockEntity be; - private final ItemStack item; private String url; private int volume; private boolean ready = false; // GUI - private final int imageWidth = 256; - private final int imageHeight = 256; + private static final int imageWidth = 256; + private static final int imageHeight = 256; private int leftPos; private int topPos; @@ -56,7 +57,6 @@ public class RadioScreen extends Screen { public RadioScreen(BlockEntity be) { super(Component.translatable("gui.radio_screen.title")); this.be = (RadioBlockEntity) be; - this.item = null; this.url = this.be.getUrl(); this.volume = this.be.getVolume(); } @@ -64,7 +64,6 @@ public RadioScreen(BlockEntity be) { public RadioScreen(ItemStack item) { super(Component.translatable("gui.radio_screen.title")); this.be = null; - this.item = item; // this.url = HandRadioItem.getUrl(item); // this.volume = HandRadioItem.getVolume(item); @@ -96,10 +95,9 @@ protected void init() { addRenderableWidget(urlField = new EditBox(font, leftPos + 12, height / 2 - 30, imageWidth - 28, 20, Component.literal(""))); urlField.setResponder(text -> { if (!ready) return; - if (countryList.getSelectedText().equals("Custom")) { - if (text.matches(urlPattern)) + if (countryList.getSelectedText().equals("Custom") && text.matches(urlPattern)) sendUpdate(urlField.getValue(), volume, true, 0, false); - } + }); urlField.setEditable(countryList.getSelectedText().equals("Custom")); urlField.setMaxLength(32767); diff --git a/src/main/java/com/github/NGoedix/videoplayer/client/gui/TVVideoScreen.java b/src/main/java/com/github/NGoedix/videoplayer/client/gui/TVVideoScreen.java index d95859d..0a9b3d1 100644 --- a/src/main/java/com/github/NGoedix/videoplayer/client/gui/TVVideoScreen.java +++ b/src/main/java/com/github/NGoedix/videoplayer/client/gui/TVVideoScreen.java @@ -49,12 +49,12 @@ public class TVVideoScreen extends Screen { private int volume; private long maxDuration; - private final int videoWidth = 200; - private final int videoHeight = 150; + private static final int videoWidth = 200; + private static final int videoHeight = 150; // GUI - private final int imageWidth = 256; - private final int imageHeight = 256; + private static final int imageWidth = 256; + private static final int imageHeight = 256; private int leftPos; private int topPos; @@ -88,8 +88,7 @@ protected void init() { urlBox.setResponder(s -> { if (s != null && !s.isEmpty()) { urlBox.setSuggestion(""); - if (s.matches(urlPattern) && (be.getTick() > 5 || url.isEmpty())) { - if (!url.equals(s)) { + if (s.matches(urlPattern) && (be.getTick() > 5 || url.isEmpty()) && !url.equals(s)) { be.setTick(0); url = s; PacketHandler.sendC2SVideoUpdateMessage(be.getBlockPos(), url, volume, 0, true, false, false); @@ -102,7 +101,7 @@ protected void init() { be.requestDisplay().stop(); be.requestDisplay().resume(0); } - } + } else { urlBox.setSuggestion("https://youtube.com/watch?v=FUIcBBM5-xQ"); } diff --git a/src/main/java/com/github/NGoedix/videoplayer/client/gui/components/ScrollingStringList.java b/src/main/java/com/github/NGoedix/videoplayer/client/gui/components/ScrollingStringList.java index 94a822c..d05ddb7 100644 --- a/src/main/java/com/github/NGoedix/videoplayer/client/gui/components/ScrollingStringList.java +++ b/src/main/java/com/github/NGoedix/videoplayer/client/gui/components/ScrollingStringList.java @@ -2,6 +2,7 @@ import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.AbstractSelectionList.Entry; import java.awt.*; import java.util.List; diff --git a/src/main/java/com/github/NGoedix/videoplayer/commands/StopVideoCommand.java b/src/main/java/com/github/NGoedix/videoplayer/commands/StopVideoCommand.java index 2c3f357..605c99f 100644 --- a/src/main/java/com/github/NGoedix/videoplayer/commands/StopVideoCommand.java +++ b/src/main/java/com/github/NGoedix/videoplayer/commands/StopVideoCommand.java @@ -5,6 +5,7 @@ import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; + import net.minecraft.commands.CommandBuildContext; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; diff --git a/src/main/java/com/github/NGoedix/videoplayer/util/math/geo/VecNd.java b/src/main/java/com/github/NGoedix/videoplayer/util/math/geo/VecNd.java index 98d9dab..d14abcc 100644 --- a/src/main/java/com/github/NGoedix/videoplayer/util/math/geo/VecNd.java +++ b/src/main/java/com/github/NGoedix/videoplayer/util/math/geo/VecNd.java @@ -1,7 +1,7 @@ package com.github.NGoedix.videoplayer.util.math.geo; -public abstract class VecNd { - public VecNd() { +public abstract class VecNd> { + protected VecNd() { } public abstract void set(T var1); diff --git a/src/main/java/com/github/NGoedix/videoplayer/util/math/geo/VecNf.java b/src/main/java/com/github/NGoedix/videoplayer/util/math/geo/VecNf.java index 1837838..de1c579 100644 --- a/src/main/java/com/github/NGoedix/videoplayer/util/math/geo/VecNf.java +++ b/src/main/java/com/github/NGoedix/videoplayer/util/math/geo/VecNf.java @@ -1,7 +1,7 @@ package com.github.NGoedix.videoplayer.util.math.geo; -public abstract class VecNf { - public VecNf() { +public abstract class VecNf> { + protected VecNf() { } public abstract void set(T var1);