diff --git a/README.md b/README.md index 6b7476640..292f25753 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ community describe an interest in it (This excludes versions listed as **N/A - B | MC Version | Immersive Weapons Latest Version | |------------|--------------------------------------------------------------------------------------------------------------| | 1.19.3 | [Latest](https://github.com/AnonymousHacker1279/ImmersiveWeapons/releases) | +| 1.19.2 | [N/A - Build From Source](https://github.com/AnonymousHacker1279/ImmersiveWeapons/tree/1.19.2-dev) | | 1.19 | [1.18.4](https://github.com/AnonymousHacker1279/ImmersiveWeapons/releases/tag/1.18.4) | | 1.18.2 | [1.17.4](https://github.com/AnonymousHacker1279/ImmersiveWeapons/releases/tag/v1.17.4) | | 1.18.1 | [(ALPHA) 1.14.0-alpha1](https://github.com/AnonymousHacker1279/ImmersiveWeapons/releases/tag/v1.14.0-alpha1) | diff --git a/build.gradle b/build.gradle index bced4d767..da8a0e780 100644 --- a/build.gradle +++ b/build.gradle @@ -49,7 +49,7 @@ minecraft { property 'forge.logging.console.level', 'debug' - // For Patchouli to work in-dev + // For some dependencies to work in-dev property 'mixin.env.remapRefMap', 'true' property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" @@ -69,7 +69,7 @@ minecraft { property 'forge.logging.console.level', 'debug' - // For Patchouli to work in-dev + // For some dependencies to work in-dev property 'mixin.env.remapRefMap', 'true' property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" @@ -89,7 +89,7 @@ minecraft { property 'forge.logging.console.level', 'debug' - // For Patchouli to work in-dev + // For some dependencies to work in-dev property 'mixin.env.remapRefMap', 'true' property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" @@ -110,7 +110,7 @@ minecraft { sourceSets.main.resources { srcDir 'src/generated/resources' } dependencies { - implementation 'org.jetbrains:annotations:23.0.0' + implementation 'org.jetbrains:annotations:24.0.1' minecraft "net.minecraftforge:forge:${forge_version}" @@ -118,14 +118,12 @@ dependencies { implementation fg.deobf("com.github.glitchfiend:TerraBlender-forge:${terrablender_version}") // Include Immersive Weapons Compatibility Bridge (IWCB) - // runtimeOnly fg.deobf("tech.anonymoushacker1279.iwcompatbridge:IWCompatBridge:${iwcb_version}") + runtimeOnly fg.deobf("tech.anonymoushacker1279.iwcompatbridge:IWCompatBridge:${iwcb_version}") // Include JEI runtimeOnly fg.deobf("mezz.jei:jei-1.19.3-forge:${jei_version}") // Include WTHIT and badpackets runtimeOnly fg.deobf("mcp.mobius.waila:wthit:forge-${wthit_version}") implementation fg.deobf("lol.bai:badpackets:forge-${badpackets_version}") - // Include MmmMmmMmmMmm (Target Dummy) - // runtimeOnly fg.deobf("curse.maven:mmmmmmmmmmmm-225738:${target_dummy_version}") // TODO: Uncomment when ported to 1.19.3 } java { diff --git a/gradle.properties b/gradle.properties index ba4cb120c..169592856 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,14 +2,13 @@ org.gradle.jvmargs=-Xmx6G org.gradle.daemon=true org.gradle.caching=true org.gradle.parallel=true -version=1.19.3-1.20.0 +version=1.19.3-1.20.1 group=tech.anonymoushacker1279.immersiveweapons mappings_channel=parchment -mappings_version=2023.02.26-1.19.3 -forge_version=1.19.3-44.1.21 +mappings_version=2023.03.12-1.19.3 +forge_version=1.19.3-44.1.23 terrablender_version=1.19.3-2.1.0.139 iwcb_version=1.19.3-1.2.0 jei_version=12.2.0.16 -wthit_version=6.1.4 -badpackets_version=0.3.4 -target_dummy_version=4132216 \ No newline at end of file +wthit_version=6.2.0 +badpackets_version=0.3.4 \ No newline at end of file diff --git a/src/generated/resources/assets/immersiveweapons/lang/en_us.json b/src/generated/resources/assets/immersiveweapons/lang/en_us.json index 71767237d..80b11990a 100644 --- a/src/generated/resources/assets/immersiveweapons/lang/en_us.json +++ b/src/generated/resources/assets/immersiveweapons/lang/en_us.json @@ -398,6 +398,7 @@ "config.immersiveweapons.celestial_tower_minions_wave_size_modifier": "Multiplier to change the wave size from Celestial Tower summons.\nSet less than 1 to reduce, greater than 1 to increase.\nIncreasing the wave size will negatively affect the server ticks in Tiltros. - Default 1.0", "config.immersiveweapons.celestial_tower_spawn_check_radius": "Set the spawn checking radius for the Celestial Tower.\nSetting this higher may slightly negatively impact server ticks in Tiltros, but make Celestial Lanterns more effective - Default 128", "config.immersiveweapons.cursed_sight_staff_max_use_range": "Set the maximum range in blocks of the Cursed Sight Staff - Default 50", + "config.immersiveweapons.discovery_advancement_range": "Set the range for checking criteria of the discovery advancement (value is squared) - Default 50\nLowering this value may improve server performance,\n", "config.immersiveweapons.fancy_smoke_grenade_particles": "Render smoke grenade particles at 66% of the regular size, spawn 3x more, and add translucency.\nThis will negatively impact performance, but make smoke grenades appear more realistic. - Default false", "config.immersiveweapons.flintlock_pistol_fire_inaccuracy": "Set the inaccuracy of bullets fired by the Flintlock Pistol - Default 1.75", "config.immersiveweapons.flintlock_pistol_fire_velocity": "Set the velocity of bullets fired by the Flintlock Pistol - Default 2.5", @@ -421,6 +422,7 @@ "death.attack.immersiveweapons.bleeding": "%s bled to death", "death.attack.immersiveweapons.bleeding.player": "%s bled to death at the hands of %s", "death.attack.immersiveweapons.deadmans_desert": "%s was poisoned by the atmosphere", + "death.attack.immersiveweapons.deadmans_desert.player": "%s was poisoned by the atmosphere at the hands of %s", "death.attack.immersiveweapons.deathweed": "%s was poisoned by deathweed", "death.attack.immersiveweapons.deathweed.player": "%s was poisoned by deathweed at the hands of %s", "death.attack.immersiveweapons.explosive_chocolate_bar": "%s learned to not accept candy from strangers", @@ -500,6 +502,12 @@ "immersiveweapons.block.wall_shelf.locked": "This shelf has been locked", "immersiveweapons.block.wall_shelf.unlocked": "This shelf has been unlocked", "immersiveweapons.boss.celestial_tower.waves": "Wave %s of %s", + "immersiveweapons.debugTracing.celestialProtectionChanceForNoDamage": "Celestial Protection Chance: %s", + "immersiveweapons.debugTracing.damageBonus": "Damage Bonus: %s", + "immersiveweapons.debugTracing.gunBaseVelocity": "Gun Base Velocity: %s", + "immersiveweapons.debugTracing.liveBulletDamage": "Live Bullet Damage: %s (is crit: %s)", + "immersiveweapons.debugTracing.meleeItemDamage": "Melee Item Damage: %s", + "immersiveweapons.debugTracing.selectedAmmo": "Selected Ammo: %s (base damage: %s)", "immersiveweapons.item.azul_locator.no_spawn": "Unable to teleport: No spawn point set.", "immersiveweapons.item.azul_locator.teleported": "Teleported to spawn point!", "immersiveweapons.item.azul_locator.teleporting": "Teleporting to spawn point in %s seconds...", @@ -726,6 +734,7 @@ "itemGroup.immersiveweapons.creative_tab": "Immersive Weapons", "key.categories.immersiveweapons": "Immersive Weapons", "key.immersiveweapons.astralArmorDashEffect": "Astral Armor Dash", + "key.immersiveweapons.debugTracing": "Debug Tracing", "key.immersiveweapons.toggleArmorEffect": "Toggle Armor Effect", "loot.immersiveweapons.chest.village.battlefield.medic_station.iron_axe": "The Amputator", "subtitles.immersiveweapons.armor.astral.equip": "Astral armor resonates", diff --git a/src/generated/resources/data/immersiveweapons/recipes/burned_oak_slab.json b/src/generated/resources/data/immersiveweapons/recipes/burned_oak_slab.json index 8daba4489..9c90e0061 100644 --- a/src/generated/resources/data/immersiveweapons/recipes/burned_oak_slab.json +++ b/src/generated/resources/data/immersiveweapons/recipes/burned_oak_slab.json @@ -1,6 +1,7 @@ { "type": "minecraft:crafting_shaped", "category": "building", + "group": "wooden_slab", "key": { "a": { "item": "immersiveweapons:burned_oak_planks" diff --git a/src/generated/resources/data/immersiveweapons/recipes/burned_oak_stairs.json b/src/generated/resources/data/immersiveweapons/recipes/burned_oak_stairs.json index 8f0597df4..6be1f56de 100644 --- a/src/generated/resources/data/immersiveweapons/recipes/burned_oak_stairs.json +++ b/src/generated/resources/data/immersiveweapons/recipes/burned_oak_stairs.json @@ -1,6 +1,7 @@ { "type": "minecraft:crafting_shaped", "category": "building", + "group": "wooden_stairs", "key": { "a": { "item": "immersiveweapons:burned_oak_planks" diff --git a/src/generated/resources/data/immersiveweapons/recipes/hardened_mud_slab_from_hardened_mud_stonecutting.json b/src/generated/resources/data/immersiveweapons/recipes/hardened_mud_slab_from_hardened_mud_stonecutting.json index e1e6e442a..58da048b5 100644 --- a/src/generated/resources/data/immersiveweapons/recipes/hardened_mud_slab_from_hardened_mud_stonecutting.json +++ b/src/generated/resources/data/immersiveweapons/recipes/hardened_mud_slab_from_hardened_mud_stonecutting.json @@ -1,7 +1,6 @@ { "type": "minecraft:stonecutting", "count": 2, - "group": "mud", "ingredient": { "item": "immersiveweapons:hardened_mud" }, diff --git a/src/generated/resources/data/immersiveweapons/recipes/hardened_mud_stairs_from_hardened_mud_stonecutting.json b/src/generated/resources/data/immersiveweapons/recipes/hardened_mud_stairs_from_hardened_mud_stonecutting.json index 7854f04e8..4b1cc8115 100644 --- a/src/generated/resources/data/immersiveweapons/recipes/hardened_mud_stairs_from_hardened_mud_stonecutting.json +++ b/src/generated/resources/data/immersiveweapons/recipes/hardened_mud_stairs_from_hardened_mud_stonecutting.json @@ -1,7 +1,6 @@ { "type": "minecraft:stonecutting", "count": 1, - "group": "mud", "ingredient": { "item": "immersiveweapons:hardened_mud" }, diff --git a/src/generated/resources/data/immersiveweapons/recipes/stardust_slab.json b/src/generated/resources/data/immersiveweapons/recipes/stardust_slab.json index 976e6e1ff..2b6cd9c08 100644 --- a/src/generated/resources/data/immersiveweapons/recipes/stardust_slab.json +++ b/src/generated/resources/data/immersiveweapons/recipes/stardust_slab.json @@ -1,6 +1,7 @@ { "type": "minecraft:crafting_shaped", "category": "building", + "group": "wooden_slab", "key": { "a": { "item": "immersiveweapons:stardust_planks" diff --git a/src/generated/resources/data/immersiveweapons/recipes/stardust_stairs.json b/src/generated/resources/data/immersiveweapons/recipes/stardust_stairs.json index e14b3bdef..5b0663152 100644 --- a/src/generated/resources/data/immersiveweapons/recipes/stardust_stairs.json +++ b/src/generated/resources/data/immersiveweapons/recipes/stardust_stairs.json @@ -1,6 +1,7 @@ { "type": "minecraft:crafting_shaped", "category": "building", + "group": "wooden_stairs", "key": { "a": { "item": "immersiveweapons:stardust_planks" diff --git a/src/generated/resources/data/immersiveweapons/recipes/tesla_synthesizer.json b/src/generated/resources/data/immersiveweapons/recipes/tesla_synthesizer.json index 3b1c712f4..844311d0b 100644 --- a/src/generated/resources/data/immersiveweapons/recipes/tesla_synthesizer.json +++ b/src/generated/resources/data/immersiveweapons/recipes/tesla_synthesizer.json @@ -4,7 +4,7 @@ "group": "tesla", "key": { "a": { - "item": "minecraft:netherite_block" + "item": "minecraft:netherite_ingot" }, "b": { "item": "immersiveweapons:molten_block" diff --git a/src/generated/resources/data/immersiveweapons/worldgen/configured_feature/molten_ore.json b/src/generated/resources/data/immersiveweapons/worldgen/configured_feature/molten_ore.json index 24be1bfc5..a149d572f 100644 --- a/src/generated/resources/data/immersiveweapons/worldgen/configured_feature/molten_ore.json +++ b/src/generated/resources/data/immersiveweapons/worldgen/configured_feature/molten_ore.json @@ -2,7 +2,7 @@ "type": "minecraft:ore", "config": { "discard_chance_on_air_exposure": 1.0, - "size": 2, + "size": 4, "targets": [ { "state": { diff --git a/src/generated/resources/data/immersiveweapons/worldgen/placed_feature/molten_ore.json b/src/generated/resources/data/immersiveweapons/worldgen/placed_feature/molten_ore.json index 9c4d57a1b..7fa5478b3 100644 --- a/src/generated/resources/data/immersiveweapons/worldgen/placed_feature/molten_ore.json +++ b/src/generated/resources/data/immersiveweapons/worldgen/placed_feature/molten_ore.json @@ -6,10 +6,10 @@ "height": { "type": "minecraft:trapezoid", "max_inclusive": { - "absolute": 72 + "absolute": 48 }, "min_inclusive": { - "absolute": -64 + "absolute": 0 } } }, diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/blockentity/AzulStainedOrchidBlockEntity.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/blockentity/AzulStainedOrchidBlockEntity.java index 30eaae187..3a570715b 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/blockentity/AzulStainedOrchidBlockEntity.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/blockentity/AzulStainedOrchidBlockEntity.java @@ -37,15 +37,15 @@ public void entityInside(BlockPos pos, Entity entity) { entity.portalEntrancePos = pos.immutable(); } - Level entityWorld = entity.level; - MinecraftServer server = entityWorld.getServer(); - ResourceKey destination = entityWorld.dimension() == IWDimensions.TILTROS ? Level.OVERWORLD + Level entityLevel = entity.level; + MinecraftServer server = entityLevel.getServer(); + ResourceKey destination = entityLevel.dimension() == IWDimensions.TILTROS ? Level.OVERWORLD : IWDimensions.TILTROS; if (server != null) { ServerLevel destinationLevel = server.getLevel(destination); if (destinationLevel != null && !entity.isPassenger()) { - entityWorld.getProfiler().push("tiltros_portal"); + entityLevel.getProfiler().push("tiltros_portal"); entity.setPortalCooldown(); // Get a valid target position if it is unset @@ -55,7 +55,7 @@ public void entityInside(BlockPos pos, Entity entity) { entity.changeDimension(destinationLevel, new TiltrosTeleporter(targetPos, pos)); - entityWorld.getProfiler().pop(); + entityLevel.getProfiler().pop(); } } } else if (teleportDelay > 0) { @@ -84,7 +84,22 @@ private BlockPos findValidTeleportPosition(ServerLevel destinationLevel, BlockPo BlockPos pos = new BlockPos(x + i, y, z + j); if (!destinationLevel.getBiome(pos).is(IWBiomes.DEADMANS_DESERT)) { // Move the target position at least 10 blocks away from the edge of the chunk - targetPos = new BlockPos(pos.getX() + 10, pos.getY(), pos.getZ() + 10); + // Determine if 10 should be added or subtracted to either the X or Z coordinate + int xDiff = Math.abs(pos.getX() - x); + int zDiff = Math.abs(pos.getZ() - z); + if (xDiff > zDiff) { + if (pos.getX() > x) { + targetPos = pos.offset(10, 0, 0); + } else { + targetPos = pos.offset(-10, 0, 0); + } + } else { + if (pos.getZ() > z) { + targetPos = pos.offset(0, 0, 10); + } else { + targetPos = pos.offset(0, 0, -10); + } + } found = true; break; } diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/client/IWKeyBinds.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/client/IWKeyBinds.java index 1bdffa1d0..3699f74a7 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/client/IWKeyBinds.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/client/IWKeyBinds.java @@ -18,6 +18,11 @@ public class IWKeyBinds { public static final KeyMapping ASTRAL_ARMOR_DASH_EFFECT = new KeyMapping("key." + ImmersiveWeapons.MOD_ID + ".astralArmorDashEffect", KeyConflictContext.IN_GAME, Type.MOUSE, - 5, // Mouse button 5 + 4, // Mouse button 5 + CATEGORY); + public static final KeyMapping DEBUG_TRACING = new KeyMapping("key." + ImmersiveWeapons.MOD_ID + ".debugTracing", + KeyConflictContext.IN_GAME, + Type.KEYSYM, + InputConstants.KEY_F9, CATEGORY); } \ No newline at end of file diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/client/gui/IWOverlays.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/client/gui/IWOverlays.java index 12dd7c065..652a404df 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/client/gui/IWOverlays.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/client/gui/IWOverlays.java @@ -1,13 +1,13 @@ package tech.anonymoushacker1279.immersiveweapons.client.gui; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.*; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.client.gui.Font; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.gui.overlay.IGuiOverlay; import org.jetbrains.annotations.Nullable; import tech.anonymoushacker1279.immersiveweapons.ImmersiveWeapons; +import tech.anonymoushacker1279.immersiveweapons.client.gui.overlays.DebugTracingOverlay; +import tech.anonymoushacker1279.immersiveweapons.client.gui.overlays.ScopeOverlay; import tech.anonymoushacker1279.immersiveweapons.item.projectile.gun.data.GunData; public class IWOverlays { @@ -16,65 +16,26 @@ public class IWOverlays { @Nullable public static IGuiOverlay SCOPE_ELEMENT; + @Nullable + public static IGuiOverlay DEBUG_TRACING_ELEMENT; public static void init() { ImmersiveWeapons.LOGGER.info("Initializing overlays"); + Minecraft minecraft = Minecraft.getInstance(); + Font fontRenderer = minecraft.font; + SCOPE_ELEMENT = (gui, poseStack, partialTick, screenWidth, screenHeight) -> { gui.setupOverlayRenderState(true, false); - Minecraft minecraft = Minecraft.getInstance(); if (GunData.changingPlayerFOV != -1 && minecraft.options.getCameraType().isFirstPerson()) { - renderScope(screenWidth, screenHeight, GunData.scopeScale); + ScopeOverlay.renderOverlay(screenWidth, screenHeight, GunData.scopeScale); } }; - } - - private static void renderScope(int screenWidth, int screenHeight, float scopeScale) { - RenderSystem.depthMask(false); - RenderSystem.setShaderColor(0.0f, 0.0f, 0.0f, 0.1f); - RenderSystem.setShader(GameRenderer::getPositionTexShader); - RenderSystem.setShaderTexture(0, SCOPE_LOCATION); - Tesselator tesselator = Tesselator.getInstance(); - BufferBuilder bufferbuilder = tesselator.getBuilder(); - float minScreenWidthAndHeight = (float) Math.min(screenWidth, screenHeight); - float scaled = Math.min((float) screenWidth / minScreenWidthAndHeight, (float) screenHeight / minScreenWidthAndHeight) * scopeScale; - float scaledMinScreeWidthAndHeight = minScreenWidthAndHeight * scaled; - float x = ((float) screenWidth - scaledMinScreeWidthAndHeight) / 2.0F; - float y = ((float) screenHeight - scaledMinScreeWidthAndHeight) / 2.0F; - float x1 = x + scaledMinScreeWidthAndHeight; - float y1 = y + scaledMinScreeWidthAndHeight; - bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); - bufferbuilder.vertex(x, y1, -90.0D).uv(0.0F, 1.0F).endVertex(); - bufferbuilder.vertex(x1, y1, -90.0D).uv(1.0F, 1.0F).endVertex(); - bufferbuilder.vertex(x1, y, -90.0D).uv(1.0F, 0.0F).endVertex(); - bufferbuilder.vertex(x, y, -90.0D).uv(0.0F, 0.0F).endVertex(); - tesselator.end(); - RenderSystem.setShader(GameRenderer::getPositionColorShader); - RenderSystem.disableTexture(); - bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); - bufferbuilder.vertex(0.0D, screenHeight, -90.0D).color(0, 0, 0, 255).endVertex(); - bufferbuilder.vertex(screenWidth, screenHeight, -90.0D).color(0, 0, 0, 255).endVertex(); - bufferbuilder.vertex(screenWidth, y1, -90.0D).color(0, 0, 0, 255).endVertex(); - bufferbuilder.vertex(0.0D, y1, -90.0D).color(0, 0, 0, 255).endVertex(); - bufferbuilder.vertex(0.0D, y, -90.0D).color(0, 0, 0, 255).endVertex(); - bufferbuilder.vertex(screenWidth, y, -90.0D).color(0, 0, 0, 255).endVertex(); - bufferbuilder.vertex(screenWidth, 0.0D, -90.0D).color(0, 0, 0, 255).endVertex(); - bufferbuilder.vertex(0.0D, 0.0D, -90.0D).color(0, 0, 0, 255).endVertex(); - bufferbuilder.vertex(0.0D, y1, -90.0D).color(0, 0, 0, 255).endVertex(); - bufferbuilder.vertex(x, y1, -90.0D).color(0, 0, 0, 255).endVertex(); - bufferbuilder.vertex(x, y, -90.0D).color(0, 0, 0, 255).endVertex(); - bufferbuilder.vertex(0.0D, y, -90.0D).color(0, 0, 0, 255).endVertex(); - - bufferbuilder.vertex(x1, y1, -90.0D).color(0, 0, 0, 255).endVertex(); - bufferbuilder.vertex(screenWidth, y1, -90.0D).color(0, 0, 0, 255).endVertex(); - bufferbuilder.vertex(screenWidth, y, -90.0D).color(0, 0, 0, 255).endVertex(); - bufferbuilder.vertex(x1, y, -90.0D).color(0, 0, 0, 255).endVertex(); - tesselator.end(); - RenderSystem.enableTexture(); - RenderSystem.depthMask(true); - RenderSystem.enableDepthTest(); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + DEBUG_TRACING_ELEMENT = (gui, poseStack, partialTick, screenWidth, screenHeight) -> { + gui.setupOverlayRenderState(true, false); + DebugTracingOverlay.renderOverlay(poseStack, fontRenderer, screenHeight); + }; } } \ No newline at end of file diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/client/gui/overlays/DebugTracingData.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/client/gui/overlays/DebugTracingData.java new file mode 100644 index 000000000..49c9a2ec5 --- /dev/null +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/client/gui/overlays/DebugTracingData.java @@ -0,0 +1,86 @@ +package tech.anonymoushacker1279.immersiveweapons.client.gui.overlays; + +import com.google.common.collect.Multimap; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.MobType; +import net.minecraft.world.entity.ai.attributes.*; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.*; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.level.Level; +import tech.anonymoushacker1279.immersiveweapons.init.ItemRegistry; +import tech.anonymoushacker1279.immersiveweapons.item.projectile.gun.AbstractGunItem; + +import java.util.ArrayList; +import java.util.List; + +/** + * This class contains data for debug tracing. + */ +public class DebugTracingData { + + public static boolean isDebugTracingEnabled = false; + + public static float meleeItemDamage = 0; + + public static float gunBaseVelocity = 0; + public static Item selectedAmmo = Items.AIR; + public static double liveBulletDamage = 0; + public static boolean isBulletCritical = false; + + public static List damageBonusList = new ArrayList<>(5); + + public static void handleTracing(Player player) { + if (player.tickCount % 20 == 0) { + // Get the melee damage attribute of the currently held item + ItemStack heldItem = player.getMainHandItem(); + Multimap modifiers = heldItem.getAttributeModifiers(EquipmentSlot.MAINHAND); + + if (modifiers.isEmpty()) { + meleeItemDamage = 0; + } else { + modifiers.forEach((attribute, modifier) -> { + if (attribute.equals(Attributes.ATTACK_DAMAGE)) { + double damage = modifier.getAmount() + 1; + damage += EnchantmentHelper.getDamageBonus(heldItem, MobType.UNDEFINED); + meleeItemDamage = (float) damage; + } + }); + } + + if (heldItem.getItem() instanceof AbstractGunItem gunItem) { + // Round to nearest 0.1 + gunBaseVelocity = Math.round(gunItem.getFireVelocity() * 10.0f) / 10.0f; + selectedAmmo = gunItem.findAmmo(heldItem, player).getItem(); + } else { + gunBaseVelocity = 0; + selectedAmmo = Items.AIR; + } + + damageBonusList.clear(); + if (player.getItemBySlot(EquipmentSlot.HEAD).getItem() == ItemRegistry.STARSTORM_HELMET.get() && + player.getItemBySlot(EquipmentSlot.CHEST).getItem() == ItemRegistry.STARSTORM_CHESTPLATE.get() && + player.getItemBySlot(EquipmentSlot.LEGS).getItem() == ItemRegistry.STARSTORM_LEGGINGS.get() && + player.getItemBySlot(EquipmentSlot.FEET).getItem() == ItemRegistry.STARSTORM_BOOTS.get()) { + + damageBonusList.add(0.2); + } + if (player.getItemBySlot(EquipmentSlot.HEAD).getItem() == ItemRegistry.MOLTEN_HELMET.get() && + player.getItemBySlot(EquipmentSlot.CHEST).getItem() == ItemRegistry.MOLTEN_CHESTPLATE.get() && + player.getItemBySlot(EquipmentSlot.LEGS).getItem() == ItemRegistry.MOLTEN_LEGGINGS.get() && + player.getItemBySlot(EquipmentSlot.FEET).getItem() == ItemRegistry.MOLTEN_BOOTS.get()) { + + double damageBonus = 0; + if (player.level.dimension() == Level.NETHER) { + damageBonus += 0.2; + } + + if (player.isInLava()) { + damageBonus += 0.1; + } + + damageBonusList.add(damageBonus); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/client/gui/overlays/DebugTracingOverlay.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/client/gui/overlays/DebugTracingOverlay.java new file mode 100644 index 000000000..15d74ab09 --- /dev/null +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/client/gui/overlays/DebugTracingOverlay.java @@ -0,0 +1,82 @@ +package tech.anonymoushacker1279.immersiveweapons.client.gui.overlays; + +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.ChatFormatting; +import net.minecraft.client.gui.Font; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import tech.anonymoushacker1279.immersiveweapons.event.environment_effects.EnvironmentEffects; +import tech.anonymoushacker1279.immersiveweapons.item.projectile.bullet.AbstractBulletItem; + +public class DebugTracingOverlay { + + public static void renderOverlay(PoseStack poseStack, Font fontRenderer, int screenHeight) { + RenderSystem.depthMask(false); + RenderSystem.setShaderColor(0.0f, 0.0f, 0.0f, 0.1f); + + // Render damage tracing metrics to the screen + int textHeightPosition = screenHeight; + + if (DebugTracingData.meleeItemDamage > 0) { + MutableComponent meleeItemDamage = Component.translatable("immersiveweapons.debugTracing.meleeItemDamage", + DebugTracingData.meleeItemDamage) + .withStyle(ChatFormatting.BOLD, ChatFormatting.RED); + textHeightPosition -= 15; + fontRenderer.draw(poseStack, meleeItemDamage, 5, textHeightPosition, 0xFFFFFF); + } + if (DebugTracingData.gunBaseVelocity > 0) { + MutableComponent gunBaseVelocity = Component.translatable("immersiveweapons.debugTracing.gunBaseVelocity", + DebugTracingData.gunBaseVelocity) + .withStyle(ChatFormatting.BOLD, ChatFormatting.BLUE); + textHeightPosition -= 15; + fontRenderer.draw(poseStack, gunBaseVelocity, 5, textHeightPosition, 0xFFFFFF); + } + if (DebugTracingData.selectedAmmo instanceof AbstractBulletItem bullet) { + MutableComponent selectedAmmo = Component.translatable("immersiveweapons.debugTracing.selectedAmmo", + bullet.getDescription(), + bullet.damage) + .withStyle(ChatFormatting.BOLD, ChatFormatting.GREEN); + textHeightPosition -= 15; + fontRenderer.draw(poseStack, selectedAmmo, 5, textHeightPosition, 0xFFFFFF); + } + if (DebugTracingData.liveBulletDamage > 0) { + MutableComponent liveBulletDamage = Component.translatable("immersiveweapons.debugTracing.liveBulletDamage", + DebugTracingData.liveBulletDamage, + DebugTracingData.isBulletCritical) + .withStyle(ChatFormatting.BOLD, ChatFormatting.RED); + textHeightPosition -= 15; + fontRenderer.draw(poseStack, liveBulletDamage, 5, textHeightPosition, 0xFFFFFF); + } + + // Iterate all the values in the damageBonusList and add them together + float totalDamageBonus = 0; + for (double damageBonus : DebugTracingData.damageBonusList) { + totalDamageBonus += damageBonus; + } + // Convert to a percent and round to nearest 0.1 + totalDamageBonus = Math.round(totalDamageBonus * 1000.0f) / 10.0f; + if (totalDamageBonus > 0) { + MutableComponent damageBonus = Component.translatable("immersiveweapons.debugTracing.damageBonus", + totalDamageBonus + "%") + .withStyle(ChatFormatting.BOLD, ChatFormatting.GOLD); + textHeightPosition -= 15; + fontRenderer.draw(poseStack, damageBonus, 5, textHeightPosition, 0xFFFFFF); + } + + if (EnvironmentEffects.celestialProtectionChanceForNoDamage > 0) { + // Convert to a percent and round to nearest 0.01 + float noDamageChance = Math.round(EnvironmentEffects.celestialProtectionChanceForNoDamage * 10000.0f) / 100.0f; + MutableComponent celestialProtectionChanceForNoDamage = Component.translatable("immersiveweapons.debugTracing.celestialProtectionChanceForNoDamage", + noDamageChance + "%") + .withStyle(ChatFormatting.BOLD, ChatFormatting.AQUA); + textHeightPosition -= 15; + fontRenderer.draw(poseStack, celestialProtectionChanceForNoDamage, 5, textHeightPosition, 0xFFFFFF); + } + + RenderSystem.enableTexture(); + RenderSystem.depthMask(true); + RenderSystem.enableDepthTest(); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + } +} \ No newline at end of file diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/client/gui/overlays/ScopeOverlay.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/client/gui/overlays/ScopeOverlay.java new file mode 100644 index 000000000..512c7714c --- /dev/null +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/client/gui/overlays/ScopeOverlay.java @@ -0,0 +1,57 @@ +package tech.anonymoushacker1279.immersiveweapons.client.gui.overlays; + +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.*; +import net.minecraft.client.renderer.GameRenderer; +import tech.anonymoushacker1279.immersiveweapons.client.gui.IWOverlays; + +public class ScopeOverlay { + + public static void renderOverlay(int screenWidth, int screenHeight, float scopeScale) { + RenderSystem.depthMask(false); + RenderSystem.setShaderColor(0.0f, 0.0f, 0.0f, 0.1f); + RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShaderTexture(0, IWOverlays.SCOPE_LOCATION); + Tesselator tesselator = Tesselator.getInstance(); + BufferBuilder bufferbuilder = tesselator.getBuilder(); + float minScreenWidthAndHeight = (float) Math.min(screenWidth, screenHeight); + float scaled = Math.min((float) screenWidth / minScreenWidthAndHeight, (float) screenHeight / minScreenWidthAndHeight) * scopeScale; + float scaledMinScreeWidthAndHeight = minScreenWidthAndHeight * scaled; + float x = ((float) screenWidth - scaledMinScreeWidthAndHeight) / 2.0F; + float y = ((float) screenHeight - scaledMinScreeWidthAndHeight) / 2.0F; + float x1 = x + scaledMinScreeWidthAndHeight; + float y1 = y + scaledMinScreeWidthAndHeight; + bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); + bufferbuilder.vertex(x, y1, -90.0D).uv(0.0F, 1.0F).endVertex(); + bufferbuilder.vertex(x1, y1, -90.0D).uv(1.0F, 1.0F).endVertex(); + bufferbuilder.vertex(x1, y, -90.0D).uv(1.0F, 0.0F).endVertex(); + bufferbuilder.vertex(x, y, -90.0D).uv(0.0F, 0.0F).endVertex(); + tesselator.end(); + RenderSystem.setShader(GameRenderer::getPositionColorShader); + RenderSystem.disableTexture(); + bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + bufferbuilder.vertex(0.0D, screenHeight, -90.0D).color(0, 0, 0, 255).endVertex(); + bufferbuilder.vertex(screenWidth, screenHeight, -90.0D).color(0, 0, 0, 255).endVertex(); + bufferbuilder.vertex(screenWidth, y1, -90.0D).color(0, 0, 0, 255).endVertex(); + bufferbuilder.vertex(0.0D, y1, -90.0D).color(0, 0, 0, 255).endVertex(); + + bufferbuilder.vertex(0.0D, y, -90.0D).color(0, 0, 0, 255).endVertex(); + bufferbuilder.vertex(screenWidth, y, -90.0D).color(0, 0, 0, 255).endVertex(); + bufferbuilder.vertex(screenWidth, 0.0D, -90.0D).color(0, 0, 0, 255).endVertex(); + bufferbuilder.vertex(0.0D, 0.0D, -90.0D).color(0, 0, 0, 255).endVertex(); + bufferbuilder.vertex(0.0D, y1, -90.0D).color(0, 0, 0, 255).endVertex(); + bufferbuilder.vertex(x, y1, -90.0D).color(0, 0, 0, 255).endVertex(); + bufferbuilder.vertex(x, y, -90.0D).color(0, 0, 0, 255).endVertex(); + bufferbuilder.vertex(0.0D, y, -90.0D).color(0, 0, 0, 255).endVertex(); + + bufferbuilder.vertex(x1, y1, -90.0D).color(0, 0, 0, 255).endVertex(); + bufferbuilder.vertex(screenWidth, y1, -90.0D).color(0, 0, 0, 255).endVertex(); + bufferbuilder.vertex(screenWidth, y, -90.0D).color(0, 0, 0, 255).endVertex(); + bufferbuilder.vertex(x1, y, -90.0D).color(0, 0, 0, 255).endVertex(); + tesselator.end(); + RenderSystem.enableTexture(); + RenderSystem.depthMask(true); + RenderSystem.enableDepthTest(); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + } +} \ No newline at end of file diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/client/gui/overlays/package-info.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/client/gui/overlays/package-info.java new file mode 100644 index 000000000..3c274fb78 --- /dev/null +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/client/gui/overlays/package-info.java @@ -0,0 +1,9 @@ +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +@FieldsAreNonnullByDefault +package tech.anonymoushacker1279.immersiveweapons.client.gui.overlays; + +import net.minecraft.FieldsAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/config/CommonConfig.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/config/CommonConfig.java index f6b27c7f9..481907020 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/config/CommonConfig.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/config/CommonConfig.java @@ -16,6 +16,9 @@ public class CommonConfig { // Entity settings + // General + public static ForgeConfigSpec.ConfigValue DISCOVERY_ADVANCEMENT_RANGE; + // Celestial Tower public static ForgeConfigSpec.ConfigValue CELESTIAL_TOWER_SPAWN_CHECK_RADIUS; public static ForgeConfigSpec.ConfigValue CELESTIAL_TOWER_MINIONS_WAVE_SIZE_MODIFIER; @@ -68,6 +71,14 @@ public class CommonConfig { builder.push("Entity Settings"); + builder.push("General"); + DISCOVERY_ADVANCEMENT_RANGE = builder + .comment("Set the range for checking criteria of the discovery advancement (value is squared) - Default 50") + .comment("Lowering this value may improve server performance.") + .translation("config.immersiveweapons.discovery_advancement_range") + .define("discovery_advancement_range", 50); + builder.pop(); + builder.push("Celestial Tower"); CELESTIAL_TOWER_SPAWN_CHECK_RADIUS = builder .comment("Set the spawn checking radius for the Celestial Tower.\n" + diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/data/features/IWConfiguredFeatures.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/data/features/IWConfiguredFeatures.java index b8f6800f3..f0ba913c2 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/data/features/IWConfiguredFeatures.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/data/features/IWConfiguredFeatures.java @@ -124,7 +124,7 @@ public static void bootstrap(BootstapContext> context) { )); register(context, MOLTEN_ORE_CONFIGURATION, Feature.ORE, - new OreConfiguration(OreReplacementTargets.MOLTEN_ORE_TARGETS, 2, 1.0f)); + new OreConfiguration(OreReplacementTargets.MOLTEN_ORE_TARGETS, 4, 1.0f)); register(context, NETHER_SULFUR_ORE_CONFIGURATION, Feature.ORE, new OreConfiguration(OreReplacementTargets.SULFUR_ORE_TARGETS, 16, 0.08f)); diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/data/features/IWPlacedFeatures.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/data/features/IWPlacedFeatures.java index 7637d1c61..964cacd60 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/data/features/IWPlacedFeatures.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/data/features/IWPlacedFeatures.java @@ -93,8 +93,8 @@ public static void bootstrap(BootstapContext context) { )); register(context, MOLTEN_ORE, configuredFeatures.getOrThrow(IWConfiguredFeatures.MOLTEN_ORE_CONFIGURATION), - List.of(HeightRangePlacement.triangle(VerticalAnchor.absolute(-64), - VerticalAnchor.absolute(72)), + List.of(HeightRangePlacement.triangle(VerticalAnchor.absolute(0), + VerticalAnchor.absolute(48)), BiomeFilter.biome(), InSquarePlacement.spread(), CountPlacement.of(6) diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/data/lang/LanguageGenerator.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/data/lang/LanguageGenerator.java index 0a834ebb7..716bd8d0d 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/data/lang/LanguageGenerator.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/data/lang/LanguageGenerator.java @@ -393,6 +393,7 @@ private void addKeys() { addKey("toggleArmorEffect", "Toggle Armor Effect"); addKey("astralArmorDashEffect", "Astral Armor Dash"); + addKey("debugTracing", "Debug Tracing"); } private void addMessages() { @@ -422,6 +423,7 @@ private void addDeathMessages() { addDeathMessage("bleeding", "%s bled to death"); addDeathMessage("bleeding.player", "%s bled to death at the hands of %s"); addDeathMessage("deadmans_desert", "%s was poisoned by the atmosphere"); + addDeathMessage("deadmans_desert.player", "%s was poisoned by the atmosphere at the hands of %s"); addDeathMessage("deathweed", "%s was poisoned by deathweed"); addDeathMessage("deathweed.player", "%s was poisoned by deathweed at the hands of %s"); addDeathMessage("meteor", "%s was hit by a meteor"); @@ -732,6 +734,13 @@ private void addConfigDescriptions() { addConfigDescription("tiltros_enabled", "Enable the Tiltros dimension portal - Default true"); // Entity + + // General + addConfigDescription("discovery_advancement_range", """ + Set the range for checking criteria of the discovery advancement (value is squared) - Default 50 + Lowering this value may improve server performance, + """); + // Celestial Tower addConfigDescription("celestial_tower_spawn_check_radius", "Set the spawn checking radius for the Celestial Tower." + "\nSetting this higher may slightly negatively impact server ticks in Tiltros, but make Celestial Lanterns more effective - Default 128"); @@ -772,6 +781,14 @@ private void addMisc() { // Convert the number to a roman numeral add("enchantment.level." + i, GeneralUtilities.convertToRoman(i)); } + + // Debug tracing strings + add("immersiveweapons.debugTracing.meleeItemDamage", "Melee Item Damage: %s"); + add("immersiveweapons.debugTracing.gunBaseVelocity", "Gun Base Velocity: %s"); + add("immersiveweapons.debugTracing.selectedAmmo", "Selected Ammo: %s (base damage: %s)"); + add("immersiveweapons.debugTracing.liveBulletDamage", "Live Bullet Damage: %s (is crit: %s)"); + add("immersiveweapons.debugTracing.damageBonus", "Damage Bonus: %s"); + add("immersiveweapons.debugTracing.celestialProtectionChanceForNoDamage", "Celestial Protection Chance: %s"); } /** diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/data/recipes/RecipeGenerator.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/data/recipes/RecipeGenerator.java index 2bdc1248d..0c4c2372e 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/data/recipes/RecipeGenerator.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/data/recipes/RecipeGenerator.java @@ -228,8 +228,6 @@ private void createMudItems() { Item MUD = BlockItemRegistry.MUD_ITEM.get(); Item DRIED_MUD = BlockItemRegistry.DRIED_MUD_ITEM.get(); Item HARDENED_MUD = BlockItemRegistry.HARDENED_MUD_ITEM.get(); - Item HARDENED_MUD_SLAB = BlockItemRegistry.HARDENED_MUD_SLAB_ITEM.get(); - Item HARDENED_MUD_STAIRS = BlockItemRegistry.HARDENED_MUD_STAIRS_ITEM.get(); createSmeltingRecipe(MUD, DRIED_MUD, 0.1f, 100, "mud"); @@ -241,28 +239,14 @@ private void createMudItems() { 0.1f, 50, "mud"); // Slab from crafting table - ShapedRecipeBuilder builder = ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, HARDENED_MUD_SLAB, 6) - .group("mud") - .unlockedBy("hardened_mud", has(HARDENED_MUD)); - createSlab(builder, HARDENED_MUD); + CraftingTableRecipes.slab(BlockRegistry.HARDENED_MUD_SLAB.get(), HARDENED_MUD, "mud", "hardened_mud", has(HARDENED_MUD)); // Slab from stonecutter - SingleItemRecipeBuilder.stonecutting(Ingredient.of(HARDENED_MUD), RecipeCategory.BUILDING_BLOCKS, HARDENED_MUD_SLAB, 2) - .group("mud") - .unlockedBy("hardened_mud", has(HARDENED_MUD)) - .save(finishedRecipeConsumer, ImmersiveWeapons.MOD_ID + ":" - + getConversionRecipeName(HARDENED_MUD_SLAB, HARDENED_MUD) + "_stonecutting"); + StonecutterRecipes.slab(BlockRegistry.HARDENED_MUD_SLAB.get(), HARDENED_MUD, "hardened_mud", has(HARDENED_MUD)); // Stairs from crafting table - builder = ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, HARDENED_MUD_STAIRS, 4) - .group("mud") - .unlockedBy("hardened_mud", has(HARDENED_MUD)); - createStairs(builder, HARDENED_MUD); + CraftingTableRecipes.stairs(BlockRegistry.HARDENED_MUD_STAIRS.get(), HARDENED_MUD, "mud", "hardened_mud", has(HARDENED_MUD)); // Stairs from stonecutter - SingleItemRecipeBuilder.stonecutting(Ingredient.of(HARDENED_MUD), RecipeCategory.BUILDING_BLOCKS, HARDENED_MUD_STAIRS) - .group("mud") - .unlockedBy("hardened_mud", has(HARDENED_MUD)) - .save(finishedRecipeConsumer, ImmersiveWeapons.MOD_ID + ":" - + getConversionRecipeName(HARDENED_MUD_STAIRS, HARDENED_MUD) + "_stonecutting"); + StonecutterRecipes.stairs(BlockRegistry.HARDENED_MUD_STAIRS.get(), HARDENED_MUD, "hardened_mud", has(HARDENED_MUD)); // Hardened mud window ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, BlockItemRegistry.HARDENED_MUD_WINDOW_ITEM.get(), 8) @@ -290,10 +274,27 @@ private void createMudItems() { private void createCobaltItems() { createCobaltIngot(ItemRegistry.COBALT_INGOT.get(), BlockItemRegistry.COBALT_BLOCK_ITEM.get()); - createCobaltBlock(BlockItemRegistry.COBALT_BLOCK_ITEM.get()); - createCobaltNugget(ItemRegistry.COBALT_NUGGET.get()); - createRawCobalt(ItemRegistry.RAW_COBALT.get(), BlockItemRegistry.RAW_COBALT_BLOCK_ITEM.get()); - createRawCobaltBlock(BlockItemRegistry.RAW_COBALT_BLOCK_ITEM.get(), ItemRegistry.RAW_COBALT.get()); + + ShapedRecipeBuilder shapedBuilder = ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, BlockItemRegistry.COBALT_BLOCK_ITEM.get()) + .group("cobalt") + .unlockedBy("cobalt_ingot", has(ForgeItemTagGroups.COBALT_INGOTS)); + create3x3Object(shapedBuilder, ForgeItemTagGroups.COBALT_INGOTS); + + ShapelessRecipeBuilder shapelessBuilder = ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ItemRegistry.COBALT_NUGGET.get(), 9) + .group("cobalt") + .unlockedBy("cobalt_ingot", has(ForgeItemTagGroups.COBALT_INGOTS)); + createNuggetFromIngot(shapelessBuilder, ForgeItemTagGroups.COBALT_INGOTS); + + ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ItemRegistry.RAW_COBALT.get(), 9) + .requires(BlockItemRegistry.RAW_COBALT_BLOCK_ITEM.get()) + .group("cobalt") + .unlockedBy("raw_cobalt_block", has(BlockItemRegistry.RAW_COBALT_BLOCK_ITEM.get())) + .save(finishedRecipeConsumer); + + shapedBuilder = ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, BlockItemRegistry.RAW_COBALT_BLOCK_ITEM.get()) + .group("cobalt") + .unlockedBy("raw_cobalt", has(ItemRegistry.RAW_COBALT.get())); + create3x3Object(shapedBuilder, ItemRegistry.RAW_COBALT.get()); } private void createCopperItems() { @@ -348,10 +349,24 @@ private void createVentusItems() { private void createTeslaItems() { createTeslaIngot(ItemRegistry.TESLA_INGOT.get(), BlockItemRegistry.TESLA_BLOCK_ITEM.get()); - createTeslaSynthesizer(BlockItemRegistry.TESLA_SYNTHESIZER_ITEM.get()); teslaSynthesizing(Items.STONE, Items.LAPIS_LAZULI, ItemRegistry.CONDUCTIVE_ALLOY.get(), 24000, ItemRegistry.ELECTRIC_INGOT.get()); + // Tesla Synthesizer + ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, BlockRegistry.TESLA_SYNTHESIZER.get()) + .define('a', Items.NETHERITE_INGOT) + .define('b', BlockItemRegistry.MOLTEN_BLOCK_ITEM.get()) + .define('c', Tags.Items.INGOTS_COPPER) + .define('d', Tags.Items.GLASS_PANES) + .define('e', Tags.Items.INGOTS_IRON) + .define('f', ItemRegistry.TESLA_INGOT.get()) + .pattern("fff") + .pattern("cde") + .pattern("aba") + .group("tesla") + .unlockedBy("tesla_ingot", has(ImmersiveWeaponsItemTagGroups.TESLA_INGOTS)) + .save(finishedRecipeConsumer); + // Tesla block ShapedRecipeBuilder builder = ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, BlockItemRegistry.TESLA_BLOCK_ITEM.get()) .group("tesla") @@ -360,29 +375,29 @@ private void createTeslaItems() { } private void createAstralItems() { - ShapelessRecipeBuilder builder = ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ItemRegistry.ASTRAL_INGOT.get(), 9) + ShapelessRecipeBuilder shapelessRecipeBuilder = ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ItemRegistry.ASTRAL_INGOT.get(), 9) .group("astral") .unlockedBy("astral_block", has(BlockItemRegistry.ASTRAL_BLOCK_ITEM.get())); - createIngotFromBlock(builder, BlockItemRegistry.ASTRAL_BLOCK_ITEM.get()); + createIngotFromBlock(shapelessRecipeBuilder, BlockItemRegistry.ASTRAL_BLOCK_ITEM.get()); // Astral block - ShapedRecipeBuilder builder1 = ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, BlockItemRegistry.ASTRAL_BLOCK_ITEM.get()) + ShapedRecipeBuilder shapedRecipeBuilder = ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, BlockItemRegistry.ASTRAL_BLOCK_ITEM.get()) .group("astral") .unlockedBy("astral_ingot", has(ImmersiveWeaponsItemTagGroups.ASTRAL_INGOTS)); - create3x3Object(builder1, ImmersiveWeaponsItemTagGroups.ASTRAL_INGOTS); + create3x3Object(shapedRecipeBuilder, ImmersiveWeaponsItemTagGroups.ASTRAL_INGOTS); } private void createStarstormItems() { - ShapelessRecipeBuilder builder = ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ItemRegistry.STARSTORM_INGOT.get(), 9) + ShapelessRecipeBuilder shapelessRecipeBuilder = ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ItemRegistry.STARSTORM_INGOT.get(), 9) .group("starstorm") .unlockedBy("starstorm_block", has(BlockItemRegistry.STARSTORM_BLOCK_ITEM.get())); - createIngotFromBlock(builder, BlockItemRegistry.STARSTORM_BLOCK_ITEM.get()); + createIngotFromBlock(shapelessRecipeBuilder, BlockItemRegistry.STARSTORM_BLOCK_ITEM.get()); // Starstorm block - ShapedRecipeBuilder builder1 = ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, BlockItemRegistry.STARSTORM_BLOCK_ITEM.get()) + ShapedRecipeBuilder shapedRecipeBuilder = ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, BlockItemRegistry.STARSTORM_BLOCK_ITEM.get()) .group("starstorm") .unlockedBy("starstorm_ingot", has(ImmersiveWeaponsItemTagGroups.STARSTORM_INGOTS)); - create3x3Object(builder1, ImmersiveWeaponsItemTagGroups.STARSTORM_INGOTS); + create3x3Object(shapedRecipeBuilder, ImmersiveWeaponsItemTagGroups.STARSTORM_INGOTS); } private void createSmithingItems() { @@ -474,13 +489,32 @@ private void createAstralCrystalSorceryItems() { } private void createSmokeGrenades() { - createSmokeGrenade(ItemRegistry.SMOKE_GRENADE.get()); + ShapedRecipeBuilder.shaped(RecipeCategory.COMBAT, ItemRegistry.SMOKE_GRENADE.get(), 2) + .define('a', Items.BAMBOO) + .define('b', ItemRegistry.GRENADE_ASSEMBLY.get()) + .define('c', ItemRegistry.SMOKE_POWDER.get()) + .pattern(" cb") + .pattern(" a ") + .pattern(" a ") + .group("smoke_grenade") + .unlockedBy("smoke_powder", has(ItemRegistry.SMOKE_POWDER.get())) + .save(finishedRecipeConsumer); + createColoredSmokeGrenade(ItemRegistry.SMOKE_GRENADE_BLUE.get(), Tags.Items.DYES_BLUE); createColoredSmokeGrenade(ItemRegistry.SMOKE_GRENADE_GREEN.get(), Tags.Items.DYES_GREEN); createColoredSmokeGrenade(ItemRegistry.SMOKE_GRENADE_RED.get(), Tags.Items.DYES_RED); createColoredSmokeGrenade(ItemRegistry.SMOKE_GRENADE_PURPLE.get(), Tags.Items.DYES_PURPLE); createColoredSmokeGrenade(ItemRegistry.SMOKE_GRENADE_YELLOW.get(), Tags.Items.DYES_YELLOW); - createSmokeGrenadeArrow(ItemRegistry.SMOKE_GRENADE_ARROW.get()); + + ShapedRecipeBuilder.shaped(RecipeCategory.COMBAT, ItemRegistry.SMOKE_GRENADE_ARROW.get(), 4) + .define('a', Items.ARROW) + .define('b', ItemRegistry.SMOKE_POWDER.get()) + .pattern("aab") + .pattern("aa ") + .group("smoke_grenade") + .unlockedBy("smoke_powder", has(ItemRegistry.SMOKE_POWDER.get())) + .save(finishedRecipeConsumer); + createColoredSmokeGrenadeArrow(ItemRegistry.SMOKE_GRENADE_ARROW_BLUE.get(), Tags.Items.DYES_BLUE); createColoredSmokeGrenadeArrow(ItemRegistry.SMOKE_GRENADE_ARROW_GREEN.get(), Tags.Items.DYES_GREEN); createColoredSmokeGrenadeArrow(ItemRegistry.SMOKE_GRENADE_ARROW_RED.get(), Tags.Items.DYES_RED); @@ -499,10 +533,45 @@ private void createSmokeGrenades() { } private void createCorrugatedIronItems() { - createCorrugatedIronPanel(BlockItemRegistry.CORRUGATED_IRON_PANEL_ITEM.get(), - BlockItemRegistry.CORRUGATED_IRON_PANEL_FLAT_ITEM.get()); - createCorrugatedIronPanelBars(BlockItemRegistry.CORRUGATED_IRON_PANEL_BARS_ITEM.get(), - BlockItemRegistry.CORRUGATED_IRON_PANEL_FLAT_BARS_ITEM.get()); + Item PANEL_ITEM = BlockItemRegistry.CORRUGATED_IRON_PANEL_ITEM.get(); + Item PANEL_ITEM_BARS = BlockItemRegistry.CORRUGATED_IRON_PANEL_BARS_ITEM.get(); + Item FLAT_PANEL_ITEM = BlockItemRegistry.CORRUGATED_IRON_PANEL_FLAT_ITEM.get(); + Item FLAT_PANEL_ITEM_BARS = BlockItemRegistry.CORRUGATED_IRON_PANEL_FLAT_BARS_ITEM.get(); + + ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, PANEL_ITEM, 8) + .define('a', Tags.Items.STORAGE_BLOCKS_IRON) + .pattern("aaa") + .group("corrugated_iron") + .unlockedBy("iron_block", has(Tags.Items.STORAGE_BLOCKS_IRON)) + .save(finishedRecipeConsumer); + ShapelessRecipeBuilder.shapeless(RecipeCategory.BUILDING_BLOCKS, PANEL_ITEM) + .requires(FLAT_PANEL_ITEM) + .group("corrugated_iron") + .unlockedBy("iron_block", has(Tags.Items.STORAGE_BLOCKS_IRON)) + .save(finishedRecipeConsumer, ImmersiveWeapons.MOD_ID + ":" + getItemName(PANEL_ITEM) + "_alt"); + ShapelessRecipeBuilder.shapeless(RecipeCategory.BUILDING_BLOCKS, FLAT_PANEL_ITEM) + .requires(PANEL_ITEM) + .group("corrugated_iron") + .unlockedBy("iron_block", has(Tags.Items.STORAGE_BLOCKS_IRON)) + .save(finishedRecipeConsumer); + + ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, PANEL_ITEM_BARS, 8) + .define('a', Tags.Items.STORAGE_BLOCKS_IRON) + .define('b', Items.IRON_BARS) + .pattern("aba") + .group("corrugated_iron") + .unlockedBy("iron_block", has(Tags.Items.STORAGE_BLOCKS_IRON)) + .save(finishedRecipeConsumer); + ShapelessRecipeBuilder.shapeless(RecipeCategory.BUILDING_BLOCKS, PANEL_ITEM_BARS) + .requires(FLAT_PANEL_ITEM_BARS) + .group("corrugated_iron") + .unlockedBy("iron_block", has(Tags.Items.STORAGE_BLOCKS_IRON)) + .save(finishedRecipeConsumer, ImmersiveWeapons.MOD_ID + ":" + getItemName(PANEL_ITEM_BARS) + "_alt"); + ShapelessRecipeBuilder.shapeless(RecipeCategory.BUILDING_BLOCKS, FLAT_PANEL_ITEM_BARS) + .requires(PANEL_ITEM_BARS) + .group("corrugated_iron") + .unlockedBy("iron_block", has(Tags.Items.STORAGE_BLOCKS_IRON)) + .save(finishedRecipeConsumer); } private void createShardItems() { @@ -984,8 +1053,16 @@ private void createMiscellaneousItems() { .save(finishedRecipeConsumer); // Sulfur stuff - createRawSulfurBlock(BlockItemRegistry.RAW_SULFUR_BLOCK_ITEM.get(), ItemRegistry.SULFUR.get()); - createSulfur(ItemRegistry.SULFUR.get(), BlockItemRegistry.RAW_SULFUR_BLOCK_ITEM.get()); + ShapedRecipeBuilder builder = ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, BlockItemRegistry.RAW_SULFUR_BLOCK_ITEM.get()) + .group("sulfur") + .unlockedBy("sulfur", has(ItemRegistry.SULFUR.get())); + create3x3Object(builder, ItemRegistry.SULFUR.get()); + + ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ItemRegistry.SULFUR.get(), 9) + .requires(BlockItemRegistry.RAW_SULFUR_BLOCK_ITEM.get()) + .group("sulfur") + .unlockedBy("raw_sulfur_block", has(BlockItemRegistry.RAW_SULFUR_BLOCK_ITEM.get())) + .save(finishedRecipeConsumer); // Meteor Staff ShapedRecipeBuilder.shaped(RecipeCategory.COMBAT, ItemRegistry.METEOR_STAFF.get()) @@ -1092,35 +1169,6 @@ private static void createCobaltIngot(ItemLike ingotItem, ItemLike ingotBlock) { 0.8f, 100, "cobalt"); } - private static void createCobaltBlock(ItemLike blockItem) { - ShapedRecipeBuilder builder = ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, blockItem) - .group("cobalt") - .unlockedBy("cobalt_ingot", has(ForgeItemTagGroups.COBALT_INGOTS)); - create3x3Object(builder, ForgeItemTagGroups.COBALT_INGOTS); - } - - private static void createRawCobalt(ItemLike rawItem, ItemLike material) { - ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, rawItem, 9) - .requires(material) - .group("cobalt") - .unlockedBy("raw_cobalt_block", has(BlockItemRegistry.RAW_COBALT_BLOCK_ITEM.get())) - .save(finishedRecipeConsumer); - } - - private static void createRawCobaltBlock(ItemLike blockItem, ItemLike material) { - ShapedRecipeBuilder builder = ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, blockItem) - .group("cobalt") - .unlockedBy("raw_cobalt", has(ItemRegistry.RAW_COBALT.get())); - create3x3Object(builder, material); - } - - private static void createCobaltNugget(ItemLike nuggetItem) { - ShapelessRecipeBuilder builder = ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, nuggetItem, 9) - .group("cobalt") - .unlockedBy("cobalt_ingot", has(ForgeItemTagGroups.COBALT_INGOTS)); - createNuggetFromIngot(builder, ForgeItemTagGroups.COBALT_INGOTS); - } - private static void createMoltenIngot(ItemLike ingotItem, ItemLike ingotBlock) { ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ingotItem) .define('a', ImmersiveWeaponsItemTagGroups.MOLTEN_SHARDS) @@ -1159,22 +1207,6 @@ private static void createTeslaIngot(ItemLike ingotItem, ItemLike ingotBlock) { 1.3f, 100, "tesla"); } - private static void createTeslaSynthesizer(ItemLike synthesizerItem) { - ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, synthesizerItem) - .define('a', Items.NETHERITE_BLOCK) - .define('b', BlockItemRegistry.MOLTEN_BLOCK_ITEM.get()) - .define('c', Tags.Items.INGOTS_COPPER) - .define('d', Tags.Items.GLASS_PANES) - .define('e', Tags.Items.INGOTS_IRON) - .define('f', ItemRegistry.TESLA_INGOT.get()) - .pattern("fff") - .pattern("cde") - .pattern("aba") - .group("tesla") - .unlockedBy("tesla_ingot", has(ImmersiveWeaponsItemTagGroups.TESLA_INGOTS)) - .save(finishedRecipeConsumer); - } - private static void createBulletproofStainedGlass(ItemLike stainedGlassItem, TagKey colorTag) { ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, stainedGlassItem, 8) .define('a', BlockRegistry.BULLETPROOF_GLASS.get()) @@ -1187,21 +1219,6 @@ private static void createBulletproofStainedGlass(ItemLike stainedGlassItem, Tag .save(finishedRecipeConsumer); } - private static void createRawSulfurBlock(ItemLike blockItem, ItemLike material) { - ShapedRecipeBuilder builder = ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, blockItem) - .group("sulfur") - .unlockedBy("sulfur", has(ItemRegistry.SULFUR.get())); - create3x3Object(builder, material); - } - - private static void createSulfur(ItemLike rawItem, ItemLike material) { - ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, rawItem, 9) - .requires(material) - .group("sulfur") - .unlockedBy("raw_sulfur_block", has(BlockItemRegistry.RAW_SULFUR_BLOCK_ITEM.get())) - .save(finishedRecipeConsumer); - } - private static void create3x3Object(ShapedRecipeBuilder builder, TagKey material) { builder.define('a', material) .pattern("aaa") @@ -1218,20 +1235,6 @@ private static void create3x3Object(ShapedRecipeBuilder builder, ItemLike materi .save(finishedRecipeConsumer); } - private static void createStairs(ShapedRecipeBuilder builder, ItemLike material) { - builder.define('a', material) - .pattern("a ") - .pattern("aa ") - .pattern("aaa") - .save(finishedRecipeConsumer); - } - - private static void createSlab(ShapedRecipeBuilder builder, ItemLike material) { - builder.define('a', material) - .pattern("aaa") - .save(finishedRecipeConsumer); - } - private static void createIngotFromBlock(ShapelessRecipeBuilder builder, ItemLike ingotBlock) { builder.requires(ingotBlock) .save(finishedRecipeConsumer, ImmersiveWeapons.MOD_ID + ":" + getItemName(builder.getResult()) + "_from_" + getItemName(ingotBlock)); @@ -1242,19 +1245,6 @@ private static void createNuggetFromIngot(ShapelessRecipeBuilder builder, TagKey .save(finishedRecipeConsumer); } - private static void createSmokeGrenade(ItemLike smokeGrenadeItem) { - ShapedRecipeBuilder.shaped(RecipeCategory.COMBAT, smokeGrenadeItem, 2) - .define('a', Items.BAMBOO) - .define('b', ItemRegistry.GRENADE_ASSEMBLY.get()) - .define('c', ItemRegistry.SMOKE_POWDER.get()) - .pattern(" cb") - .pattern(" a ") - .pattern(" a ") - .group("smoke_grenade") - .unlockedBy("smoke_powder", has(ItemRegistry.SMOKE_POWDER.get())) - .save(finishedRecipeConsumer); - } - private static void createColoredSmokeGrenade(ItemLike smokeGrenadeItem, TagKey colorTag) { ShapedRecipeBuilder.shaped(RecipeCategory.COMBAT, smokeGrenadeItem, 2) .define('a', Items.BAMBOO) @@ -1269,17 +1259,6 @@ private static void createColoredSmokeGrenade(ItemLike smokeGrenadeItem, TagKey< .save(finishedRecipeConsumer); } - private static void createSmokeGrenadeArrow(ItemLike arrowItem) { - ShapedRecipeBuilder.shaped(RecipeCategory.COMBAT, arrowItem, 4) - .define('a', Items.ARROW) - .define('b', ItemRegistry.SMOKE_POWDER.get()) - .pattern("aab") - .pattern("aa ") - .group("smoke_grenade") - .unlockedBy("smoke_powder", has(ItemRegistry.SMOKE_POWDER.get())) - .save(finishedRecipeConsumer); - } - private static void createColoredSmokeGrenadeArrow(ItemLike arrowItem, TagKey colorTag) { ShapedRecipeBuilder.shaped(RecipeCategory.COMBAT, arrowItem, 4) .define('a', Items.ARROW) @@ -1292,45 +1271,6 @@ private static void createColoredSmokeGrenadeArrow(ItemLike arrowItem, TagKey consumer) { .save(consumer, blockRegistryPath(family.standingSign().get())); // Slab - RecipeGenerator.CraftingTableRecipes.slab(family.slab().get(), planks, planksTriggerName, planksTrigger); + RecipeGenerator.CraftingTableRecipes.slab(family.slab().get(), planks, "wooden_slab", planksTriggerName, planksTrigger); // Stairs - RecipeGenerator.CraftingTableRecipes.stairs(family.stairs().get(), planks, planksTriggerName, planksTrigger); + RecipeGenerator.CraftingTableRecipes.stairs(family.stairs().get(), planks, "wooden_stairs", planksTriggerName, planksTrigger); // Trapdoor ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, family.trapdoor().get(), 2) diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/entity/GrantAdvancementOnDiscovery.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/entity/GrantAdvancementOnDiscovery.java index 8acdf84b5..f8ad75a21 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/entity/GrantAdvancementOnDiscovery.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/entity/GrantAdvancementOnDiscovery.java @@ -11,6 +11,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraftforge.registries.ForgeRegistries; import tech.anonymoushacker1279.immersiveweapons.advancement.IWCriteriaTriggers; +import tech.anonymoushacker1279.immersiveweapons.config.CommonConfig; import java.util.Objects; @@ -20,9 +21,10 @@ default void checkForDiscovery(LivingEntity entity) { Level level = entity.level; BlockPos entityPos = entity.blockPosition(); - if (!level.isClientSide) { - AABB scanningBox = new AABB(entityPos.offset(-50, -50, -50), - entityPos.offset(50, 50, 50)); + if (!level.isClientSide && entity.tickCount % 20 == 0) { + int scanningRange = CommonConfig.DISCOVERY_ADVANCEMENT_RANGE.get(); + AABB scanningBox = new AABB(entityPos.offset(-scanningRange, -scanningRange, -scanningRange), + entityPos.offset(scanningRange, scanningRange, scanningRange)); for (Player player : level.getNearbyPlayers(TargetingConditions.forNonCombat(), entity, scanningBox)) { if (isLookingAtMe(entity, player)) { diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/entity/ai/goal/FlyRandomlyGoal.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/entity/ai/goal/FlyRandomlyGoal.java index 75a6353af..d2e331e5c 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/entity/ai/goal/FlyRandomlyGoal.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/entity/ai/goal/FlyRandomlyGoal.java @@ -18,6 +18,7 @@ public class FlyRandomlyGoal extends Goal { private final EvilEyeEntity evilEyeEntity; @Nullable private BlockPos targetPosition; + private int targetingCooldown; public FlyRandomlyGoal(EvilEyeEntity pMob) { evilEyeEntity = pMob; @@ -32,6 +33,11 @@ public boolean canUse() { public void tick() { // If the entity has no target position, or the target position is too close, pick a new one + if (targetingCooldown > 0) { + --targetingCooldown; + return; + } + Vec3i immutablePosition = new Vec3i(evilEyeEntity.getX(), evilEyeEntity.getY(), evilEyeEntity.getZ()); if (targetPosition == null) { @@ -59,6 +65,7 @@ public void tick() { ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, evilEyeEntity)).getType() != HitResult.Type.MISS) { // If there is no direct path, set the target position to null targetPosition = null; + targetingCooldown = 40; return; } @@ -68,6 +75,7 @@ public void tick() { // Ensure the target position is in the Deadman's Desert biome if (!evilEyeEntity.getLevel().getBiome(targetPosition).is(IWBiomes.DEADMANS_DESERT)) { targetPosition = null; + targetingCooldown = 40; return; } } diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/entity/monster/EvilEyeEntity.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/entity/monster/EvilEyeEntity.java index bb77a2301..b26f9ec44 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/entity/monster/EvilEyeEntity.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/entity/monster/EvilEyeEntity.java @@ -105,9 +105,9 @@ public void aiStep() { targetedEntityUUID = null; } - // Find players in a 16 block radius every 16 ticks if not summoned by a staff + // Find players in a 16 block radius every 40 ticks if not summoned by a staff if (!level.isClientSide) { - if (!summonedByStaff && tickCount % 16 == 0) { + if (!summonedByStaff && tickCount % 40 == 0) { Player player = level.getNearestPlayer(this, 16); // Check for proper targeting conditions if (player != null) { diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/entity/projectile/bullet/BulletEntity.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/entity/projectile/bullet/BulletEntity.java index 4e831de2c..03fb8c4b2 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/entity/projectile/bullet/BulletEntity.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/entity/projectile/bullet/BulletEntity.java @@ -3,9 +3,11 @@ import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.BlockTags; import net.minecraft.util.Mth; @@ -25,9 +27,15 @@ import net.minecraft.world.phys.*; import net.minecraft.world.phys.HitResult.Type; import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.Tags; import net.minecraftforge.event.ForgeEventFactory; +import net.minecraftforge.fml.DistExecutor; +import net.minecraftforge.network.NetworkEvent; +import net.minecraftforge.network.NetworkEvent.Context; +import net.minecraftforge.network.PacketDistributor; import org.jetbrains.annotations.Nullable; +import tech.anonymoushacker1279.immersiveweapons.client.gui.overlays.DebugTracingData; import tech.anonymoushacker1279.immersiveweapons.client.particle.bullet_impact.BulletImpactParticleOptions; import tech.anonymoushacker1279.immersiveweapons.config.CommonConfig; import tech.anonymoushacker1279.immersiveweapons.data.tags.groups.forge.ForgeBlockTagGroups; @@ -35,6 +43,8 @@ import tech.anonymoushacker1279.immersiveweapons.item.projectile.gun.MusketItem; import tech.anonymoushacker1279.immersiveweapons.util.GeneralUtilities; +import java.util.function.Supplier; + public class BulletEntity extends AbstractArrow { private static final boolean canBreakGlass = CommonConfig.BULLETS_BREAK_GLASS.get(); @@ -110,6 +120,13 @@ public void tick() { leftOwner = checkLeftOwner(); } + if (tickCount % 10 == 0 && !inGround) { + if (!level.isClientSide) { + PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) getOwner()), + new BulletEntityPacketHandler(calculateDamage(), isCritArrow())); + } + } + baseTick(); // Run extra stuff while ticking, useful for classes extending this class @@ -296,6 +313,21 @@ public void setFiringItem(Item stack) { firingItem = stack; } + public float calculateDamage() { + float velocityModifier = (float) getDeltaMovement().length(); + // Determine the damage to be dealt, which is calculated by multiplying the velocity modifier + // and the base damage. It's clamped if the velocity is extremely high. + int damage = Mth.ceil(Mth.clamp(velocityModifier * baseDamage, 0.0D, 2.147483647E9D)); + + // Add crit modifier if the bullet is critical + if (isCritArrow()) { + int randomCritModifier = random.nextInt(damage / 2 + 2); + damage = (int) Math.min(randomCritModifier + damage, 2.147483647E9D); + } + + return damage; + } + /** * Runs when an entity is hit. * @@ -304,10 +336,8 @@ public void setFiringItem(Item stack) { @Override protected void onHitEntity(EntityHitResult entityRayTraceResult) { Entity entity = entityRayTraceResult.getEntity(); - float velocityModifier = (float) getDeltaMovement().length(); - // Determine the damage to be dealt, which is calculated by multiplying the velocity modifier - // and the base damage. It's clamped if the velocity is extremely high. - int damage = Mth.ceil(Mth.clamp(velocityModifier * baseDamage, 0.0D, 2.147483647E9D)); + + float damage = calculateDamage(); int pierceLevel = getPierceLevel(); @@ -330,12 +360,6 @@ protected void onHitEntity(EntityHitResult entityRayTraceResult) { piercedEntities.add(entity.getId()); } - // Add crit modifier if the bullet is critical - if (isCritArrow()) { - long randomCritModifier = random.nextInt(damage / 2 + 2); - damage = (int) Math.min(randomCritModifier + damage, 2147483647L); - } - Entity owner = getOwner(); DamageSource damageSource; @@ -542,4 +566,33 @@ protected void doWhileTicking() { protected void doWhenHitEntity(Entity entity) { level.broadcastEntityEvent(this, VANILLA_IMPACT_STATUS_ID); } + + @Override + public void kill() { + super.kill(); + DebugTracingData.liveBulletDamage = 0; + DebugTracingData.isBulletCritical = false; + } + + public record BulletEntityPacketHandler(double liveBulletDamage, boolean isBulletCritical) { + + public static void encode(BulletEntityPacketHandler msg, FriendlyByteBuf packetBuffer) { + packetBuffer.writeDouble(msg.liveBulletDamage).writeBoolean(msg.isBulletCritical); + } + + public static BulletEntityPacketHandler decode(FriendlyByteBuf packetBuffer) { + return new BulletEntityPacketHandler(packetBuffer.readDouble(), packetBuffer.readBoolean()); + } + + public static void handle(BulletEntityPacketHandler msg, Supplier contextSupplier) { + NetworkEvent.Context context = contextSupplier.get(); + context.enqueueWork(() -> DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> runOnClient(msg))); + context.setPacketHandled(true); + } + + private static void runOnClient(BulletEntityPacketHandler msg) { + DebugTracingData.liveBulletDamage = msg.liveBulletDamage; + DebugTracingData.isBulletCritical = msg.isBulletCritical; + } + } } \ No newline at end of file diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/event/ClientForgeEventSubscriber.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/event/ClientForgeEventSubscriber.java index 6ef8f32b1..c8e006dfe 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/event/ClientForgeEventSubscriber.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/event/ClientForgeEventSubscriber.java @@ -17,7 +17,9 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; import tech.anonymoushacker1279.immersiveweapons.ImmersiveWeapons; +import tech.anonymoushacker1279.immersiveweapons.client.IWKeyBinds; import tech.anonymoushacker1279.immersiveweapons.client.gui.IWOverlays; +import tech.anonymoushacker1279.immersiveweapons.client.gui.overlays.DebugTracingData; import tech.anonymoushacker1279.immersiveweapons.init.ItemRegistry; import tech.anonymoushacker1279.immersiveweapons.item.projectile.gun.data.GunData; @@ -82,13 +84,14 @@ public static void computeFovEvent(ComputeFov event) { } } + @SubscribeEvent public static void RenderGuiOverlayPostEvent(RenderGuiOverlayEvent.Post event) { + int screenHeight = event.getWindow().getGuiScaledHeight(); + int screenWidth = event.getWindow().getGuiScaledWidth(); + if (GunData.changingPlayerFOV != -1) { if (minecraft.options.getCameraType().isFirstPerson()) { - int screenHeight = event.getWindow().getGuiScaledHeight(); - int screenWidth = event.getWindow().getGuiScaledWidth(); - float deltaFrame = minecraft.getDeltaFrameTime() / 8; GunData.scopeScale = Mth.lerp(0.25F * deltaFrame, GunData.scopeScale, 1.125F); @@ -101,5 +104,19 @@ public static void RenderGuiOverlayPostEvent(RenderGuiOverlayEvent.Post event) { } } } + + if (IWKeyBinds.DEBUG_TRACING.consumeClick()) { + DebugTracingData.isDebugTracingEnabled = !DebugTracingData.isDebugTracingEnabled; + } + + if (DebugTracingData.isDebugTracingEnabled) { + if (IWOverlays.DEBUG_TRACING_ELEMENT != null) { + IWOverlays.DEBUG_TRACING_ELEMENT.render((ForgeGui) minecraft.gui, + event.getPoseStack(), + event.getPartialTick(), + screenWidth, + screenHeight); + } + } } } \ No newline at end of file diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/event/ClientModEventSubscriber.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/event/ClientModEventSubscriber.java index 1e6e2f1fe..ceb00937b 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/event/ClientModEventSubscriber.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/event/ClientModEventSubscriber.java @@ -283,6 +283,7 @@ public static void registerKeyBinds(RegisterKeyMappingsEvent event) { event.register(IWKeyBinds.TOGGLE_ARMOR_EFFECT); event.register(IWKeyBinds.ASTRAL_ARMOR_DASH_EFFECT); + event.register(IWKeyBinds.DEBUG_TRACING); } @SubscribeEvent diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/event/ForgeEventSubscriber.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/event/ForgeEventSubscriber.java index 6727e81b5..fd465905a 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/event/ForgeEventSubscriber.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/event/ForgeEventSubscriber.java @@ -1,5 +1,6 @@ package tech.anonymoushacker1279.immersiveweapons.event; +import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; import net.minecraft.world.damagesource.DamageSource; @@ -18,6 +19,7 @@ import net.minecraftforge.registries.MissingMappingsEvent.Mapping; import tech.anonymoushacker1279.immersiveweapons.ImmersiveWeapons; import tech.anonymoushacker1279.immersiveweapons.client.gui.IWOverlays; +import tech.anonymoushacker1279.immersiveweapons.client.gui.overlays.DebugTracingData; import tech.anonymoushacker1279.immersiveweapons.data.biomes.IWBiomes; import tech.anonymoushacker1279.immersiveweapons.event.environment_effects.EnvironmentEffects; import tech.anonymoushacker1279.immersiveweapons.init.*; @@ -33,9 +35,15 @@ public class ForgeEventSubscriber { @SubscribeEvent public static void registerGuiOverlaysEvent(RegisterGuiOverlaysEvent event) { - if (IWOverlays.SCOPE_ELEMENT != null) { - event.registerAbove(new ResourceLocation("vignette"), ImmersiveWeapons.MOD_ID + ":scope", IWOverlays.SCOPE_ELEMENT); - } + assert IWOverlays.SCOPE_ELEMENT != null; + event.registerAbove(new ResourceLocation("vignette"), + ImmersiveWeapons.MOD_ID + ":scope", + IWOverlays.SCOPE_ELEMENT); + + assert IWOverlays.DEBUG_TRACING_ELEMENT != null; + event.registerAbove(new ResourceLocation(ImmersiveWeapons.MOD_ID + ":scope"), + ImmersiveWeapons.MOD_ID + ":debug_tracing", + IWOverlays.DEBUG_TRACING_ELEMENT); } /** @@ -291,6 +299,13 @@ public static void playerTickEvent(PlayerTickEvent event) { } } } + + // Debug tracing + if (DebugTracingData.isDebugTracingEnabled) { + if (player == Minecraft.getInstance().player) { + DebugTracingData.handleTracing(player); + } + } } @SubscribeEvent diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/event/environment_effects/EnvironmentEffects.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/event/environment_effects/EnvironmentEffects.java index 089c6c845..4675ae762 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/event/environment_effects/EnvironmentEffects.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/event/environment_effects/EnvironmentEffects.java @@ -1,18 +1,25 @@ package tech.anonymoushacker1279.immersiveweapons.event.environment_effects; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; +import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.event.entity.living.LivingHurtEvent; -import tech.anonymoushacker1279.immersiveweapons.init.EffectRegistry; -import tech.anonymoushacker1279.immersiveweapons.init.ItemRegistry; +import net.minecraftforge.fml.DistExecutor; +import net.minecraftforge.network.NetworkEvent; +import net.minecraftforge.network.NetworkEvent.Context; +import net.minecraftforge.network.PacketDistributor; +import tech.anonymoushacker1279.immersiveweapons.init.*; import tech.anonymoushacker1279.immersiveweapons.util.GeneralUtilities; import java.util.Objects; +import java.util.function.Supplier; public class EnvironmentEffects { - private float celestialProtectionChanceForNoDamage = 0.0f; + public static float celestialProtectionChanceForNoDamage = 0.0f; public EnvironmentEffects() { } @@ -44,6 +51,11 @@ public void celestialProtectionEffect(LivingHurtEvent event, LivingEntity damage celestialProtectionChanceForNoDamage += damage * 0.01f; // Other armor has a 1% charge rate } + if (damagedEntity instanceof ServerPlayer player) { + PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), + new EnvironmentEffectsPacketHandler(celestialProtectionChanceForNoDamage)); + } + // This effect grants a 5% damage reduction to all damage taken, unless they rolled for no damage damage = damage * 0.95f; event.setAmount(damage); @@ -102,4 +114,25 @@ public void moltenArmorSetBonus(LivingHurtEvent event, LivingEntity sourceEntity } } } + + public record EnvironmentEffectsPacketHandler(float celestialProtectionChanceForNoDamage) { + + public static void encode(EnvironmentEffectsPacketHandler msg, FriendlyByteBuf packetBuffer) { + packetBuffer.writeFloat(msg.celestialProtectionChanceForNoDamage); + } + + public static EnvironmentEffectsPacketHandler decode(FriendlyByteBuf packetBuffer) { + return new EnvironmentEffectsPacketHandler(packetBuffer.readFloat()); + } + + public static void handle(EnvironmentEffectsPacketHandler msg, Supplier contextSupplier) { + NetworkEvent.Context context = contextSupplier.get(); + context.enqueueWork(() -> DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> runOnClient(msg))); + context.setPacketHandled(true); + } + + private static void runOnClient(EnvironmentEffectsPacketHandler msg) { + EnvironmentEffects.celestialProtectionChanceForNoDamage = msg.celestialProtectionChanceForNoDamage; + } + } } \ No newline at end of file diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/init/PacketHandler.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/init/PacketHandler.java index e45a4c63b..92b8d8cf3 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/init/PacketHandler.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/init/PacketHandler.java @@ -11,6 +11,8 @@ import tech.anonymoushacker1279.immersiveweapons.entity.monster.lava_revenant.LavaRevenantEntity.LavaRevenantEntityPacketHandler; import tech.anonymoushacker1279.immersiveweapons.entity.neutral.AbstractFieldMedicEntity.AbstractFieldMedicEntityPacketHandler; import tech.anonymoushacker1279.immersiveweapons.entity.projectile.SmokeGrenadeEntity.SmokeGrenadeEntityPacketHandler; +import tech.anonymoushacker1279.immersiveweapons.entity.projectile.bullet.BulletEntity.BulletEntityPacketHandler; +import tech.anonymoushacker1279.immersiveweapons.event.environment_effects.EnvironmentEffects.EnvironmentEffectsPacketHandler; import tech.anonymoushacker1279.immersiveweapons.item.armor.AstralArmorItem.AstralArmorItemPacketHandler; import tech.anonymoushacker1279.immersiveweapons.item.armor.CobaltArmorItem.CobaltArmorItemPacketHandler; import tech.anonymoushacker1279.immersiveweapons.item.armor.TeslaArmorItem.TeslaArmorItemPacketHandler; @@ -100,11 +102,23 @@ public static void registerPackets() { AstralArmorItemPacketHandler::decode, AstralArmorItemPacketHandler::handle ); - PacketHandler.INSTANCE.registerMessage(networkId, + PacketHandler.INSTANCE.registerMessage(networkId++, AstralCrystalBlockPacketHandler.class, AstralCrystalBlockPacketHandler::encode, AstralCrystalBlockPacketHandler::decode, AstralCrystalBlockPacketHandler::handle ); + PacketHandler.INSTANCE.registerMessage(networkId++, + BulletEntityPacketHandler.class, + BulletEntityPacketHandler::encode, + BulletEntityPacketHandler::decode, + BulletEntityPacketHandler::handle + ); + PacketHandler.INSTANCE.registerMessage(networkId, + EnvironmentEffectsPacketHandler.class, + EnvironmentEffectsPacketHandler::encode, + EnvironmentEffectsPacketHandler::decode, + EnvironmentEffectsPacketHandler::handle + ); } } \ No newline at end of file diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/item/AzulLocatorItem.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/item/AzulLocatorItem.java index ab8253d68..38a283505 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/item/AzulLocatorItem.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/item/AzulLocatorItem.java @@ -3,6 +3,7 @@ import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; @@ -12,6 +13,8 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; +import java.util.Objects; + public class AzulLocatorItem extends Item { public AzulLocatorItem(Properties properties) { @@ -42,15 +45,19 @@ public void onUseTick(Level level, LivingEntity livingEntity, ItemStack stack, i if (!level.isClientSide) { ServerPlayer serverPlayer = (ServerPlayer) player; BlockPos spawnPos = serverPlayer.getRespawnPosition(); + ServerLevel spawnLevel = Objects.requireNonNull(serverPlayer.getServer()).getLevel(serverPlayer.getRespawnDimension()); if (spawnPos == null) { player.displayClientMessage(Component.translatable("immersiveweapons.item.azul_locator.no_spawn") .withStyle(ChatFormatting.RED), true); player.getCooldowns().addCooldown(this, 60); } else { - player.teleportTo(spawnPos.getX() + 0.5f, spawnPos.getY(), spawnPos.getZ() + 0.5f); - player.displayClientMessage(Component.translatable("immersiveweapons.item.azul_locator.teleported") - .withStyle(ChatFormatting.GREEN), true); + if (spawnLevel != null) { + serverPlayer.teleportTo(spawnLevel, spawnPos.getX() + 0.5f, spawnPos.getY(), spawnPos.getZ() + 0.5f, player.getYRot(), player.getXRot()); + player.teleportTo(spawnPos.getX() + 0.5f, spawnPos.getY(), spawnPos.getZ() + 0.5f); + player.displayClientMessage(Component.translatable("immersiveweapons.item.azul_locator.teleported") + .withStyle(ChatFormatting.GREEN), true); + } if (!player.isCreative()) { stack.hurtAndBreak(1, player, (entity) -> entity.broadcastBreakEvent(player.getUsedItemHand())); diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/item/materials/CustomItemMaterials.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/item/materials/CustomItemMaterials.java index eeac91dc0..898be7dc3 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/item/materials/CustomItemMaterials.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/item/materials/CustomItemMaterials.java @@ -43,7 +43,7 @@ public class CustomItemMaterials { List.of(Tiers.NETHERITE), List.of()); public static final Tier STARSTORM = TierSortingRegistry.registerTier( new ForgeTier(4, 1800, 14.0F, 7.0F, 20, BlockTags.create(new ResourceLocation("")), - () -> Ingredient.of(ItemRegistry.ASTRAL_INGOT.get())), + () -> Ingredient.of(ItemRegistry.STARSTORM_INGOT.get())), new ResourceLocation("immersiveweapons:starstorm"), List.of(Tiers.NETHERITE), List.of()); } \ No newline at end of file diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/item/projectile/gun/AbstractGunItem.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/item/projectile/gun/AbstractGunItem.java index 399574fa7..e79c25209 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/item/projectile/gun/AbstractGunItem.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/item/projectile/gun/AbstractGunItem.java @@ -172,32 +172,25 @@ public void releaseUsing(ItemStack itemStack, Level level, LivingEntity livingEn } } - /** - * Find ammunition. - * - * @param itemStack the ItemStack to look for - * @param livingEntity the LivingEntity to be searched - * @return ItemStack - */ - ItemStack findAmmo(ItemStack itemStack, LivingEntity livingEntity) { - Player playerEntity = (Player) livingEntity; - if (!(itemStack.getItem() instanceof AbstractGunItem)) { + public ItemStack findAmmo(ItemStack gun, LivingEntity livingEntity) { + Player player = (Player) livingEntity; + if (!(gun.getItem() instanceof AbstractGunItem)) { return ItemStack.EMPTY; } else { - Predicate ammoPredicate = ((AbstractGunItem) itemStack.getItem()).getAmmoPredicate(); - ItemStack heldAmmo = AbstractGunItem.getHeldAmmo(playerEntity, ammoPredicate); + Predicate ammoPredicate = ((AbstractGunItem) gun.getItem()).getAmmoPredicate(); + ItemStack heldAmmo = AbstractGunItem.getHeldAmmo(player, ammoPredicate); if (!heldAmmo.isEmpty()) { return heldAmmo; } else { - ammoPredicate = ((AbstractGunItem) itemStack.getItem()).getInventoryAmmoPredicate(); - for (int i = 0; i < playerEntity.getInventory().getContainerSize(); ++i) { - ItemStack ammoItem = playerEntity.getInventory().getItem(i); + ammoPredicate = ((AbstractGunItem) gun.getItem()).getInventoryAmmoPredicate(); + for (int i = 0; i < player.getInventory().getContainerSize(); ++i) { + ItemStack ammoItem = player.getInventory().getItem(i); if (ammoPredicate.test(ammoItem)) { return ammoItem; } } - return playerEntity.isCreative() ? new ItemStack(defaultAmmo()) : ItemStack.EMPTY; + return player.isCreative() ? new ItemStack(defaultAmmo()) : ItemStack.EMPTY; } } } @@ -397,6 +390,10 @@ public boolean canScope() { return false; } + public float getFireVelocity() { + return CommonConfig.FLINTLOCK_PISTOL_FIRE_VELOCITY.get().floatValue(); + } + protected void fireBullets(AbstractBulletItem bulletItem, Level level, Player player, ItemStack firingItem) { BulletEntity bulletEntity = bulletItem.createBullet(level, player); @@ -404,7 +401,7 @@ protected void fireBullets(AbstractBulletItem bulletItem, Level level, Player pl bulletEntity.shootFromRotation(player, player.xRot, player.yRot, 0.0F, - CommonConfig.FLINTLOCK_PISTOL_FIRE_VELOCITY.get().floatValue(), + getFireVelocity(), CommonConfig.FLINTLOCK_PISTOL_FIRE_INACCURACY.get().floatValue()); // Roll for random crits diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/item/projectile/gun/MusketItem.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/item/projectile/gun/MusketItem.java index 550db852e..62db8a17f 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/item/projectile/gun/MusketItem.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/item/projectile/gun/MusketItem.java @@ -34,7 +34,9 @@ protected void fireBullets(AbstractBulletItem bulletItem, Level level, Player pl bulletEntity.setFiringItem(firingItem.getItem()); bulletEntity.shootFromRotation(player, player.xRot, player.yRot, - 0.0F, CommonConfig.MUSKET_FIRE_VELOCITY.get().floatValue(), CommonConfig.MUSKET_FIRE_INACCURACY.get().floatValue()); + 0.0F, + getFireVelocity(), + CommonConfig.MUSKET_FIRE_INACCURACY.get().floatValue()); // Roll for random crits if (GeneralUtilities.getRandomNumber(0f, 1f) <= CommonConfig.GUN_CRIT_CHANCE.get()) { @@ -89,4 +91,9 @@ public float getMaxXRecoil() { public boolean canScope() { return hasScope; } + + @Override + public float getFireVelocity() { + return CommonConfig.MUSKET_FIRE_VELOCITY.get().floatValue(); + } } \ No newline at end of file diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/item/projectile/gun/SimpleShotgunItem.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/item/projectile/gun/SimpleShotgunItem.java index 2da79f047..076241565 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/item/projectile/gun/SimpleShotgunItem.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/item/projectile/gun/SimpleShotgunItem.java @@ -33,7 +33,9 @@ protected void fireBullets(AbstractBulletItem bulletItem, Level level, Player pl bulletEntity.shootFromRotation(player, player.xRot + GeneralUtilities.getRandomNumber(-5.0f, 5.0f), player.yRot + GeneralUtilities.getRandomNumber(-5.0f, 5.0f), - 0.0F, CommonConfig.BLUNDERBUSS_FIRE_VELOCITY.get().floatValue(), CommonConfig.BLUNDERBUSS_FIRE_INACCURACY.get().floatValue()); + 0.0F, + getFireVelocity(), + CommonConfig.BLUNDERBUSS_FIRE_INACCURACY.get().floatValue()); // Roll for random crits if (GeneralUtilities.getRandomNumber(0f, 1f) <= CommonConfig.GUN_CRIT_CHANCE.get()) { @@ -89,4 +91,9 @@ public float getMaxXRecoil() { public int getMaxBulletsToFire() { return 4; } + + @Override + public float getFireVelocity() { + return CommonConfig.BLUNDERBUSS_FIRE_VELOCITY.get().floatValue(); + } } \ No newline at end of file diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/world/TiltrosTeleporter.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/world/TiltrosTeleporter.java index c73c4d7c9..5fe4ec721 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/world/TiltrosTeleporter.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/world/TiltrosTeleporter.java @@ -36,12 +36,8 @@ public Entity placeEntity(Entity entity, ServerLevel currentWorld, ServerLevel d // Build a spawn area with another portal, if one doesn't already exist Stream destinationBlockStates = destWorld.getBlockStates( - new AABB(targetPos.getX() - 2, - targetPos.getY() - 2, - targetPos.getZ() - 2, - targetPos.getX() + 2, - targetPos.getY() + 2, - targetPos.getZ() + 2)); + new AABB(targetPos.below(3).relative(entity.getDirection().getOpposite(), 2), + targetPos.above(3).relative(entity.getDirection(), 2))); if (destinationBlockStates.noneMatch(blockState -> blockState == BlockRegistry.AZUL_STAINED_ORCHID.get().defaultBlockState())) { diff --git a/src/main/java/tech/anonymoushacker1279/immersiveweapons/world/level/levelgen/OreReplacementData.java b/src/main/java/tech/anonymoushacker1279/immersiveweapons/world/level/levelgen/OreReplacementData.java index 6dcdae3c6..8372418ba 100644 --- a/src/main/java/tech/anonymoushacker1279/immersiveweapons/world/level/levelgen/OreReplacementData.java +++ b/src/main/java/tech/anonymoushacker1279/immersiveweapons/world/level/levelgen/OreReplacementData.java @@ -1,14 +1,11 @@ package tech.anonymoushacker1279.immersiveweapons.world.level.levelgen; -import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BlockTags; -import net.minecraft.tags.TagKey; -import net.minecraft.world.level.block.Block; import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration; import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration.TargetBlockState; import net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest; import net.minecraft.world.level.levelgen.structure.templatesystem.TagMatchTest; +import net.minecraftforge.common.Tags.Blocks; import tech.anonymoushacker1279.immersiveweapons.init.BlockRegistry; import java.util.List; @@ -18,13 +15,8 @@ public class OreReplacementData { static final class ReplacementRules { public static final RuleTest REGULAR_STONE = new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES); public static final RuleTest DEEPSLATE_STONE = new TagMatchTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES); + public static final RuleTest NETHER_STONE = new TagMatchTest(Blocks.ORE_BEARING_GROUND_NETHERRACK); - public static final RuleTest NETHER_STONE = createRuleFromTag("forge:ore_bearing_ground/netherrack"); - - public static RuleTest createRuleFromTag(String tagLocation) { - TagKey blockTag = TagKey.create(Registries.BLOCK, new ResourceLocation(tagLocation)); - return new TagMatchTest(blockTag); - } } public static class OreReplacementTargets { diff --git a/src/main/resources/data/immersiveweapons/worldgen/template_pool/biodome.json b/src/main/resources/data/immersiveweapons/worldgen/template_pool/biodome.json index 206a28a47..65ebc8d90 100644 --- a/src/main/resources/data/immersiveweapons/worldgen/template_pool/biodome.json +++ b/src/main/resources/data/immersiveweapons/worldgen/template_pool/biodome.json @@ -6,7 +6,7 @@ "weight": 1, "element": { "location": "immersiveweapons:biodome", - "processors": "minecraft:empty", + "processors": "immersiveweapons:rust_70_percent", "projection": "rigid", "element_type": "minecraft:single_pool_element" } diff --git a/update.json b/update.json index b0ebde30d..c48e75281 100644 --- a/update.json +++ b/update.json @@ -1,8 +1,8 @@ { "homepage": "https://www.curseforge.com/minecraft/mc-mods/immersive-weapons", "promos": { - "1.19.3-latest": "1.19.3-1.20.0", - "1.19.3-recommended": "1.19.3-1.20.0", + "1.19.3-latest": "1.19.3-1.20.1", + "1.19.3-recommended": "1.19.3-1.20.1", "1.19-latest": "1.19-1.18.4", "1.19-recommended": "1.19-1.18.4", "1.18.2-latest": "1.18.2-1.17.4", @@ -19,6 +19,7 @@ "1.16.4-recommended": "1.16.5-1.1.1" }, "1.19.3": { + "1.19.3-1.20.1": "Improvements and bugfixes - https://github.com/AnonymousHacker1279/ImmersiveWeapons/releases/tag/v1.20.1", "1.19.3-1.20.0": "Features, improvements, bugfixes - https://github.com/AnonymousHacker1279/ImmersiveWeapons/releases/tag/v1.20.0", "1.19.3-1.19.1": "Bugfixes and improvements - https://github.com/AnonymousHacker1279/ImmersiveWeapons/releases/tag/v1.19.1", "1.19.3-1.19.0": "Features, improvements, bugfixes, and initial 1.19.3 release - https://github.com/AnonymousHacker1279/ImmersiveWeapons/releases/tag/v1.19.0"