-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
476 additions
and
566 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,5 +24,6 @@ build | |
eclipse | ||
run_client | ||
run_server | ||
run_test | ||
*.txt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pluginManagement.repositories { | ||
gradlePluginPortal() | ||
maven { url = 'https://maven.minecraftforge.net/' } | ||
} | ||
|
||
rootProject.name = 'SlideShow' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.teacon.slides; | ||
|
||
import net.minecraft.FieldsAreNonnullByDefault; | ||
import net.minecraft.MethodsReturnNonnullByDefault; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.screens.MenuScreens; | ||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; | ||
import net.minecraftforge.api.distmarker.Dist; | ||
import net.minecraftforge.client.event.RegisterGuiOverlaysEvent; | ||
import net.minecraftforge.client.gui.overlay.VanillaGuiOverlay; | ||
import net.minecraftforge.event.TickEvent; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; | ||
import org.teacon.slides.projector.ProjectorScreen; | ||
import org.teacon.slides.renderer.ProjectorRenderer; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.ParametersAreNonnullByDefault; | ||
|
||
@FieldsAreNonnullByDefault | ||
@MethodsReturnNonnullByDefault | ||
@ParametersAreNonnullByDefault | ||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) | ||
public final class ClientRegistries { | ||
public static final boolean IS_OPTIFINE_LOADED = isOptifineLoaded(); | ||
|
||
private static boolean isOptifineLoaded() { | ||
try { | ||
Class.forName("optifine.Installer"); | ||
return true; | ||
} catch (ClassNotFoundException ignored) { | ||
return false; | ||
} | ||
} | ||
|
||
@SubscribeEvent | ||
public static void setupClient(final FMLClientSetupEvent event) { | ||
SlideShow.LOGGER.info("Optifine loaded: {}", IS_OPTIFINE_LOADED); | ||
MenuScreens.register(ModRegistries.MENU.get(), ProjectorScreen::new); | ||
BlockEntityRenderers.register(ModRegistries.BLOCK_ENTITY.get(), ProjectorRenderer.INSTANCE::onCreate); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package org.teacon.slides; | ||
|
||
import net.minecraft.FieldsAreNonnullByDefault; | ||
import net.minecraft.MethodsReturnNonnullByDefault; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.inventory.MenuType; | ||
import net.minecraft.world.level.block.entity.BlockEntityType; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; | ||
import net.minecraftforge.network.NetworkDirection; | ||
import net.minecraftforge.network.NetworkRegistry; | ||
import net.minecraftforge.network.simple.SimpleChannel; | ||
import net.minecraftforge.registries.ForgeRegistries; | ||
import net.minecraftforge.registries.RegisterEvent; | ||
import net.minecraftforge.registries.RegistryObject; | ||
import net.minecraftforge.server.permission.events.PermissionGatherEvent; | ||
import net.minecraftforge.server.permission.nodes.PermissionNode; | ||
import net.minecraftforge.server.permission.nodes.PermissionTypes; | ||
import org.teacon.slides.projector.*; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; | ||
import java.util.Optional; | ||
|
||
@FieldsAreNonnullByDefault | ||
@MethodsReturnNonnullByDefault | ||
@ParametersAreNonnullByDefault | ||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) | ||
public final class ModRegistries { | ||
/** | ||
* The networking channel version. Since we follow SemVer, this is | ||
* always the same as the MAJOR version of the mod version. | ||
*/ | ||
// Remember to update the network version when MAJOR is bumped | ||
// Last Update: Thu, 17 Dec 2020 15:00:00 +0800 (0 => 1) | ||
// Last Update: Tue, 18 Jan 2022 20:00:00 +0800 (1 => 2) | ||
// Last Update: Sun, 26 Mar 2023 22:00:00 +0800 (2 => 3) | ||
public static final String NETWORK_VERSION = "2"; | ||
|
||
public static final ResourceLocation PROJECTOR_ID = new ResourceLocation(SlideShow.ID, "projector"); | ||
|
||
public static final ResourceLocation CHANNEL_ID = new ResourceLocation(SlideShow.ID, "network"); | ||
|
||
public static final PermissionNode<Boolean> INTERACT_PERM; | ||
|
||
public static final SimpleChannel CHANNEL; | ||
|
||
public static final RegistryObject<ProjectorBlock> PROJECTOR; | ||
|
||
public static final RegistryObject<BlockEntityType<ProjectorBlockEntity>> BLOCK_ENTITY; | ||
|
||
public static final RegistryObject<MenuType<ProjectorContainerMenu>> MENU; | ||
|
||
static { | ||
// FIXME: permission resolving | ||
INTERACT_PERM = new PermissionNode<>(SlideShow.ID, "interact.projector", | ||
PermissionTypes.BOOLEAN, (player, playerUUID, context) -> true); | ||
CHANNEL = NetworkRegistry.newSimpleChannel(CHANNEL_ID, | ||
() -> NETWORK_VERSION, NETWORK_VERSION::equals, NETWORK_VERSION::equals); | ||
PROJECTOR = RegistryObject.create(PROJECTOR_ID, ForgeRegistries.BLOCKS); | ||
BLOCK_ENTITY = RegistryObject.create(PROJECTOR_ID, ForgeRegistries.BLOCK_ENTITY_TYPES); | ||
MENU = RegistryObject.create(PROJECTOR_ID, ForgeRegistries.MENU_TYPES); | ||
} | ||
|
||
@SubscribeEvent | ||
public static void register(final RegisterEvent event) { | ||
event.register(ForgeRegistries.BLOCKS.getRegistryKey(), PROJECTOR_ID, ProjectorBlock::new); | ||
event.register(ForgeRegistries.ITEMS.getRegistryKey(), PROJECTOR_ID, ProjectorItem::new); | ||
event.register(ForgeRegistries.BLOCK_ENTITY_TYPES.getRegistryKey(), PROJECTOR_ID, ProjectorBlockEntity::create); | ||
event.register(ForgeRegistries.MENU_TYPES.getRegistryKey(), PROJECTOR_ID, ProjectorContainerMenu::create); | ||
} | ||
|
||
@SubscribeEvent | ||
public static void setupCommon(final FMLCommonSetupEvent event) { | ||
// register network channel | ||
int index = 0; | ||
// noinspection UnusedAssignment | ||
CHANNEL.registerMessage(index++, | ||
ProjectorUpdatePacket.class, | ||
ProjectorUpdatePacket::write, | ||
ProjectorUpdatePacket::new, | ||
ProjectorUpdatePacket::handle, | ||
Optional.of(NetworkDirection.PLAY_TO_SERVER)); | ||
// register permission node | ||
MinecraftForge.EVENT_BUS.addListener(ModRegistries::gatherPermNodes); | ||
} | ||
|
||
private static void gatherPermNodes(final PermissionGatherEvent.Nodes event) { | ||
event.addNodes(INTERACT_PERM); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,141 +1,19 @@ | ||
package org.teacon.slides; | ||
|
||
import com.mojang.datafixers.DSL; | ||
import net.minecraft.client.gui.screens.MenuScreens; | ||
import net.minecraft.client.renderer.ItemBlockRenderTypes; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.inventory.MenuType; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.entity.BlockEntityType; | ||
import net.minecraftforge.api.distmarker.Dist; | ||
import net.minecraftforge.api.distmarker.OnlyIn; | ||
import net.minecraftforge.client.event.ModelRegistryEvent; | ||
import net.minecraftforge.client.event.RegisterShadersEvent; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.common.extensions.IForgeMenuType; | ||
import net.minecraftforge.event.RegistryEvent; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
import net.minecraft.FieldsAreNonnullByDefault; | ||
import net.minecraft.MethodsReturnNonnullByDefault; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; | ||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; | ||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; | ||
import net.minecraftforge.network.NetworkDirection; | ||
import net.minecraftforge.network.NetworkRegistry; | ||
import net.minecraftforge.network.simple.SimpleChannel; | ||
import net.minecraftforge.server.permission.events.PermissionGatherEvent; | ||
import net.minecraftforge.server.permission.nodes.PermissionNode; | ||
import net.minecraftforge.server.permission.nodes.PermissionTypes; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.teacon.slides.projector.*; | ||
import org.teacon.slides.renderer.ProjectorRenderer; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
@Mod(SlideShow.ID) | ||
@FieldsAreNonnullByDefault | ||
@MethodsReturnNonnullByDefault | ||
@ParametersAreNonnullByDefault | ||
public final class SlideShow { | ||
|
||
public static final String ID = "slide_show"; // as well as the namespace | ||
public static final Logger LOGGER = LogManager.getLogger("SlideShow"); | ||
|
||
public static boolean sOptiFineLoaded; | ||
|
||
/** | ||
* The networking channel version. Since we follow SemVer, this is | ||
* always the same as the MAJOR version of the mod version. | ||
*/ | ||
// Remember to update the network version when MAJOR is bumped | ||
// Last Update: Thu, 17 Dec 2020 15:00:00 +0800 (0 => 1) | ||
// Last Update: Tue, 18 Jan 2022 20:00:00 +0800 (1 => 2) | ||
private static final String NETWORK_VERSION = "2"; | ||
public static SimpleChannel CHANNEL; | ||
|
||
static { | ||
try { | ||
Class.forName("optifine.Installer"); | ||
sOptiFineLoaded = true; | ||
} catch (ClassNotFoundException ignored) { | ||
} | ||
} | ||
|
||
public SlideShow() { | ||
FMLJavaModLoadingContext.get().getModEventBus().register(SlideShow.class); | ||
MinecraftForge.EVENT_BUS.addListener(SlideShow::gatherPermNodes); | ||
} | ||
|
||
@SubscribeEvent | ||
public static void registerBlocks(final RegistryEvent.Register<Block> event) { | ||
event.getRegistry().register(new ProjectorBlock().setRegistryName("projector")); | ||
} | ||
|
||
@SubscribeEvent | ||
public static void registerItems(final RegistryEvent.Register<Item> event) { | ||
event.getRegistry().register(new ProjectorItem().setRegistryName("projector")); | ||
} | ||
|
||
@SubscribeEvent | ||
public static void registerMenus(final RegistryEvent.Register<MenuType<?>> event) { | ||
event.getRegistry().register(IForgeMenuType.create(ProjectorContainerMenu::new) | ||
.setRegistryName("projector")); | ||
} | ||
|
||
@SubscribeEvent | ||
public static void registerBlockEntities(final RegistryEvent.Register<BlockEntityType<?>> event) { | ||
event.getRegistry().register(new BlockEntityType<>(ProjectorBlockEntity::new, | ||
Set.of(Registries.PROJECTOR), DSL.remainderType()) | ||
.setRegistryName("projector")); | ||
} | ||
|
||
//FIXME permission resolving | ||
public static final PermissionNode<Boolean> INTERACT_PERM = | ||
new PermissionNode<>(ID, "interact.projector", PermissionTypes.BOOLEAN, | ||
(player, playerUUID, context) -> true); | ||
|
||
private static void gatherPermNodes(final PermissionGatherEvent.Nodes event) { | ||
event.addNodes(INTERACT_PERM); | ||
} | ||
|
||
@SubscribeEvent | ||
public static void setupCommon(final FMLCommonSetupEvent event) { | ||
CHANNEL = NetworkRegistry.newSimpleChannel(new ResourceLocation(ID, "network"), () -> NETWORK_VERSION, | ||
NETWORK_VERSION::equals, NETWORK_VERSION::equals); | ||
int index = 0; | ||
// noinspection UnusedAssignment | ||
CHANNEL.registerMessage(index++, ProjectorUpdatePacket.class, | ||
ProjectorUpdatePacket::write, | ||
ProjectorUpdatePacket::new, | ||
ProjectorUpdatePacket::handle, | ||
Optional.of(NetworkDirection.PLAY_TO_SERVER)); | ||
} | ||
|
||
@OnlyIn(Dist.CLIENT) | ||
@SubscribeEvent | ||
public static void setupClient(final FMLClientSetupEvent event) { | ||
MenuScreens.register(Registries.MENU, ProjectorScreen::new); | ||
ItemBlockRenderTypes.setRenderLayer(Registries.PROJECTOR, RenderType.cutout()); | ||
BlockEntityRenderers.register(Registries.BLOCK_ENTITY, ProjectorRenderer.INSTANCE::onCreate); | ||
} | ||
|
||
@OnlyIn(Dist.CLIENT) | ||
@SubscribeEvent | ||
public static void onModelRegistry(final ModelRegistryEvent event) { | ||
//RenderSystem.recordRenderCall(ProjectorWorldRender::loadShader); | ||
} | ||
|
||
@OnlyIn(Dist.CLIENT) | ||
@SubscribeEvent | ||
public static void onRegisterShadersEvent(final RegisterShadersEvent event) { | ||
final ResourceLocation location = new ResourceLocation("slide_show", "shaders/post/projector_outline"); | ||
/*event.registerShader(new ShaderInstance(event.getResourceManager(), location, DefaultVertexFormat.BLOCK), | ||
(i) -> { | ||
SLIDE_SHOW_SHADER = new RenderStateShard.ShaderStateShard(() -> i); | ||
});*/ | ||
} | ||
public static final Logger LOGGER = LogManager.getLogger("SlideShow"); | ||
} |
Oops, something went wrong.