From 3ac5c5bba5161f2fbb1ede46eadbec799b13a177 Mon Sep 17 00:00:00 2001 From: noi2coco Date: Mon, 28 Jun 2021 21:42:34 +0200 Subject: [PATCH] Remove Fray mechanic --- .../dimdoors/DimensionalDoorsComponents.java | 13 +-- .../dimdoors/DimensionalDoorsInitializer.java | 1 - .../java/org/dimdev/dimdoors/ModConfig.java | 25 ----- .../dimdoors/block/EternalFluidBlock.java | 2 - .../dimdev/dimdoors/command/FrayCommand.java | 44 -------- .../dimdev/dimdoors/command/ModCommands.java | 1 - .../enchantment/FrayedEnchantment.java | 24 ---- .../dimdoors/enchantment/ModEnchants.java | 6 - .../dimdoors/entity/ai/MonolithAggroGoal.java | 11 -- .../dimdoors/mixin/PlayerEntityMixin.java | 5 - .../mixin/ServerPlayerEntityMixin.java | 71 ------------ .../dimdoors/mixin/client/InGameHudMixin.java | 10 -- .../mixin/client/PostProcessShaderMixin.java | 10 -- .../component/PlayerModifiersComponent.java | 104 ----------------- .../resources/assets/dimdoors/lang/en_us.json | 26 +---- .../minecraft/shaders/post/transparency.json | 7 +- .../assets/minecraft/shaders/program/fray.fsh | 105 ------------------ .../minecraft/shaders/program/fray.json | 14 --- .../assets/minecraft/shaders/program/fray.vsh | 15 --- 19 files changed, 3 insertions(+), 491 deletions(-) delete mode 100644 src/main/java/org/dimdev/dimdoors/command/FrayCommand.java delete mode 100644 src/main/java/org/dimdev/dimdoors/enchantment/FrayedEnchantment.java delete mode 100644 src/main/java/org/dimdev/dimdoors/world/level/component/PlayerModifiersComponent.java delete mode 100644 src/main/resources/assets/minecraft/shaders/program/fray.fsh delete mode 100644 src/main/resources/assets/minecraft/shaders/program/fray.json delete mode 100644 src/main/resources/assets/minecraft/shaders/program/fray.vsh diff --git a/src/main/java/org/dimdev/dimdoors/DimensionalDoorsComponents.java b/src/main/java/org/dimdev/dimdoors/DimensionalDoorsComponents.java index da6adef5..e102da45 100644 --- a/src/main/java/org/dimdev/dimdoors/DimensionalDoorsComponents.java +++ b/src/main/java/org/dimdev/dimdoors/DimensionalDoorsComponents.java @@ -3,15 +3,10 @@ package org.dimdev.dimdoors; import dev.onyxstudios.cca.api.v3.chunk.ChunkComponentFactoryRegistry; import dev.onyxstudios.cca.api.v3.chunk.ChunkComponentInitializer; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.Identifier; -import dev.onyxstudios.cca.api.v3.component.ComponentFactory; import dev.onyxstudios.cca.api.v3.component.ComponentKey; import dev.onyxstudios.cca.api.v3.component.ComponentRegistryV3; -import dev.onyxstudios.cca.api.v3.entity.EntityComponentFactoryRegistry; -import dev.onyxstudios.cca.api.v3.entity.EntityComponentInitializer; -import dev.onyxstudios.cca.api.v3.entity.RespawnCopyStrategy; import dev.onyxstudios.cca.api.v3.item.ItemComponentFactoryRegistry; import dev.onyxstudios.cca.api.v3.item.ItemComponentInitializer; import dev.onyxstudios.cca.api.v3.level.LevelComponentFactoryRegistry; @@ -19,12 +14,10 @@ import dev.onyxstudios.cca.api.v3.level.LevelComponentInitializer; import org.dimdev.dimdoors.item.ModItems; import org.dimdev.dimdoors.world.level.component.ChunkLazilyGeneratedComponent; import org.dimdev.dimdoors.item.component.CounterComponent; -import org.dimdev.dimdoors.world.level.component.PlayerModifiersComponent; import org.dimdev.dimdoors.world.level.registry.DimensionalRegistry; @SuppressWarnings("UnstableApiUsage") -public class DimensionalDoorsComponents implements LevelComponentInitializer, ItemComponentInitializer, ChunkComponentInitializer, EntityComponentInitializer { - public static final ComponentKey PLAYER_MODIFIERS_COMPONENT_KEY = ComponentRegistryV3.INSTANCE.getOrCreate(new Identifier("dimdoors:player_modifiers"), PlayerModifiersComponent.class); +public class DimensionalDoorsComponents implements LevelComponentInitializer, ItemComponentInitializer, ChunkComponentInitializer { public static final ComponentKey DIMENSIONAL_REGISTRY_COMPONENT_KEY = ComponentRegistryV3.INSTANCE.getOrCreate(new Identifier("dimdoors:dimensional_registry"), DimensionalRegistry.class); public static final ComponentKey COUNTER_COMPONENT_KEY = ComponentRegistryV3.INSTANCE.getOrCreate(new Identifier("dimdoors:counter"), CounterComponent.class); public static final ComponentKey CHUNK_LAZILY_GENERATED_COMPONENT_KEY = ComponentRegistryV3.INSTANCE.getOrCreate(new Identifier("dimdoors:chunk_lazily_generated"), ChunkLazilyGeneratedComponent.class); @@ -44,8 +37,4 @@ public class DimensionalDoorsComponents implements LevelComponentInitializer, It registry.register(CHUNK_LAZILY_GENERATED_COMPONENT_KEY, chunk -> new ChunkLazilyGeneratedComponent()); } - @Override - public void registerEntityComponentFactories(EntityComponentFactoryRegistry registry) { - registry.registerForPlayers(PLAYER_MODIFIERS_COMPONENT_KEY, PlayerModifiersComponent::new, RespawnCopyStrategy.ALWAYS_COPY); - } } diff --git a/src/main/java/org/dimdev/dimdoors/DimensionalDoorsInitializer.java b/src/main/java/org/dimdev/dimdoors/DimensionalDoorsInitializer.java index ea2ad3bc..570a2eb4 100644 --- a/src/main/java/org/dimdev/dimdoors/DimensionalDoorsInitializer.java +++ b/src/main/java/org/dimdev/dimdoors/DimensionalDoorsInitializer.java @@ -19,7 +19,6 @@ import org.dimdev.dimdoors.block.door.data.condition.Condition; import org.dimdev.dimdoors.block.entity.ModBlockEntityTypes; import org.dimdev.dimdoors.command.ModCommands; import org.dimdev.dimdoors.command.PocketCommand; -import org.dimdev.dimdoors.enchantment.FrayedEnchantment; import org.dimdev.dimdoors.enchantment.ModEnchants; import org.dimdev.dimdoors.entity.ModEntityTypes; import org.dimdev.dimdoors.criteria.ModCriteria; diff --git a/src/main/java/org/dimdev/dimdoors/ModConfig.java b/src/main/java/org/dimdev/dimdoors/ModConfig.java index 1ac17b02..66791775 100644 --- a/src/main/java/org/dimdev/dimdoors/ModConfig.java +++ b/src/main/java/org/dimdev/dimdoors/ModConfig.java @@ -40,9 +40,6 @@ public final class ModConfig implements ConfigData { @Category("world") private World world = new World(); @TransitiveObject - @Category("player") - private Player player = new Player(); - @TransitiveObject @Category("dungeons") private Dungeons dungeons = new Dungeons(); @TransitiveObject @@ -70,10 +67,6 @@ public final class ModConfig implements ConfigData { return this.world; } - public Player getPlayerConfig() { - return this.player; - } - public Dungeons getDungeonsConfig() { return this.dungeons; } @@ -163,24 +156,6 @@ public final class ModConfig implements ConfigData { @Tooltip public List gatewayDimBlacklist = new LinkedList<>(); } - public static class Player { - @CollapsibleObject @Tooltip public Fray fray = new Fray(); - - public static class Fray { - @Tooltip public int maxFray = 200; - @Tooltip public int riftFrayIncrement = 5; - @Tooltip public int monolithTeleportationIncrement = 5; - @Tooltip public int eternalFluidFrayDecrease = 100; - @Tooltip public int nameplateGlitchFray = 80; - @Tooltip public int staticOverlayFray = 100; - @Tooltip public int armorDamageFray = 125; - @Tooltip public int grayScreenFray = 175; - @Tooltip public int unravelledStatueFray = 200; - @Tooltip public int minFrayForTickFray = 125; - @Tooltip public int unravledFabricInInventoryFray = 150; - } - } - public static class Dungeons { @Tooltip public int maxDungeonDepth = 50; } diff --git a/src/main/java/org/dimdev/dimdoors/block/EternalFluidBlock.java b/src/main/java/org/dimdev/dimdoors/block/EternalFluidBlock.java index 816c4eae..2bc21134 100644 --- a/src/main/java/org/dimdev/dimdoors/block/EternalFluidBlock.java +++ b/src/main/java/org/dimdev/dimdoors/block/EternalFluidBlock.java @@ -16,7 +16,6 @@ import net.minecraft.entity.Entity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import org.dimdev.dimdoors.api.util.math.MathUtil; -import org.dimdev.dimdoors.world.level.component.PlayerModifiersComponent; public class EternalFluidBlock extends FluidBlock { private static final EntityTarget TARGET = new EscapeTarget(true); @@ -35,7 +34,6 @@ public class EternalFluidBlock extends FluidBlock { if (TARGET.receiveEntity(entity, Vec3d.ZERO, MathUtil.entityEulerAngle(entity), entity.getVelocity())) { if (entity instanceof PlayerEntity) { LimboExitReason.ETERNAL_FLUID.broadcast((PlayerEntity) entity); - PlayerModifiersComponent.incrementFray((PlayerEntity) entity, -DimensionalDoorsInitializer.getConfig().getPlayerConfig().fray.eternalFluidFrayDecrease); } } } catch (Throwable e) { diff --git a/src/main/java/org/dimdev/dimdoors/command/FrayCommand.java b/src/main/java/org/dimdev/dimdoors/command/FrayCommand.java deleted file mode 100644 index c06ee4b5..00000000 --- a/src/main/java/org/dimdev/dimdoors/command/FrayCommand.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.dimdev.dimdoors.command; - -import com.mojang.brigadier.Command; -import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.arguments.FloatArgumentType; -import com.mojang.brigadier.arguments.IntegerArgumentType; -import net.minecraft.command.argument.ColorArgumentType; -import net.minecraft.command.argument.DimensionArgumentType; -import net.minecraft.command.argument.Vec3ArgumentType; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.network.MessageType; -import net.minecraft.server.command.CommandManager; -import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.text.LiteralText; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; -import net.minecraft.util.math.EulerAngle; -import net.minecraft.util.math.Vec3d; -import org.dimdev.dimdoors.api.util.TeleportUtil; -import org.dimdev.dimdoors.api.util.math.MathUtil; -import org.dimdev.dimdoors.world.level.component.PlayerModifiersComponent; - -public class FrayCommand { - public static void register(CommandDispatcher dispatcher) { - dispatcher.register(CommandManager.literal("fray") - .then(CommandManager - .argument("amount", IntegerArgumentType.integer()) - .executes(ctx -> { - ServerPlayerEntity player = ctx.getSource().getPlayer(); - return addFray(ctx.getSource(), Formatting.ITALIC, player, IntegerArgumentType.getInteger(ctx, "amount")); - }) - ) - ); - } - private static int addFray(ServerCommandSource source, Formatting formatting, PlayerEntity player, int amount) { - PlayerModifiersComponent.incrementFray(player, amount); - final Text text = new LiteralText("added : " + amount + " player now has : " + PlayerModifiersComponent.getFray(player)).formatted(formatting); - source.getMinecraftServer().getPlayerManager().broadcastChatMessage(text, MessageType.CHAT, player.getUuid()); - return Command.SINGLE_SUCCESS; - } -} diff --git a/src/main/java/org/dimdev/dimdoors/command/ModCommands.java b/src/main/java/org/dimdev/dimdoors/command/ModCommands.java index 6848c538..b2bf699c 100644 --- a/src/main/java/org/dimdev/dimdoors/command/ModCommands.java +++ b/src/main/java/org/dimdev/dimdoors/command/ModCommands.java @@ -7,7 +7,6 @@ public final class ModCommands { CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> { DimTeleportCommand.register(dispatcher); PocketCommand.register(dispatcher); - FrayCommand.register(dispatcher); }); } } diff --git a/src/main/java/org/dimdev/dimdoors/enchantment/FrayedEnchantment.java b/src/main/java/org/dimdev/dimdoors/enchantment/FrayedEnchantment.java deleted file mode 100644 index 9df5c875..00000000 --- a/src/main/java/org/dimdev/dimdoors/enchantment/FrayedEnchantment.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.dimdev.dimdoors.enchantment; - -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentTarget; -import net.minecraft.entity.EquipmentSlot; - -public class FrayedEnchantment extends Enchantment { - public FrayedEnchantment(Rarity weight, EnchantmentTarget type, EquipmentSlot[] slotTypes) { - super(weight, type, slotTypes); - } - @Override - public int getMinPower(int level) { - return 10000; - } - @Override - public int getMaxLevel() { - return 1; - } - @Override - public boolean isCursed(){ - return true; - } - -} diff --git a/src/main/java/org/dimdev/dimdoors/enchantment/ModEnchants.java b/src/main/java/org/dimdev/dimdoors/enchantment/ModEnchants.java index 715d34d3..654ad708 100644 --- a/src/main/java/org/dimdev/dimdoors/enchantment/ModEnchants.java +++ b/src/main/java/org/dimdev/dimdoors/enchantment/ModEnchants.java @@ -7,14 +7,8 @@ import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; public class ModEnchants { - public static Enchantment FRAYED_ENCHANTMENT; public static Enchantment STRING_THEORY_ENCHANTMENT; public static void init() { - FRAYED_ENCHANTMENT = Registry.register( - Registry.ENCHANTMENT, - new Identifier("dimdoors", "frayed"), - new FrayedEnchantment(Enchantment.Rarity.VERY_RARE, EnchantmentTarget.BREAKABLE, new EquipmentSlot[] {EquipmentSlot.MAINHAND, EquipmentSlot.CHEST, EquipmentSlot.FEET, EquipmentSlot.HEAD, EquipmentSlot.LEGS}) - ); STRING_THEORY_ENCHANTMENT = Registry.register( Registry.ENCHANTMENT, new Identifier("dimdoors", "string_theory"), diff --git a/src/main/java/org/dimdev/dimdoors/entity/ai/MonolithAggroGoal.java b/src/main/java/org/dimdev/dimdoors/entity/ai/MonolithAggroGoal.java index 816843d9..e0191360 100644 --- a/src/main/java/org/dimdev/dimdoors/entity/ai/MonolithAggroGoal.java +++ b/src/main/java/org/dimdev/dimdoors/entity/ai/MonolithAggroGoal.java @@ -3,8 +3,6 @@ package org.dimdev.dimdoors.entity.ai; import java.util.EnumSet; import java.util.Random; -import io.netty.buffer.Unpooled; -import org.dimdev.dimdoors.DimensionalDoorsComponents; import org.dimdev.dimdoors.DimensionalDoorsInitializer; import org.dimdev.dimdoors.entity.MonolithEntity; import org.dimdev.dimdoors.entity.stat.ModStats; @@ -13,23 +11,15 @@ import org.dimdev.dimdoors.network.ServerPacketHandler; import org.dimdev.dimdoors.network.packet.s2c.MonolithAggroParticlesPacket; import org.dimdev.dimdoors.network.packet.s2c.MonolithTeleportParticlesPacket; import org.dimdev.dimdoors.sound.ModSoundEvents; -import org.dimdev.dimdoors.world.level.component.PlayerModifiersComponent; import net.minecraft.entity.ai.TargetPredicate; import net.minecraft.entity.ai.goal.Goal; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.network.PacketByteBuf; import net.minecraft.predicate.entity.EntityPredicates; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.SoundCategory; -import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; -import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; -import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; - -import static net.minecraft.predicate.entity.EntityPredicates.EXCEPT_SPECTATOR; import static org.dimdev.dimdoors.entity.MonolithEntity.MAX_AGGRO; public class MonolithAggroGoal extends Goal { @@ -108,7 +98,6 @@ public class MonolithAggroGoal extends Goal { this.target.teleport(this.target.getX(), this.target.getY() + 256, this.target.getZ()); this.target.world.playSound(null, new BlockPos(this.target.getPos()), ModSoundEvents.CRACK, SoundCategory.HOSTILE, 13, 1); this.target.incrementStat(ModStats.TIMES_TELEPORTED_BY_MONOLITH); - PlayerModifiersComponent.incrementFray(this.target, -DimensionalDoorsInitializer.getConfig().getPlayerConfig().fray.monolithTeleportationIncrement); ServerPacketHandler.get((ServerPlayerEntity) this.target).sendPacket(new MonolithTeleportParticlesPacket()); } } diff --git a/src/main/java/org/dimdev/dimdoors/mixin/PlayerEntityMixin.java b/src/main/java/org/dimdev/dimdoors/mixin/PlayerEntityMixin.java index 7fb53ece..1cfc44bf 100644 --- a/src/main/java/org/dimdev/dimdoors/mixin/PlayerEntityMixin.java +++ b/src/main/java/org/dimdev/dimdoors/mixin/PlayerEntityMixin.java @@ -1,11 +1,8 @@ package org.dimdev.dimdoors.mixin; -import net.minecraft.item.ItemStack; import org.dimdev.dimdoors.DimensionalDoorsInitializer; -import org.dimdev.dimdoors.item.ModItems; import org.dimdev.dimdoors.mixin.accessor.EntityAccessor; import org.dimdev.dimdoors.world.ModDimensions; -import org.dimdev.dimdoors.world.level.component.PlayerModifiersComponent; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -21,8 +18,6 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.Identifier; import net.minecraft.world.World; -import java.util.Random; - @Mixin(value = PlayerEntity.class, priority = 900) public abstract class PlayerEntityMixin extends LivingEntity { diff --git a/src/main/java/org/dimdev/dimdoors/mixin/ServerPlayerEntityMixin.java b/src/main/java/org/dimdev/dimdoors/mixin/ServerPlayerEntityMixin.java index c9ae504d..65518f07 100644 --- a/src/main/java/org/dimdev/dimdoors/mixin/ServerPlayerEntityMixin.java +++ b/src/main/java/org/dimdev/dimdoors/mixin/ServerPlayerEntityMixin.java @@ -1,15 +1,12 @@ package org.dimdev.dimdoors.mixin; import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; import net.minecraft.server.network.ServerRecipeBook; import org.dimdev.dimdoors.DimensionalDoorsInitializer; -import org.dimdev.dimdoors.ModConfig; import org.dimdev.dimdoors.block.UnravelledFabricBlock; import org.dimdev.dimdoors.criteria.ModCriteria; -import org.dimdev.dimdoors.enchantment.ModEnchants; import org.dimdev.dimdoors.entity.limbo.LimboEntranceSource; import org.dimdev.dimdoors.entity.stat.ModStats; import org.dimdev.dimdoors.api.util.TeleportUtil; @@ -17,7 +14,6 @@ import org.dimdev.dimdoors.item.ModItems; import org.dimdev.dimdoors.network.ExtendedServerPlayNetworkHandler; import org.dimdev.dimdoors.network.packet.s2c.PlayerInventorySlotUpdateS2CPacket; import org.dimdev.dimdoors.world.ModDimensions; -import org.dimdev.dimdoors.world.level.component.PlayerModifiersComponent; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -46,11 +42,7 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin { public abstract void readCustomDataFromNbt(NbtCompound nbt); private static final float RANDOM_ACTION_CHANCE = 0.1F; - private static final float CHANCE_TO_DECREASE_ARMOR_DURABILITY = 0.03F; - private static final float CHANCE_TO_REPLACE_ITEMSLOT_WITH_UNRAVLED_FABRIC = 0.005F; - private static final float CHANCE_TO_ENCHANT_WITH_FRAY = 0.01F; private static final float CHANCE_TO_MAKE_LIMBO_LIKE_OTHER_DIMENSIONS = 0.1F; - private static final float RANDOM_INCREMENT_FRAY_CHANCE = 0.1F; private static final int CHUNK_SIZES = 25; private static final int POSITION_AWAY = 50; private static final float RANDOM_LIQUID_CHANCE = 0.7F; @@ -63,14 +55,7 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin { @Inject(method = "tick", at = @At("HEAD"), cancellable = true) public void playerTickMixin(CallbackInfo ci) { if (random.nextFloat() <= RANDOM_ACTION_CHANCE) { - if(random.nextFloat() <= RANDOM_INCREMENT_FRAY_CHANCE && PlayerModifiersComponent.getFray((PlayerEntity) (Object)this) < 180 && ModDimensions.isLimboDimension((((PlayerEntity)(Object)(this)).getEntityWorld()))) { - PlayerModifiersComponent.incrementFray((PlayerEntity) (Object)this, 1); - } - if (PlayerModifiersComponent.getFray(this) >= 125) { - doRandomFunction(this); - } if(ModDimensions.isLimboDimension(((PlayerEntity)(Object)(this)).getEntityWorld())) { - tryAddingFrayEnchantment((PlayerEntity) (Object)this); tryMakingLimboLikeOtherDimensions((PlayerEntity)(Object)this); } } @@ -148,62 +133,6 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin { } } - private void doRandomFunction(LivingEntity player) { - switch (random.nextInt(2)) { - case 0: - decreaseArmorDurability((PlayerEntity) player); - break; - case 1: - addRandomUnravledFabric((PlayerEntity) player); - break; - default: - } - - } - - private void tryAddingFrayEnchantment(PlayerEntity player) { - if (!(random.nextFloat() <= CHANCE_TO_ENCHANT_WITH_FRAY)) { - return; - } - int slot = random.nextInt(player.getInventory().size()); - if (!player.getInventory().getStack(slot).isEnchantable()) { - return; - } - ItemStack stack = player.getInventory().getStack(slot); - stack.addEnchantment(ModEnchants.FRAYED_ENCHANTMENT, 1); - player.getInventory().setStack(slot, stack); - ((ExtendedServerPlayNetworkHandler) (Object) ((ServerPlayerEntity) (Object) this).networkHandler).getDimDoorsPacketHandler().sendPacket(new PlayerInventorySlotUpdateS2CPacket(slot, stack)); - - } - - //TODO: Fix this shit so it syncs. - private void addRandomUnravledFabric(PlayerEntity player) { - if (PlayerModifiersComponent.getFray(player) < DimensionalDoorsInitializer.getConfig().getPlayerConfig().fray.unravledFabricInInventoryFray) - return; - if (!(random.nextFloat() <= CHANCE_TO_REPLACE_ITEMSLOT_WITH_UNRAVLED_FABRIC)) - return; - - int slot = random.nextInt(player.getInventory().main.size()); - - if (!player.getInventory().main.get(slot).isEmpty() && !(player.getInventory().main.get(slot).getItem() == ModItems.UNRAVELLED_FABRIC)) - return; - if (player.getInventory().main.get(slot).getCount() >= 64) - return; - ItemStack stack = new ItemStack(ModItems.UNRAVELLED_FABRIC, 1 + player.getInventory().main.get(slot).getCount()); - player.getInventory().main.set(slot, stack); - ((ExtendedServerPlayNetworkHandler) (Object) ((ServerPlayerEntity) (Object) this).networkHandler).getDimDoorsPacketHandler().sendPacket(new PlayerInventorySlotUpdateS2CPacket(slot, stack)); - } - - private void decreaseArmorDurability(PlayerEntity player) { - if (PlayerModifiersComponent.getFray(player) < DimensionalDoorsInitializer.getConfig().getPlayerConfig().fray.unravledFabricInInventoryFray) - return; - for (int i = 0; i < player.getInventory().armor.size(); i++) - if (random.nextFloat() <= CHANCE_TO_DECREASE_ARMOR_DURABILITY) - player.getArmorItems().forEach((itemStack) -> { - itemStack.setDamage(itemStack.getDamage() + 1); - }); - } - @Inject(method = "onDeath", at = @At("HEAD"), cancellable = true) public void checkDeathServer(DamageSource source, CallbackInfo ci) { this.doOnDeathStuff(source, ci); diff --git a/src/main/java/org/dimdev/dimdoors/mixin/client/InGameHudMixin.java b/src/main/java/org/dimdev/dimdoors/mixin/client/InGameHudMixin.java index 52522fea..3e748491 100644 --- a/src/main/java/org/dimdev/dimdoors/mixin/client/InGameHudMixin.java +++ b/src/main/java/org/dimdev/dimdoors/mixin/client/InGameHudMixin.java @@ -1,17 +1,9 @@ package org.dimdev.dimdoors.mixin.client; -import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.*; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.Identifier; import org.dimdev.dimdoors.DimensionalDoorsInitializer; import org.dimdev.dimdoors.ModConfig; -import org.dimdev.dimdoors.client.ModShaders; -import org.dimdev.dimdoors.world.ModBiomes; -import org.dimdev.dimdoors.world.ModDimensions; -import org.dimdev.dimdoors.world.level.component.PlayerModifiersComponent; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -19,7 +11,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import net.minecraft.client.gui.hud.InGameHud; -import net.minecraft.entity.Entity; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @@ -29,7 +20,6 @@ import net.fabricmc.api.Environment; public abstract class InGameHudMixin{ private int frame = 0; private static final float OVERLAY_OPACITY_ADJUSTEMENT = 1.5F; - private ModConfig.Player config = DimensionalDoorsInitializer.getConfig().getPlayerConfig(); @Shadow private int scaledHeight; @Shadow diff --git a/src/main/java/org/dimdev/dimdoors/mixin/client/PostProcessShaderMixin.java b/src/main/java/org/dimdev/dimdoors/mixin/client/PostProcessShaderMixin.java index 53f7fdbf..4cc477dc 100644 --- a/src/main/java/org/dimdev/dimdoors/mixin/client/PostProcessShaderMixin.java +++ b/src/main/java/org/dimdev/dimdoors/mixin/client/PostProcessShaderMixin.java @@ -3,14 +3,12 @@ package org.dimdev.dimdoors.mixin.client; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gl.JsonEffectGlShader; import net.minecraft.client.gl.PostProcessShader; -import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import com.mojang.blaze3d.systems.RenderSystem; import org.dimdev.dimdoors.DimensionalDoorsInitializer; import org.dimdev.dimdoors.ModConfig; -import org.dimdev.dimdoors.world.level.component.PlayerModifiersComponent; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -20,20 +18,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(PostProcessShader.class) public class PostProcessShaderMixin { - private ModConfig.Player config = DimensionalDoorsInitializer.getConfig().getPlayerConfig(); @Shadow @Final private JsonEffectGlShader program; @Inject(method = "render(F)V", at = @At("HEAD"), cancellable = true) public void render(float time, CallbackInfo cir) { program.getUniformByNameOrDummy("GameTime").set(RenderSystem.getShaderGameTime()); - - if (PlayerModifiersComponent.getFray(getCameraPlayer()) > config.fray.grayScreenFray) { - float overlayOpacity = (config.fray.grayScreenFray - PlayerModifiersComponent.getFray(getCameraPlayer())) / (config.fray.grayScreenFray - (float) config.fray.maxFray); - program.getUniformByNameOrDummy("FrayIntensity").set(overlayOpacity); - } else { - program.getUniformByNameOrDummy("FrayIntensity").set(0.0f); - } } private PlayerEntity getCameraPlayer() { diff --git a/src/main/java/org/dimdev/dimdoors/world/level/component/PlayerModifiersComponent.java b/src/main/java/org/dimdev/dimdoors/world/level/component/PlayerModifiersComponent.java deleted file mode 100644 index 3b2620d9..00000000 --- a/src/main/java/org/dimdev/dimdoors/world/level/component/PlayerModifiersComponent.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.dimdev.dimdoors.world.level.component; - -import dev.onyxstudios.cca.api.v3.component.ComponentV3; -import dev.onyxstudios.cca.api.v3.component.sync.AutoSyncedComponent; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.entity.LivingEntity; -import org.apache.logging.log4j.Level; -import org.dimdev.dimdoors.DimensionalDoorsComponents; -import org.dimdev.dimdoors.DimensionalDoorsInitializer; - -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.network.PacketByteBuf; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.util.math.MathHelper; -import org.dimdev.dimdoors.block.ModBlocks; -import org.dimdev.dimdoors.enchantment.ModEnchants; - -import java.util.Random; -import java.util.concurrent.atomic.AtomicBoolean; - -import static org.dimdev.dimdoors.util.schematic.SchematicPlacer.LOGGER; - -public class PlayerModifiersComponent implements ComponentV3, AutoSyncedComponent { - private int fray = 0; - - public PlayerModifiersComponent(@SuppressWarnings("unused") PlayerEntity player) { - } - - @Override - public void readFromNbt(NbtCompound nbt) { - fray = nbt.getInt("Fray"); - } - - @Override - public void writeToNbt(NbtCompound nbt) { - nbt.putInt("Fray", fray); - } - - @Override - public void writeSyncPacket(PacketByteBuf buf, ServerPlayerEntity recipient) { - buf.writeVarInt(fray); - } - - @Override - public void applySyncPacket(PacketByteBuf buf) { - fray = buf.readVarInt(); - } - - public int getFray() { - return fray; - } - - public void resetFray() {fray = 0;} - - public int incrementFray(int amount) { - return (fray = MathHelper.clamp(fray + amount, 0, DimensionalDoorsInitializer.getConfig().getPlayerConfig().fray.maxFray)); - } - - public static PlayerModifiersComponent get(PlayerEntity player) { - return DimensionalDoorsComponents.PLAYER_MODIFIERS_COMPONENT_KEY.get(player); - } - - public static void resetFray(PlayerEntity player) { - get(player).resetFray(); - } - - - - public static int getFray(LivingEntity player) { - return get((PlayerEntity) player).getFray(); - } - - public static void sync(PlayerEntity player) { - DimensionalDoorsComponents.PLAYER_MODIFIERS_COMPONENT_KEY.sync(player); - } - - public static int incrementFray(PlayerEntity player, int amount) { - for(int i = 0; i < player.getInventory().armor.size(); i++) { - if(EnchantmentHelper.getLevel(ModEnchants.STRING_THEORY_ENCHANTMENT, player.getInventory().armor.get(i)) > 0) { - amount *= 0.85; - } - } - int v = get(player).incrementFray(amount); - PlayerModifiersComponent.sync(player); - if(getFray(player) == DimensionalDoorsInitializer.getConfig().getPlayerConfig().fray.maxFray) { - killPlayer(player); - } - if(false) { - LOGGER.log(Level.INFO, "fray amount is : " + getFray(player)); - } - return v; - } - - private static void killPlayer(PlayerEntity player) { - player.kill(); - //Fray should be reset by mixinging into the player class and changing the kill event or some other funciton that happens when a player dies. - //This is just temporary - //On second thought, this should get rid of fray, and fray should stay with the player otherwise, that way they have to actively try to get rid of it without just like, dying. - resetFray(player); - player.getEntityWorld().setBlockState(player.getBlockPos(), ModBlocks.STONE_PLAYER.getDefaultState(), 3); - } -} diff --git a/src/main/resources/assets/dimdoors/lang/en_us.json b/src/main/resources/assets/dimdoors/lang/en_us.json index 80dc4553..4da19ecc 100644 --- a/src/main/resources/assets/dimdoors/lang/en_us.json +++ b/src/main/resources/assets/dimdoors/lang/en_us.json @@ -266,28 +266,6 @@ "text.autoconfig.dimdoors.option.limbo.decaySpreadChance": "Decay Spread Chance", "text.autoconfig.dimdoors.option.limbo.decaySpreadChance.@Tooltip": "To be filled out.", - "text.autoconfig.dimdoors.category.player": "Player", - "text.autoconfig.dimdoors.option.player.fray": "Fray", - "text.autoconfig.dimdoors.option.player.fray.@Tooltip": "To be filled out.", - "text.autoconfig.dimdoors.option.player.fray.maxFray": "Max Fray", - "text.autoconfig.dimdoors.option.player.fray.maxFray.@Tooltip": "Title", - "text.autoconfig.dimdoors.option.player.fray.riftFrayIncrement": "Rift Fray Increment", - "text.autoconfig.dimdoors.option.player.fray.riftFrayIncrement.@Tooltip": "Title", - "text.autoconfig.dimdoors.option.player.fray.monolithTeleportationIncrement": "Monolith Teleportation Increment", - "text.autoconfig.dimdoors.option.player.fray.monolithTeleportationIncrement.@Tooltip": "Title", - "text.autoconfig.dimdoors.option.player.fray.eternalFluidFrayDecrease": "Eternal Fluid Fray Decrease", - "text.autoconfig.dimdoors.option.player.fray.eternalFluidFrayDecrease.@Tooltip": "Title", - "text.autoconfig.dimdoors.option.player.fray.nameplateGlitchFray": "Nameplate Glitch Fray", - "text.autoconfig.dimdoors.option.player.fray.nameplateGlitchFray.@Tooltip": "Amount of fray needed for nameplate to glitch.", - "text.autoconfig.dimdoors.option.player.fray.staticOverlayFray": "Static Overlay Fray", - "text.autoconfig.dimdoors.option.player.fray.staticOverlayFray.@Tooltip": "Amount of fray needed for screen to start having static", - "text.autoconfig.dimdoors.option.player.fray.armorDamageFray": "Armor Damage Fray", - "text.autoconfig.dimdoors.option.player.fray.armorDamageFray.@Tooltip": "Amount of fray needed for your armor to start taking damage", - "text.autoconfig.dimdoors.option.player.fray.grayScreenFray": "Gray Screen Fray", - "text.autoconfig.dimdoors.option.player.fray.grayScreenFray.@Tooltip": "Title", - "text.autoconfig.dimdoors.option.player.fray.unravelledStatueFray": "Unravelled Statue Fray", - "text.autoconfig.dimdoors.option.player.fray.unravelledStatueFray.@Tooltip": "Title", - "text.autoconfig.dimdoors.category.graphics": "Graphics Settings", "text.autoconfig.dimdoors.option.graphics.highlightRiftCoreFor": "Time to Highlight Rift Core", "text.autoconfig.dimdoors.option.graphics.highlightRiftCoreFor.@Tooltip": "How long, in milliseconds, the rift's core (tesseract animation) should be shown for when attempting to place a door near a large rift but not directly on it. Set to -1 to disable.", @@ -433,7 +411,5 @@ "resourcePackActivationType.alwaysEnabled": "Always Enabled", "dimdoors.mode.enable": "Enable", - "dimdoors.mode.disable": "Disable", - - "enchantment.dimdoors.frayed" : "Frayed" + "dimdoors.mode.disable": "Disable" } diff --git a/src/main/resources/assets/minecraft/shaders/post/transparency.json b/src/main/resources/assets/minecraft/shaders/post/transparency.json index f3fe388c..dc407206 100644 --- a/src/main/resources/assets/minecraft/shaders/post/transparency.json +++ b/src/main/resources/assets/minecraft/shaders/post/transparency.json @@ -59,11 +59,6 @@ "id": "weather:depth" } ] - }, - { - "name": "fray", - "intarget": "final", - "outtarget": "minecraft:main" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/minecraft/shaders/program/fray.fsh b/src/main/resources/assets/minecraft/shaders/program/fray.fsh deleted file mode 100644 index 26d440fc..00000000 --- a/src/main/resources/assets/minecraft/shaders/program/fray.fsh +++ /dev/null @@ -1,105 +0,0 @@ -#version 150 - -//make this a uniform when implementing in practice. -//ranges from 0 to 1. -//note: the shader should not be used when the effect strength is 0, -//because this will cause division-by-zero issues inside the shader. -uniform float FrayIntensity; -uniform sampler2D DiffuseSampler; -uniform vec2 OutSize; - -in vec2 texcoord; - -out vec4 fragColor; - -float square(float f) { return f * f; } -vec2 square(vec2 v) { return v * v; } - -float smoothify(float f) { return f * f * (f * -2.0 + 3.0); } -vec2 smoothify(vec2 v) { return v * v * (v * -2.0 + 3.0); } - -float unmix(float low, float high, float frac) { return (frac - low) / (high - low); } -vec2 unmix(vec2 low, vec2 high, vec2 frac) { return (frac - low) / (high - low); } - -float hash11(float p) { //from https://www.shadertoy.com/view/4djSRW - p = fract(p * 10.31); - p *= p + 33.33; - p *= p + p; - return fract(p); -} - -float noise11(float coord, float wrap) { - float fracCoord = fract(coord); - vec2 corners; - corners.x = mod(coord - fracCoord, wrap); - corners.y = mod(corners.x + 1.0, wrap); - fracCoord = smoothify(fracCoord); - return mix(hash11(corners.x), hash11(corners.y), fracCoord); -} - -vec2 hash22(vec2 p) { //from https://www.shadertoy.com/view/4djSRW - vec3 p3 = fract(vec3(p.xyx) * vec3(10.31, 10.30, 9.73)); - p3 += dot(p3, p3.yzx + 33.33); - return fract((p3.xx + p3.yz) * p3.zy); -} - -vec2 noise22(vec2 coord) { - vec2 fracCoord = fract(coord); - vec4 corners; - corners.xy = coord - fracCoord; - corners.zw = corners.xy + vec2(1.0); - fracCoord = smoothify(fracCoord); - return mix( - mix( - hash22(corners.xy), - hash22(corners.xw), - fracCoord.y - ), - mix( - hash22(corners.zy), - hash22(corners.zw), - fracCoord.y - ), - fracCoord.x - ); -} - -void main(){ - //-1 to +1 instead of 0 to 1. - vec2 signedTexcoord = texcoord * 2.0 - 1.0; - //0 in the center, 1 on the edges. - //this is not a euclidean distance. - float centerDistance = sqrt(1.0 - (1.0 - signedTexcoord.x * signedTexcoord.x) * (1.0 - signedTexcoord.y * signedTexcoord.y)); - - //offset the texcoord a bit so the lines are more wiggley. - vec2 offset = noise22(texcoord * 4.0); - offset += noise22(texcoord * 8.0) * 0.5; - offset += noise22(texcoord * 16.0) * 0.25; - offset /= 1.0 + 0.5 + 0.25; //0 to 1 - offset = offset * 2.0 - 1.0; //-1 to +1 - //don't offset the texcoord in the exact middle of the screen, - //because we want the lines to converge on the center. - offset *= centerDistance; - //0.03125 is the amount of wiggleyness to apply. - vec2 tc = texcoord + offset * 0.03125; - - //texcoord, in polar coordinates, ranging from 0 to 1 instead of -pi to +pi. - float angle = atan(tc.y - 0.5, tc.x - 0.5) * (0.5 / 3.14159265359) + 0.5; - - //noise used for the lines. - //this is one-dimensional noise, where the angle is the - float noise = noise11(angle * 64.0, 64.0); - noise += noise11(angle * 128.0, 128.0) * 0.5; - noise += noise11(angle * 256.0, 256.0) * 0.25; - noise /= 1.0 + 0.5 + 0.25; //0 to 1 - //4.0 controls the "initial" thickness of the lines. - //higher numbers will be thinner, and lower numbers will be thicker. - noise = abs(noise * 2.0 - 1.0) * 4.0; - - //0 at the edges, and... more than 0 at the center. - float distanceFactor = unmix(1.0, 1.0 - FrayIntensity, centerDistance); - float finalMultiplier = (noise + distanceFactor) * (1.0 - FrayIntensity); - - fragColor = texture(DiffuseSampler, texcoord); - fragColor.rgb *= min(finalMultiplier, 1.0); -} \ No newline at end of file diff --git a/src/main/resources/assets/minecraft/shaders/program/fray.json b/src/main/resources/assets/minecraft/shaders/program/fray.json deleted file mode 100644 index a17af8f2..00000000 --- a/src/main/resources/assets/minecraft/shaders/program/fray.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "blend": { "func": "add", "srcrgb": "one", "dstrgb": "zero" }, - "vertex": "fray", - "fragment": "fray", - "attributes": [ "Position" ], - "samplers": [ - { "name": "DiffuseSampler" } - ], - "uniforms": [ - { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, - { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, - { "name": "FrayIntensity", "type": "float", "count": 1, "values": [ 0.1 ] } - ] -} \ No newline at end of file diff --git a/src/main/resources/assets/minecraft/shaders/program/fray.vsh b/src/main/resources/assets/minecraft/shaders/program/fray.vsh deleted file mode 100644 index 79d7c755..00000000 --- a/src/main/resources/assets/minecraft/shaders/program/fray.vsh +++ /dev/null @@ -1,15 +0,0 @@ -#version 150 - -in vec4 Position; - -uniform mat4 ProjMat; -uniform vec2 OutSize; - -out vec2 texcoord; - -void main(){ - vec4 outPos = ProjMat * vec4(Position.xy, 0.0, 1.0); - gl_Position = vec4(outPos.xy, 0.2, 1.0); - - texcoord = Position.xy / OutSize; -}