Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

}

Expand Down Expand Up @@ -71,4 +71,4 @@ jar {
from("LICENSE") {
rename { "${it}_${base.archivesName.get()}"}
}
}
}
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
fabric_version=0.115.0+1.21.1
watermedia_version=2.1.37
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TVBlockEntity> TV_BLOCK_ENTITY;
public static BlockEntityType<TVBlockEntity> RADIO_BLOCK_ENTITY;
public static BlockEntityType<TVBlockEntity> HAND_RADIO_BLOCK_ENTITY;
public static final BlockEntityType<TVBlockEntity> TV_BLOCK_ENTITY = registerBlockEntity("radio_block_entity");
public static final BlockEntityType<TVBlockEntity> RADIO_BLOCK_ENTITY = registerBlockEntity("tv_block_entity");
// public static BlockEntityType<TVBlockEntity> 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<TVBlockEntity> 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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -56,15 +57,13 @@ 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();
}

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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -102,7 +101,7 @@ protected void init() {
be.requestDisplay().stop();
be.requestDisplay().resume(0);
}
}

} else {
urlBox.setSuggestion("https://youtube.com/watch?v=FUIcBBM5-xQ");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.NGoedix.videoplayer.util.math.geo;

public abstract class VecNd<T extends VecNd> {
public VecNd() {
public abstract class VecNd<T extends VecNd<T>> {
protected VecNd() {
}

public abstract void set(T var1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.NGoedix.videoplayer.util.math.geo;

public abstract class VecNf<T extends VecNf> {
public VecNf() {
public abstract class VecNf<T extends VecNf<T>> {
protected VecNf() {
}

public abstract void set(T var1);
Expand Down