Skip to content

Commit

Permalink
Added VisionType.REDUCED, changed raccoon's vision for #1149
Browse files Browse the repository at this point in the history
  • Loading branch information
LtxProgrammer committed Nov 5, 2024
1 parent 266906f commit d074de7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexFormat;
import net.ltxprogrammer.changed.entity.LatexType;
import net.ltxprogrammer.changed.entity.VisionType;
import net.ltxprogrammer.changed.entity.beast.DarkLatexEntity;
import net.ltxprogrammer.changed.process.ProcessTransfur;
import net.ltxprogrammer.changed.util.Color3;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -31,15 +33,20 @@ public class VariantBlindnessOverlay {
public static void eventHandler(RenderGameOverlayEvent.Pre event) {
if (event.getType() == RenderGameOverlayEvent.ElementType.ALL) {
Player player = Minecraft.getInstance().player;
if (player == null || !ProcessTransfur.isPlayerTransfurred(player))
if (!ProcessTransfur.isPlayerTransfurred(player))
return;
var variant = ProcessTransfur.getPlayerTransfurVariant(player);
if (variant == null || variant.getLatexType() == LatexType.NEUTRAL)
if (variant == null)
return;
if (variant.getChangedEntity() instanceof DarkLatexEntity darkLatex && (darkLatex.isMaskless()
|| player.hasEffect(MobEffects.NIGHT_VISION)))
if (player.hasEffect(MobEffects.NIGHT_VISION))
return; // Override effect
if (variant.getChangedEntity() instanceof DarkLatexEntity darkLatex) {
if (darkLatex.isMaskless())
return;
}
else if (variant.getParent().visionType != VisionType.REDUCED)
return;
float color = variant.getLatexType() == LatexType.DARK_LATEX ? 0.0F : 1.0F;
Color3 color = variant.getParent().getColors().getFirst();
float darkness = (15 - player.level.getRawBrightness(player.eyeBlockPosition(), 0)) / 15.0f;
float alpha;
if (variant.getLatexType() == LatexType.DARK_LATEX)
Expand All @@ -61,10 +68,10 @@ public static void eventHandler(RenderGameOverlayEvent.Pre event) {
Tesselator tesselator = Tesselator.getInstance();
BufferBuilder bufferbuilder = tesselator.getBuilder();
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
bufferbuilder.vertex(0.0D, (double)j1, -90).uv(0.0F, 1.0F).color(color, color, color, alpha).endVertex();
bufferbuilder.vertex((double)i1, (double)j1, -90).uv(1.0F, 1.0F).color(color, color, color, alpha).endVertex();
bufferbuilder.vertex((double)i1, 0.0D, -90).uv(1.0F, 0.0F).color(color, color, color, alpha).endVertex();
bufferbuilder.vertex(0.0D, 0.0D, -90).uv(0.0F, 0.0F).color(color, color, color, alpha).endVertex();
bufferbuilder.vertex(0.0D, (double)j1, -90).uv(0.0F, 1.0F).color(color.red(), color.green(), color.blue(), alpha).endVertex();
bufferbuilder.vertex((double)i1, (double)j1, -90).uv(1.0F, 1.0F).color(color.red(), color.green(), color.blue(), alpha).endVertex();
bufferbuilder.vertex((double)i1, 0.0D, -90).uv(1.0F, 0.0F).color(color.red(), color.green(), color.blue(), alpha).endVertex();
bufferbuilder.vertex(0.0D, 0.0D, -90).uv(0.0F, 0.0F).color(color.red(), color.green(), color.blue(), alpha).endVertex();
tesselator.end();
RenderSystem.depthMask(true);
RenderSystem.defaultBlendFunc();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
public enum VisionType implements StringRepresentable, Predicate<MobEffect> {
NORMAL("normal", effect -> false),
NIGHT_VISION("night_vision", MobEffects.NIGHT_VISION::equals),
BLIND("blind", MobEffects.BLINDNESS::equals);
BLIND("blind", MobEffects.BLINDNESS::equals),
REDUCED("reduced", effect -> false);

public static Codec<VisionType> CODEC = Codec.STRING.comapFlatMap(VisionType::fromSerial, VisionType::getSerializedName).orElse(NORMAL);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.ltxprogrammer.changed.entity.ChangedEntity;
import net.ltxprogrammer.changed.entity.LatexType;
import net.ltxprogrammer.changed.entity.TransfurMode;
import net.ltxprogrammer.changed.entity.VisionType;
import net.ltxprogrammer.changed.entity.beast.*;
import net.ltxprogrammer.changed.entity.variant.GenderedPair;
import net.ltxprogrammer.changed.entity.variant.TransfurVariant;
Expand Down Expand Up @@ -79,7 +80,7 @@ public class ChangedTransfurVariants {
public static final RegistryObject<TransfurVariant<LatexMoth>> LATEX_MOTH = register("form_latex_moth",
TransfurVariant.Builder.of(ChangedEntities.LATEX_MOTH).extraJumps(6).reducedFall().breatheMode(TransfurVariant.BreatheMode.WEAK));
public static final RegistryObject<TransfurVariant<LatexMutantBloodcellWolf>> LATEX_MUTANT_BLODDCELL_WOLF = register("form_latex_mutant_bloodcell_wolf",
TransfurVariant.Builder.of(ChangedEntities.LATEX_MUTANT_BLOODCELL_WOLF).stepSize(0.7f).faction(LatexType.WHITE_LATEX).absorbing());
TransfurVariant.Builder.of(ChangedEntities.LATEX_MUTANT_BLOODCELL_WOLF).stepSize(0.7f).faction(LatexType.WHITE_LATEX).visionType(VisionType.REDUCED).absorbing());
public static final RegistryObject<TransfurVariant<LatexOrca>> LATEX_ORCA = register("form_latex_orca",
TransfurVariant.Builder.of(ChangedEntities.LATEX_ORCA).stepSize(0.7f).gills());
public static final RegistryObject<TransfurVariant<LatexOtter>> LATEX_OTTER = register("form_latex_otter",
Expand All @@ -93,7 +94,7 @@ public class ChangedTransfurVariants {
public static final RegistryObject<TransfurVariant<LatexPurpleFox>> LATEX_PURPLE_FOX = register("form_latex_purple_fox",
TransfurVariant.Builder.of(ChangedEntities.LATEX_PURPLE_FOX).stepSize(0.7f));
public static final RegistryObject<TransfurVariant<LatexRaccoon>> LATEX_RACCOON = register("form_latex_raccoon",
TransfurVariant.Builder.of(ChangedEntities.LATEX_RACCOON).noVision());
TransfurVariant.Builder.of(ChangedEntities.LATEX_RACCOON).visionType(VisionType.REDUCED));
public static final RegistryObject<TransfurVariant<LatexRedDragon>> LATEX_RED_DRAGON = register("form_latex_red_dragon",
TransfurVariant.Builder.of(ChangedEntities.LATEX_RED_DRAGON).glide());
public static final RegistryObject<TransfurVariant<LatexRedPanda>> LATEX_RED_PANDA = register("form_latex_red_panda",
Expand Down Expand Up @@ -154,7 +155,7 @@ public class ChangedTransfurVariants {
TransfurVariant.Builder.of(ChangedEntities.WHITE_WOLF_MALE).stepSize(0.7f).sound(ChangedSounds.SOUND3.getLocation()));

public static final RegistryObject<TransfurVariant<PureWhiteLatexWolf>> PURE_WHITE_LATEX_WOLF = register("form_pure_white_latex_wolf",
TransfurVariant.Builder.of(ChangedEntities.PURE_WHITE_LATEX_WOLF).stepSize(0.7f).faction(LatexType.WHITE_LATEX));
TransfurVariant.Builder.of(ChangedEntities.PURE_WHITE_LATEX_WOLF).stepSize(0.7f).faction(LatexType.WHITE_LATEX).visionType(VisionType.REDUCED));

public static final Supplier<? extends TransfurVariant<?>> FALLBACK_VARIANT = WHITE_LATEX_WOLF_MALE;

Expand Down

0 comments on commit d074de7

Please sign in to comment.