Skip to content

Commit

Permalink
Fix peeking eye capability
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepy-evelyn committed Dec 2, 2024
1 parent 37bafe9 commit 6b26ebb
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 27 deletions.
8 changes: 6 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ dependencies {
modCompileOnly "com.terraformersmc:modmenu:$project.modmenu_version"

// Cardinal Components
/**modImplementation(include("dev.onyxstudios.cardinal-components-api:cardinal-components-base:$project.cardinal_components"))
modImplementation(include("dev.onyxstudios.cardinal-components-api:cardinal-components-entity:$project.cardinal_components"))**/
modImplementation(include("dev.onyxstudios.cardinal-components-api:cardinal-components-base:$project.cardinal_components"))
modImplementation(include("dev.onyxstudios.cardinal-components-api:cardinal-components-entity:$project.cardinal_components"))

include "dev.onyxstudios.cardinal-components-api:cardinal-components-base:${project.cardinal_components}"
include "dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${project.cardinal_components}"

// EMI
modCompileOnly "dev.emi:emi-fabric:$emi_version:api"
modLocalRuntime "dev.emi:emi-fabric:$emi_version"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package io.github.sleepy_evelyn.territorial.api.component;

import dev.onyxstudios.cca.api.v3.component.Component;
import dev.onyxstudios.cca.api.v3.component.sync.AutoSyncedComponent;
import dev.onyxstudios.cca.api.v3.component.tick.ClientTickingComponent;
import dev.onyxstudios.cca.api.v3.component.tick.ServerTickingComponent;
import io.github.sleepy_evelyn.territorial.api.component.BoundBlockEntity;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import org.jetbrains.annotations.Nullable;

/**

public interface IPeekingEyeComponent extends Component, AutoSyncedComponent, ClientTickingComponent, ServerTickingComponent {

void startPeeking(@Nullable BoundBlockEntity bbe);
Expand All @@ -19,4 +23,3 @@ public interface IPeekingEyeComponent extends Component, AutoSyncedComponent, Cl
@Nullable BlockEntity getBoundBlockEntity();
default Item getItemToDrop() { return Items.ENDER_EYE; }
}
**/
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.sleepy_evelyn.territorial.block;

import io.github.sleepy_evelyn.territorial.block.entity.PlinthOfPeekingBlockEntity;
import io.github.sleepy_evelyn.territorial.component.TerritorialComponents;
import io.github.sleepy_evelyn.territorial.init.TerritorialBlockEntities;
//import gay.sylv.territorial.component.TerritorialComponents;
import io.github.sleepy_evelyn.territorial.util.NetworkingUtils;
Expand Down Expand Up @@ -56,7 +57,7 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt

if(be instanceof PlinthOfPeekingBlockEntity ppbe && !world.isClient) {
boolean hasEmptyPodium = ppbe.getPodiumEye() == Items.AIR;
//var peekingComponent = player.getComponent(TerritorialComponents.PEEKING_EYE);
var peekingComponent = player.getComponent(TerritorialComponents.PEEKING_EYE);

if(hasEmptyPodium) {
if(mainHandStack.getItem() instanceof EnderEyeItem enderEyeItem) {
Expand All @@ -68,10 +69,10 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt
if(player.isSneaking()) {
dropStack(world, pos.up(), ppbe.getPodiumEye().getDefaultStack());
ppbe.setPodiumEye(Items.AIR);
} /* else if(!peekingComponent.isPeeking()) {
} else if(!peekingComponent.isPeeking()) {
ppbe.setPodiumEye(Items.AIR);
peekingComponent.startPeeking(ppbe);
}*/
}
}
NetworkingUtils.markDirtyAndSync(be, world);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package io.github.sleepy_evelyn.territorial.client.render.entity;

import io.github.sleepy_evelyn.territorial.Territorial;
import io.github.sleepy_evelyn.territorial.component.TerritorialComponents;
import io.github.sleepy_evelyn.territorial.event.template.RenderEvents;
import io.github.sleepy_evelyn.territorial.networking.c2s.CancelPeekingPacket;
import io.github.sleepy_evelyn.territorial.util.MovementUtils;
import io.github.sleepy_evelyn.territorial.util.RenderUtils;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.render.OverlayTexture;
Expand All @@ -16,8 +20,11 @@
import net.minecraft.client.world.ClientWorld;
import net.minecraft.item.Items;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.text.Text;
import net.minecraft.util.math.Axis;

import java.io.IOException;

public class PeekingEyeRenderer {

private static final int EXIT_MESSAGE_TICK_DURATION = 40;
Expand All @@ -33,8 +40,6 @@ public static void registerEvents() {
private static void renderShaderOverlay(WorldRenderContext context) {
var player = MinecraftClient.getInstance().player;
if(player != null) {
/*
var peekingCapability = player.getComponent(TerritorialComponents.PEEKING_EYE);
if(peekingCapability.isPeeking()) {
if(!RenderUtils.Shader.isLoaded()) {
Expand All @@ -44,38 +49,31 @@ private static void renderShaderOverlay(WorldRenderContext context) {
}
RenderUtils.Shader.render(context.tickDelta());
}
*/
}
}

private static void handleExitTick(ClientWorld world) {
var player = MinecraftClient.getInstance().player;
if(player != null) {
/*
var peekingComponent = player.getComponent(TerritorialComponents.PEEKING_EYE);
if(peekingComponent.isPeeking()) {
if(Screen.hasAltDown()) {
RenderUtils.Shader.close();
new CancelPeekingPacket().send();
}
if(peekingComponent.getTicksPeeking() < exitMessageTickDuration)
if(peekingComponent.getTicksPeeking() < EXIT_MESSAGE_TICK_DURATION)
player.sendMessage(Text.translatable("text.territorial.overlay.exit_peeking_mode"), true);
}
*/
}
}

private static boolean beforeRenderPlayer(AbstractClientPlayerEntity player, MatrixStack matrices, VertexConsumerProvider vertexConsumer, float tickDelta, int light) {
/*
var peekingComponent = player.getComponent(TerritorialComponents.PEEKING_EYE);
if(peekingComponent.isPeeking()) {
render(player, matrices, vertexConsumer, tickDelta, light);
return true;
} else
return false;
*/
return false;
}

private static boolean beforeRenderPlayerArms(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, AbstractClientPlayerEntity player, ModelPart arm, ModelPart sleeve) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.github.sleepy_evelyn.territorial.api.component.BoundBlockEntity;
import io.github.sleepy_evelyn.territorial.api.component.BoundBlockEntityParams;
import io.github.sleepy_evelyn.territorial.api.component.IPeekingEyeComponent;
import io.github.sleepy_evelyn.territorial.client.sound.PeekingSoundInstance;
import io.github.sleepy_evelyn.territorial.init.TerritorialDamageSources;
import io.github.sleepy_evelyn.territorial.util.NetworkingUtils;
Expand All @@ -24,7 +25,7 @@
import net.minecraft.world.dimension.DimensionType;
import org.jetbrains.annotations.Nullable;

/**

public class PeekingEyeComponent implements IPeekingEyeComponent {

private boolean isPeeking;
Expand Down Expand Up @@ -202,4 +203,4 @@ public void rebind(BoundBlockEntity bbe) {
}
return null;
}
}**/
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.github.sleepy_evelyn.territorial.component;

/**
import dev.onyxstudios.cca.api.v3.component.ComponentKey;
import dev.onyxstudios.cca.api.v3.component.ComponentRegistry;
import dev.onyxstudios.cca.api.v3.entity.EntityComponentFactoryRegistry;
Expand All @@ -19,5 +18,5 @@ public class TerritorialComponents implements EntityComponentInitializer {
public void registerEntityComponentFactories(EntityComponentFactoryRegistry registry) {
registry.registerForPlayers(PEEKING_EYE, PeekingEyeComponent::new, RespawnCopyStrategy.NEVER_COPY);
}
}**/
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import io.github.sleepy_evelyn.territorial.Territorial;
import io.github.sleepy_evelyn.territorial.api.recipe.FakePortalRecipe;
import io.github.sleepy_evelyn.territorial.api.registry.TerritorialRegistries;
import io.github.sleepy_evelyn.territorial.config.TerritorialConfig;
import io.github.sleepy_evelyn.territorial.recipe.ConditionalRecipes;
import io.github.sleepy_evelyn.territorial.recipe.LensRecipe;
import net.minecraft.block.Blocks;
Expand All @@ -20,7 +19,7 @@ public final class TerritorialRecipes {
public static final SpecialRecipeSerializer<ConditionalRecipes.OmniscientObsidian> OMNISCIENT_OBSIDIAN_RECIPE_SERIALIZER
= new SpecialRecipeSerializer<>((id, category) -> new ConditionalRecipes.OmniscientObsidian(id));
public static final SpecialRecipeSerializer<LensRecipe> LENS_RECIPE_SERIALIZER
= register("special_lens", new SpecialRecipeSerializer<>((id, category) -> new LensRecipe(id)));
= register("crafting_special_lens", new SpecialRecipeSerializer<>((id, category) -> new LensRecipe(id)));

public static final FakePortalRecipe CRYING_OBSIDIAN_PORTAL_RECIPE
= registerFakePortalRecipe("crying_obsidian", new FakePortalRecipe(
Expand All @@ -30,10 +29,7 @@ public final class TerritorialRecipes {
)
);

public static void initialize() {
//if(TerritorialConfig.common().omniscientObsidianRecipe())
register( "crafting_omniscient_obsidian", OMNISCIENT_OBSIDIAN_RECIPE_SERIALIZER);
}
public static void initialize() {}

private static <T extends RecipeSerializer<?>> T register(String id, T recipeSerializer) {
return Registry.register(Registries.RECIPE_SERIALIZER, Territorial.id(id), recipeSerializer);
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
],
"emi": [
"io.github.sleepy_evelyn.territorial.integration.emi.TerritorialEmiProvider"
],
"cardinal-components": [
"io.github.sleepy_evelyn.territorial.component.TerritorialComponents"
]
},
"mixins": [
Expand Down

0 comments on commit 6b26ebb

Please sign in to comment.