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
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'java'
id 'idea'
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'fabric-loom' version '1.9-SNAPSHOT'
}

version = project.mod_version
Expand Down 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:build:2.0.69'
implementation 'com.github.WaterMediaTeam:watermedia:2.1.19'

}

Expand All @@ -56,15 +56,15 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
// Minecraft 1.21 (1.20.6) upwards uses Java 21.
it.options.release = 21
}

java {
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

jar {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true

# Fabric Properties
minecraft_version=1.20.1
minecraft_version=1.21.1
mappings_channel=parchment
mappings_version=2023.09.03
loader_version=0.16.0
mappings_version=2024.11.17
loader_version=0.16.10

# Mod Properties
mod_version = 3.0.5
modid = videoplayer
maven_group = com.github.ngoedix
archives_base_name = VideoPlayer-3.0.5-FABRIC-1.20.X
archives_base_name = VideoPlayer-3.0.5-FABRIC-1.21.X

# Dependencies
fabric_version=0.92.1+1.20.1
fabric_version=0.115.0+1.21.1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
5 changes: 3 additions & 2 deletions src/main/java/com/github/NGoedix/videoplayer/VideoPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

public class VideoPlayer implements ModInitializer {

public static final CreativeModeTab VIDEO_PLAYER_TAB = Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, new ResourceLocation("tab"), FabricItemGroup.builder().title(Component.translatable("itemGroup.videoplayer.items"))
public static final CreativeModeTab VIDEO_PLAYER_TAB = Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "tab"), FabricItemGroup.builder().title(Component.translatable("itemGroup.videoplayer.items"))
.icon(() -> new ItemStack(ModBlocks.TV_BLOCK)).displayItems((displayContext, entries) -> {
entries.accept(new ItemStack(ModBlocks.TV_BLOCK));
entries.accept(new ItemStack(ModBlocks.RADIO_BLOCK));
Expand All @@ -31,8 +31,9 @@ public void onInitialize() {

ModBlocks.registerModBlocks();
ModBlockEntities.registerAllBlockEntities();
ArgumentTypeRegistry.registerArgumentType(new ResourceLocation(Reference.MOD_ID, "symbol_string"), SymbolStringArgumentType.class, new SymbolStringArgumentSerializer());
ArgumentTypeRegistry.registerArgumentType(ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "symbol_string"), SymbolStringArgumentType.class, new SymbolStringArgumentSerializer());

PacketHandler.registerPackets();
PacketHandler.registerC2SPackets();

CommandRegistrationCallback.EVENT.register(PlayVideoCommand::register);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.github.NGoedix.videoplayer.VideoPlayer;
import com.github.NGoedix.videoplayer.block.custom.RadioBlock;
import com.github.NGoedix.videoplayer.block.custom.TVBlock;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -30,7 +29,7 @@ public class ModBlocks {
VideoPlayer.VIDEO_PLAYER_TAB);

private static Block registerBlockWithoutBlockItem(String name, Block block, CreativeModeTab group) {
return Registry.register(BuiltInRegistries.BLOCK, new ResourceLocation(Reference.MOD_ID, name), block);
return Registry.register(BuiltInRegistries.BLOCK, ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, name), block);
}

private static ToIntFunction<BlockState> litBlockEmission(int pLightValue) {
Expand All @@ -39,12 +38,12 @@ private static ToIntFunction<BlockState> litBlockEmission(int pLightValue) {

private static Block registerBlock(String name, Block block, CreativeModeTab group) {
registerBlockItem(name, block, group);
return Registry.register(BuiltInRegistries.BLOCK, new ResourceLocation(Reference.MOD_ID, name), block);
return Registry.register(BuiltInRegistries.BLOCK, ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, name), block);
}

private static Item registerBlockItem(String name, Block block, CreativeModeTab group) {
return Registry.register(BuiltInRegistries.ITEM, new ResourceLocation(Reference.MOD_ID, name),
new BlockItem(block, new FabricItemSettings()));
return Registry.register(BuiltInRegistries.ITEM, ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, name),
new BlockItem(block, new Item.Properties()));
}

public static void registerModBlocks() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.github.NGoedix.videoplayer.block.entity.custom.VideoPlayerBlockEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.context.BlockPlaceContext;
Expand Down Expand Up @@ -67,7 +66,7 @@ public boolean isPossibleToRespawnInThis(BlockState state) {
}

@Override
public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHit) {
protected InteractionResult useWithoutItem(BlockState state, Level pLevel, BlockPos pPos, Player pPlayer, BlockHitResult hitResult) {
BlockEntity blockEntity = pLevel.getBlockEntity(pPos);
if (!pLevel.isClientSide) {
if (blockEntity instanceof RadioBlockEntity radioBlockEntity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,25 @@
import com.github.NGoedix.videoplayer.util.math.geo.Facing;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.item.ItemStack;
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.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import org.jetbrains.annotations.Nullable;

public class TVBlock extends Block implements EntityBlock {
Expand Down Expand Up @@ -86,7 +85,7 @@ public boolean useShapeForLightOcclusion(BlockState state) {
}

@Override
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ public class ModBlockEntities {

public static void registerAllBlockEntities() {
TV_BLOCK_ENTITY = Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE,
new ResourceLocation(Reference.MOD_ID, "tv_block_entity"),
ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "tv_block_entity"),
FabricBlockEntityTypeBuilder.create(TVBlockEntity::new,
ModBlocks.TV_BLOCK).build(null));

RADIO_BLOCK_ENTITY = Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE,
new ResourceLocation(Reference.MOD_ID, "radio_block_entity"),
ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "radio_block_entity"),
FabricBlockEntityTypeBuilder.create(TVBlockEntity::new,
ModBlocks.RADIO_BLOCK).build(null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.github.NGoedix.videoplayer.block.entity.ModBlockEntities;
import com.github.NGoedix.videoplayer.network.PacketHandler;
import net.minecraft.core.BlockPos;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerPlayer;
Expand Down Expand Up @@ -48,14 +49,14 @@ public void setBeingUsed(UUID player) {
}

@Override
protected void saveAdditional(CompoundTag pTag) {
super.saveAdditional(pTag);
protected void saveAdditional(CompoundTag pTag, HolderLookup.Provider provider) {
super.saveAdditional(pTag, provider);
pTag.putUUID("beingUsed", playerUsing == null ? new UUID(0, 0) : playerUsing);
}

@Override
public void load(CompoundTag pTag) {
super.load(pTag);
public void loadAdditional(CompoundTag pTag, HolderLookup.Provider provider) {
super.loadAdditional(pTag, provider);

loadFromNBT(pTag);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,20 @@
import com.github.NGoedix.videoplayer.block.custom.TVBlock;
import com.github.NGoedix.videoplayer.block.entity.ModBlockEntities;
import com.github.NGoedix.videoplayer.network.PacketHandler;
import com.github.NGoedix.videoplayer.util.cache.TextureCache;
import com.github.NGoedix.videoplayer.util.displayers.IDisplay;
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 com.github.NGoedix.videoplayer.util.math.geo.Vec3d;
import net.fabricmc.api.Environment;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.HolderLookup;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;

import java.util.UUID;

import static net.fabricmc.api.EnvType.CLIENT;

public class TVBlockEntity extends VideoPlayerBlockEntity {

private UUID playerUsing;
Expand Down Expand Up @@ -60,14 +53,14 @@ public void setBeingUsed(UUID player) {
}

@Override
protected void saveAdditional(CompoundTag nbt) {
super.saveAdditional(nbt);
protected void saveAdditional(CompoundTag nbt, HolderLookup.Provider provider) {
super.saveAdditional(nbt, provider);
nbt.putUUID("beingUsed", playerUsing == null ? new UUID(0, 0) : playerUsing);
}

@Override
public void load(CompoundTag nbt) {
super.load(nbt);
public void loadAdditional(CompoundTag nbt, HolderLookup.Provider provider) {
super.loadAdditional(nbt, provider);

loadFromNBT(nbt);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.core.BlockPos;
import net.minecraft.core.HolderLookup;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.Connection;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
Expand Down Expand Up @@ -116,8 +116,8 @@ public Packet<ClientGamePacketListener> getUpdatePacket() {
}

@Override
public CompoundTag getUpdateTag() {
return this.saveWithFullMetadata();
public CompoundTag getUpdateTag(HolderLookup.Provider registries) {
return this.saveWithFullMetadata(registries);
}

@Override
Expand All @@ -131,8 +131,8 @@ public boolean isClient() {
}

@Override
protected void saveAdditional(CompoundTag pTag) {
super.saveAdditional(pTag);
protected void saveAdditional(CompoundTag pTag, HolderLookup.Provider registries) {
super.saveAdditional(pTag, registries);

pTag.putString("url", url == null ? "" : url);
pTag.putBoolean("playing", playing);
Expand All @@ -141,8 +141,8 @@ protected void saveAdditional(CompoundTag pTag) {
}

@Override
public void load(CompoundTag pTag) {
super.load(pTag);
public void loadAdditional(CompoundTag pTag, HolderLookup.Provider registries) {
super.loadAdditional(pTag, registries);

loadFromNBTInternal(pTag);
loadFromNBT(pTag);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.NGoedix.videoplayer.client;

import com.github.NGoedix.videoplayer.Reference;
import com.github.NGoedix.videoplayer.VideoPlayerUtils;
import com.github.NGoedix.videoplayer.block.entity.ModBlockEntities;
import com.github.NGoedix.videoplayer.block.entity.custom.RadioBlockEntity;
Expand All @@ -9,20 +10,20 @@
import com.github.NGoedix.videoplayer.client.gui.VideoScreen;
import com.github.NGoedix.videoplayer.client.render.TVBlockRenderer;
import com.github.NGoedix.videoplayer.network.PacketHandler;
import com.github.NGoedix.videoplayer.Reference;
import com.github.NGoedix.videoplayer.util.RadioStreams;
import me.srrapero720.watermedia.api.image.ImageAPI;
import me.srrapero720.watermedia.api.image.ImageRenderer;
import me.srrapero720.watermedia.api.player.SyncMusicPlayer;
import me.srrapero720.watermedia.core.tools.JarTool;
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.core.BlockPos;
import net.minecraft.world.level.block.entity.BlockEntity;
import org.watermedia.api.image.ImageAPI;
import org.watermedia.api.image.ImageRenderer;
import org.watermedia.api.player.videolan.MusicPlayer;
import org.watermedia.core.tools.JarTool;

import java.net.URI;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -47,7 +48,7 @@ public class ClientHandler implements ClientModInitializer {
@Environment(EnvType.CLIENT)
public static ImageRenderer step5Image() { return IMG_STEP5; }

private static final List<SyncMusicPlayer> musicPlayers = new ArrayList<>();
private static final List<MusicPlayer> musicPlayers = new ArrayList<>();

@Override
public void onInitializeClient() {
Expand Down Expand Up @@ -103,7 +104,7 @@ public static void stopVideoIfExists(Minecraft client) {
public static void playMusic(Minecraft client, String url, int volume) {
client.execute(() -> {
// Until any callback in SyncMusicPlayer I will check if the music is playing when added other music player
for (SyncMusicPlayer musicPlayer : musicPlayers) {
for (MusicPlayer musicPlayer : musicPlayers) {
if (musicPlayer.isPlaying()) {
musicPlayer.stop();
musicPlayer.release();
Expand All @@ -112,16 +113,16 @@ public static void playMusic(Minecraft client, String url, int volume) {
}

// Add the new player
SyncMusicPlayer musicPlayer = new SyncMusicPlayer();
MusicPlayer musicPlayer = new MusicPlayer();
musicPlayers.add(musicPlayer);
musicPlayer.setVolume(volume);
musicPlayer.start(url);
musicPlayer.start(URI.create(url));
});
}

public static void stopMusicIfPlaying(Minecraft client) {
client.execute(() -> {
for (SyncMusicPlayer musicPlayer : musicPlayers) {
for (MusicPlayer musicPlayer : musicPlayers) {
if (musicPlayer.isPlaying()) {
musicPlayer.stop();
musicPlayer.release();
Expand Down
Loading