From 93214f9e9e731dfdbab75af20fcf501d4c7f2fcc Mon Sep 17 00:00:00 2001 From: Corosauce Date: Sat, 7 Oct 2023 16:18:12 +0100 Subject: [PATCH] more updates and temp removals, stripped out shader work --- .../ParticleManagerExtended.java | 235 +-- .../ParticleRegistry2ElectricBubbleoo.java | 32 +- .../particle/ParticleRegistry.java | 140 +- .../particle/entity/EntityRotFX.java | 23 +- .../particle/entity/ParticleCrossSection.java | 13 +- .../particle/entity/ParticleCube.java | 18 +- .../entity/ParticleTexExtraRender.java | 9 +- .../entity/WaterDropParticleImpl.java | 12 + src/main/java/weather2/ClientRegistry.java | 2 +- .../java/weather2/ClientWeatherProxy.java | 6 +- src/main/java/weather2/DeferredHelper.java | 206 +++ src/main/java/weather2/EntityRegistry.java | 19 +- src/main/java/weather2/EventHandlerForge.java | 28 +- src/main/java/weather2/ServerTickHandler.java | 10 +- src/main/java/weather2/SoundRegistry.java | 17 +- src/main/java/weather2/Weather.java | 15 +- src/main/java/weather2/WeatherBlocks.java | 33 +- src/main/java/weather2/WeatherItems.java | 3 +- src/main/java/weather2/WeatherTab.java | 9 +- .../java/weather2/block/ForecastBlock.java | 10 +- .../blockentity/DeflectorBlockEntity.java | 3 +- .../client/MovingSoundStreamingSource.java | 7 +- .../java/weather2/client/SceneEnhancer.java | 48 +- .../shaders/ShaderInstanceExtended.java | 558 -------- .../shaders/ShaderInstanceExtendedEh.java | 105 -- .../client/shaders/VertexBufferInstanced.java | 321 ----- .../client/shaders/WeatherShaders.java | 84 -- .../weather2/client/shaderstest/Cloud.java | 22 - .../client/shaderstest/CloudManager.java | 143 -- .../client/shaderstest/CloudNode.java | 114 -- .../client/shaderstest/CloudPiece.java | 382 ----- .../shaderstest/InstancedMeshParticle.java | 191 --- .../client/shaderstest/Matrix4fe.java | 692 --------- .../weather2/client/shaderstest/Mesh.java | 262 ---- .../MeshBufferManagerParticle.java | 417 ------ .../weather2/client/shaderstest/Model.java | 12 - .../java/weather2/command/WeatherCommand.java | 4 +- .../weather2/data/WeatherRecipeProvider.java | 5 +- src/main/java/weather2/item/WeatherItem.java | 7 +- .../mixin/client/RenderParticlesOverride.java | 7 +- src/main/java/weather2/util/WeatherUtil.java | 21 +- .../java/weather2/util/WeatherUtilBlock.java | 18 +- .../java/weather2/util/WeatherUtilDim.java | 2 +- .../weathersystem/WeatherManagerClient.java | 26 +- .../weathersystem/WeatherManagerServer.java | 7 +- .../weathersystem/sky/CloudRenderHandler.java | 1257 ----------------- .../sky/WeatherParticleRenderHandler.java | 17 - .../storm/LightningBoltWeather.java | 4 - .../storm/LightningBoltWeatherNew.java | 4 - .../weathersystem/storm/StormObject.java | 23 +- .../weathersystem/storm/TornadoHelper.java | 5 +- .../storm/WeatherObjectParticleStorm.java | 3 +- .../storm/WeatherObjectSandstormOld.java | 3 +- .../weathersystem/tornado/TornadoFunnel.java | 15 +- .../tornado/TornadoManagerTodoRenameMe.java | 16 +- .../weathersystem/wind/WindManager.java | 15 +- 56 files changed, 615 insertions(+), 5045 deletions(-) create mode 100644 src/main/java/extendedrenderer/particle/entity/WaterDropParticleImpl.java create mode 100644 src/main/java/weather2/DeferredHelper.java delete mode 100644 src/main/java/weather2/client/shaders/ShaderInstanceExtended.java delete mode 100644 src/main/java/weather2/client/shaders/ShaderInstanceExtendedEh.java delete mode 100644 src/main/java/weather2/client/shaders/VertexBufferInstanced.java delete mode 100644 src/main/java/weather2/client/shaders/WeatherShaders.java delete mode 100644 src/main/java/weather2/client/shaderstest/Cloud.java delete mode 100644 src/main/java/weather2/client/shaderstest/CloudManager.java delete mode 100644 src/main/java/weather2/client/shaderstest/CloudNode.java delete mode 100644 src/main/java/weather2/client/shaderstest/CloudPiece.java delete mode 100644 src/main/java/weather2/client/shaderstest/InstancedMeshParticle.java delete mode 100644 src/main/java/weather2/client/shaderstest/Matrix4fe.java delete mode 100644 src/main/java/weather2/client/shaderstest/Mesh.java delete mode 100644 src/main/java/weather2/client/shaderstest/MeshBufferManagerParticle.java delete mode 100644 src/main/java/weather2/client/shaderstest/Model.java delete mode 100644 src/main/java/weather2/weathersystem/sky/CloudRenderHandler.java delete mode 100644 src/main/java/weather2/weathersystem/sky/WeatherParticleRenderHandler.java diff --git a/src/main/java/extendedrenderer/ParticleManagerExtended.java b/src/main/java/extendedrenderer/ParticleManagerExtended.java index a322364c..c9a77e4c 100644 --- a/src/main/java/extendedrenderer/ParticleManagerExtended.java +++ b/src/main/java/extendedrenderer/ParticleManagerExtended.java @@ -1,40 +1,42 @@ package extendedrenderer; -import com.google.common.base.Charsets; import com.google.common.collect.*; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.BufferBuilder; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.Tesselator; +import com.mojang.logging.LogUtils; import extendedrenderer.particle.entity.EntityRotFX; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import net.minecraft.CrashReport; import net.minecraft.CrashReportCategory; import net.minecraft.ReportedException; +import net.minecraft.Util; import net.minecraft.client.Camera; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.particle.*; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite; +import net.minecraft.client.renderer.texture.SpriteLoader; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -import net.minecraft.core.BuiltInRegistries; import net.minecraft.core.particles.ParticleGroup; import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleType; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.FileToIdConverter; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.resources.PreparableReloadListener; import net.minecraft.server.packs.resources.Resource; import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.util.GsonHelper; import net.minecraft.util.Mth; +import net.minecraft.util.RandomSource; import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.block.RenderShape; @@ -43,10 +45,10 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import org.slf4j.Logger; import javax.annotation.Nullable; import java.io.IOException; -import java.io.InputStreamReader; import java.io.Reader; import java.util.*; import java.util.concurrent.CompletableFuture; @@ -55,13 +57,16 @@ @OnlyIn(Dist.CLIENT) public class ParticleManagerExtended implements PreparableReloadListener { + private static final Logger LOGGER = LogUtils.getLogger(); + private static final FileToIdConverter PARTICLE_LISTER = FileToIdConverter.json("particles"); + private static final ResourceLocation PARTICLES_ATLAS_INFO = new ResourceLocation("particles"); private static final int MAX_PARTICLES_PER_LAYER = 16384; - private static final List RENDER_ORDER = ImmutableList.of(ParticleRenderType.TERRAIN_SHEET, ParticleRenderType.PARTICLE_SHEET_OPAQUE, ParticleRenderType.PARTICLE_SHEET_LIT, ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT, ParticleRenderType.CUSTOM, EntityRotFX.SORTED_OPAQUE_BLOCK, EntityRotFX.SORTED_TRANSLUCENT); + private static final List RENDER_ORDER = ImmutableList.of(ParticleRenderType.TERRAIN_SHEET, ParticleRenderType.PARTICLE_SHEET_OPAQUE, ParticleRenderType.PARTICLE_SHEET_LIT, ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT, ParticleRenderType.CUSTOM, ParticleRenderType.CUSTOM, EntityRotFX.SORTED_OPAQUE_BLOCK, EntityRotFX.SORTED_TRANSLUCENT); protected ClientLevel level; private final Map> particles = Maps.newTreeMap(net.minecraftforge.client.ForgeHooksClient.makeParticleRenderTypeComparator(RENDER_ORDER)); private final Queue trackingEmitters = Queues.newArrayDeque(); private final TextureManager textureManager; - private final Random random = new Random(); + private final RandomSource random = RandomSource.create(); private final Map> providers = new java.util.HashMap<>(); private final Queue particlesToAdd = Queues.newArrayDeque(); private final Map spriteSets = Maps.newHashMap(); @@ -75,43 +80,87 @@ public ParticleManagerExtended(ClientLevel p_107299_, TextureManager p_107300_) this.textureManager = p_107300_; } + /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */ + @Deprecated public void register(ParticleType p_107382_, ParticleProvider p_107383_) { this.providers.put(BuiltInRegistries.PARTICLE_TYPE.getKey(p_107382_), p_107383_); } + /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */ + @Deprecated + public void register(ParticleType p_273423_, ParticleProvider.Sprite p_273134_) { + this.register(p_273423_, (p_272320_) -> { + return (p_272323_, p_272324_, p_272325_, p_272326_, p_272327_, p_272328_, p_272329_, p_272330_) -> { + TextureSheetParticle texturesheetparticle = p_273134_.createParticle(p_272323_, p_272324_, p_272325_, p_272326_, p_272327_, p_272328_, p_272329_, p_272330_); + if (texturesheetparticle != null) { + texturesheetparticle.pickSprite(p_272320_); + } + + return texturesheetparticle; + }; + }); + } + + /** @deprecated Register via {@link net.minecraftforge.client.event.RegisterParticleProvidersEvent} */ + @Deprecated public void register(ParticleType p_107379_, ParticleManagerExtended.SpriteParticleRegistration p_107380_) { ParticleManagerExtended.MutableSpriteSet particleengine$mutablespriteset = new ParticleManagerExtended.MutableSpriteSet(); this.spriteSets.put(BuiltInRegistries.PARTICLE_TYPE.getKey(p_107379_), particleengine$mutablespriteset); this.providers.put(BuiltInRegistries.PARTICLE_TYPE.getKey(p_107379_), p_107380_.create(particleengine$mutablespriteset)); } - public CompletableFuture reload(PreparationBarrier p_107305_, ResourceManager p_107306_, ProfilerFiller p_107307_, ProfilerFiller p_107308_, Executor p_107309_, Executor p_107310_) { - Map> map = Maps.newConcurrentMap(); - CompletableFuture[] completablefuture = BuiltInRegistries.PARTICLE_TYPE.keySet().stream().map((p_107315_) -> { - return CompletableFuture.runAsync(() -> { - this.loadParticleDescription(p_107306_, p_107315_, map); - }, p_107309_); - }).toArray((p_107303_) -> { - return new CompletableFuture[p_107303_]; + public CompletableFuture reload(PreparableReloadListener.PreparationBarrier p_107305_, ResourceManager p_107306_, ProfilerFiller p_107307_, ProfilerFiller p_107308_, Executor p_107309_, Executor p_107310_) { + @OnlyIn(Dist.CLIENT) + record ParticleDefinition(ResourceLocation id, Optional> sprites) { + } + CompletableFuture> completablefuture = CompletableFuture.supplyAsync(() -> { + return PARTICLE_LISTER.listMatchingResources(p_107306_); + }, p_107309_).thenCompose((p_247914_) -> { + List> list = new ArrayList<>(p_247914_.size()); + p_247914_.forEach((p_247903_, p_247904_) -> { + ResourceLocation resourcelocation = PARTICLE_LISTER.fileToId(p_247903_); + list.add(CompletableFuture.supplyAsync(() -> { + return new ParticleDefinition(resourcelocation, this.loadParticleDescription(resourcelocation, p_247904_)); + }, p_107309_)); + }); + return Util.sequence(list); }); - return CompletableFuture.allOf(completablefuture).thenApplyAsync((p_107324_) -> { - p_107307_.startTick(); - p_107307_.push("stitching"); - TextureAtlas.Preparations textureatlas$preparations = this.textureAtlas.prepareToStitch(p_107306_, map.values().stream().flatMap(Collection::stream), p_107307_, 0); - p_107307_.pop(); - p_107307_.endTick(); - return textureatlas$preparations; - }, p_107309_).thenCompose(p_107305_::wait).thenAcceptAsync((p_107328_) -> { - this.particles.clear(); + CompletableFuture completablefuture1 = SpriteLoader.create(this.textureAtlas).loadAndStitch(p_107306_, PARTICLES_ATLAS_INFO, 0, p_107309_).thenCompose(SpriteLoader.Preparations::waitForUpload); + return CompletableFuture.allOf(completablefuture1, completablefuture).thenCompose(p_107305_::wait).thenAcceptAsync((p_247900_) -> { + this.clearParticles(); p_107308_.startTick(); p_107308_.push("upload"); - this.textureAtlas.reload(p_107328_); + SpriteLoader.Preparations spriteloader$preparations = completablefuture1.join(); + this.textureAtlas.upload(spriteloader$preparations); p_107308_.popPush("bindSpriteSets"); - TextureAtlasSprite textureatlassprite = this.textureAtlas.getSprite(MissingTextureAtlasSprite.getLocation()); - map.forEach((p_172268_, p_172269_) -> { - ImmutableList immutablelist = p_172269_.isEmpty() ? ImmutableList.of(textureatlassprite) : p_172269_.stream().map(this.textureAtlas::getSprite).collect(ImmutableList.toImmutableList()); - this.spriteSets.get(p_172268_).rebind(immutablelist); + Set set = new HashSet<>(); + TextureAtlasSprite textureatlassprite = spriteloader$preparations.missing(); + completablefuture.join().forEach((p_247911_) -> { + Optional> optional = p_247911_.sprites(); + if (!optional.isEmpty()) { + List list = new ArrayList<>(); + + for(ResourceLocation resourcelocation : optional.get()) { + TextureAtlasSprite textureatlassprite1 = spriteloader$preparations.regions().get(resourcelocation); + if (textureatlassprite1 == null) { + set.add(resourcelocation); + list.add(textureatlassprite); + } else { + list.add(textureatlassprite1); + } + } + + if (list.isEmpty()) { + list.add(textureatlassprite); + } + + this.spriteSets.get(p_247911_.id()).rebind(list); + } }); + if (!set.isEmpty()) { + LOGGER.warn("Missing particle sprites: {}", set.stream().sorted().map(ResourceLocation::toString).collect(Collectors.joining(","))); + } + p_107308_.pop(); p_107308_.endTick(); }, p_107310_); @@ -121,61 +170,17 @@ public void close() { this.textureAtlas.clearTextureData(); } - private void loadParticleDescription(ResourceManager p_107317_, ResourceLocation p_107318_, Map> p_107319_) { - ResourceLocation resourcelocation = new ResourceLocation(p_107318_.getNamespace(), "particles/" + p_107318_.getPath() + ".json"); - - try { - Resource resource = p_107317_.getResource(resourcelocation); - - try { - Reader reader = new InputStreamReader(resource.getInputStream(), Charsets.UTF_8); - - try { - ParticleDescription particledescription = ParticleDescription.fromJson(GsonHelper.parse(reader)); - List list = particledescription.getTextures(); - boolean flag = this.spriteSets.containsKey(p_107318_); - if (list == null) { - if (flag) { - throw new IllegalStateException("Missing texture list for particle " + p_107318_); - } - } else { - if (!flag) { - throw new IllegalStateException("Redundant texture list for particle " + p_107318_); - } - - p_107319_.put(p_107318_, list.stream().map((p_107387_) -> { - return new ResourceLocation(p_107387_.getNamespace(), "particle/" + p_107387_.getPath()); - }).collect(Collectors.toList())); - } - } catch (Throwable throwable2) { - try { - reader.close(); - } catch (Throwable throwable1) { - throwable2.addSuppressed(throwable1); - } - - throw throwable2; - } - - reader.close(); - } catch (Throwable throwable3) { - if (resource != null) { - try { - resource.close(); - } catch (Throwable throwable) { - throwable3.addSuppressed(throwable); - } - } - - throw throwable3; - } - - if (resource != null) { - resource.close(); + private Optional> loadParticleDescription(ResourceLocation p_250648_, Resource p_248793_) { + if (!this.spriteSets.containsKey(p_250648_)) { + LOGGER.debug("Redundant texture list for particle: {}", (Object)p_250648_); + return Optional.empty(); + } else { + try (Reader reader = p_248793_.openAsReader()) { + ParticleDescription particledescription = ParticleDescription.fromJson(GsonHelper.parse(reader)); + return Optional.of(particledescription.getTextures()); + } catch (IOException ioexception) { + throw new IllegalStateException("Failed to load description for particle " + p_250648_, ioexception); } - - } catch (IOException ioexception) { - throw new IllegalStateException("Failed to load description for particle " + p_107318_, ioexception); } } @@ -218,9 +223,9 @@ public void add(Particle p_107345_) { } public void tick() { - this.particles.forEach((p_107349_, p_107350_) -> { - this.level.getProfiler().push(p_107349_.toString()); - this.tickParticleList(p_107350_); + this.particles.forEach((p_288249_, p_288250_) -> { + this.level.getProfiler().push(p_288249_.toString()); + this.tickParticleList(p_288250_); this.level.getProfiler().pop(); }); if (!this.trackingEmitters.isEmpty()) { @@ -288,32 +293,39 @@ public void render(PoseStack p_107337_, MultiBufferSource.BufferSource p_107338_ } public void render(PoseStack p_107337_, MultiBufferSource.BufferSource p_107338_, LightTexture p_107339_, Camera p_107340_, float p_107341_, @Nullable net.minecraft.client.renderer.culling.Frustum clippingHelper) { + //if (true) return; float fogStart = RenderSystem.getShaderFogStart(); float fogEnd = RenderSystem.getShaderFogEnd(); RenderSystem.setShaderFogStart(fogStart * 4); RenderSystem.setShaderFogEnd(fogEnd * 4); + p_107339_.turnOnLightLayer(); RenderSystem.enableDepthTest(); + + //these didnt exist in our 1.18 modification, why? + RenderSystem.activeTexture(org.lwjgl.opengl.GL13.GL_TEXTURE2); + RenderSystem.activeTexture(org.lwjgl.opengl.GL13.GL_TEXTURE0); + PoseStack posestack = RenderSystem.getModelViewStack(); posestack.pushPose(); posestack.mulPoseMatrix(p_107337_.last().pose()); RenderSystem.applyModelViewMatrix(); RenderSystem.disableCull(); - int particleCount = 0; + for(ParticleRenderType particlerendertype : this.particles.keySet()) { // Forge: allow custom IParticleRenderType's if (particlerendertype == ParticleRenderType.NO_RENDER) continue; Iterable iterable = this.particles.get(particlerendertype); if (iterable != null) { RenderSystem.setShader(GameRenderer::getParticleShader); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); Tesselator tesselator = Tesselator.getInstance(); BufferBuilder bufferbuilder = tesselator.getBuilder(); particlerendertype.begin(bufferbuilder, this.textureManager); for(Particle particle : iterable) { + if (particle instanceof EntityRotFX) { if (clippingHelper != null && particle.shouldCull() && !clippingHelper.isVisible(((EntityRotFX)particle).getBoundingBoxForRender(p_107341_))) continue; @@ -321,9 +333,9 @@ public void render(PoseStack p_107337_, MultiBufferSource.BufferSource p_107338_ if (clippingHelper != null && particle.shouldCull() && !clippingHelper.isVisible(particle.getBoundingBox())) continue; } + try { particle.render(bufferbuilder, p_107340_, p_107341_); - particleCount++; } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Rendering Particle"); CrashReportCategory crashreportcategory = crashreport.addCategory("Particle being rendered"); @@ -342,15 +354,45 @@ public void render(PoseStack p_107337_, MultiBufferSource.BufferSource p_107338_ RenderSystem.depthMask(true); RenderSystem.disableBlend(); p_107339_.turnOffLightLayer(); + RenderSystem.setShaderFogStart(fogStart); RenderSystem.setShaderFogEnd(fogEnd); } public void setLevel(@Nullable ClientLevel p_107343_) { this.level = p_107343_; - this.particles.clear(); + this.clearParticles(); this.trackingEmitters.clear(); - this.trackedParticleCounts.clear(); + } + + public void destroy(BlockPos p_107356_, BlockState p_107357_) { + if (!p_107357_.isAir()) { + VoxelShape voxelshape = p_107357_.getShape(this.level, p_107356_); + double d0 = 0.25D; + voxelshape.forAllBoxes((p_172273_, p_172274_, p_172275_, p_172276_, p_172277_, p_172278_) -> { + double d1 = Math.min(1.0D, p_172276_ - p_172273_); + double d2 = Math.min(1.0D, p_172277_ - p_172274_); + double d3 = Math.min(1.0D, p_172278_ - p_172275_); + int i = Math.max(2, Mth.ceil(d1 / 0.25D)); + int j = Math.max(2, Mth.ceil(d2 / 0.25D)); + int k = Math.max(2, Mth.ceil(d3 / 0.25D)); + + for(int l = 0; l < i; ++l) { + for(int i1 = 0; i1 < j; ++i1) { + for(int j1 = 0; j1 < k; ++j1) { + double d4 = ((double)l + 0.5D) / (double)i; + double d5 = ((double)i1 + 0.5D) / (double)j; + double d6 = ((double)j1 + 0.5D) / (double)k; + double d7 = d4 * d1 + p_172273_; + double d8 = d5 * d2 + p_172274_; + double d9 = d6 * d3 + p_172275_; + this.add(new TerrainParticle(this.level, (double)p_107356_.getX() + d7, (double)p_107356_.getY() + d8, (double)p_107356_.getZ() + d9, d4 - 0.5D, d5 - 0.5D, d6 - 0.5D, p_107357_, p_107356_).updateSprite(p_107357_, p_107356_)); + } + } + } + + }); + } } public void crack(BlockPos p_107368_, Direction p_107369_) { @@ -400,16 +442,23 @@ private boolean hasSpaceInParticleLimit(ParticleGroup p_172280_) { return this.trackedParticleCounts.getInt(p_172280_) < p_172280_.getLimit(); } + private void clearParticles() { + this.particles.clear(); + this.particlesToAdd.clear(); + this.trackingEmitters.clear(); + this.trackedParticleCounts.clear(); + } + @OnlyIn(Dist.CLIENT) - class MutableSpriteSet implements SpriteSet { + static class MutableSpriteSet implements SpriteSet { private List sprites; public TextureAtlasSprite get(int p_107413_, int p_107414_) { return this.sprites.get(p_107413_ * (this.sprites.size() - 1) / p_107414_); } - public TextureAtlasSprite get(Random p_107418_) { - return this.sprites.get(p_107418_.nextInt(this.sprites.size())); + public TextureAtlasSprite get(RandomSource p_233889_) { + return this.sprites.get(p_233889_.nextInt(this.sprites.size())); } public void rebind(List p_107416_) { diff --git a/src/main/java/extendedrenderer/ParticleRegistry2ElectricBubbleoo.java b/src/main/java/extendedrenderer/ParticleRegistry2ElectricBubbleoo.java index b171eaa2..5c0ecba2 100644 --- a/src/main/java/extendedrenderer/ParticleRegistry2ElectricBubbleoo.java +++ b/src/main/java/extendedrenderer/ParticleRegistry2ElectricBubbleoo.java @@ -1,36 +1,46 @@ package extendedrenderer; +import weather2.DeferredHelper; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.WaterDropParticle; import net.minecraft.core.particles.SimpleParticleType; -import net.minecraft.core.particles.ParticleType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.event.ParticleFactoryRegisterEvent; -import net.minecraftforge.event.RegistryEvent; +import net.minecraftforge.client.event.RegisterParticleProvidersEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.registries.ObjectHolder; +import net.minecraftforge.registries.RegistryObject; import weather2.Weather; -@ObjectHolder(Weather.MODID) +//@ObjectHolder(Weather.MODID) @Mod.EventBusSubscriber(modid = Weather.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public class ParticleRegistry2ElectricBubbleoo { - @ObjectHolder("acidrain_splash") - public static SimpleParticleType ACIDRAIN_SPLASH; + //@ObjectHolder("acidrain_splash") + //public static SimpleParticleType ACIDRAIN_SPLASH; + public static final RegistryObject ACIDRAIN_SPLASH = Weather.R.particle("acidrain_splash", () -> new SimpleParticleType(false)); - @SubscribeEvent + /*@SubscribeEvent public static void registerParticles(RegistryEvent.Register> evt){ SimpleParticleType acidrain_splash = new SimpleParticleType(false); acidrain_splash.setRegistryName(Weather.MODID, "acidrain_splash"); evt.getRegistry().register(acidrain_splash); - } + }*/ - @OnlyIn(Dist.CLIENT) + /*@OnlyIn(Dist.CLIENT) @SubscribeEvent public static void registerParticleFactory(ParticleFactoryRegisterEvent evt){ - Minecraft.getInstance().particleEngine.register(ParticleRegistry2ElectricBubbleoo.ACIDRAIN_SPLASH, + Minecraft.getInstance().particleEngine.register(ParticleRegistry2ElectricBubbleoo.ACIDRAIN_SPLASH.get(), WaterDropParticle.Provider::new); + }*/ + + @SubscribeEvent + @OnlyIn(Dist.CLIENT) + public static void factories(RegisterParticleProvidersEvent event) { + //event.registerSprite(ACIDRAIN_SPLASH.get(), WaterDropParticleImpl::new); + Minecraft.getInstance().particleEngine.register(new SimpleParticleType(false), WaterDropParticle.Provider::new); + //event.registerSpecial(new SimpleParticleType(false), WaterDropParticle.Provider::new); } + + public static void bootstrap() {} } diff --git a/src/main/java/extendedrenderer/particle/ParticleRegistry.java b/src/main/java/extendedrenderer/particle/ParticleRegistry.java index 1d41d537..128d7198 100644 --- a/src/main/java/extendedrenderer/particle/ParticleRegistry.java +++ b/src/main/java/extendedrenderer/particle/ParticleRegistry.java @@ -6,6 +6,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.client.event.RegisterParticleProvidersEvent; import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -58,143 +59,4 @@ public class ParticleRegistry { public static TextureAtlasSprite cloud_square; public static TextureAtlasSprite square16; public static TextureAtlasSprite square64; - - @SubscribeEvent - @OnlyIn(Dist.CLIENT) - public static void registerParticles(TextureStitchEvent. event) { - - /** - * avoid stitching to all maps - * - * event.getAtlas().getBasePath(): - * textures - * textures/particle - * textures/painting - * textures/mob_effect - * - */ - if (!event.getAtlas().location().equals(TextureAtlas.LOCATION_PARTICLES)) { - return; - } - - //TODO: 1.14 uncomment - /*MeshBufferManagerParticle.cleanup(); - MeshBufferManagerFoliage.cleanup();*/ - - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/white")); - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/smoke_00")); - //smokeTest = event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/smoke_2")); - //cloud = event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/cloud64")); - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/cloud256")); - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/cloud256_fire")); - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/cloud256_test")); - //cloud256_2 = event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/cloud256_5")); - //ground splash - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/cloud256_6")); - //cloud256_7 = event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/cloud256_7")); - //downfall2 = event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/downfall2")); - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/downfall3")); - //downfall4 = event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/downfall4")); - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/chicken")); - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/potato")); - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/leaf")); - //rain = event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/rain")); - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/test_texture")); - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/white_square")); - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/rain_white")); - //rain_white_trans = event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/rain_white_trans")); - //rain_white_2 = event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/rain_white_2")); - //rain_10 = event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/rain_10")); - //rain_vanilla = event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/vanilla/rain")); - //snow_vanilla = event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/vanilla/snow")); - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/snow")); - //cloud256dark = event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/cloud256dark")); - //cloudDownfall = event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/downfall")); - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/tumbleweed")); - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/debris_1")); - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/debris_2")); - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/debris_3")); - /*for (int i = 1; i <= 9; i++) { - listFish.add(event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/fish_" + i))); - } - for (int i = 1; i <= 7; i++) { - listSeaweed.add(event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/seaweed_section_" + i))); - }*/ - //used indirectly not via reference - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/grass")); - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/hail")); - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/cloud")); - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/cloud_square")); - - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/white16")); - event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/white64")); - } - - @SubscribeEvent - @OnlyIn(Dist.CLIENT) - public static void getRegisteredParticles(TextureStitchEvent.Post event) { - - if (!event.getAtlas().location().equals(TextureAtlas.LOCATION_PARTICLES)) { - return; - } - - squareGrey = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/white")); - smoke = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/smoke_00")); - //smokeTest = event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/smoke_2")); - //cloud = event.addSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/cloud64")); - cloud256 = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/cloud256")); - cloud256_fire = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/cloud256_fire")); - cloud256_test = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/cloud256_test")); - //cloud256_2 = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/cloud256_5")); - //ground splash - cloud256_6 = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/cloud256_6")); - //cloud256_7 = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/cloud256_7")); - //downfall2 = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/downfall2")); - downfall3 = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/downfall3")); - //downfall4 = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/downfall4")); - chicken = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/chicken")); - potato = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/potato")); - leaf = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/leaf")); - //rain = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/rain")); - test_texture = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/test_texture")); - white_square = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/white_square")); - rain_white = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/rain_white")); - //rain_white_trans = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/rain_white_trans")); - //rain_white_2 = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/rain_white_2")); - //rain_10 = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/rain_10")); - //rain_vanilla = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/vanilla/rain")); - //snow_vanilla = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/vanilla/snow")); - snow = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/snow")); - //cloud256dark = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/cloud256dark")); - //cloudDownfall = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/downfall")); - tumbleweed = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/tumbleweed")); - debris_1 = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/debris_1")); - debris_2 = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/debris_2")); - debris_3 = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/debris_3")); - /*for (int i = 1; i <= 9; i++) { - listFish.add(event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/fish_" + i))); - } - for (int i = 1; i <= 7; i++) { - listSeaweed.add(event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/seaweed_section_" + i))); - }*/ - //used indirectly not via reference - grass = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/grass")); - hail = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/hail")); - cloudNew = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/cloud")); - cloud_square = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/cloud_square")); - - square16 = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/white16")); - square64 = event.getAtlas().getSprite(new ResourceLocation(ExtendedRenderer.modid + ":particles/white64")); - - //TODO: 1.14 uncomment - /*if (RotatingParticleManager.useShaders) { - RotatingParticleManager.forceShaderReset = true; - }*/ - - } - - /*public static TextureAtlasSprite addSprite(TextureStitchEvent.Pre event, ResourceLocation resourceLocation) { - event.addSprite(resourceLocation); - return event.getAtlas().getSprite(resourceLocation); - }*/ } diff --git a/src/main/java/extendedrenderer/particle/entity/EntityRotFX.java b/src/main/java/extendedrenderer/particle/entity/EntityRotFX.java index d091a935..94422fe7 100644 --- a/src/main/java/extendedrenderer/particle/entity/EntityRotFX.java +++ b/src/main/java/extendedrenderer/particle/entity/EntityRotFX.java @@ -3,6 +3,7 @@ import com.corosus.coroutil.util.CoroUtilBlock; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.*; +import com.mojang.math.Axis; import extendedrenderer.particle.behavior.ParticleBehaviors; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.ParticleRenderType; @@ -44,7 +45,8 @@ public void begin(BufferBuilder p_217600_1_, TextureManager p_217600_2_) { @Override public void end(Tesselator p_217599_1_) { - p_217599_1_.getBuilder().setQuadSortOrigin(0, 0, 0); + //TODO: not possible in 1.20 now i guess, cant remember why this line was important + //p_217599_1_.getBuilder().setQuadSortOrigin(0, 0, 0); ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT.end(p_217599_1_); } @@ -66,7 +68,8 @@ public void begin(BufferBuilder p_217600_1_, TextureManager p_217600_2_) { @Override public void end(Tesselator p_217599_1_) { - p_217599_1_.getBuilder().setQuadSortOrigin(0, 0, 0); + //TODO: not possible in 1.20 now i guess, cant remember why this line was important + //p_217599_1_.getBuilder().setQuadSortOrigin(0, 0, 0); ParticleRenderType.PARTICLE_SHEET_OPAQUE.end(p_217599_1_); } @@ -632,11 +635,19 @@ public void render(VertexConsumer buffer, Camera renderInfo, float partialTicks) // override rotations quaternion = new Quaternionf(0, 0, 0, 1); if (facePlayerYaw) { - quaternion.mul(Vector3f.YP.rotationDegrees(-renderInfo.getYRot())); + quaternion.mul(Axis.YP.rotationDegrees(-renderInfo.getYRot())); } else { - quaternion.mul(Vector3f.YP.rotationDegrees(Mth.lerp(partialTicks, this.prevRotationYaw, rotationYaw))); + quaternion.mul(Axis.YP.rotationDegrees(Mth.lerp(partialTicks, this.prevRotationYaw, rotationYaw))); } - quaternion.mul(Vector3f.XP.rotationDegrees(Mth.lerp(partialTicks, this.prevRotationPitch, rotationPitch))); + quaternion.mul(Axis.XP.rotationDegrees(Mth.lerp(partialTicks, this.prevRotationPitch, rotationPitch))); + } + + Quaternionf quaternionf; + if (this.roll == 0.0F) { + quaternionf = renderInfo.rotation(); + } else { + quaternionf = new Quaternionf(renderInfo.rotation()); + quaternionf.rotateZ(Mth.lerp(partialTicks, this.oRoll, this.roll)); } Vector3f[] avector3f = new Vector3f[]{new Vector3f(-1.0F, -1.0F, 0.0F), new Vector3f(-1.0F, 1.0F, 0.0F), new Vector3f(1.0F, 1.0F, 0.0F), new Vector3f(1.0F, -1.0F, 0.0F)}; @@ -644,7 +655,7 @@ public void render(VertexConsumer buffer, Camera renderInfo, float partialTicks) for(int i = 0; i < 4; ++i) { Vector3f vector3f = avector3f[i]; - vector3f.transform(quaternion); + vector3f.rotate(quaternion); vector3f.mul(f4); vector3f.add(f, f1, f2); } diff --git a/src/main/java/extendedrenderer/particle/entity/ParticleCrossSection.java b/src/main/java/extendedrenderer/particle/entity/ParticleCrossSection.java index 6bf7d33f..5d4e66c7 100644 --- a/src/main/java/extendedrenderer/particle/entity/ParticleCrossSection.java +++ b/src/main/java/extendedrenderer/particle/entity/ParticleCrossSection.java @@ -1,6 +1,7 @@ package extendedrenderer.particle.entity; import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.math.Axis; import net.minecraft.client.Camera; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.multiplayer.ClientLevel; @@ -32,11 +33,11 @@ public void render(VertexConsumer buffer, Camera renderInfo, float partialTicks) // override rotations quaternion = new Quaternionf(0, 0, 0, 1); if (facePlayerYaw) { - quaternion.mul(Vector3f.YP.rotationDegrees(-renderInfo.getYRot())); + quaternion.mul(Axis.YP.rotationDegrees(-renderInfo.getYRot())); } else { - quaternion.mul(Vector3f.YP.rotationDegrees(Mth.lerp(partialTicks, this.prevRotationYaw, rotationYaw))); + quaternion.mul(Axis.YP.rotationDegrees(Mth.lerp(partialTicks, this.prevRotationYaw, rotationYaw))); } - quaternion.mul(Vector3f.XP.rotationDegrees(Mth.lerp(partialTicks, this.prevRotationPitch, rotationPitch))); + quaternion.mul(Axis.XP.rotationDegrees(Mth.lerp(partialTicks, this.prevRotationPitch, rotationPitch))); } Vector3f[] avector3f = new Vector3f[]{ @@ -61,21 +62,21 @@ public void render(VertexConsumer buffer, Camera renderInfo, float partialTicks) for(int i = 0; i < 4; ++i) { Vector3f vector3f = avector3f[i]; - vector3f.transform(quaternion); + vector3f.rotate(quaternion); vector3f.mul(f4); vector3f.add(f, f1, f2); } for(int i = 0; i < 4; ++i) { Vector3f vector3f = avector3f2[i]; - vector3f.transform(quaternion); + vector3f.rotate(quaternion); vector3f.mul(f4); vector3f.add(f, f1, f2); } for(int i = 0; i < 4; ++i) { Vector3f vector3f = avector3f3[i]; - vector3f.transform(quaternion); + vector3f.rotate(quaternion); vector3f.mul(f4); vector3f.add(f, f1, f2); } diff --git a/src/main/java/extendedrenderer/particle/entity/ParticleCube.java b/src/main/java/extendedrenderer/particle/entity/ParticleCube.java index 6651c222..5e382e14 100644 --- a/src/main/java/extendedrenderer/particle/entity/ParticleCube.java +++ b/src/main/java/extendedrenderer/particle/entity/ParticleCube.java @@ -1,12 +1,15 @@ package extendedrenderer.particle.entity; import com.corosus.coroutil.util.CULog; +import com.corosus.coroutil.util.CoroUtilBlock; import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.math.Axis; import extendedrenderer.particle.ParticleRegistry; import net.minecraft.client.Camera; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.particle.ParticleRenderType; +import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.block.BlockRenderDispatcher; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -46,7 +49,7 @@ public ParticleCube(Level worldIn, double posXIn, double posYIn, setSprite(sprite); } } - int multiplier = Minecraft.getInstance().getBlockColors().getColor(state, this.level, new BlockPos(posXIn, posYIn, posZIn), 0); + int multiplier = Minecraft.getInstance().getBlockColors().getColor(state, this.level, CoroUtilBlock.blockPos(posXIn, posYIn, posZIn), 0); float mr = ((multiplier >>> 16) & 0xFF) / 255f; float mg = ((multiplier >>> 8) & 0xFF) / 255f; float mb = (multiplier & 0xFF) / 255f; @@ -57,10 +60,11 @@ public TextureAtlasSprite getSpriteFromState(BlockState state) { BlockRenderDispatcher blockrenderdispatcher = Minecraft.getInstance().getBlockRenderer(); BakedModel model = blockrenderdispatcher.getBlockModel(state); for(Direction direction : Direction.values()) { - List list = model.getQuads(state, direction, new Random(), net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); + //TODO: 1.20 + /*List list = model.getQuads(state, direction, new Random(), net.minecraftforge.client.model.data.ModelData.EMPTY); if (list.size() > 0) { return list.get(0).getSprite(); - } + }*/ } return null; } @@ -79,11 +83,11 @@ public void render(VertexConsumer buffer, Camera renderInfo, float partialTicks) // override rotations quaternion = new Quaternionf(0, 0, 0, 1); if (facePlayerYaw) { - quaternion.mul(Vector3f.YP.rotationDegrees(-renderInfo.getYRot())); + quaternion.mul(Axis.YP.rotationDegrees(-renderInfo.getYRot())); } else { - quaternion.mul(Vector3f.YP.rotationDegrees(Mth.lerp(partialTicks, this.prevRotationYaw, rotationYaw))); + quaternion.mul(Axis.YP.rotationDegrees(Mth.lerp(partialTicks, this.prevRotationYaw, rotationYaw))); } - quaternion.mul(Vector3f.XP.rotationDegrees(Mth.lerp(partialTicks, this.prevRotationPitch, rotationPitch))); + quaternion.mul(Axis.XP.rotationDegrees(Mth.lerp(partialTicks, this.prevRotationPitch, rotationPitch))); } TextureAtlasSprite sprite = null; @@ -144,7 +148,7 @@ public void render(VertexConsumer buffer, Camera renderInfo, float partialTicks) for (Vector3f[] entryFace : faces) { for(int i = 0; i < 4; ++i) { - entryFace[i].transform(quaternion); + entryFace[i].rotate(quaternion); entryFace[i].mul(f4); entryFace[i].add(f, f1, f2); } diff --git a/src/main/java/extendedrenderer/particle/entity/ParticleTexExtraRender.java b/src/main/java/extendedrenderer/particle/entity/ParticleTexExtraRender.java index 6b3aa99f..1e6aa9a4 100644 --- a/src/main/java/extendedrenderer/particle/entity/ParticleTexExtraRender.java +++ b/src/main/java/extendedrenderer/particle/entity/ParticleTexExtraRender.java @@ -3,6 +3,7 @@ import com.corosus.coroutil.util.CoroUtilBlock; import com.corosus.coroutil.util.CoroUtilParticle; import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.math.Axis; import net.minecraft.client.Camera; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.multiplayer.ClientLevel; @@ -87,10 +88,10 @@ public void render(VertexConsumer buffer, Camera renderInfo, float partialTicks) } else { // override rotations quaternion = new Quaternionf(0, 0, 0, 1); - quaternion.mul(Vector3f.YP.rotationDegrees(this.rotationYaw)); - quaternion.mul(Vector3f.XP.rotationDegrees(this.rotationPitch)); + quaternion.mul(Axis.YP.rotationDegrees(this.rotationYaw)); + quaternion.mul(Axis.XP.rotationDegrees(this.rotationPitch)); if (extraRandomSecondaryYawRotation > 0) { - quaternion.mul(Vector3f.YP.rotationDegrees(getEntityId() % extraRandomSecondaryYawRotation)); + quaternion.mul(Axis.YP.rotationDegrees(getEntityId() % extraRandomSecondaryYawRotation)); } } @@ -167,7 +168,7 @@ public void render(VertexConsumer buffer, Camera renderInfo, float partialTicks) for(int v = 0; v < 4; ++v) { Vector3f vector3f = avector3f[v]; - vector3f.transform(quaternion); + vector3f.rotate(quaternion); vector3f.mul(scale); vector3f.add(posX, posY, posZ); } diff --git a/src/main/java/extendedrenderer/particle/entity/WaterDropParticleImpl.java b/src/main/java/extendedrenderer/particle/entity/WaterDropParticleImpl.java new file mode 100644 index 00000000..68c4e493 --- /dev/null +++ b/src/main/java/extendedrenderer/particle/entity/WaterDropParticleImpl.java @@ -0,0 +1,12 @@ +package extendedrenderer.particle.entity; + +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.particle.WaterDropParticle; +import net.minecraft.core.particles.SimpleParticleType; +import net.minecraft.world.level.Level; + +public class WaterDropParticleImpl extends WaterDropParticle { + public WaterDropParticleImpl(SimpleParticleType simpleParticleType, ClientLevel p_108484_, double p_108485_, double p_108486_, double p_108487_, double v3, double v4, double v5) { + super(p_108484_, p_108485_, p_108486_, p_108487_); + } +} diff --git a/src/main/java/weather2/ClientRegistry.java b/src/main/java/weather2/ClientRegistry.java index 69d1ba4c..6d2c885d 100644 --- a/src/main/java/weather2/ClientRegistry.java +++ b/src/main/java/weather2/ClientRegistry.java @@ -14,7 +14,7 @@ public class ClientRegistry { @OnlyIn(Dist.CLIENT) @SubscribeEvent public static void registerRenderers(FMLClientSetupEvent event) { - EntityRenderers.register(EntityRegistry.lightning_bolt, render -> new LightningBoltWeatherNewRenderer(render)); + EntityRenderers.register(EntityRegistry.LIGHTNING_BOLT.get(), render -> new LightningBoltWeatherNewRenderer(render)); } } diff --git a/src/main/java/weather2/ClientWeatherProxy.java b/src/main/java/weather2/ClientWeatherProxy.java index 537bc102..9c1b21a1 100644 --- a/src/main/java/weather2/ClientWeatherProxy.java +++ b/src/main/java/weather2/ClientWeatherProxy.java @@ -58,9 +58,9 @@ public PrecipitationType getPrecipitationType(Biome biome) { return ClientWeatherIntegration.get().getPrecipitationType(); } else { if (biome == null) return null; - if (biome.getPrecipitation() == Biome.Precipitation.RAIN) return PrecipitationType.NORMAL; - if (biome.getPrecipitation() == Biome.Precipitation.SNOW) return PrecipitationType.SNOW; - if (biome.getPrecipitation() == Biome.Precipitation.NONE) return null; + if (biome.hasPrecipitation() && biome.getModifiedClimateSettings().temperatureModifier() == Biome.TemperatureModifier.NONE) return PrecipitationType.NORMAL; + if (biome.hasPrecipitation() && biome.getModifiedClimateSettings().temperatureModifier() == Biome.TemperatureModifier.FROZEN) return PrecipitationType.SNOW; + if (!biome.hasPrecipitation()) return null; } return null; } diff --git a/src/main/java/weather2/DeferredHelper.java b/src/main/java/weather2/DeferredHelper.java new file mode 100644 index 00000000..8e87803b --- /dev/null +++ b/src/main/java/weather2/DeferredHelper.java @@ -0,0 +1,206 @@ +package weather2; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collections; +import java.util.IdentityHashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Supplier; + +import net.minecraft.core.Registry; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleType; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.stats.StatFormatter; +import net.minecraft.stats.StatType; +import net.minecraft.stats.Stats; +import net.minecraft.world.Container; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.ai.attributes.Attribute; +import net.minecraft.world.entity.decoration.PaintingVariant; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.alchemy.Potion; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; +import net.minecraft.world.level.material.Fluid; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.registries.RegisterEvent; +import net.minecraftforge.registries.RegistryObject; + +public class DeferredHelper { + + protected final String modid; + protected final Map>, List>> objects; + + /** + * Creates a new DeferredHelper and registers it to the mod event bus. + * + * @param modid The modid of the owning mod. + * @return A new DeferredHelper. + */ + public static DeferredHelper create(String modid) { + DeferredHelper helper = new DeferredHelper(modid); + FMLJavaModLoadingContext.get().getModEventBus().register(helper); + return helper; + } + + protected DeferredHelper(String modid) { + this.modid = modid; + this.objects = new IdentityHashMap<>(); + } + + public RegistryObject block(String path, Supplier factory) { + return this.create(path, Registries.BLOCK, factory); + } + + public RegistryObject fluid(String path, Supplier factory) { + return this.create(path, Registries.FLUID, factory); + } + + public RegistryObject item(String path, Supplier factory) { + return this.create(path, Registries.ITEM, factory); + } + + public RegistryObject effect(String path, Supplier factory) { + return this.create(path, Registries.MOB_EFFECT, factory); + } + + public RegistryObject sound(String path, Supplier factory) { + return this.create(path, Registries.SOUND_EVENT, factory); + } + + public RegistryObject sound(String path) { + return sound(path, () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(modid, path))); + } + + public RegistryObject potion(String path, Supplier factory) { + return this.create(path, Registries.POTION, factory); + } + + public RegistryObject enchant(String path, Supplier factory) { + return this.create(path, Registries.ENCHANTMENT, factory); + } + + public > RegistryObject entity(String path, Supplier factory) { + return this.create(path, Registries.ENTITY_TYPE, factory); + } + + public > RegistryObject blockEntity(String path, Supplier factory) { + return this.create(path, Registries.BLOCK_ENTITY_TYPE, factory); + } + + public > RegistryObject particle(String path, Supplier factory) { + return this.create(path, Registries.PARTICLE_TYPE, factory); + } + + public > RegistryObject menu(String path, Supplier factory) { + return this.create(path, Registries.MENU, factory); + } + + public RegistryObject painting(String path, Supplier factory) { + return this.create(path, Registries.PAINTING_VARIANT, factory); + } + + public , T extends RecipeType> RegistryObject recipe(String path, Supplier factory) { + return this.create(path, Registries.RECIPE_TYPE, factory); + } + + public , T extends RecipeSerializer> RegistryObject recipeSerializer(String path, Supplier factory) { + return this.create(path, Registries.RECIPE_SERIALIZER, factory); + } + + public RegistryObject attribute(String path, Supplier factory) { + return this.create(path, Registries.ATTRIBUTE, factory); + } + + public , T extends StatType> RegistryObject stat(String path, Supplier factory) { + return this.create(path, Registries.STAT_TYPE, factory); + } + + /** + * Creates a custom stat with the given path and formatter.
+ * Calling {@link StatType#get} on {@link Stats#CUSTOM} is required for full registration, for some reason. + * + * @see Stats#makeCustomStat + */ + public RegistryObject customStat(String path, StatFormatter formatter) { + return this.create(path, Registries.CUSTOM_STAT, () -> { + ResourceLocation id = new ResourceLocation(this.modid, path); + Stats.CUSTOM.get(id, formatter); + return id; + }); + } + + public > RegistryObject feature(String path, Supplier factory) { + return this.create(path, Registries.FEATURE, factory); + } + + public RegistryObject tab(String path, Supplier factory) { + return this.create(path, Registries.CREATIVE_MODE_TAB, factory); + } + + public RegistryObject custom(String path, ResourceKey> registry, Supplier factory) { + return this.create(path, registry, factory); + } + + protected RegistryObject create(String path, ResourceKey> regKey, Supplier factory) { + List> registrars = this.objects.computeIfAbsent(regKey, k -> new ArrayList<>()); + ResourceLocation id = new ResourceLocation(this.modid, path); + RegistryObject obj = RegistryObject.create(id, regKey, this.modid); + registrars.add(new Registrar<>(id, obj, factory)); + return obj; + } + + private static MethodHandle RO_updateReference; + + static { + try { + Method m = RegistryObject.class.getDeclaredMethod("updateReference", RegisterEvent.class); + m.setAccessible(true); + RO_updateReference = MethodHandles.lookup().unreflect(m); + } + catch (Exception ex) { + // Failing means we're using Neo, and RO has been replaced with DH, so this is unnecessary anyway. + } + } + + @SubscribeEvent + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void register(RegisterEvent e) { + this.objects.getOrDefault(e.getRegistryKey(), Collections.emptyList()).forEach(registrar -> { + e.register((ResourceKey) e.getRegistryKey(), registrar.id, (Supplier) registrar.factory); + if (RO_updateReference != null) { + try { + RO_updateReference.invoke(registrar.obj, e); + } + catch (Throwable t) { + throw new RuntimeException(t); + } + } + }); + } + + protected static record Registrar(ResourceLocation id, RegistryObject obj, Supplier factory) { + + } + +} diff --git a/src/main/java/weather2/EntityRegistry.java b/src/main/java/weather2/EntityRegistry.java index 6b1e5ee1..0a80df9c 100644 --- a/src/main/java/weather2/EntityRegistry.java +++ b/src/main/java/weather2/EntityRegistry.java @@ -2,19 +2,24 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MobCategory; -import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.registries.IForgeRegistry; -import net.minecraftforge.registries.ObjectHolder; +import net.minecraftforge.registries.RegistryObject; import weather2.weathersystem.storm.LightningBoltWeatherNew; @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) public class EntityRegistry { - @ObjectHolder(Weather.MODID + ":lightning_bolt") - public static EntityType lightning_bolt; + /*@ObjectHolder(Weather.MODID + ":lightning_bolt") + public static EntityType lightning_bolt;*/ + public static final RegistryObject> LIGHTNING_BOLT = Weather.R.entity("lightning_bolt", () -> EntityType.Builder + .of(LightningBoltWeatherNew::new, MobCategory.MISC) + .noSave() + .sized(0.0F, 0.0F) + .clientTrackingRange(16) + .updateInterval(Integer.MAX_VALUE) + .build("gateway")); + /* @SubscribeEvent public static void registerEntity(RegistryEvent.Register> e) { IForgeRegistry> r = e.getRegistry(); @@ -26,6 +31,6 @@ public static void registerEntity(RegistryEvent.Register> e) { .updateInterval(Integer.MAX_VALUE) .build("lightning_bolt") .setRegistryName("lightning_bolt")); - } + }*/ } diff --git a/src/main/java/weather2/EventHandlerForge.java b/src/main/java/weather2/EventHandlerForge.java index f2af238d..4e3dd0a9 100644 --- a/src/main/java/weather2/EventHandlerForge.java +++ b/src/main/java/weather2/EventHandlerForge.java @@ -10,9 +10,7 @@ import net.minecraft.world.level.biome.Biome; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.event.EntityViewRenderEvent.FogColors; -import net.minecraftforge.client.event.EntityViewRenderEvent.RenderFogEvent; -import net.minecraftforge.client.event.RenderLevelLastEvent; +import net.minecraftforge.client.event.RenderLevelStageEvent; import net.minecraftforge.client.event.ViewportEvent; import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.entity.living.LivingEvent; @@ -29,9 +27,11 @@ public class EventHandlerForge { @SubscribeEvent @OnlyIn(Dist.CLIENT) - public void worldRender(RenderLevelLastEvent event) + public void worldRender(RenderLevelStageEvent event) { - ClientTickHandler.getClientWeather(); + if (event.getStage() == RenderLevelStageEvent.Stage.AFTER_WEATHER) { + ClientTickHandler.getClientWeather(); + } } @SubscribeEvent @@ -43,7 +43,7 @@ public void onFogColors(ViewportEvent.ComputeFogColor event) { @SubscribeEvent @OnlyIn(Dist.CLIENT) - public void onFogRender(RenderFogEvent event) { + public void onFogRender(ViewportEvent.RenderFog event) { SceneEnhancer.getFogAdjuster().onFogRender(event); } @@ -54,9 +54,9 @@ public void onRenderTick(TickEvent.RenderTickEvent event) { } @SubscribeEvent - public void onEntityLivingUpdate(LivingEvent.LivingUpdateEvent event) { + public void onEntityLivingUpdate(LivingEvent.LivingTickEvent event) { Entity ent = event.getEntity(); - if (ent.level.isClientSide && (ent instanceof Player && ((Player) ent).isLocalPlayer())) { + if (ent.level().isClientSide && (ent instanceof Player && ((Player) ent).isLocalPlayer())) { onClientPlayerUpdate(event); } /*if (!ent.level.isClientSide && ent instanceof Player) { @@ -64,12 +64,12 @@ public void onEntityLivingUpdate(LivingEvent.LivingUpdateEvent event) { }*/ } - public void onServerPlayerUpdate(LivingEvent.LivingUpdateEvent event) { - Level level = event.getEntity().level; + public void onServerPlayerUpdate(LivingEvent.LivingTickEvent event) { + Level level = event.getEntity().level(); if (level.getGameTime() % 40 == 0) { Entity ent = event.getEntity(); - Biome bgb = level.m_204166_(WeatherUtilBlock.getPrecipitationHeightSafe(level, new BlockPos(Mth.floor(ent.position().x), 0, Mth.floor(ent.position().z)))).m_203334_(); - float biomeTemp = CoroUtilCompatibility.getAdjustedTemperature(ent.level, bgb, new BlockPos(Mth.floor(ent.position().x), Mth.floor(ent.position().y), Mth.floor(ent.position().z))); + Biome bgb = level.getBiome(WeatherUtilBlock.getPrecipitationHeightSafe(level, new BlockPos(Mth.floor(ent.position().x), 0, Mth.floor(ent.position().z)))).get(); + float biomeTemp = CoroUtilCompatibility.getAdjustedTemperature(ent.level(), bgb, new BlockPos(Mth.floor(ent.position().x), Mth.floor(ent.position().y), Mth.floor(ent.position().z))); CULog.dbg("biomeTemp: " + biomeTemp); } @@ -77,7 +77,7 @@ public void onServerPlayerUpdate(LivingEvent.LivingUpdateEvent event) { @SubscribeEvent @OnlyIn(Dist.CLIENT) - public void onClientPlayerUpdate(LivingEvent.LivingUpdateEvent event) { + public void onClientPlayerUpdate(LivingEvent.LivingTickEvent event) { Entity ent = event.getEntity(); WeatherManagerClient weatherMan = ClientTickHandler.weatherManager; @@ -87,7 +87,7 @@ public void onClientPlayerUpdate(LivingEvent.LivingUpdateEvent event) { ClientWeatherProxy weather = ClientWeatherProxy.get(); if (weather.isSnowstorm() || weather.isSandstorm()) { - if (ent.isOnGround() && !ent.isSpectator() && !WeatherUtilEntity.isPlayerSheltered(ent)/* && ent.world.getGameTime() % 20 == 0*/) { + if (ent.onGround() && !ent.isSpectator() && !WeatherUtilEntity.isPlayerSheltered(ent)/* && ent.world.getGameTime() % 20 == 0*/) { float playerSpeed = (float) Math.sqrt(ent.getDeltaMovement().x * ent.getDeltaMovement().x + ent.getDeltaMovement().z * ent.getDeltaMovement().z); diff --git a/src/main/java/weather2/ServerTickHandler.java b/src/main/java/weather2/ServerTickHandler.java index c97146e6..e06e8846 100644 --- a/src/main/java/weather2/ServerTickHandler.java +++ b/src/main/java/weather2/ServerTickHandler.java @@ -10,7 +10,7 @@ import net.minecraft.world.level.Level; import net.minecraft.server.level.ServerLevel; import net.minecraftforge.event.TickEvent; -import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.event.level.LevelEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.InterModComms; import net.minecraftforge.fml.common.Mod; @@ -27,8 +27,8 @@ public class ServerTickHandler { private static final HashMap MANAGERSLOOKUP = new HashMap<>(); @SubscribeEvent - public static void onWorldLoad(WorldEvent.Load event) { - LevelAccessor world = event.getWorld(); + public static void onWorldLoad(LevelEvent.Load event) { + LevelAccessor world = event.getLevel(); if (!world.isClientSide() && world instanceof ServerLevel) { ServerLevel serverWorld = (ServerLevel) world; ResourceKey dimension = serverWorld.dimension(); @@ -40,8 +40,8 @@ public static void onWorldLoad(WorldEvent.Load event) { } @SubscribeEvent - public static void onWorldUnload(WorldEvent.Unload event) { - LevelAccessor world = event.getWorld(); + public static void onWorldUnload(LevelEvent.Unload event) { + LevelAccessor world = event.getLevel(); if (!world.isClientSide() && world instanceof ServerLevel) { ServerLevel serverWorld = (ServerLevel) world; MANAGERS.remove(serverWorld.dimension()); diff --git a/src/main/java/weather2/SoundRegistry.java b/src/main/java/weather2/SoundRegistry.java index f8ed54e1..3b56fcdf 100644 --- a/src/main/java/weather2/SoundRegistry.java +++ b/src/main/java/weather2/SoundRegistry.java @@ -2,26 +2,14 @@ import java.util.HashMap; -import net.minecraft.world.level.block.Block; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; -import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.eventbus.api.EventPriority; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.ForgeRegistries; public class SoundRegistry { private static HashMap lookupStringToEvent = new HashMap(); - @Mod.EventBusSubscriber(modid = Weather.MODID,bus=Mod.EventBusSubscriber.Bus.MOD) - public static class RegistryEvents { - @SubscribeEvent(priority = EventPriority.HIGHEST) - public static void onBlocksRegistry(final RegistryEvent.Register event) { - SoundRegistry.init(); - } - } public static void init() { register("env.waterfall"); @@ -60,9 +48,10 @@ public static void init() { public static void register(String soundPath) { ResourceLocation resLoc = new ResourceLocation(Weather.MODID, soundPath); - SoundEvent event = new SoundEvent(resLoc).setRegistryName(resLoc); + //SoundEvent event = new SoundEvent(resLoc).setRegistryName(resLoc); + SoundEvent event = SoundEvent.createVariableRangeEvent(resLoc); //TODO: WIP SoundEvent event = SoundEvent.createVariableRangeEvent(resLoc).setRegistryName(resLoc); - ForgeRegistries.SOUND_EVENTS.register(event); + ForgeRegistries.SOUND_EVENTS.register(resLoc, event); if (lookupStringToEvent.containsKey(soundPath)) { System.out.println("WEATHER SOUNDS WARNING: duplicate sound registration for " + soundPath); } diff --git a/src/main/java/weather2/Weather.java b/src/main/java/weather2/Weather.java index 2432a2d5..353d6b7f 100644 --- a/src/main/java/weather2/Weather.java +++ b/src/main/java/weather2/Weather.java @@ -4,10 +4,12 @@ import com.corosus.modconfig.ConfigMod; import com.corosus.modconfig.IConfigCategory; import com.mojang.brigadier.CommandDispatcher; +import extendedrenderer.ParticleRegistry2ElectricBubbleoo; import net.minecraft.commands.CommandSourceStack; import net.minecraft.data.DataGenerator; import net.minecraft.world.item.CreativeModeTab; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.data.event.GatherDataEvent; import net.minecraftforge.event.RegisterCommandsEvent; import net.minecraftforge.event.server.ServerStartedEvent; import net.minecraftforge.event.server.ServerStoppedEvent; @@ -19,7 +21,6 @@ import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import weather2.command.WeatherCommand; @@ -40,6 +41,8 @@ public class Weather // Directly reference a log4j logger. public static final Logger LOGGER = LogManager.getLogger(); + public static final DeferredHelper R = DeferredHelper.create(Weather.MODID); + public static final String MODID = "weather2"; public static boolean initProperNeededForWorld = true; @@ -47,9 +50,12 @@ public class Weather public static List listConfigs = new ArrayList<>(); public static ConfigMisc configMisc = null; - public static final CreativeModeTab CREATIVE_TAB = new WeatherTab(); + //public static final CreativeModeTab CREATIVE_TAB = new WeatherTab(); public Weather() { + + ParticleRegistry2ElectricBubbleoo.bootstrap(); + // Register the setup method for modloading IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus(); modBus.addListener(this::setup); @@ -81,6 +87,8 @@ public Weather() { ConfigMod.addConfigFile(MODID, addConfig(new ConfigParticle())); ConfigMod.addConfigFile(MODID, addConfig(new ConfigFoliage())); //WeatherUtilConfig.nbtLoadDataAll(); + + SoundRegistry.init(); } public static IConfigCategory addConfig(IConfigCategory config) { @@ -138,7 +146,8 @@ private void registerCommands(RegisterCommandsEvent event) { private void gatherData(GatherDataEvent event) { DataGenerator gen = event.getGenerator(); if (event.includeServer()) { - gen.addProvider(new WeatherRecipeProvider(gen)); + //TODO: 1.20 + //gen.addProvider(new WeatherRecipeProvider(gen)); } } } diff --git a/src/main/java/weather2/WeatherBlocks.java b/src/main/java/weather2/WeatherBlocks.java index 90b69f46..7fc42226 100644 --- a/src/main/java/weather2/WeatherBlocks.java +++ b/src/main/java/weather2/WeatherBlocks.java @@ -1,17 +1,13 @@ package weather2; -import com.google.common.collect.ImmutableSet; import net.minecraft.world.entity.ai.village.poi.PoiType; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; -import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Material; -import net.minecraftforge.event.RegistryEvent; +import net.minecraft.world.level.material.MapColor; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -21,9 +17,6 @@ import weather2.block.*; import weather2.blockentity.DeflectorBlockEntity; import weather2.blockentity.SirenBlockEntity; -import weather2.blockentity.WeatherMachineBlockEntity; - -import java.util.Set; @Mod.EventBusSubscriber(modid = Weather.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public class WeatherBlocks { @@ -44,20 +37,21 @@ public class WeatherBlocks { public static final String POCKET_SAND = "pocket_sand"; private static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, Weather.MODID); - private static final DeferredRegister> BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, Weather.MODID); + private static final DeferredRegister> BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, Weather.MODID); - public static final RegistryObject BLOCK_SAND_LAYER = BLOCKS.register(SAND_LAYER, () -> new SandLayerBlock(BlockBehaviour.Properties.of(Material.SAND).randomTicks().strength(0.1F).requiresCorrectToolForDrops().sound(SoundType.SAND))); - public static final RegistryObject BLOCK_DEFLECTOR = BLOCKS.register(DEFLECTOR, () -> new DeflectorBlock(BlockBehaviour.Properties.of(Material.STONE).randomTicks().strength(1.5F, 6F).requiresCorrectToolForDrops().sound(SoundType.STONE))); - public static final RegistryObject BLOCK_FORECAST = BLOCKS.register(WEATHER_FORECAST, () -> new ForecastBlock(BlockBehaviour.Properties.of(Material.STONE).randomTicks().strength(1.5F, 6F).requiresCorrectToolForDrops().sound(SoundType.STONE))); + public static final RegistryObject BLOCK_SAND_LAYER = BLOCKS.register(SAND_LAYER, () -> new SandLayerBlock(BlockBehaviour.Properties.of().mapColor(MapColor.SAND).randomTicks().strength(0.1F).requiresCorrectToolForDrops().sound(SoundType.SAND))); + public static final RegistryObject BLOCK_DEFLECTOR = BLOCKS.register(DEFLECTOR, () -> new DeflectorBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE).randomTicks().strength(1.5F, 6F).requiresCorrectToolForDrops().sound(SoundType.STONE))); + public static final RegistryObject BLOCK_FORECAST = BLOCKS.register(WEATHER_FORECAST, () -> new ForecastBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE).randomTicks().strength(1.5F, 6F).requiresCorrectToolForDrops().sound(SoundType.STONE))); //public static final RegistryObject BLOCK_TORNADO_SENSOR = BLOCKS.register(TORNADO_SENSOR, () -> new SensorBlock(BlockBehaviour.Properties.of(Material.STONE).randomTicks().strength(1.5F, 6F).requiresCorrectToolForDrops().sound(SoundType.STONE))); - public static final RegistryObject BLOCK_TORNADO_SIREN = BLOCKS.register(TORNADO_SIREN, () -> new SirenBlock(BlockBehaviour.Properties.of(Material.STONE).randomTicks().strength(1.5F, 6F).requiresCorrectToolForDrops().sound(SoundType.STONE))); + public static final RegistryObject BLOCK_TORNADO_SIREN = BLOCKS.register(TORNADO_SIREN, () -> new SirenBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE).randomTicks().strength(1.5F, 6F).requiresCorrectToolForDrops().sound(SoundType.STONE))); //public static final RegistryObject BLOCK_WEATHER_MACHINE = BLOCKS.register(WEATHER_MACHINE, () -> new WeatherMachineBlock(BlockBehaviour.Properties.of(Material.STONE).randomTicks().strength(1.5F, 6F).requiresCorrectToolForDrops().sound(SoundType.STONE))); private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, Weather.MODID); - public static final RegistryObject BLOCK_DEFLECTOR_ITEM = ITEMS.register(DEFLECTOR, () -> new BlockItem(BLOCK_DEFLECTOR.get(), new Item.Properties().tab(Weather.CREATIVE_TAB))); - public static final RegistryObject BLOCK_TORNADO_SIREN_ITEM = ITEMS.register(TORNADO_SIREN, () -> new BlockItem(BLOCK_TORNADO_SIREN.get(), new Item.Properties().tab(Weather.CREATIVE_TAB))); - public static final RegistryObject BLOCK_SAND_LAYER_ITEM = ITEMS.register(SAND_LAYER, () -> new BlockItem(BLOCK_SAND_LAYER.get(), new Item.Properties().tab(Weather.CREATIVE_TAB))); - public static final RegistryObject BLOCK_FORECAST_ITEM = ITEMS.register(WEATHER_FORECAST, () -> new BlockItem(BLOCK_FORECAST.get(), new Item.Properties().tab(Weather.CREATIVE_TAB))); + //TODO: 1.20 tabs + public static final RegistryObject BLOCK_DEFLECTOR_ITEM = ITEMS.register(DEFLECTOR, () -> new BlockItem(BLOCK_DEFLECTOR.get(), new Item.Properties()/*.tab(Weather.CREATIVE_TAB)*/)); + public static final RegistryObject BLOCK_TORNADO_SIREN_ITEM = ITEMS.register(TORNADO_SIREN, () -> new BlockItem(BLOCK_TORNADO_SIREN.get(), new Item.Properties()/*.tab(Weather.CREATIVE_TAB)*/)); + public static final RegistryObject BLOCK_SAND_LAYER_ITEM = ITEMS.register(SAND_LAYER, () -> new BlockItem(BLOCK_SAND_LAYER.get(), new Item.Properties()/*.tab(Weather.CREATIVE_TAB)*/)); + public static final RegistryObject BLOCK_FORECAST_ITEM = ITEMS.register(WEATHER_FORECAST, () -> new BlockItem(BLOCK_FORECAST.get(), new Item.Properties()/*.tab(Weather.CREATIVE_TAB)*/)); @SuppressWarnings("ConstantConditions") public static final RegistryObject> BLOCK_ENTITY_DEFLECTOR = BLOCK_ENTITIES.register(DEFLECTOR, () -> @@ -79,13 +73,14 @@ public static void registerHandlers(IEventBus modBus) { BLOCKS.register(modBus); BLOCK_ENTITIES.register(modBus); ITEMS.register(modBus); - } + }/* + //TODO: 1.20 @SubscribeEvent public static void registerBlocks(final RegistryEvent.Register event) { String registryName = Weather.MODID + ":" + DEFLECTOR; POI_DEFLECTOR = (new PoiType(registryName, PoiType.getBlockStates(BLOCK_DEFLECTOR.get()), 0, 1)).setRegistryName(registryName); event.getRegistry().register(POI_DEFLECTOR); - } + }*/ } diff --git a/src/main/java/weather2/WeatherItems.java b/src/main/java/weather2/WeatherItems.java index 14a46b74..8ec92980 100644 --- a/src/main/java/weather2/WeatherItems.java +++ b/src/main/java/weather2/WeatherItems.java @@ -11,7 +11,8 @@ public class WeatherItems { private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, Weather.MODID); - public static final RegistryObject WEATHER_ITEM = ITEMS.register("weather_item", () -> new WeatherItem(new Item.Properties().stacksTo(64), Weather.CREATIVE_TAB)); + //TODO: 1.20 + //public static final RegistryObject WEATHER_ITEM = ITEMS.register("weather_item", () -> new WeatherItem(new Item.Properties().stacksTo(64), Weather.CREATIVE_TAB)); public static void registerHandlers(IEventBus modBus) { ITEMS.register(modBus); diff --git a/src/main/java/weather2/WeatherTab.java b/src/main/java/weather2/WeatherTab.java index 09333ba1..1afe91a9 100644 --- a/src/main/java/weather2/WeatherTab.java +++ b/src/main/java/weather2/WeatherTab.java @@ -7,7 +7,12 @@ public class WeatherTab extends CreativeModeTab { private ItemStack tabIcon; - WeatherTab() { + public WeatherTab(Builder builder, ItemStack tabIcon) { + super(builder); + this.tabIcon = tabIcon; + } + + /*WeatherTab() { super(Weather.MODID); } @@ -17,5 +22,5 @@ public ItemStack makeIcon() { tabIcon = new ItemStack(WeatherItems.WEATHER_ITEM.get()); } return tabIcon; - } + }*/ } diff --git a/src/main/java/weather2/block/ForecastBlock.java b/src/main/java/weather2/block/ForecastBlock.java index 544a1fb0..e1b22963 100644 --- a/src/main/java/weather2/block/ForecastBlock.java +++ b/src/main/java/weather2/block/ForecastBlock.java @@ -2,23 +2,15 @@ import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.BaseEntityBlock; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.RenderShape; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.entity.BlockEntityTicker; -import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; -import org.jetbrains.annotations.Nullable; import weather2.ServerTickHandler; -import weather2.WeatherBlocks; -import weather2.blockentity.DeflectorBlockEntity; import weather2.weathersystem.WeatherManagerServer; public class ForecastBlock extends Block { @@ -39,7 +31,7 @@ public InteractionResult use(BlockState p_60503_, Level p_60504_, BlockPos p_605 WeatherManagerServer wm = ServerTickHandler.getWeatherManagerFor(p_60506_.level().dimension()); float chance = wm.getBiomeBasedStormSpawnChanceInArea(new BlockPos(p_60506_.blockPosition())); - p_60506_.sendMessage(Component.literal(String.format("Likelyhood of storms to spawn here within 1024 blocks: %.2f", (chance * 100F)) + "%"), p_60506_.getUUID()); + p_60506_.sendSystemMessage(Component.literal(String.format("Likelyhood of storms to spawn here within 1024 blocks: %.2f", (chance * 100F)) + "%")); } return InteractionResult.CONSUME; diff --git a/src/main/java/weather2/blockentity/DeflectorBlockEntity.java b/src/main/java/weather2/blockentity/DeflectorBlockEntity.java index 0a234f97..731944a2 100644 --- a/src/main/java/weather2/blockentity/DeflectorBlockEntity.java +++ b/src/main/java/weather2/blockentity/DeflectorBlockEntity.java @@ -30,7 +30,8 @@ public void tick() { public void init() { if (!level.isClientSide()) { CULog.dbg("adding weather deflector poi at " + getBlockPos()); - ((ServerLevel)level).getPoiManager().add(getBlockPos(), WeatherBlocks.POI_DEFLECTOR); + //TODO: 1.20 + //((ServerLevel)level).getPoiManager().add(getBlockPos(), () -> WeatherBlocks.POI_DEFLECTOR); } } } diff --git a/src/main/java/weather2/client/MovingSoundStreamingSource.java b/src/main/java/weather2/client/MovingSoundStreamingSource.java index d3ac8b52..907bd73d 100644 --- a/src/main/java/weather2/client/MovingSoundStreamingSource.java +++ b/src/main/java/weather2/client/MovingSoundStreamingSource.java @@ -3,6 +3,7 @@ import com.corosus.coroutil.util.CULog; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.sounds.AbstractTickableSoundInstance; +import net.minecraft.client.resources.sounds.SoundInstance; import net.minecraft.world.entity.player.Player; import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundEvent; @@ -18,7 +19,7 @@ public class MovingSoundStreamingSource extends AbstractTickableSoundInstance { public boolean lockToPlayer = false; public MovingSoundStreamingSource(Vec3 parPos, SoundEvent event, SoundSource category, float parVolume, float parPitch, boolean lockToPlayer) { - super(event, category); + super(event, category, SoundInstance.createUnseededRandom()); this.looping = false; this.volume = parVolume; this.pitch = parPitch; @@ -32,7 +33,7 @@ public MovingSoundStreamingSource(Vec3 parPos, SoundEvent event, SoundSource cat //constructor for non moving sounds public MovingSoundStreamingSource(Vec3 parPos, SoundEvent event, SoundSource category, float parVolume, float parPitch, float parCutOffRange) { - super(event, category); + super(event, category, SoundInstance.createUnseededRandom()); this.looping = false; this.volume = parVolume; this.pitch = parPitch; @@ -46,7 +47,7 @@ public MovingSoundStreamingSource(Vec3 parPos, SoundEvent event, SoundSource cat //constructor for moving sounds public MovingSoundStreamingSource(StormObject parStorm, SoundEvent event, SoundSource category, float parVolume, float parPitch, float parCutOffRange) { - super(event, category); + super(event, category, SoundInstance.createUnseededRandom()); this.storm = parStorm; this.looping = false; this.volume = parVolume; diff --git a/src/main/java/weather2/client/SceneEnhancer.java b/src/main/java/weather2/client/SceneEnhancer.java index db829d0e..6c72fb52 100644 --- a/src/main/java/weather2/client/SceneEnhancer.java +++ b/src/main/java/weather2/client/SceneEnhancer.java @@ -9,6 +9,7 @@ import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.*; import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.MapColor; import weather2.config.ConfigMisc; import weather2.datatypes.PrecipitationType; import weather2.datatypes.WeatherEventType; @@ -16,7 +17,6 @@ import extendedrenderer.particle.behavior.ParticleBehaviorSandstorm; import extendedrenderer.particle.entity.*; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.FlameParticle; import net.minecraft.client.particle.Particle; @@ -233,7 +233,8 @@ public synchronized void trySoundPlaying() Block block = getBlock(worldRef, cCor.getX(), cCor.getY(), cCor.getZ());//Block.blocksList[id]; - if (block == null || (block.defaultBlockState().getMaterial() != Material.WATER && block.defaultBlockState().getMaterial() != Material.LEAVES)) { + //if (block == null || (block.defaultBlockState().getMaterial() != Material.WATER && block.defaultBlockState().getMaterial() != Material.LEAVES)) { + if (block == null || (block.defaultMapColor() != MapColor.WATER && block.defaultMapColor() != MapColor.PLANT)) { soundLocations.remove(i); soundTimeLocations.remove(cCor); } else { @@ -309,7 +310,7 @@ public void tickRainSound() { LevelReader levelreader = minecraft.level; BlockPos blockpos = player.blockPosition(); BlockPos blockpos1 = null; - int i = (int)(100.0F * precipitationStrength * precipitationStrength) / (minecraft.options.particles == ParticleStatus.DECREASED ? 2 : 1); + int i = (int)(100.0F * precipitationStrength * precipitationStrength) / (minecraft.options.particles.get() == ParticleStatus.DECREASED ? 2 : 1); for(int j = 0; j < i; ++j) { int k = random.nextInt(21) - 10; @@ -318,7 +319,7 @@ public void tickRainSound() { Biome biome = levelreader.getBiome(blockpos2).get(); if (blockpos2.getY() > levelreader.getMinBuildHeight() && blockpos2.getY() <= blockpos.getY() + 10 && blockpos2.getY() >= blockpos.getY() - 10 && biome.getPrecipitationAt(blockpos2) == Biome.Precipitation.RAIN && biome.warmEnoughToRain(blockpos2)) { blockpos1 = blockpos2.below(); - if (minecraft.options.particles == ParticleStatus.MINIMAL) { + if (minecraft.options.particles.get() == ParticleStatus.MINIMAL) { break; } @@ -378,7 +379,7 @@ public static void tryAmbientSounds() Block block = getBlock(worldRef, xx, yy, zz); if (block != null) { - if (((block.defaultBlockState().getMaterial() == Material.LEAVES))) { + if (((block.defaultMapColor() == MapColor.PLANT))) { boolean proxFail = false; for (ChunkCoordinatesBlock soundLocation : soundLocations) { if (Math.sqrt(soundLocation.distSqr(new Vec3i(xx, yy, zz))) < 15) { @@ -512,9 +513,9 @@ public void tickEnvironmentalParticleSpawning() { } float particleSettingsAmplifier = 1F; - if (Minecraft.getInstance().options.particles == ParticleStatus.DECREASED) { + if (Minecraft.getInstance().options.particles.get() == ParticleStatus.DECREASED) { particleSettingsAmplifier = 0.5F; - } else if (Minecraft.getInstance().options.particles == ParticleStatus.MINIMAL) { + } else if (Minecraft.getInstance().options.particles.get() == ParticleStatus.MINIMAL) { particleSettingsAmplifier = 0.2F; } @@ -676,7 +677,7 @@ public void tickEnvironmentalParticleSpawning() { if (canPrecipitateAt(world, pos.above())) { //fix for splash spawning invisibly 1 block underwater - if (world.getBlockState(pos).getMaterial() == Material.WATER) { + if (world.getBlockState(pos).getBlock().defaultMapColor() == MapColor.WATER) { pos = pos.offset(0,1,0); } @@ -827,7 +828,7 @@ public void tickEnvironmentalParticleSpawning() { continue; //block above topmost ground - if (canPrecipitateAt(world, pos.above()) && world.getBlockState(pos).getMaterial() != Material.WATER) { + if (canPrecipitateAt(world, pos.above()) && world.getBlockState(pos).getBlock().defaultMapColor() != MapColor.WATER) { world.addParticle(ParticleTypes.SMOKE, pos.getX() + rand.nextFloat(), pos.getY() + 0.01D + maxY, pos.getZ() + rand.nextFloat(), 0.0D, 0.0D, 0.0D); world.addParticle(ParticleTypes.FLAME, pos.getX() + rand.nextFloat(), pos.getY() + 0.01D + maxY, pos.getZ() + rand.nextFloat(), 0.0D, 0.0D, 0.0D); @@ -906,7 +907,7 @@ public void tickEnvironmentalParticleSpawning() { Vec3 windForce = ClientTickHandler.getClientWeather().getWindManager().getWindForce(); double upwindDistAdjust = -10D; windForce = windForce.multiply(upwindDistAdjust, upwindDistAdjust, upwindDistAdjust); - pos = pos.offset(windForce.x, windForce.y, windForce.z); + pos = pos.offset(Mth.floor(windForce.x), Mth.floor(windForce.y), Mth.floor(windForce.z)); if (WeatherUtilEntity.getDistanceSqEntToPos(entP, pos) < closeDistCutoff * closeDistCutoff) continue; @@ -1151,9 +1152,9 @@ public void profileSurroundings() spawnRateRandChanceOdds = (int) ((spawnRateRandChanceOdds / (scaleRate + 0.001F)) / (particleCreationRate + 0.001F)); float particleSettingsAmplifier = 1F; - if (Minecraft.getInstance().options.particles == ParticleStatus.DECREASED) { + if (Minecraft.getInstance().options.particles.get() == ParticleStatus.DECREASED) { particleSettingsAmplifier = 0.5F; - } else if (Minecraft.getInstance().options.particles == ParticleStatus.MINIMAL) { + } else if (Minecraft.getInstance().options.particles.get() == ParticleStatus.MINIMAL) { particleSettingsAmplifier = 0.2F; } @@ -1186,9 +1187,7 @@ public void profileSurroundings() if (block != null) { //leaf particle spawning - if ((block.defaultBlockState().getMaterial() == Material.LEAVES - || block.defaultBlockState().getMaterial() == Material.REPLACEABLE_PLANT || - block.defaultBlockState().getMaterial() == Material.PLANT)) { + if ((block.defaultMapColor() == MapColor.PLANT)) { lastTickFoundBlocks++; @@ -1236,8 +1235,10 @@ public void profileSurroundings() } } if (windStr >= 0.1F) { - if (block instanceof GrassBlock || block.defaultBlockState().getMaterial() == Material.DIRT || block.defaultBlockState().getMaterial() == Material.SAND || block.defaultBlockState().getMaterial() == Material.REPLACEABLE_PLANT || - block.defaultBlockState().getMaterial() == Material.PLANT) { + if (block instanceof GrassBlock + || block.defaultMapColor() == MapColor.DIRT + || block.defaultMapColor() == MapColor.SAND + || block.defaultMapColor() == MapColor.PLANT) { lastTickFoundBlocks++; @@ -1246,13 +1247,14 @@ public void profileSurroundings() boolean spawnAboveSnow = false; //boolean placeAbove = false; - if (block instanceof GrassBlock || block.defaultBlockState().getMaterial() == Material.DIRT || block.defaultBlockState().getMaterial() == Material.SAND) { + if (block instanceof GrassBlock + || block.defaultMapColor() == MapColor.DIRT + || block.defaultMapColor() == MapColor.SAND) { spawnAbove = true; } int oddsTo1 = spawnRateRandChanceOdds; - if (block.defaultBlockState().getMaterial() == Material.REPLACEABLE_PLANT || - block.defaultBlockState().getMaterial() == Material.PLANT) { + if (block.defaultMapColor() == MapColor.PLANT) { oddsTo1 = spawnRateRandChanceOdds / 3; spawnInside = true; } @@ -1432,7 +1434,7 @@ private static BlockState getBlockState(Level parWorld, int x, int y, int z) public static boolean isFogOverridding() { Minecraft client = Minecraft.getInstance(); BlockState blockAtCamera = client.gameRenderer.getMainCamera().getBlockAtCamera(); - if (blockAtCamera.getMaterial().isLiquid()) return false; + if (blockAtCamera.getBlock().defaultMapColor() == MapColor.WATER) return false; //return heatwaveIntensity > 0; //return true; return fogAdjuster.isFogOverriding(); @@ -1484,9 +1486,9 @@ public static void tickSandstorm() { adjustAmountSmooth75 *= 0.3F; } - if (Minecraft.getInstance().options.particles == ParticleStatus.DECREASED) { + if (Minecraft.getInstance().options.particles.get() == ParticleStatus.DECREASED) { adjustAmountSmooth75 *= 0.5F; - } else if (Minecraft.getInstance().options.particles == ParticleStatus.MINIMAL) { + } else if (Minecraft.getInstance().options.particles.get() == ParticleStatus.MINIMAL) { adjustAmountSmooth75 *= 0.25F; } diff --git a/src/main/java/weather2/client/shaders/ShaderInstanceExtended.java b/src/main/java/weather2/client/shaders/ShaderInstanceExtended.java deleted file mode 100644 index 453fc830..00000000 --- a/src/main/java/weather2/client/shaders/ShaderInstanceExtended.java +++ /dev/null @@ -1,558 +0,0 @@ -package weather2.client.shaders; - -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.mojang.blaze3d.pipeline.RenderTarget; -import com.mojang.blaze3d.platform.GlStateManager; -import com.mojang.blaze3d.preprocessor.GlslPreprocessor; -import com.mojang.blaze3d.shaders.AbstractUniform; -import com.mojang.blaze3d.shaders.BlendMode; -import com.mojang.blaze3d.shaders.Program; -import com.mojang.blaze3d.shaders.ProgramManager; -import com.mojang.blaze3d.shaders.Shader; -import com.mojang.blaze3d.shaders.Uniform; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.VertexFormat; -import it.unimi.dsi.fastutil.ints.IntArrayList; -import it.unimi.dsi.fastutil.ints.IntList; -import java.io.Closeable; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; -import java.util.List; -import java.util.Map; -import java.util.Set; -import javax.annotation.Nullable; -import net.minecraft.FileUtil; -import net.minecraft.client.renderer.texture.AbstractTexture; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.ChainedJsonException; -import net.minecraft.server.packs.resources.Resource; -import net.minecraft.server.packs.resources.ResourceProvider; -import net.minecraft.util.GsonHelper; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import org.apache.commons.io.IOUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import weather2.client.shaderstest.InstancedMeshParticle; - -@OnlyIn(Dist.CLIENT) -public class ShaderInstanceExtended implements Shader, AutoCloseable { - private static final String SHADER_PATH = "shaders/core/"; - private static final String SHADER_INCLUDE_PATH = "shaders/include/"; - static final Logger LOGGER = LogManager.getLogger(); - private static final AbstractUniform DUMMY_UNIFORM = new AbstractUniform(); - private static final boolean ALWAYS_REAPPLY = true; - private static ShaderInstanceExtended lastAppliedShader; - private static int lastProgramId = -1; - private final Map samplerMap = Maps.newHashMap(); - private final List samplerNames = Lists.newArrayList(); - private final List samplerLocations = Lists.newArrayList(); - private final List uniforms = Lists.newArrayList(); - private final List uniformLocations = Lists.newArrayList(); - private final Map uniformMap = Maps.newHashMap(); - private final int programId; - private final String name; - private boolean dirty; - private final BlendMode blend; - private final List attributes; - private final List attributeNames; - private final Program vertexProgram; - private final Program fragmentProgram; - private final VertexFormat vertexFormat; - @Nullable - public final Uniform MODEL_VIEW_MATRIX; - @Nullable - public final Uniform PROJECTION_MATRIX; - @Nullable - public final Uniform TEXTURE_MATRIX; - @Nullable - public final Uniform SCREEN_SIZE; - @Nullable - public final Uniform COLOR_MODULATOR; - @Nullable - public final Uniform LIGHT0_DIRECTION; - @Nullable - public final Uniform LIGHT1_DIRECTION; - @Nullable - public final Uniform FOG_START; - @Nullable - public final Uniform FOG_END; - @Nullable - public final Uniform FOG_COLOR; - @Nullable - public final Uniform LINE_WIDTH; - @Nullable - public final Uniform GAME_TIME; - @Nullable - public final Uniform CHUNK_OFFSET; - - @Nullable - public final Uniform CUSTOM_TIME; - - @Deprecated // FORGE: Use the ResourceLocation variant below - public ShaderInstanceExtended(ResourceProvider p_173336_, String p_173337_, VertexFormat p_173338_) throws IOException { - this(p_173336_, new ResourceLocation(p_173337_), p_173338_); - } - public ShaderInstanceExtended(ResourceProvider p_173336_, ResourceLocation shaderLocation, VertexFormat p_173338_) throws IOException { - this.name = shaderLocation.getNamespace().equals("minecraft") ? shaderLocation.getPath() : shaderLocation.toString(); - this.vertexFormat = p_173338_; - ResourceLocation resourcelocation = new ResourceLocation(shaderLocation.getNamespace(), "shaders/core/" + shaderLocation.getPath() + ".json"); - Resource resource = null; - - try { - resource = p_173336_.getResource(resourcelocation); - JsonObject jsonobject = GsonHelper.parse(new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8)); - String s = GsonHelper.getAsString(jsonobject, "vertex"); - String s1 = GsonHelper.getAsString(jsonobject, "fragment"); - JsonArray jsonarray = GsonHelper.getAsJsonArray(jsonobject, "samplers", (JsonArray)null); - if (jsonarray != null) { - int i = 0; - - for(JsonElement jsonelement : jsonarray) { - try { - this.parseSamplerNode(jsonelement); - } catch (Exception exception2) { - ChainedJsonException chainedjsonexception1 = ChainedJsonException.forException(exception2); - chainedjsonexception1.prependJsonKey("samplers[" + i + "]"); - throw chainedjsonexception1; - } - - ++i; - } - } - - JsonArray jsonarray1 = GsonHelper.getAsJsonArray(jsonobject, "attributes", (JsonArray)null); - if (jsonarray1 != null) { - int j = 0; - this.attributes = Lists.newArrayListWithCapacity(jsonarray1.size()); - this.attributeNames = Lists.newArrayListWithCapacity(jsonarray1.size()); - - for(JsonElement jsonelement1 : jsonarray1) { - try { - this.attributeNames.add(GsonHelper.convertToString(jsonelement1, "attribute")); - } catch (Exception exception1) { - ChainedJsonException chainedjsonexception2 = ChainedJsonException.forException(exception1); - chainedjsonexception2.prependJsonKey("attributes[" + j + "]"); - throw chainedjsonexception2; - } - - ++j; - } - } else { - this.attributes = null; - this.attributeNames = null; - } - - JsonArray jsonarray2 = GsonHelper.getAsJsonArray(jsonobject, "uniforms", (JsonArray)null); - if (jsonarray2 != null) { - int k = 0; - - for(JsonElement jsonelement2 : jsonarray2) { - try { - this.parseUniformNode(jsonelement2); - } catch (Exception exception) { - ChainedJsonException chainedjsonexception3 = ChainedJsonException.forException(exception); - chainedjsonexception3.prependJsonKey("uniforms[" + k + "]"); - throw chainedjsonexception3; - } - - ++k; - } - } - - this.blend = parseBlendNode(GsonHelper.getAsJsonObject(jsonobject, "blend", (JsonObject)null)); - this.vertexProgram = getOrCreate(p_173336_, Program.Type.VERTEX, s); - this.fragmentProgram = getOrCreate(p_173336_, Program.Type.FRAGMENT, s1); - this.programId = ProgramManager.createProgram(); - if (this.attributeNames != null) { - int l = 0; - - for(String s2 : p_173338_.getElementAttributeNames()) { - //Uniform.glBindAttribLocation(this.programId, l, s2); - //Uniform.glBindAttribLocation(this.programId, getAttribLocationForAttrib(s2), s2); - this.attributes.add(l); - ++l; - } - - Uniform.glBindAttribLocation(this.programId, 0, "Position"); - Uniform.glBindAttribLocation(this.programId, 1, "UV0"); - Uniform.glBindAttribLocation(this.programId, 2, "Normal"); - //ShaderManager.glBindAttribLocation(programId, vertexShaderAttributeVertexNormal, "vertexNormal"); - /*Uniform.glBindAttribLocation(this.programId, vertexShaderAttributeModelMatrix, "Color"); - Uniform.glBindAttribLocation(this.programId, vertexShaderAttributeBrightness, "Normal");*/ - Uniform.glBindAttribLocation(this.programId, InstancedMeshParticle.vboSizeMesh, "ModelMatrix"); - Uniform.glBindAttribLocation(this.programId, InstancedMeshParticle.vboSizeMesh + 4, "Brightness"); - Uniform.glBindAttribLocation(this.programId, InstancedMeshParticle.vboSizeMesh + 5, "Color"); - } - - ProgramManager.linkShader(this); - this.updateLocations(); - } catch (Exception exception3) { - ChainedJsonException chainedjsonexception = ChainedJsonException.forException(exception3); - chainedjsonexception.setFilenameAndFlush(resourcelocation.getPath()); - throw chainedjsonexception; - } finally { - IOUtils.closeQuietly((Closeable)resource); - } - - this.markDirty(); - this.MODEL_VIEW_MATRIX = this.getUniform("ModelViewMat"); - this.PROJECTION_MATRIX = this.getUniform("ProjMat"); - this.TEXTURE_MATRIX = this.getUniform("TextureMat"); - this.SCREEN_SIZE = this.getUniform("ScreenSize"); - this.COLOR_MODULATOR = this.getUniform("ColorModulator"); - this.LIGHT0_DIRECTION = this.getUniform("Light0_Direction"); - this.LIGHT1_DIRECTION = this.getUniform("Light1_Direction"); - this.FOG_START = this.getUniform("FogStart"); - this.FOG_END = this.getUniform("FogEnd"); - this.FOG_COLOR = this.getUniform("FogColor"); - this.LINE_WIDTH = this.getUniform("LineWidth"); - this.GAME_TIME = this.getUniform("GameTime"); - this.CHUNK_OFFSET = this.getUniform("ChunkOffset"); - - this.CUSTOM_TIME = this.getUniform("CustomTime"); - }/* - - public int getAttribLocationForAttrib(String attrib) { - - }*/ - - private static Program getOrCreate(final ResourceProvider p_173341_, Program.Type p_173342_, String p_173343_) throws IOException { - Program program1 = p_173342_.getPrograms().get(p_173343_); - Program program; - if (program1 == null) { - ResourceLocation loc = new ResourceLocation(p_173343_); - String s = "shaders/core/" + loc.getPath() + p_173342_.getExtension(); - ResourceLocation resourcelocation = new ResourceLocation(loc.getNamespace(), s); - Resource resource = p_173341_.getResource(resourcelocation); - final String s1 = FileUtil.getFullResourcePath(s); - - try { - program = Program.compileShader(p_173342_, p_173343_, resource.getInputStream(), resource.getSourceName(), new GlslPreprocessor() { - private final Set importedPaths = Sets.newHashSet(); - - public String applyImport(boolean p_173374_, String p_173375_) { - String str = "shaders/include/"; - if (p_173375_.contains("weather2:")) { - str = "weather2:" + str; - p_173375_ = p_173375_.replace("weather2:", ""); - } - p_173375_ = FileUtil.normalizeResourcePath((p_173374_ ? s1 : str) + p_173375_); - if (!this.importedPaths.add(p_173375_)) { - return null; - } else { - ResourceLocation resourcelocation1 = new ResourceLocation(p_173375_); - - try { - Resource resource1 = p_173341_.getResource(resourcelocation1); - - String s2; - try { - s2 = IOUtils.toString(resource1.getInputStream(), StandardCharsets.UTF_8); - } catch (Throwable throwable1) { - if (resource1 != null) { - try { - resource1.close(); - } catch (Throwable throwable) { - throwable1.addSuppressed(throwable); - } - } - - throw throwable1; - } - - if (resource1 != null) { - resource1.close(); - } - - return s2; - } catch (IOException ioexception) { - ShaderInstanceExtended.LOGGER.error("Could not open GLSL import {}: {}", p_173375_, ioexception.getMessage()); - return "#error " + ioexception.getMessage(); - } - } - } - }); - } finally { - IOUtils.closeQuietly((Closeable)resource); - } - } else { - program = program1; - } - - return program; - } - - public static BlendMode parseBlendNode(JsonObject p_173347_) { - if (p_173347_ == null) { - return new BlendMode(); - } else { - int i = 32774; - int j = 1; - int k = 0; - int l = 1; - int i1 = 0; - boolean flag = true; - boolean flag1 = false; - if (GsonHelper.isStringValue(p_173347_, "func")) { - i = BlendMode.stringToBlendFunc(p_173347_.get("func").getAsString()); - if (i != 32774) { - flag = false; - } - } - - if (GsonHelper.isStringValue(p_173347_, "srcrgb")) { - j = BlendMode.stringToBlendFactor(p_173347_.get("srcrgb").getAsString()); - if (j != 1) { - flag = false; - } - } - - if (GsonHelper.isStringValue(p_173347_, "dstrgb")) { - k = BlendMode.stringToBlendFactor(p_173347_.get("dstrgb").getAsString()); - if (k != 0) { - flag = false; - } - } - - if (GsonHelper.isStringValue(p_173347_, "srcalpha")) { - l = BlendMode.stringToBlendFactor(p_173347_.get("srcalpha").getAsString()); - if (l != 1) { - flag = false; - } - - flag1 = true; - } - - if (GsonHelper.isStringValue(p_173347_, "dstalpha")) { - i1 = BlendMode.stringToBlendFactor(p_173347_.get("dstalpha").getAsString()); - if (i1 != 0) { - flag = false; - } - - flag1 = true; - } - - if (flag) { - return new BlendMode(); - } else { - return flag1 ? new BlendMode(j, k, l, i1, i) : new BlendMode(j, k, i); - } - } - } - - public void close() { - for(Uniform uniform : this.uniforms) { - uniform.close(); - } - - ProgramManager.releaseProgram(this); - } - - public void clear() { - RenderSystem.assertOnRenderThread(); - ProgramManager.glUseProgram(0); - lastProgramId = -1; - lastAppliedShader = null; - int i = GlStateManager._getActiveTexture(); - - for(int j = 0; j < this.samplerLocations.size(); ++j) { - if (this.samplerMap.get(this.samplerNames.get(j)) != null) { - GlStateManager._activeTexture('\u84c0' + j); - GlStateManager._bindTexture(0); - } - } - - GlStateManager._activeTexture(i); - } - - public void apply() { - RenderSystem.assertOnRenderThread(); - this.dirty = false; - lastAppliedShader = this; - this.blend.apply(); - - //TODO: TEMP!!!!! - ProgramManager.glUseProgram(this.programId); - - if (this.programId != lastProgramId) { - ProgramManager.glUseProgram(this.programId); - lastProgramId = this.programId; - } - - int i = GlStateManager._getActiveTexture(); - - for(int j = 0; j < this.samplerLocations.size(); ++j) { - String s = this.samplerNames.get(j); - if (this.samplerMap.get(s) != null) { - int k = Uniform.glGetUniformLocation(this.programId, s); - Uniform.uploadInteger(k, j); - RenderSystem.activeTexture('\u84c0' + j); - RenderSystem.enableTexture(); - Object object = this.samplerMap.get(s); - int l = -1; - if (object instanceof RenderTarget) { - l = ((RenderTarget)object).getColorTextureId(); - } else if (object instanceof AbstractTexture) { - l = ((AbstractTexture)object).getId(); - } else if (object instanceof Integer) { - l = (Integer)object; - } - - if (l != -1) { - RenderSystem.bindTexture(l); - } - } - } - - GlStateManager._activeTexture(i); - - for(Uniform uniform : this.uniforms) { - uniform.upload(); - } - - } - - public void markDirty() { - this.dirty = true; - } - - @Nullable - public Uniform getUniform(String p_173349_) { - RenderSystem.assertOnRenderThread(); - return this.uniformMap.get(p_173349_); - } - - public AbstractUniform safeGetUniform(String p_173357_) { - RenderSystem.isOnGameThread(); - Uniform uniform = this.getUniform(p_173357_); - return (AbstractUniform)(uniform == null ? DUMMY_UNIFORM : uniform); - } - - private void updateLocations() { - RenderSystem.assertOnRenderThread(); - IntList intlist = new IntArrayList(); - - for(int i = 0; i < this.samplerNames.size(); ++i) { - String s = this.samplerNames.get(i); - int j = Uniform.glGetUniformLocation(this.programId, s); - if (j == -1) { - LOGGER.warn("Shader {} could not find sampler named {} in the specified shader program.", this.name, s); - this.samplerMap.remove(s); - intlist.add(i); - } else { - this.samplerLocations.add(j); - } - } - - for(int l = intlist.size() - 1; l >= 0; --l) { - int i1 = intlist.getInt(l); - this.samplerNames.remove(i1); - } - - for(Uniform uniform : this.uniforms) { - String s1 = uniform.getName(); - int k = Uniform.glGetUniformLocation(this.programId, s1); - if (k == -1) { - LOGGER.warn("Shader {} could not find uniform named {} in the specified shader program.", this.name, s1); - } else { - this.uniformLocations.add(k); - uniform.setLocation(k); - this.uniformMap.put(s1, uniform); - } - } - - } - - private void parseSamplerNode(JsonElement p_173345_) { - JsonObject jsonobject = GsonHelper.convertToJsonObject(p_173345_, "sampler"); - String s = GsonHelper.getAsString(jsonobject, "name"); - if (!GsonHelper.isStringValue(jsonobject, "file")) { - this.samplerMap.put(s, (Object)null); - this.samplerNames.add(s); - } else { - this.samplerNames.add(s); - } - } - - public void setSampler(String p_173351_, Object p_173352_) { - this.samplerMap.put(p_173351_, p_173352_); - this.markDirty(); - } - - private void parseUniformNode(JsonElement p_173355_) throws ChainedJsonException { - JsonObject jsonobject = GsonHelper.convertToJsonObject(p_173355_, "uniform"); - String s = GsonHelper.getAsString(jsonobject, "name"); - int i = Uniform.getTypeFromString(GsonHelper.getAsString(jsonobject, "type")); - int j = GsonHelper.getAsInt(jsonobject, "count"); - float[] afloat = new float[Math.max(j, 16)]; - JsonArray jsonarray = GsonHelper.getAsJsonArray(jsonobject, "values"); - if (jsonarray.size() != j && jsonarray.size() > 1) { - throw new ChainedJsonException("Invalid amount of values specified (expected " + j + ", found " + jsonarray.size() + ")"); - } else { - int k = 0; - - for(JsonElement jsonelement : jsonarray) { - try { - afloat[k] = GsonHelper.convertToFloat(jsonelement, "value"); - } catch (Exception exception) { - ChainedJsonException chainedjsonexception = ChainedJsonException.forException(exception); - chainedjsonexception.prependJsonKey("values[" + k + "]"); - throw chainedjsonexception; - } - - ++k; - } - - if (j > 1 && jsonarray.size() == 1) { - while(k < j) { - afloat[k] = afloat[0]; - ++k; - } - } - - int l = j > 1 && j <= 4 && i < 8 ? j - 1 : 0; - Uniform uniform = new Uniform(s, i + l, j, this); - if (i <= 3) { - uniform.setSafe((int)afloat[0], (int)afloat[1], (int)afloat[2], (int)afloat[3]); - } else if (i <= 7) { - uniform.setSafe(afloat[0], afloat[1], afloat[2], afloat[3]); - } else { - uniform.set(afloat); - } - - this.uniforms.add(uniform); - } - } - - public Program getVertexProgram() { - return this.vertexProgram; - } - - public Program getFragmentProgram() { - return this.fragmentProgram; - } - - public void attachToProgram() { - this.fragmentProgram.attachToShader(this); - this.vertexProgram.attachToShader(this); - } - - public VertexFormat getVertexFormat() { - return this.vertexFormat; - } - - public String getName() { - return this.name; - } - - public int getId() { - return this.programId; - } -} diff --git a/src/main/java/weather2/client/shaders/ShaderInstanceExtendedEh.java b/src/main/java/weather2/client/shaders/ShaderInstanceExtendedEh.java deleted file mode 100644 index 5192f1c7..00000000 --- a/src/main/java/weather2/client/shaders/ShaderInstanceExtendedEh.java +++ /dev/null @@ -1,105 +0,0 @@ -package weather2.client.shaders; - -import com.google.common.collect.Lists; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.mojang.blaze3d.shaders.Program; -import com.mojang.blaze3d.shaders.Shader; -import com.mojang.blaze3d.shaders.Uniform; -import com.mojang.blaze3d.vertex.VertexFormat; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.ChainedJsonException; -import net.minecraft.server.packs.resources.Resource; -import net.minecraft.server.packs.resources.ResourceProvider; -import net.minecraft.util.GsonHelper; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import org.apache.commons.io.IOUtils; - -import javax.annotation.Nullable; -import java.io.Closeable; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; - -@OnlyIn(Dist.CLIENT) -public class ShaderInstanceExtendedEh implements Shader, AutoCloseable { - - //@Nullable - //public final Uniform CUSTOM_TIME; - - public ShaderInstanceExtendedEh(ResourceProvider p_173336_, ResourceLocation shaderLocation, VertexFormat p_173338_) throws IOException { - //super(p_173336_, shaderLocation, p_173338_); - - /*ResourceLocation resourcelocation = new ResourceLocation(shaderLocation.getNamespace(), "shaders/core/" + shaderLocation.getPath() + ".json"); - Resource resource = null; - - try { - resource = p_173336_.getResource(resourcelocation); - JsonObject jsonobject = GsonHelper.parse(new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8)); - String s = GsonHelper.getAsString(jsonobject, "vertex"); - String s1 = GsonHelper.getAsString(jsonobject, "fragment"); - JsonArray jsonarray1 = GsonHelper.getAsJsonArray(jsonobject, "attributes", (JsonArray) null); - if (jsonarray1 != null) { - int j = 0; - this.attributes = Lists.newArrayListWithCapacity(jsonarray1.size()); - this.attributeNames = Lists.newArrayListWithCapacity(jsonarray1.size()); - - for (JsonElement jsonelement1 : jsonarray1) { - try { - this.attributeNames.add(GsonHelper.convertToString(jsonelement1, "attribute")); - } catch (Exception exception1) { - ChainedJsonException chainedjsonexception2 = ChainedJsonException.forException(exception1); - chainedjsonexception2.prependJsonKey("attributes[" + j + "]"); - throw chainedjsonexception2; - } - - ++j; - } - } else { - this.attributes = null; - this.attributeNames = null; - } - } catch (Exception exception3) { - ChainedJsonException chainedjsonexception = ChainedJsonException.forException(exception3); - chainedjsonexception.setFilenameAndFlush(resourcelocation.getPath()); - throw chainedjsonexception; - } finally { - IOUtils.closeQuietly((Closeable)resource); - } - - this.CUSTOM_TIME = this.getUniform("CustomTime");*/ - } - - - @Override - public int getId() { - return 0; - } - - @Override - public void markDirty() { - - } - - @Override - public Program getVertexProgram() { - return null; - } - - @Override - public Program getFragmentProgram() { - return null; - } - - @Override - public void attachToProgram() { - - } - - @Override - public void close() throws Exception { - - } -} diff --git a/src/main/java/weather2/client/shaders/VertexBufferInstanced.java b/src/main/java/weather2/client/shaders/VertexBufferInstanced.java deleted file mode 100644 index 73fe320f..00000000 --- a/src/main/java/weather2/client/shaders/VertexBufferInstanced.java +++ /dev/null @@ -1,321 +0,0 @@ -package weather2.client.shaders; - -import com.mojang.blaze3d.platform.Window; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.BufferBuilder; -import com.mojang.blaze3d.vertex.BufferUploader; -import com.mojang.blaze3d.vertex.VertexFormat; -import com.mojang.datafixers.util.Pair; -import com.mojang.math.Matrix4f; -import java.nio.ByteBuffer; -import java.util.concurrent.CompletableFuture; -import net.minecraft.client.Minecraft; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; - -@OnlyIn(Dist.CLIENT) -public class VertexBufferInstanced implements AutoCloseable { - private int vertextBufferId; - private int indexBufferId; - private VertexFormat.IndexType indexType; - private int arrayObjectId; - private int indexCount; - private VertexFormat.Mode mode; - private boolean sequentialIndices; - private VertexFormat format; - - public VertexBufferInstanced() { - RenderSystem.glGenBuffers((p_85928_) -> { - this.vertextBufferId = p_85928_; - }); - RenderSystem.glGenVertexArrays((p_166881_) -> { - this.arrayObjectId = p_166881_; - }); - RenderSystem.glGenBuffers((p_166872_) -> { - this.indexBufferId = p_166872_; - }); - } - - public void bind() { - RenderSystem.glBindBuffer(34962, () -> { - return this.vertextBufferId; - }); - if (this.sequentialIndices) { - RenderSystem.glBindBuffer(34963, () -> { - RenderSystem.AutoStorageIndexBuffer rendersystem$autostorageindexbuffer = RenderSystem.getSequentialBuffer(this.mode, this.indexCount); - this.indexType = rendersystem$autostorageindexbuffer.type(); - return rendersystem$autostorageindexbuffer.name(); - }); - } else { - RenderSystem.glBindBuffer(34963, () -> { - return this.indexBufferId; - }); - } - - } - - public void upload(BufferBuilder p_85926_) { - if (!RenderSystem.isOnRenderThread()) { - RenderSystem.recordRenderCall(() -> { - this.upload_(p_85926_); - }); - } else { - this.upload_(p_85926_); - } - - } - - public CompletableFuture uploadLater(BufferBuilder p_85933_) { - if (!RenderSystem.isOnRenderThread()) { - return CompletableFuture.runAsync(() -> { - this.upload_(p_85933_); - }, (p_166874_) -> { - RenderSystem.recordRenderCall(p_166874_::run); - }); - } else { - this.upload_(p_85933_); - return CompletableFuture.completedFuture((Void)null); - } - } - - private void upload_(BufferBuilder p_85936_) { - Pair pair = p_85936_.popNextBuffer(); - if (this.vertextBufferId != 0) { - BufferUploader.reset(); - BufferBuilder.DrawState bufferbuilder$drawstate = pair.getFirst(); - ByteBuffer bytebuffer = pair.getSecond(); - int i = bufferbuilder$drawstate.vertexBufferSize(); - this.indexCount = bufferbuilder$drawstate.indexCount(); - this.indexType = bufferbuilder$drawstate.indexType(); - this.format = bufferbuilder$drawstate.format(); - this.mode = bufferbuilder$drawstate.mode(); - this.sequentialIndices = bufferbuilder$drawstate.sequentialIndex(); - this.bindVertexArray(); - this.bind(); - if (!bufferbuilder$drawstate.indexOnly()) { - bytebuffer.limit(i); - RenderSystem.glBufferData(34962, bytebuffer, 35044); - bytebuffer.position(i); - } - - if (!this.sequentialIndices) { - bytebuffer.limit(bufferbuilder$drawstate.bufferSize()); - RenderSystem.glBufferData(34963, bytebuffer, 35044); - bytebuffer.position(0); - } else { - bytebuffer.limit(bufferbuilder$drawstate.bufferSize()); - bytebuffer.position(0); - } - - unbind(); - unbindVertexArray(); - } - } - - private void bindVertexArray() { - RenderSystem.glBindVertexArray(() -> { - return this.arrayObjectId; - }); - } - - public static void unbindVertexArray() { - RenderSystem.glBindVertexArray(() -> { - return 0; - }); - } - - public void draw() { - if (this.indexCount != 0) { - RenderSystem.drawElements(this.mode.asGLMode, this.indexCount, this.indexType.asGLType); - } - } - - public void drawWithShader(Matrix4f p_166868_, Matrix4f p_166869_, ShaderInstanceExtended p_166870_) { - if (!RenderSystem.isOnRenderThread()) { - RenderSystem.recordRenderCall(() -> { - this._drawWithShader(p_166868_.copy(), p_166869_.copy(), p_166870_); - }); - } else { - this._drawWithShader(p_166868_, p_166869_, p_166870_); - } - - } - - public void _drawWithShader(Matrix4f p_166877_, Matrix4f p_166878_, ShaderInstanceExtended p_166879_) { - if (this.indexCount != 0) { - RenderSystem.assertOnRenderThread(); - BufferUploader.reset(); - - for(int i = 0; i < 12; ++i) { - int j = RenderSystem.getShaderTexture(i); - p_166879_.setSampler("Sampler" + i, j); - } - - if (p_166879_.MODEL_VIEW_MATRIX != null) { - p_166879_.MODEL_VIEW_MATRIX.set(p_166877_); - } - - if (p_166879_.PROJECTION_MATRIX != null) { - p_166879_.PROJECTION_MATRIX.set(p_166878_); - } - - if (p_166879_.COLOR_MODULATOR != null) { - p_166879_.COLOR_MODULATOR.set(RenderSystem.getShaderColor()); - } - - if (p_166879_.FOG_START != null) { - p_166879_.FOG_START.set(RenderSystem.getShaderFogStart()); - } - - if (p_166879_.FOG_END != null) { - p_166879_.FOG_END.set(RenderSystem.getShaderFogEnd()); - } - - if (p_166879_.FOG_COLOR != null) { - p_166879_.FOG_COLOR.set(RenderSystem.getShaderFogColor()); - } - - if (p_166879_.TEXTURE_MATRIX != null) { - p_166879_.TEXTURE_MATRIX.set(RenderSystem.getTextureMatrix()); - } - - if (p_166879_.GAME_TIME != null) { - p_166879_.GAME_TIME.set(RenderSystem.getShaderGameTime()); - } - - if (p_166879_.SCREEN_SIZE != null) { - Window window = Minecraft.getInstance().getWindow(); - p_166879_.SCREEN_SIZE.set((float)window.getWidth(), (float)window.getHeight()); - } - - if (p_166879_.LINE_WIDTH != null && (this.mode == VertexFormat.Mode.LINES || this.mode == VertexFormat.Mode.LINE_STRIP)) { - p_166879_.LINE_WIDTH.set(RenderSystem.getShaderLineWidth()); - } - - //RenderSystem.setupShaderLights(p_166879_); - - this.bindVertexArray(); - this.bind(); - this.getFormat().setupBufferState(); - p_166879_.apply(); - RenderSystem.drawElements(this.mode.asGLMode, this.indexCount, this.indexType.asGLType); - p_166879_.clear(); - this.getFormat().clearBufferState(); - unbind(); - unbindVertexArray(); - } - } - - public void _drawWithShaderDummyStart(Matrix4f p_166877_, Matrix4f p_166878_, ShaderInstanceExtended p_166879_) { - //if (this.indexCount != 0) { - RenderSystem.assertOnRenderThread(); - BufferUploader.reset(); - - for(int i = 0; i < 12; ++i) { - int j = RenderSystem.getShaderTexture(i); - p_166879_.setSampler("Sampler" + i, j); - } - - if (p_166879_.MODEL_VIEW_MATRIX != null) { - p_166879_.MODEL_VIEW_MATRIX.set(p_166877_); - } - - if (p_166879_.PROJECTION_MATRIX != null) { - p_166879_.PROJECTION_MATRIX.set(p_166878_); - } - - if (p_166879_.COLOR_MODULATOR != null) { - p_166879_.COLOR_MODULATOR.set(RenderSystem.getShaderColor()); - } - - if (p_166879_.FOG_START != null) { - p_166879_.FOG_START.set(RenderSystem.getShaderFogStart()); - } - - if (p_166879_.FOG_END != null) { - p_166879_.FOG_END.set(RenderSystem.getShaderFogEnd()); - } - - if (p_166879_.FOG_COLOR != null) { - p_166879_.FOG_COLOR.set(RenderSystem.getShaderFogColor()); - } - - if (p_166879_.TEXTURE_MATRIX != null) { - p_166879_.TEXTURE_MATRIX.set(RenderSystem.getTextureMatrix()); - } - - if (p_166879_.GAME_TIME != null) { - p_166879_.GAME_TIME.set(RenderSystem.getShaderGameTime()); - } - - if (p_166879_.SCREEN_SIZE != null) { - Window window = Minecraft.getInstance().getWindow(); - p_166879_.SCREEN_SIZE.set((float)window.getWidth(), (float)window.getHeight()); - } - - if (p_166879_.LINE_WIDTH != null && (this.mode == VertexFormat.Mode.LINES || this.mode == VertexFormat.Mode.LINE_STRIP)) { - p_166879_.LINE_WIDTH.set(RenderSystem.getShaderLineWidth()); - } - - p_166879_.apply(); - //this.getFormat().setupBufferState(); - - //RenderSystem.setupShaderLights(p_166879_); - - /*this.bindVertexArray(); - this.bind(); - this.getFormat().setupBufferState(); - p_166879_.apply(); - RenderSystem.drawElements(this.mode.asGLMode, this.indexCount, this.indexType.asGLType); - p_166879_.clear(); - this.getFormat().clearBufferState(); - unbind(); - unbindVertexArray();*/ - //} - } - - public void _drawWithShaderDummyEnd(Matrix4f p_166877_, Matrix4f p_166878_, ShaderInstanceExtended p_166879_) { - - } - - public void drawChunkLayer() { - if (this.indexCount != 0) { - RenderSystem.assertOnRenderThread(); - this.bindVertexArray(); - this.bind(); - this.format.setupBufferState(); - RenderSystem.drawElements(this.mode.asGLMode, this.indexCount, this.indexType.asGLType); - } - } - - public static void unbind() { - RenderSystem.glBindBuffer(34962, () -> { - return 0; - }); - RenderSystem.glBindBuffer(34963, () -> { - return 0; - }); - } - - public void close() { - if (this.indexBufferId >= 0) { - RenderSystem.glDeleteBuffers(this.indexBufferId); - this.indexBufferId = -1; - } - - if (this.vertextBufferId > 0) { - RenderSystem.glDeleteBuffers(this.vertextBufferId); - this.vertextBufferId = 0; - } - - if (this.arrayObjectId > 0) { - RenderSystem.glDeleteVertexArrays(this.arrayObjectId); - this.arrayObjectId = 0; - } - - } - - public VertexFormat getFormat() { - return this.format; - } -} \ No newline at end of file diff --git a/src/main/java/weather2/client/shaders/WeatherShaders.java b/src/main/java/weather2/client/shaders/WeatherShaders.java deleted file mode 100644 index 313f36c7..00000000 --- a/src/main/java/weather2/client/shaders/WeatherShaders.java +++ /dev/null @@ -1,84 +0,0 @@ -package weather2.client.shaders; - -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.DefaultVertexFormat; -import com.mojang.blaze3d.vertex.VertexFormat; -import extendedrenderer.particle.ParticleRegistry; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.ShaderInstance; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.client.event.RegisterShadersEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; -import weather2.Weather; - -import java.io.IOException; - -public class WeatherShaders -{ - - public static ShaderInstanceExtended getShaderExtended() { - return CustomRenderTypes.cloudShader; - } - - @Mod.EventBusSubscriber(value = Dist.CLIENT, modid = Weather.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) - public static class ModClientEvents - { - @SubscribeEvent - public static void shaderRegistry(RegisterShadersEvent event) throws IOException - { - CustomRenderTypes.cloudShader = new ShaderInstanceExtended(event.getResourceManager(), - new ResourceLocation(Weather.MODID + ":rendertype_clouds"), DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL); - } - } - - public static void setupShader() { - TextureAtlasSprite sprite = ParticleRegistry.rain_white; - } - - // Accessor function, ensures that you don't use the raw methods below unintentionally. - /*public static RenderType clouds(ResourceLocation texture) - { - return CustomRenderTypes.CLOUDS.apply(texture); - }*/ - - // Keep private because this stuff isn't meant to be public - public static class CustomRenderTypes extends RenderType - { - // Holds the object loaded via RegisterShadersEvent - public static ShaderInstanceExtended cloudShader; - - // Shader state for use in the render type, the supplier ensures it updates automatically with resource reloads - //private static final ShaderStateShard RENDERTYPE_CLOUD = new ShaderStateShard(() -> cloudShader); - - // Dummy constructor needed to make java happy - private CustomRenderTypes(String s, VertexFormat v, VertexFormat.Mode m, int i, boolean b, boolean b2, Runnable r, Runnable r2) - { - super(s, v, m, i, b, b2, r, r2); - throw new IllegalStateException("This class is not meant to be constructed!"); - } - - // The memoize caches the output value for each input, meaning the expensive registration process doesn't have to rerun - //public static Function CLOUDS = Util.memoize(CustomRenderTypes::clouds); - - // Defines the RenderType. Make sure the name is unique by including your MODID in the name. - /*private static RenderType clouds(ResourceLocation locationIn) - { - RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() - .setShaderState(RENDERTYPE_CLOUD) - .setTextureState(new RenderStateShard.TextureStateShard(locationIn, false, false)) - .setTransparencyState(NO_TRANSPARENCY) - .setLightmapState(NO_LIGHTMAP) - .setOverlayState(NO_OVERLAY) - .createCompositeState(true); - return create("rendertype_clouds", DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL, - VertexFormat.Mode.QUADS, 256, true, false, rendertype$state); - }*/ - - public static ShaderInstanceExtended getCloudShader() { - return cloudShader; - } - } -} \ No newline at end of file diff --git a/src/main/java/weather2/client/shaderstest/Cloud.java b/src/main/java/weather2/client/shaderstest/Cloud.java deleted file mode 100644 index 2a439836..00000000 --- a/src/main/java/weather2/client/shaderstest/Cloud.java +++ /dev/null @@ -1,22 +0,0 @@ -package weather2.client.shaderstest; - -import com.mojang.math.Vector3f; - -import java.util.ArrayList; -import java.util.List; - -public class Cloud { - - public Vector3f pos; - public CloudNode cloudNode; - - public Cloud(Vector3f pos) { - this.pos = pos; - cloudNode = new CloudNode(this,null, new Vector3f(0, 0, 0)); - } - - public void tick() { - cloudNode.tick(); - } - -} diff --git a/src/main/java/weather2/client/shaderstest/CloudManager.java b/src/main/java/weather2/client/shaderstest/CloudManager.java deleted file mode 100644 index 58fdac35..00000000 --- a/src/main/java/weather2/client/shaderstest/CloudManager.java +++ /dev/null @@ -1,143 +0,0 @@ -package weather2.client.shaderstest; - -import com.mojang.math.Vector3f; -import com.mojang.serialization.Codec; -import com.mojang.serialization.codecs.RecordCodecBuilder; -import it.unimi.dsi.fastutil.doubles.DoubleArrayList; -import it.unimi.dsi.fastutil.doubles.DoubleList; -import net.minecraft.client.Minecraft; -import net.minecraft.client.player.LocalPlayer; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.levelgen.LegacyRandomSource; -import net.minecraft.world.level.levelgen.RandomSource; -import net.minecraft.world.level.levelgen.synth.NormalNoise; -import net.minecraft.world.level.levelgen.synth.PerlinNoise; -import net.minecraft.world.level.levelgen.synth.SimplexNoise; -import weather2.ClientTickHandler; - -import java.util.*; - -public class CloudManager { - - public List listClouds = new ArrayList<>(); - public List listCloudPieces = new ArrayList<>(); - - private SimplexNoise simplexNoise; - private PerlinNoise perlinNoise; - private NormalNoise normalNoise; - - //private static CloudManager cloudManager = null; - - public HashMap lookupPosToCloudPiece = new HashMap<>(); - - public CloudManager() { - Random random = new Random(5); - simplexNoise = new SimplexNoise(new LegacyRandomSource(random.nextLong())); - - CloudManager.NoiseParameters noiseParameters = new CloudManager.NoiseParameters(-9, 1.0D, 0.0D, 3.0D, 3.0D, 3.0D, 3.0D); - - perlinNoise = PerlinNoise.create(new LegacyRandomSource(random.nextLong()), noiseParameters.firstOctave(), noiseParameters.amplitudes()); - //normalNoise = NormalNoise.create(new LegacyRandomSource(random.nextLong()), noiseParameters.firstOctave(), noiseParameters.amplitudes()); - } - - /*public static CloudManager getInstance() { - if (cloudManager == null) cloudManager = new CloudManager(); - return cloudManager; - }*/ - - public SimplexNoise getSimplexNoise() { - return simplexNoise; - } - - public PerlinNoise getPerlinNoise() { - return perlinNoise; - } - - public NormalNoise getNormalNoise() { - return normalNoise; - } - - public static class NoiseParameters { - private final int firstOctave; - private final DoubleList amplitudes; - public static final Codec CODEC = RecordCodecBuilder.create((p_48510_) -> { - return p_48510_.group(Codec.INT.fieldOf("firstOctave").forGetter(NoiseParameters::firstOctave), Codec.DOUBLE.listOf().fieldOf("amplitudes").forGetter(NoiseParameters::amplitudes)).apply(p_48510_, NoiseParameters::new); - }); - - public NoiseParameters(int p_48506_, List p_48507_) { - this.firstOctave = p_48506_; - this.amplitudes = new DoubleArrayList(p_48507_); - } - - public NoiseParameters(int p_151854_, double... p_151855_) { - this.firstOctave = p_151854_; - this.amplitudes = new DoubleArrayList(p_151855_); - } - - public int firstOctave() { - return this.firstOctave; - } - - public DoubleList amplitudes() { - return this.amplitudes; - } - } - - public CloudPiece getOrCreateCloudPieceAtPosition(int x, int y, int z) { - long hash = BlockPos.asLong(x, y, z); - CloudPiece cloudPiece = lookupPosToCloudPiece.get(hash); - if (cloudPiece == null) { - cloudPiece = new CloudPiece(); - lookupPosToCloudPiece.put(hash, cloudPiece); - listCloudPieces.add(cloudPiece); - } - return cloudPiece; - } - - public void tick() { - - int index = 0; - - /*Iterator> it = ClientTickHandler.weatherManager.cloudManager.getLookupPosToCloudPiece().entrySet().iterator(); - while (it.hasNext()) { - CloudPiece cloudPiece = it.next().getValue();*/ - for (CloudPiece cloudPiece : ClientTickHandler.weatherManager.cloudManager.listCloudPieces) { - float rate = 0;//(float)index / (float) listCloudPieces.size(); - //rate = (float)index / (float)1000; - //rate = 1; - rate = 0.3F + (float)(cloudPiece.posY-60) / (float)150; - - if (index == 25000) { - //System.out.println("wat"); - } - - cloudPiece.prevRotX = cloudPiece.rotX; - //cloudPiece.rotX = 0; - //cloudPiece.rotX = (cloudPiece.rotX + 1F); - //cloudPiece.rotX = (cloudPiece.rotX + 3F * rate); - index++; - cloudPiece.tick(); - } - - Random random = new Random(); - while (listClouds.size() < 10) { - if (Minecraft.getInstance().player != null) { - LocalPlayer player = Minecraft.getInstance().player; - int range = 80; - int x = random.nextInt(range) - random.nextInt(range); - int y = random.nextInt(range) - random.nextInt(range); - int z = random.nextInt(range) - random.nextInt(range); - Cloud cloud = new Cloud(new Vector3f((float)player.getX() + x, (float)player.getY() + y, (float)player.getZ() + z)); - listClouds.add(cloud); - } - } - - for (Cloud cloud : listClouds) { - cloud.tick(); - } - } - - public HashMap getLookupPosToCloudPiece() { - return lookupPosToCloudPiece; - } -} diff --git a/src/main/java/weather2/client/shaderstest/CloudNode.java b/src/main/java/weather2/client/shaderstest/CloudNode.java deleted file mode 100644 index 7748b85f..00000000 --- a/src/main/java/weather2/client/shaderstest/CloudNode.java +++ /dev/null @@ -1,114 +0,0 @@ -package weather2.client.shaderstest; - -import com.mojang.math.Vector3f; -import net.minecraft.client.Minecraft; -import weather2.ClientTickHandler; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -public class CloudNode { - - //null if its the first - public Cloud cloud; - public CloudNode parent; - public List listNodes = new ArrayList<>(); - public CloudPiece cloudPiece; - - //direction and distance this node extends from its parent - public Vector3f direction; - - //extends direction - public float length; - public float lengthMax = 5; - - public int depth = 0; - - //expands from direction - public float size = 0; - public float sizeMax = 5; - - public static int depth_max = 6; - - public CloudNode(Cloud cloud, CloudNode parent, Vector3f direction) { - this.cloud = cloud; - this.parent = parent; - this.direction = direction; - if (parent != null) { - depth = parent.depth + 1; - } - } - - public Vector3f getWorldPosition() { - Vector3f parentPos; - if (parent == null) { - parentPos = cloud.pos; - } else { - parentPos = parent.getWorldPosition(); - } - Vector3f pos = parentPos.copy(); - Vector3f dir = direction.copy(); - dir.mul(length); - pos.add(dir); - //grid align it - pos.set((float)Math.floor(pos.x()), (float)Math.floor(pos.y()), (float)Math.floor(pos.z())); - return pos; - } - - public void tick() { - - sizeMax = 5; - sizeMax = (depth_max - depth) * 2; - lengthMax = 5; - - for (CloudNode node : listNodes) { - node.tick(); - } - - if (depth < depth_max) { - Random rand = new Random(); - //for (int i = 0; i < 3; i++) { - while (listNodes.size() < 3) { - CloudNode node = new CloudNode(cloud, this, new Vector3f(rand.nextFloat() - rand.nextFloat(), rand.nextFloat() - rand.nextFloat(), rand.nextFloat() - rand.nextFloat())); - listNodes.add(node); - } - } - - long time = Minecraft.getInstance().level.getGameTime(); - if (time % 20 == 0) { - if (length < lengthMax) { - length += 0.3F; - } - if (size < sizeMax) { - size += 0.3F; - } - Vector3f worldPos = getWorldPosition(); - //System.out.println(this + ": " + worldPos); - - if (cloudPiece == null) { - cloudPiece = new CloudPiece(); - ClientTickHandler.weatherManager.cloudManager.listCloudPieces.add(cloudPiece); - } else { - cloudPiece.posX = worldPos.x() + 0.5F; - cloudPiece.posY = worldPos.y() + 0.5F; - cloudPiece.posZ = worldPos.z() + 0.5F; - cloudPiece.scale = size; - } - - /*for (int x = (int) -size; x < size; x++) { - for (int z = (int) -size; z < size; z++) { - for (int y = (int) -size; y < size; y++) { - int xx = (int) Math.floor(worldPos.x() + x); - int yy = (int) Math.floor(worldPos.y() + y); - int zz = (int) Math.floor(worldPos.z() + z); - CloudPiece cloudPiece = ClientTickHandler.weatherManager.cloudManager.getOrCreateCloudPieceAtPosition(xx, yy, zz); - cloudPiece.posX = xx; - cloudPiece.posY = yy; - cloudPiece.posZ = zz; - } - } - }*/ - } - } -} diff --git a/src/main/java/weather2/client/shaderstest/CloudPiece.java b/src/main/java/weather2/client/shaderstest/CloudPiece.java deleted file mode 100644 index 7ef4a4da..00000000 --- a/src/main/java/weather2/client/shaderstest/CloudPiece.java +++ /dev/null @@ -1,382 +0,0 @@ -package weather2.client.shaderstest; - -import com.mojang.math.Matrix4f; -import com.mojang.math.Quaternion; -import com.mojang.math.Vector3f; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.culling.Frustum; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.levelgen.synth.NormalNoise; -import net.minecraft.world.level.levelgen.synth.PerlinNoise; -import net.minecraft.world.level.levelgen.synth.SimplexNoise; -import net.minecraft.world.phys.AABB; -import weather2.ClientTickHandler; - -import java.util.Random; - -public class CloudPiece { - - public int index = 0; - public int indexMax = 0; - - public float prevPosX = 0; - public float prevPosY = 0; - public float prevPosZ = 0; - - public float posX = 0; - public float posY = 0; - public float posZ = 0; - - public float rotX = 0; - public float prevRotX = 0; - - public float colorR = 1F; - public float colorG = 1F; - public float colorB = 1F; - public float alpha = 1F; - public float scale = 1F; - - public Random rand = new Random(); - - public AABB aabb = new AABB(0, 0, 0, 1, 1, 1); - - public boolean render = true; - public boolean fadingIn = false; - public boolean fadingOut = false; - public int fadeIn = 0; - public int fadeInMax = 10; - public int fadeOut = 0; - public int fadeOutMax = 10; - - public CloudPiece() { - rand = new Random(5); - } - - public void tick() { - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - - fadeInMax = 15; - fadeOutMax = 15; - - rand = new Random(index); - long time = Minecraft.getInstance().level.getGameTime(); - - int testmodes = 4; - - if (testmodes == 0) { - - //Random rand = new Random(); - int range = 150; - posY = 2 + rand.nextInt(range); - - int yRange = (int) posY; - - int wat = Math.max(1, yRange / 2); - int wat2 = Math.max(1, yRange / 4); - /*posX = rand.nextInt(yRange) - rand.nextInt(yRange); - posZ = rand.nextInt(yRange) - rand.nextInt(yRange);*/ - posX = rand.nextInt(wat) + 15 + yRange / 4 - wat2; - posZ = rand.nextInt(wat) + 15 + yRange / 4 - wat2; - - posX += rand.nextFloat(); - posY += rand.nextFloat(); - posZ += rand.nextFloat(); - - posY += 60; - - colorR = 0.7F; - colorG = 0.7F; - colorB = 0.7F; - } else if (testmodes == 1) { - int yLayers = 1; - int xWide = 200; - int xzCount = indexMax / yLayers; - int indexX = index % xWide; - int indexZ = index / xWide; - posX = indexX; - posZ = indexZ; - posY = 80; - posY -= Math.sin(((time-(indexX / 2)) / 10F) % 360) * 15; - } else if (testmodes == 2) { - int yLayers = 1; - int xWide = 200; - int xzCount = indexMax / yLayers; - int indexX = index % xWide; - int indexZ = index / xWide; - SimplexNoise noise = ClientTickHandler.weatherManager.cloudManager.getSimplexNoise(); - PerlinNoise perlinNoise = ClientTickHandler.weatherManager.cloudManager.getPerlinNoise(); - NormalNoise normalNoise = ClientTickHandler.weatherManager.cloudManager.getNormalNoise(); - double posYAdj = 0;//Math.sin(((time - (indexX / 2)) / 10F)) * 15; - double noiseVal = 0; - double scale = 30 * Math.sin(((time) / 40F) % 360); - scale = 2; - double scaleSimple = 0.1; - //time = 0; - double timeD = time * 0.01; - //noiseVal = noise.getValue(((indexX) * scaleSimple) + 0, ((indexZ) * scaleSimple) + 0); - //noiseVal = noise.getValue(((indexX) * scaleSimple) + timeD, ((indexZ) * scaleSimple) + timeD); - //noiseVal *= noise.getValue(((indexX) * scaleSimple) + timeD * 2, ((indexZ) * scaleSimple) + timeD * 2); - //noiseVal = perlinNoise.getValue(indexX + time, indexZ + time, posYAdj); - noiseVal = perlinNoise.getValue(((indexX) * scale) + time, ((indexZ) * scale) + time, posYAdj); - //noiseVal *= perlinNoise.getValue(((indexX) * scale) + time * 2, ((indexZ) * scale) + time * 2, posYAdj); - //noiseVal = normalNoise.getValue(((indexX) * scale) + time, ((indexZ) * scale) + time, posYAdj); - - posX = 0; - posY = 0; - posZ = 0; - posX = indexX; - posZ = indexZ; - posY = 1000; - //prevPosY = posY; - posY = 160; - //posY -= posYAdj; - alpha = 1F; - float adjval = (float) ((noiseVal + 1F) / 2F); - //alpha = (float) (noiseVal + 0.5F); - //alpha = adjval; - colorR = adjval; - colorG = adjval; - colorB = adjval; - /*colorG = rand.nextFloat(); - colorB = rand.nextFloat();*/ - double noiseThreshold = Math.sin(((time) / 100F)) * 0.5D; - //noiseThreshold = 0.0D; - if (noiseVal > noiseThreshold) { - //alpha = (float) (noiseVal + 1 / 2); - //alpha = (float) noiseVal; - alpha = 0F; - //prevPosY = posY; - //System.out.println(noiseVal); - } - } else if (testmodes == 3) { - // Input: k in N(ABC) - // Output: (x, y, z) in N(A) x N(B) x N(C) - int B = 80; - int C = 80; - - // N(ABC) -> N(A) x N(BC) - int y = index / (B * C); // x in N(A) - int w = index % (B * C); // w in N(BC) - - // N(BC) -> N(B) x N(C) - int x = w / C; // y in N(B) - int z = w % C; // z in N(C) - - posX = x + 0.5F; - posY = y + 0.5F; - posZ = z + 0.5F; - - posY += 25; - - //alpha = 1; - //scale = 1; - - SimplexNoise noise = ClientTickHandler.weatherManager.cloudManager.getSimplexNoise(); - PerlinNoise perlinNoise = ClientTickHandler.weatherManager.cloudManager.getPerlinNoise(); - double scale = 10; - double scale2 = 30; - double scalescale = scale2 / scale; - double scaleSimple = 0.05; - double timeD = time * 0.01; - double timeD2 = time * 0.05; - timeD2 = time * 0.3; - //timeD2 = 0; - //time = 0; - /*double noiseVal = (perlinNoise.getValue(((x) * scale) + timeD2, ((y) * scale) + 0, (z * scale) + 0) * 0.8F); - noiseVal += (perlinNoise.getValue(((x) * scale2) + timeD2*scalescale, ((y) * scale2) + 0, (z * scale2) + 0) * 0.2F);*/ - - double noiseVal = (perlinNoise.getValue(((x) * scale) + timeD2, ((0) * scale) + 0, (z * scale) + timeD2) * 1F); - //noiseVal += (perlinNoise.getValue(((x) * scale2) + timeD2*scalescale, ((y) * scale2) + 0, (z * scale2) + 0) * 0.2F); - - - //noiseVal = noise.getValue(((x) * scaleSimple) + timeD, ((z) * scaleSimple) + timeD); - //noiseVal *= noise.getValue(((y) * scaleSimple) + timeD, ((z) * scaleSimple) + timeD) / 2D; - float adjval = (float) ((noiseVal + 1F) / 1F); - //alpha = (float) (noiseVal + 0.5F); - //alpha = adjval; - - //0 - 1 - double noiseVal2 = (noiseVal + 1D) / 2D; - //noiseVal2 = (noiseVal + 0.5D) / 1D; - - double range = 0.33F; - - /*int number = (int) (255F*255F*255F * noiseVal2); - int r = (number & 0xff0000) >> 16; - int g = (number & 0x00ff00) >> 8; - int b = (number & 0x0000ff); - - colorR = (float)r / 255F; - colorG = (float)g / 255F; - colorB = (float)b / 255F;*/ - - colorR = (float) (noiseVal2 * 1.4F); - colorG = colorR; - colorB = colorR; - - /*if (noiseVal2 < range) { - colorR = (float) (noiseVal2 * 3F); - } else if (noiseVal2 < range*2 && noiseVal2 >= range) { - colorG = (float) (noiseVal2 * 3F); - } else { - colorB = (float) (noiseVal2 * 3F); - }*/ - - double noiseThreshold = Math.sin(((time) / 150F)) * 0.35D; - //noiseThreshold = 0.0D; - double yDist = Math.abs(y - 3); - //for perlin - noiseThreshold += yDist * 0.06F; - //for simple noise - //noiseThreshold += yDist * 0.3F; - //alpha = (float) noiseVal2 - 0.5F; - if (noiseVal < noiseThreshold/* || yDist >= 4*/) { - //alpha = 0F; - if (!fadingOut && alpha >= 0.5F) { - fadingOut = true; - fadeOut = 0; - } - } else { - if (!fadingIn && alpha <= 0.5F) { - fadingIn = true; - fadeIn = 0; - } - } - - /*fadingIn = false; - fadingOut = false; - alpha = 1; - scale = 1;*/ - } else if (testmodes == 4) { - alpha = 1F; - //scale = 1F; - } - - if (fadingIn) { - alpha = (float)fadeIn / (float)fadeInMax; - scale = (float)fadeIn / (float)fadeInMax; - rotX = ((float)fadeIn / (float)fadeInMax) * 90; - fadeIn++; - if (fadeIn > fadeInMax) { - fadingIn = false; - } - } else if (fadingOut) { - alpha = 1F - (float)fadeOut / (float)fadeOutMax; - scale = 1F - (float)fadeOut / (float)fadeOutMax; - rotX = (1F - (float)fadeOut / (float)fadeInMax) * 90; - fadeOut++; - if (fadeOut > fadeOutMax) { - fadingOut = false; - } - } - - /*alpha = 1; - scale = 1; - rotX = 0;*/ - - /*colorR = rand.nextFloat(); - colorG = rand.nextFloat(); - colorB = rand.nextFloat();*/ - - float size = 1.5F; - aabb = new AABB(posX, posY, posZ, posX, posY, posZ); - aabb = aabb.inflate(size); - } - - public void renderParticleForShader(InstancedMeshParticle mesh, Frustum cullingFrustum, Matrix4f modelViewMatrix, Entity entityIn, - float partialTicks, double viewEntityX, double viewEntityY, double viewEntityZ) { - - if (mesh.curBufferPos >= mesh.numInstances) return; - - int range = 50; - - float posX = (float) ((this.prevPosX + (this.posX - this.prevPosX) * (double) partialTicks) - 0); - float posY = (float) ((this.prevPosY + (this.posY - this.prevPosY) * (double) partialTicks) - 0); - float posZ = (float) ((this.prevPosZ + (this.posZ - this.prevPosZ) * (double) partialTicks) - 0); - - /*double d0 = viewEntityX - posX; - double d1 = viewEntityY - posY; - double d2 = viewEntityZ - posZ; - double dist = d0 * d0 + d1 * d1 + d2 * d2; - - if (dist > 300 * 300) return; - - if (!cullingFrustum.isVisible(aabb)) return;*/ - - //index = mesh.curBufferPos; - - float rotXSmooth = (float) (this.prevRotX + (this.rotX - this.prevRotX) * (double) partialTicks); - - Quaternion rotation = new Quaternion(0, 0, 0, 1); - //Quaternion rotation2 = new Quaternion(0, 0, 0, 1); - - rotation.mul(Vector3f.YP.rotationDegrees(rotXSmooth)); - /*rotation2.mul(Vector3f.YP.rotationDegrees(rotXSmooth)); - rotation2.mul(Vector3f.XP.rotationDegrees(rotXSmooth)); - rotation2.mul(Vector3f.ZP.rotationDegrees(rotXSmooth));*/ - - Vector3f scaleF = new Vector3f(scale, scale, scale); - - Matrix4f matrix4f = new Matrix4f(); - matrix4f.setIdentity(); - matrix4f.multiply(scale); - matrix4f.multiplyWithTranslation((float) -viewEntityX, (float) -viewEntityY, (float) -viewEntityZ); - //matrix4f.multiply(rotation); - matrix4f.multiplyWithTranslation(posX, posY, posZ); - matrix4f.multiply(rotation); - //matrix4f.multiply(rotation2); - //matrix4f.multiply(5F); - //matrix4f.multiply(rotation2); - //matrix4f.multiplyWithTranslation((float) -viewEntityX, (float) -viewEntityY + 80, (float) -viewEntityZ); - //modelViewMatrix.multiplyWithTranslation(posX, posY - 10, posZ); - //modelViewMatrix.multiply(rotation); - //Matrix4fe modelMatrix = new Matrix4fe(modelViewMatrix); - Matrix4fe modelMatrix = new Matrix4fe(matrix4f); - - //upload to buffer - modelMatrix.get(mesh.INSTANCE_SIZE_FLOATS * (mesh.curBufferPos), mesh.instanceDataBuffer); - - //brightness - float brightness; - //brightness = CoroUtilBlockLightCache.getBrightnessCached(world, (float)this.posX, (float)this.posY, (float)this.posZ); - //brightness = brightnessCache; - - brightness = rand.nextInt(15728640); - brightness = 15728640; - //brightness = -1F; - //brightness = CoroUtilBlockLightCache.brightnessPlayer; - mesh.instanceDataBuffer.put(mesh.INSTANCE_SIZE_FLOATS * (mesh.curBufferPos) + mesh.MATRIX_SIZE_FLOATS, 1); - - int rgbaIndex = 0; - mesh.instanceDataBuffer.put(mesh.INSTANCE_SIZE_FLOATS * (mesh.curBufferPos) - + mesh.MATRIX_SIZE_FLOATS + 1 + (rgbaIndex++), this.getRedColorF()); - mesh.instanceDataBuffer.put(mesh.INSTANCE_SIZE_FLOATS * (mesh.curBufferPos) - + mesh.MATRIX_SIZE_FLOATS + 1 + (rgbaIndex++), this.getGreenColorF()); - mesh.instanceDataBuffer.put(mesh.INSTANCE_SIZE_FLOATS * (mesh.curBufferPos) - + mesh.MATRIX_SIZE_FLOATS + 1 + (rgbaIndex++), this.getBlueColorF()); - mesh.instanceDataBuffer.put(mesh.INSTANCE_SIZE_FLOATS * (mesh.curBufferPos) - + mesh.MATRIX_SIZE_FLOATS + 1 + (rgbaIndex++), this.getAlphaF()); - - mesh.curBufferPos++; - - } - - private float getAlphaF() { - return 1; - } - - private float getBlueColorF() { - return colorB; - } - - private float getGreenColorF() { - return colorG; - } - - private float getRedColorF() { - return colorR; - } - -} diff --git a/src/main/java/weather2/client/shaderstest/InstancedMeshParticle.java b/src/main/java/weather2/client/shaderstest/InstancedMeshParticle.java deleted file mode 100644 index ebcd61fa..00000000 --- a/src/main/java/weather2/client/shaderstest/InstancedMeshParticle.java +++ /dev/null @@ -1,191 +0,0 @@ -package weather2.client.shaderstest; - -import com.mojang.blaze3d.platform.GlStateManager; -import org.lwjgl.BufferUtils; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL15; -import org.lwjgl.opengl.GL20; -import org.lwjgl.opengl.GL33; - -import java.nio.FloatBuffer; - -public class InstancedMeshParticle extends Mesh { - - public static final int FLOAT_SIZE_BYTES = 4; - - public static final int VECTOR4F_SIZE_BYTES = 4 * FLOAT_SIZE_BYTES; - - public static final int MATRIX_SIZE_FLOATS = 4 * 4; - - public static final int MATRIX_SIZE_BYTES = MATRIX_SIZE_FLOATS * FLOAT_SIZE_BYTES; - - public static final int INSTANCE_SIZE_BYTES = MATRIX_SIZE_BYTES + FLOAT_SIZE_BYTES * (1 + 4)/* * 2 + FLOAT_SIZE_BYTES * 2*/; - - public static final int INSTANCE_SIZE_FLOATS = MATRIX_SIZE_FLOATS + 1 + 4;// * 2 + 2; - - public static final int INSTANCE_SIZE_BYTES_TEST = FLOAT_SIZE_BYTES * 4/* * 2 + FLOAT_SIZE_BYTES * 2*/; - - public static final int INSTANCE_SIZE_FLOATS_TEST = 4; - - public final int numInstances; - - public final int instanceDataVBO; - //public final int instanceDataVBOTest; - - public FloatBuffer instanceDataBuffer; - //public FloatBuffer instanceDataBufferTest; - - public int curBufferPos = 0; - - /** - * TODO: despite the mesh only being a size of 2 vbos instead of 5, lowering this to 2 breaks something somehow (no rendering) - * need to figure out where to fix so i can optimize memory usage - * not even sure if the memory is unoptimized, theres just gaps in the memory used probably - * - * fixed, didnt account for attrib location values in shader program - * - * now 3 for normal added - */ - public static int vboSizeMesh = 3; - - public InstancedMeshParticle(float[] positions, float[] textCoords, float[] normals, int[] indices, int numInstances) { - super(positions, textCoords, normals, indices); - - this.numInstances = numInstances; - - GlStateManager._glBindVertexArray(vaoId); - - // Model Matrix - instanceDataVBO = GL15.glGenBuffers(); - vboIdList.add(instanceDataVBO); - instanceDataBuffer = BufferUtils.createFloatBuffer(numInstances * INSTANCE_SIZE_FLOATS);//MemoryUtil.memAllocFloat(numInstances * INSTANCE_SIZE_FLOATS); - GlStateManager._glBindBuffer(GL15.GL_ARRAY_BUFFER, instanceDataVBO); - int start = vboSizeMesh; - int strideStart = 0; - for (int i = 0; i < 4; i++) { - GL20.glVertexAttribPointer(start, 4, GL11.GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); - GL33.glVertexAttribDivisor(start, 1); - start++; - strideStart += VECTOR4F_SIZE_BYTES; - } - - //TODO: might become UV lightmap coord in future - //brightness - GL20.glVertexAttribPointer(start, 1, GL11.GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); - GL33.glVertexAttribDivisor(start, 1); - start++; - strideStart += FLOAT_SIZE_BYTES; - - /** - * TODO: rbg and alpha for colorization - * storm darkening uses lower rgb values to darken - * everything uses alpha for fading in and out - * - */ - - //rgba - GL20.glVertexAttribPointer(start, 4, GL11.GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); - GL33.glVertexAttribDivisor(start, 1); - start++; - strideStart += VECTOR4F_SIZE_BYTES; - - // Light view matrix - /*for (int i = 0; i < 4; i++) { - glVertexAttribPointer(start, 4, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); - glVertexAttribDivisor(start, 1); - start++; - strideStart += VECTOR4F_SIZE_BYTES; - }*/ - - // Texture offsets - /*glVertexAttribPointer(start, 2, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); - glVertexAttribDivisor(start, 1);*/ - - //test color to its own vbo - /*instanceDataBufferTest = BufferUtils.createFloatBuffer(numInstances * INSTANCE_SIZE_FLOATS_TEST); - - FloatBuffer colorBuffer = null; - instanceDataVBOTest = OpenGlHelper.glGenBuffers(); - vboIdList.add(instanceDataVBOTest); - colorBuffer = BufferUtils.createFloatBuffer(4); - float[] floats = new float[4]; - floats[0] = 1F; - floats[1] = 1F; - floats[2] = 1F; - floats[3] = 1F; - - colorBuffer.put(floats).flip(); - OpenGlHelper.glBindBuffer(GL15.GL_ARRAY_BUFFER, instanceDataVBOTest); - ShaderManager.glBufferData(GL15.GL_ARRAY_BUFFER, colorBuffer, GL15.GL_DYNAMIC_DRAW); - GL20.glVertexAttribPointer(start, 4, GL11.GL_FLOAT, false, INSTANCE_SIZE_BYTES_TEST, 0); - ShaderManager.glVertexAttribDivisor(start, 1); - start++;*/ - - GlStateManager._glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); - GlStateManager._glBindVertexArray(0); - } - - @Override - public void cleanup() { - super.cleanup(); - if (this.instanceDataBuffer != null) { - //MemoryUtil.memFree(this.instanceDataBuffer); - this.instanceDataBuffer = null; - } - - /*if (this.instanceDataBufferTest != null) { - //MemoryUtil.memFree(this.instanceDataBuffer); - this.instanceDataBufferTest = null; - }*/ - } - - @Override - public void initRender() { - super.initRender(); - } - - @Override - public void endRender() { - - super.endRender(); - } - - public void initRenderVBO1() { - int start = vboSizeMesh; - //model matrix + brightness + rgba - int numElements = 4 + 1 + 1; - for (int i = 0; i < numElements; i++) { - GL20.glEnableVertexAttribArray(start + i); - } - } - - public void endRenderVBO1() { - - int start = vboSizeMesh; - //model matrix + brightness + rgba - int numElements = 4 + 1 + 1; - for (int i = 0; i < numElements; i++) { - GL20.glDisableVertexAttribArray(start + i); - } - } - - /*public void initRenderVBO2() { - int start = vboSizeMesh; - //model matrix + brightness - int numElementsVBO1 = 5; - int numElementsVBO2 = 1; - for (int i = 0; i < numElementsVBO2; i++) { - GL20.glEnableVertexAttribArray(start + numElementsVBO1 + i); - } - } - - public void endRenderVBO2() { - int start = vboSizeMesh; - //model matrix + brightness - int numElementsVBO1 = 5; - int numElementsVBO2 = 1; - for (int i = 0; i < numElementsVBO2; i++) { - GL20.glDisableVertexAttribArray(start + numElementsVBO1 + i); - } - }*/ -} diff --git a/src/main/java/weather2/client/shaderstest/Matrix4fe.java b/src/main/java/weather2/client/shaderstest/Matrix4fe.java deleted file mode 100644 index 099ec772..00000000 --- a/src/main/java/weather2/client/shaderstest/Matrix4fe.java +++ /dev/null @@ -1,692 +0,0 @@ -package weather2.client.shaderstest; - -import com.mojang.math.Matrix4f; -import com.mojang.math.Quaternion; -import com.mojang.math.Vector3f; - -import java.nio.FloatBuffer; - -public final class Matrix4fe { - private static final int ORDER = 4; - protected float m00; - protected float m01; - protected float m02; - protected float m03; - protected float m10; - protected float m11; - protected float m12; - protected float m13; - protected float m20; - protected float m21; - protected float m22; - protected float m23; - protected float m30; - protected float m31; - protected float m32; - protected float m33; - - public Matrix4fe() { - } - - public Matrix4fe(Matrix4fe p_27621_) { - this.m00 = p_27621_.m00; - this.m01 = p_27621_.m01; - this.m02 = p_27621_.m02; - this.m03 = p_27621_.m03; - this.m10 = p_27621_.m10; - this.m11 = p_27621_.m11; - this.m12 = p_27621_.m12; - this.m13 = p_27621_.m13; - this.m20 = p_27621_.m20; - this.m21 = p_27621_.m21; - this.m22 = p_27621_.m22; - this.m23 = p_27621_.m23; - this.m30 = p_27621_.m30; - this.m31 = p_27621_.m31; - this.m32 = p_27621_.m32; - this.m33 = p_27621_.m33; - } - - public Matrix4fe(Matrix4f p_27621_) { - this.m00 = p_27621_.m00; - this.m01 = p_27621_.m01; - this.m02 = p_27621_.m02; - this.m03 = p_27621_.m03; - this.m10 = p_27621_.m10; - this.m11 = p_27621_.m11; - this.m12 = p_27621_.m12; - this.m13 = p_27621_.m13; - this.m20 = p_27621_.m20; - this.m21 = p_27621_.m21; - this.m22 = p_27621_.m22; - this.m23 = p_27621_.m23; - this.m30 = p_27621_.m30; - this.m31 = p_27621_.m31; - this.m32 = p_27621_.m32; - this.m33 = p_27621_.m33; - } - - public Matrix4fe(Quaternion p_27623_) { - float f = p_27623_.i(); - float f1 = p_27623_.j(); - float f2 = p_27623_.k(); - float f3 = p_27623_.r(); - float f4 = 2.0F * f * f; - float f5 = 2.0F * f1 * f1; - float f6 = 2.0F * f2 * f2; - this.m00 = 1.0F - f5 - f6; - this.m11 = 1.0F - f6 - f4; - this.m22 = 1.0F - f4 - f5; - this.m33 = 1.0F; - float f7 = f * f1; - float f8 = f1 * f2; - float f9 = f2 * f; - float f10 = f * f3; - float f11 = f1 * f3; - float f12 = f2 * f3; - this.m10 = 2.0F * (f7 + f12); - this.m01 = 2.0F * (f7 - f12); - this.m20 = 2.0F * (f9 - f11); - this.m02 = 2.0F * (f9 + f11); - this.m21 = 2.0F * (f8 + f10); - this.m12 = 2.0F * (f8 - f10); - } - - public boolean isInteger() { - Matrix4fe matrix4f = new Matrix4fe(); - matrix4f.m30 = 1.0F; - matrix4f.m31 = 1.0F; - matrix4f.m32 = 1.0F; - matrix4f.m33 = 0.0F; - Matrix4fe matrix4f1 = this.copy(); - matrix4f1.multiply(matrix4f); - return isInteger(matrix4f1.m00 / matrix4f1.m03) && isInteger(matrix4f1.m10 / matrix4f1.m13) && isInteger(matrix4f1.m20 / matrix4f1.m23) && isInteger(matrix4f1.m01 / matrix4f1.m03) && isInteger(matrix4f1.m11 / matrix4f1.m13) && isInteger(matrix4f1.m21 / matrix4f1.m23) && isInteger(matrix4f1.m02 / matrix4f1.m03) && isInteger(matrix4f1.m12 / matrix4f1.m13) && isInteger(matrix4f1.m22 / matrix4f1.m23); - } - - private static boolean isInteger(float p_162218_) { - return (double)Math.abs(p_162218_ - (float)Math.round(p_162218_)) <= 1.0E-5D; - } - - public boolean equals(Object p_27661_) { - if (this == p_27661_) { - return true; - } else if (p_27661_ != null && this.getClass() == p_27661_.getClass()) { - Matrix4fe matrix4f = (Matrix4fe)p_27661_; - return Float.compare(matrix4f.m00, this.m00) == 0 && Float.compare(matrix4f.m01, this.m01) == 0 && Float.compare(matrix4f.m02, this.m02) == 0 && Float.compare(matrix4f.m03, this.m03) == 0 && Float.compare(matrix4f.m10, this.m10) == 0 && Float.compare(matrix4f.m11, this.m11) == 0 && Float.compare(matrix4f.m12, this.m12) == 0 && Float.compare(matrix4f.m13, this.m13) == 0 && Float.compare(matrix4f.m20, this.m20) == 0 && Float.compare(matrix4f.m21, this.m21) == 0 && Float.compare(matrix4f.m22, this.m22) == 0 && Float.compare(matrix4f.m23, this.m23) == 0 && Float.compare(matrix4f.m30, this.m30) == 0 && Float.compare(matrix4f.m31, this.m31) == 0 && Float.compare(matrix4f.m32, this.m32) == 0 && Float.compare(matrix4f.m33, this.m33) == 0; - } else { - return false; - } - } - - public int hashCode() { - int i = this.m00 != 0.0F ? Float.floatToIntBits(this.m00) : 0; - i = 31 * i + (this.m01 != 0.0F ? Float.floatToIntBits(this.m01) : 0); - i = 31 * i + (this.m02 != 0.0F ? Float.floatToIntBits(this.m02) : 0); - i = 31 * i + (this.m03 != 0.0F ? Float.floatToIntBits(this.m03) : 0); - i = 31 * i + (this.m10 != 0.0F ? Float.floatToIntBits(this.m10) : 0); - i = 31 * i + (this.m11 != 0.0F ? Float.floatToIntBits(this.m11) : 0); - i = 31 * i + (this.m12 != 0.0F ? Float.floatToIntBits(this.m12) : 0); - i = 31 * i + (this.m13 != 0.0F ? Float.floatToIntBits(this.m13) : 0); - i = 31 * i + (this.m20 != 0.0F ? Float.floatToIntBits(this.m20) : 0); - i = 31 * i + (this.m21 != 0.0F ? Float.floatToIntBits(this.m21) : 0); - i = 31 * i + (this.m22 != 0.0F ? Float.floatToIntBits(this.m22) : 0); - i = 31 * i + (this.m23 != 0.0F ? Float.floatToIntBits(this.m23) : 0); - i = 31 * i + (this.m30 != 0.0F ? Float.floatToIntBits(this.m30) : 0); - i = 31 * i + (this.m31 != 0.0F ? Float.floatToIntBits(this.m31) : 0); - i = 31 * i + (this.m32 != 0.0F ? Float.floatToIntBits(this.m32) : 0); - return 31 * i + (this.m33 != 0.0F ? Float.floatToIntBits(this.m33) : 0); - } - - private static int bufferIndex(int p_27642_, int p_27643_) { - return p_27643_ * 4 + p_27642_; - } - - public void load(FloatBuffer p_162213_) { - this.m00 = p_162213_.get(bufferIndex(0, 0)); - this.m01 = p_162213_.get(bufferIndex(0, 1)); - this.m02 = p_162213_.get(bufferIndex(0, 2)); - this.m03 = p_162213_.get(bufferIndex(0, 3)); - this.m10 = p_162213_.get(bufferIndex(1, 0)); - this.m11 = p_162213_.get(bufferIndex(1, 1)); - this.m12 = p_162213_.get(bufferIndex(1, 2)); - this.m13 = p_162213_.get(bufferIndex(1, 3)); - this.m20 = p_162213_.get(bufferIndex(2, 0)); - this.m21 = p_162213_.get(bufferIndex(2, 1)); - this.m22 = p_162213_.get(bufferIndex(2, 2)); - this.m23 = p_162213_.get(bufferIndex(2, 3)); - this.m30 = p_162213_.get(bufferIndex(3, 0)); - this.m31 = p_162213_.get(bufferIndex(3, 1)); - this.m32 = p_162213_.get(bufferIndex(3, 2)); - this.m33 = p_162213_.get(bufferIndex(3, 3)); - } - - public void loadTransposed(FloatBuffer p_162220_) { - this.m00 = p_162220_.get(bufferIndex(0, 0)); - this.m01 = p_162220_.get(bufferIndex(1, 0)); - this.m02 = p_162220_.get(bufferIndex(2, 0)); - this.m03 = p_162220_.get(bufferIndex(3, 0)); - this.m10 = p_162220_.get(bufferIndex(0, 1)); - this.m11 = p_162220_.get(bufferIndex(1, 1)); - this.m12 = p_162220_.get(bufferIndex(2, 1)); - this.m13 = p_162220_.get(bufferIndex(3, 1)); - this.m20 = p_162220_.get(bufferIndex(0, 2)); - this.m21 = p_162220_.get(bufferIndex(1, 2)); - this.m22 = p_162220_.get(bufferIndex(2, 2)); - this.m23 = p_162220_.get(bufferIndex(3, 2)); - this.m30 = p_162220_.get(bufferIndex(0, 3)); - this.m31 = p_162220_.get(bufferIndex(1, 3)); - this.m32 = p_162220_.get(bufferIndex(2, 3)); - this.m33 = p_162220_.get(bufferIndex(3, 3)); - } - - public void load(FloatBuffer p_162215_, boolean p_162216_) { - if (p_162216_) { - this.loadTransposed(p_162215_); - } else { - this.load(p_162215_); - } - - } - - public void load(Matrix4fe p_162211_) { - this.m00 = p_162211_.m00; - this.m01 = p_162211_.m01; - this.m02 = p_162211_.m02; - this.m03 = p_162211_.m03; - this.m10 = p_162211_.m10; - this.m11 = p_162211_.m11; - this.m12 = p_162211_.m12; - this.m13 = p_162211_.m13; - this.m20 = p_162211_.m20; - this.m21 = p_162211_.m21; - this.m22 = p_162211_.m22; - this.m23 = p_162211_.m23; - this.m30 = p_162211_.m30; - this.m31 = p_162211_.m31; - this.m32 = p_162211_.m32; - this.m33 = p_162211_.m33; - } - - public String toString() { - StringBuilder stringbuilder = new StringBuilder(); - stringbuilder.append("Matrix4f:\n"); - stringbuilder.append(this.m00); - stringbuilder.append(" "); - stringbuilder.append(this.m01); - stringbuilder.append(" "); - stringbuilder.append(this.m02); - stringbuilder.append(" "); - stringbuilder.append(this.m03); - stringbuilder.append("\n"); - stringbuilder.append(this.m10); - stringbuilder.append(" "); - stringbuilder.append(this.m11); - stringbuilder.append(" "); - stringbuilder.append(this.m12); - stringbuilder.append(" "); - stringbuilder.append(this.m13); - stringbuilder.append("\n"); - stringbuilder.append(this.m20); - stringbuilder.append(" "); - stringbuilder.append(this.m21); - stringbuilder.append(" "); - stringbuilder.append(this.m22); - stringbuilder.append(" "); - stringbuilder.append(this.m23); - stringbuilder.append("\n"); - stringbuilder.append(this.m30); - stringbuilder.append(" "); - stringbuilder.append(this.m31); - stringbuilder.append(" "); - stringbuilder.append(this.m32); - stringbuilder.append(" "); - stringbuilder.append(this.m33); - stringbuilder.append("\n"); - return stringbuilder.toString(); - } - - public void store(FloatBuffer dest) { - dest.put(bufferIndex(0, 0), this.m00); - dest.put(bufferIndex(0, 1), this.m01); - dest.put(bufferIndex(0, 2), this.m02); - dest.put(bufferIndex(0, 3), this.m03); - dest.put(bufferIndex(1, 0), this.m10); - dest.put(bufferIndex(1, 1), this.m11); - dest.put(bufferIndex(1, 2), this.m12); - dest.put(bufferIndex(1, 3), this.m13); - dest.put(bufferIndex(2, 0), this.m20); - dest.put(bufferIndex(2, 1), this.m21); - dest.put(bufferIndex(2, 2), this.m22); - dest.put(bufferIndex(2, 3), this.m23); - dest.put(bufferIndex(3, 0), this.m30); - dest.put(bufferIndex(3, 1), this.m31); - dest.put(bufferIndex(3, 2), this.m32); - dest.put(bufferIndex(3, 3), this.m33); - } - - public void storeTransposed(FloatBuffer p_162230_) { - p_162230_.put(bufferIndex(0, 0), this.m00); - p_162230_.put(bufferIndex(1, 0), this.m01); - p_162230_.put(bufferIndex(2, 0), this.m02); - p_162230_.put(bufferIndex(3, 0), this.m03); - p_162230_.put(bufferIndex(0, 1), this.m10); - p_162230_.put(bufferIndex(1, 1), this.m11); - p_162230_.put(bufferIndex(2, 1), this.m12); - p_162230_.put(bufferIndex(3, 1), this.m13); - p_162230_.put(bufferIndex(0, 2), this.m20); - p_162230_.put(bufferIndex(1, 2), this.m21); - p_162230_.put(bufferIndex(2, 2), this.m22); - p_162230_.put(bufferIndex(3, 2), this.m23); - p_162230_.put(bufferIndex(0, 3), this.m30); - p_162230_.put(bufferIndex(1, 3), this.m31); - p_162230_.put(bufferIndex(2, 3), this.m32); - p_162230_.put(bufferIndex(3, 3), this.m33); - } - - public void store(FloatBuffer p_162222_, boolean p_162223_) { - if (p_162223_) { - this.storeTransposed(p_162222_); - } else { - this.store(p_162222_); - } - - } - - public void setIdentity() { - this.m00 = 1.0F; - this.m01 = 0.0F; - this.m02 = 0.0F; - this.m03 = 0.0F; - this.m10 = 0.0F; - this.m11 = 1.0F; - this.m12 = 0.0F; - this.m13 = 0.0F; - this.m20 = 0.0F; - this.m21 = 0.0F; - this.m22 = 1.0F; - this.m23 = 0.0F; - this.m30 = 0.0F; - this.m31 = 0.0F; - this.m32 = 0.0F; - this.m33 = 1.0F; - } - - public float adjugateAndDet() { - float f = this.m00 * this.m11 - this.m01 * this.m10; - float f1 = this.m00 * this.m12 - this.m02 * this.m10; - float f2 = this.m00 * this.m13 - this.m03 * this.m10; - float f3 = this.m01 * this.m12 - this.m02 * this.m11; - float f4 = this.m01 * this.m13 - this.m03 * this.m11; - float f5 = this.m02 * this.m13 - this.m03 * this.m12; - float f6 = this.m20 * this.m31 - this.m21 * this.m30; - float f7 = this.m20 * this.m32 - this.m22 * this.m30; - float f8 = this.m20 * this.m33 - this.m23 * this.m30; - float f9 = this.m21 * this.m32 - this.m22 * this.m31; - float f10 = this.m21 * this.m33 - this.m23 * this.m31; - float f11 = this.m22 * this.m33 - this.m23 * this.m32; - float f12 = this.m11 * f11 - this.m12 * f10 + this.m13 * f9; - float f13 = -this.m10 * f11 + this.m12 * f8 - this.m13 * f7; - float f14 = this.m10 * f10 - this.m11 * f8 + this.m13 * f6; - float f15 = -this.m10 * f9 + this.m11 * f7 - this.m12 * f6; - float f16 = -this.m01 * f11 + this.m02 * f10 - this.m03 * f9; - float f17 = this.m00 * f11 - this.m02 * f8 + this.m03 * f7; - float f18 = -this.m00 * f10 + this.m01 * f8 - this.m03 * f6; - float f19 = this.m00 * f9 - this.m01 * f7 + this.m02 * f6; - float f20 = this.m31 * f5 - this.m32 * f4 + this.m33 * f3; - float f21 = -this.m30 * f5 + this.m32 * f2 - this.m33 * f1; - float f22 = this.m30 * f4 - this.m31 * f2 + this.m33 * f; - float f23 = -this.m30 * f3 + this.m31 * f1 - this.m32 * f; - float f24 = -this.m21 * f5 + this.m22 * f4 - this.m23 * f3; - float f25 = this.m20 * f5 - this.m22 * f2 + this.m23 * f1; - float f26 = -this.m20 * f4 + this.m21 * f2 - this.m23 * f; - float f27 = this.m20 * f3 - this.m21 * f1 + this.m22 * f; - this.m00 = f12; - this.m10 = f13; - this.m20 = f14; - this.m30 = f15; - this.m01 = f16; - this.m11 = f17; - this.m21 = f18; - this.m31 = f19; - this.m02 = f20; - this.m12 = f21; - this.m22 = f22; - this.m32 = f23; - this.m03 = f24; - this.m13 = f25; - this.m23 = f26; - this.m33 = f27; - return f * f11 - f1 * f10 + f2 * f9 + f3 * f8 - f4 * f7 + f5 * f6; - } - - public float determinant() { - float f = this.m00 * this.m11 - this.m01 * this.m10; - float f1 = this.m00 * this.m12 - this.m02 * this.m10; - float f2 = this.m00 * this.m13 - this.m03 * this.m10; - float f3 = this.m01 * this.m12 - this.m02 * this.m11; - float f4 = this.m01 * this.m13 - this.m03 * this.m11; - float f5 = this.m02 * this.m13 - this.m03 * this.m12; - float f6 = this.m20 * this.m31 - this.m21 * this.m30; - float f7 = this.m20 * this.m32 - this.m22 * this.m30; - float f8 = this.m20 * this.m33 - this.m23 * this.m30; - float f9 = this.m21 * this.m32 - this.m22 * this.m31; - float f10 = this.m21 * this.m33 - this.m23 * this.m31; - float f11 = this.m22 * this.m33 - this.m23 * this.m32; - return f * f11 - f1 * f10 + f2 * f9 + f3 * f8 - f4 * f7 + f5 * f6; - } - - public void transpose() { - float f = this.m10; - this.m10 = this.m01; - this.m01 = f; - f = this.m20; - this.m20 = this.m02; - this.m02 = f; - f = this.m21; - this.m21 = this.m12; - this.m12 = f; - f = this.m30; - this.m30 = this.m03; - this.m03 = f; - f = this.m31; - this.m31 = this.m13; - this.m13 = f; - f = this.m32; - this.m32 = this.m23; - this.m23 = f; - } - - public boolean invert() { - float f = this.adjugateAndDet(); - if (Math.abs(f) > 1.0E-6F) { - this.multiply(f); - return true; - } else { - return false; - } - } - - public void multiply(Matrix4fe p_27645_) { - float f = this.m00 * p_27645_.m00 + this.m01 * p_27645_.m10 + this.m02 * p_27645_.m20 + this.m03 * p_27645_.m30; - float f1 = this.m00 * p_27645_.m01 + this.m01 * p_27645_.m11 + this.m02 * p_27645_.m21 + this.m03 * p_27645_.m31; - float f2 = this.m00 * p_27645_.m02 + this.m01 * p_27645_.m12 + this.m02 * p_27645_.m22 + this.m03 * p_27645_.m32; - float f3 = this.m00 * p_27645_.m03 + this.m01 * p_27645_.m13 + this.m02 * p_27645_.m23 + this.m03 * p_27645_.m33; - float f4 = this.m10 * p_27645_.m00 + this.m11 * p_27645_.m10 + this.m12 * p_27645_.m20 + this.m13 * p_27645_.m30; - float f5 = this.m10 * p_27645_.m01 + this.m11 * p_27645_.m11 + this.m12 * p_27645_.m21 + this.m13 * p_27645_.m31; - float f6 = this.m10 * p_27645_.m02 + this.m11 * p_27645_.m12 + this.m12 * p_27645_.m22 + this.m13 * p_27645_.m32; - float f7 = this.m10 * p_27645_.m03 + this.m11 * p_27645_.m13 + this.m12 * p_27645_.m23 + this.m13 * p_27645_.m33; - float f8 = this.m20 * p_27645_.m00 + this.m21 * p_27645_.m10 + this.m22 * p_27645_.m20 + this.m23 * p_27645_.m30; - float f9 = this.m20 * p_27645_.m01 + this.m21 * p_27645_.m11 + this.m22 * p_27645_.m21 + this.m23 * p_27645_.m31; - float f10 = this.m20 * p_27645_.m02 + this.m21 * p_27645_.m12 + this.m22 * p_27645_.m22 + this.m23 * p_27645_.m32; - float f11 = this.m20 * p_27645_.m03 + this.m21 * p_27645_.m13 + this.m22 * p_27645_.m23 + this.m23 * p_27645_.m33; - float f12 = this.m30 * p_27645_.m00 + this.m31 * p_27645_.m10 + this.m32 * p_27645_.m20 + this.m33 * p_27645_.m30; - float f13 = this.m30 * p_27645_.m01 + this.m31 * p_27645_.m11 + this.m32 * p_27645_.m21 + this.m33 * p_27645_.m31; - float f14 = this.m30 * p_27645_.m02 + this.m31 * p_27645_.m12 + this.m32 * p_27645_.m22 + this.m33 * p_27645_.m32; - float f15 = this.m30 * p_27645_.m03 + this.m31 * p_27645_.m13 + this.m32 * p_27645_.m23 + this.m33 * p_27645_.m33; - this.m00 = f; - this.m01 = f1; - this.m02 = f2; - this.m03 = f3; - this.m10 = f4; - this.m11 = f5; - this.m12 = f6; - this.m13 = f7; - this.m20 = f8; - this.m21 = f9; - this.m22 = f10; - this.m23 = f11; - this.m30 = f12; - this.m31 = f13; - this.m32 = f14; - this.m33 = f15; - } - - public void multiply(Quaternion p_27647_) { - this.multiply(new Matrix4fe(p_27647_)); - } - - public void multiply(float p_27631_) { - this.m00 *= p_27631_; - this.m01 *= p_27631_; - this.m02 *= p_27631_; - this.m03 *= p_27631_; - this.m10 *= p_27631_; - this.m11 *= p_27631_; - this.m12 *= p_27631_; - this.m13 *= p_27631_; - this.m20 *= p_27631_; - this.m21 *= p_27631_; - this.m22 *= p_27631_; - this.m23 *= p_27631_; - this.m30 *= p_27631_; - this.m31 *= p_27631_; - this.m32 *= p_27631_; - this.m33 *= p_27631_; - } - - public void add(Matrix4fe p_162225_) { - this.m00 += p_162225_.m00; - this.m01 += p_162225_.m01; - this.m02 += p_162225_.m02; - this.m03 += p_162225_.m03; - this.m10 += p_162225_.m10; - this.m11 += p_162225_.m11; - this.m12 += p_162225_.m12; - this.m13 += p_162225_.m13; - this.m20 += p_162225_.m20; - this.m21 += p_162225_.m21; - this.m22 += p_162225_.m22; - this.m23 += p_162225_.m23; - this.m30 += p_162225_.m30; - this.m31 += p_162225_.m31; - this.m32 += p_162225_.m32; - this.m33 += p_162225_.m33; - } - - public void subtract(Matrix4fe p_162228_) { - this.m00 -= p_162228_.m00; - this.m01 -= p_162228_.m01; - this.m02 -= p_162228_.m02; - this.m03 -= p_162228_.m03; - this.m10 -= p_162228_.m10; - this.m11 -= p_162228_.m11; - this.m12 -= p_162228_.m12; - this.m13 -= p_162228_.m13; - this.m20 -= p_162228_.m20; - this.m21 -= p_162228_.m21; - this.m22 -= p_162228_.m22; - this.m23 -= p_162228_.m23; - this.m30 -= p_162228_.m30; - this.m31 -= p_162228_.m31; - this.m32 -= p_162228_.m32; - this.m33 -= p_162228_.m33; - } - - public float trace() { - return this.m00 + this.m11 + this.m22 + this.m33; - } - - public static Matrix4fe perspective(double p_27626_, float p_27627_, float p_27628_, float p_27629_) { - float f = (float)(1.0D / Math.tan(p_27626_ * (double)((float)Math.PI / 180F) / 2.0D)); - Matrix4fe matrix4f = new Matrix4fe(); - matrix4f.m00 = f / p_27627_; - matrix4f.m11 = f; - matrix4f.m22 = (p_27629_ + p_27628_) / (p_27628_ - p_27629_); - matrix4f.m32 = -1.0F; - matrix4f.m23 = 2.0F * p_27629_ * p_27628_ / (p_27628_ - p_27629_); - return matrix4f; - } - - public static Matrix4fe orthographic(float p_27637_, float p_27638_, float p_27639_, float p_27640_) { - Matrix4fe matrix4f = new Matrix4fe(); - matrix4f.m00 = 2.0F / p_27637_; - matrix4f.m11 = 2.0F / p_27638_; - float f = p_27640_ - p_27639_; - matrix4f.m22 = -2.0F / f; - matrix4f.m33 = 1.0F; - matrix4f.m03 = -1.0F; - matrix4f.m13 = 1.0F; - matrix4f.m23 = -(p_27640_ + p_27639_) / f; - return matrix4f; - } - - public static Matrix4fe orthographic(float p_162204_, float p_162205_, float p_162206_, float p_162207_, float p_162208_, float p_162209_) { - Matrix4fe matrix4f = new Matrix4fe(); - float f = p_162205_ - p_162204_; - float f1 = p_162206_ - p_162207_; - float f2 = p_162209_ - p_162208_; - matrix4f.m00 = 2.0F / f; - matrix4f.m11 = 2.0F / f1; - matrix4f.m22 = -2.0F / f2; - matrix4f.m03 = -(p_162205_ + p_162204_) / f; - matrix4f.m13 = -(p_162206_ + p_162207_) / f1; - matrix4f.m23 = -(p_162209_ + p_162208_) / f2; - matrix4f.m33 = 1.0F; - return matrix4f; - } - - public void translate(Vector3f p_27649_) { - this.m03 += p_27649_.x(); - this.m13 += p_27649_.y(); - this.m23 += p_27649_.z(); - } - - public Matrix4fe copy() { - return new Matrix4fe(this); - } - - public void multiplyWithTranslation(float p_162200_, float p_162201_, float p_162202_) { - this.m03 += this.m00 * p_162200_ + this.m01 * p_162201_ + this.m02 * p_162202_; - this.m13 += this.m10 * p_162200_ + this.m11 * p_162201_ + this.m12 * p_162202_; - this.m23 += this.m20 * p_162200_ + this.m21 * p_162201_ + this.m22 * p_162202_; - this.m33 += this.m30 * p_162200_ + this.m31 * p_162201_ + this.m32 * p_162202_; - } - - public static Matrix4fe createScaleMatrix(float p_27633_, float p_27634_, float p_27635_) { - Matrix4fe matrix4f = new Matrix4fe(); - matrix4f.m00 = p_27633_; - matrix4f.m11 = p_27634_; - matrix4f.m22 = p_27635_; - matrix4f.m33 = 1.0F; - return matrix4f; - } - - public static Matrix4fe createTranslateMatrix(float p_27654_, float p_27655_, float p_27656_) { - Matrix4fe matrix4f = new Matrix4fe(); - matrix4f.m00 = 1.0F; - matrix4f.m11 = 1.0F; - matrix4f.m22 = 1.0F; - matrix4f.m33 = 1.0F; - matrix4f.m03 = p_27654_; - matrix4f.m13 = p_27655_; - matrix4f.m23 = p_27656_; - return matrix4f; - } - - // Forge start - public Matrix4fe(float[] values) { - m00 = values[0]; - m01 = values[1]; - m02 = values[2]; - m03 = values[3]; - m10 = values[4]; - m11 = values[5]; - m12 = values[6]; - m13 = values[7]; - m20 = values[8]; - m21 = values[9]; - m22 = values[10]; - m23 = values[11]; - m30 = values[12]; - m31 = values[13]; - m32 = values[14]; - m33 = values[15]; - } - - public void multiplyBackward(Matrix4fe other) { - Matrix4fe copy = other.copy(); - copy.multiply(this); - this.load(copy); - } - - public void setTranslation(float x, float y, float z) { - this.m00 = 1.0F; - this.m11 = 1.0F; - this.m22 = 1.0F; - this.m33 = 1.0F; - this.m03 = x; - this.m13 = y; - this.m23 = z; - } - - public FloatBuffer get(int index, FloatBuffer buffer) { - this.putN(this, index, buffer); - return buffer; - } - - /** - * Matches store() but with added offset - * @param m - * @param offset - * @param dest - */ - private void putN(Matrix4fe m, int offset, FloatBuffer dest) { - dest.put(offset + bufferIndex(0, 0), this.m00); - dest.put(offset + bufferIndex(0, 1), this.m01); - dest.put(offset + bufferIndex(0, 2), this.m02); - dest.put(offset + bufferIndex(0, 3), this.m03); - dest.put(offset + bufferIndex(1, 0), this.m10); - dest.put(offset + bufferIndex(1, 1), this.m11); - dest.put(offset + bufferIndex(1, 2), this.m12); - dest.put(offset + bufferIndex(1, 3), this.m13); - dest.put(offset + bufferIndex(2, 0), this.m20); - dest.put(offset + bufferIndex(2, 1), this.m21); - dest.put(offset + bufferIndex(2, 2), this.m22); - dest.put(offset + bufferIndex(2, 3), this.m23); - dest.put(offset + bufferIndex(3, 0), this.m30); - dest.put(offset + bufferIndex(3, 1), this.m31); - dest.put(offset + bufferIndex(3, 2), this.m32); - dest.put(offset + bufferIndex(3, 3), this.m33); - } - - private void put0(Matrix4fe m, FloatBuffer dest) { - dest.put(0, m.m00); - dest.put(1, m.m01); - dest.put(2, m.m02); - dest.put(3, m.m03); - dest.put(4, m.m10); - dest.put(5, m.m11); - dest.put(6, m.m12); - dest.put(7, m.m13); - dest.put(8, m.m20); - dest.put(9, m.m21); - dest.put(10, m.m22); - dest.put(11, m.m23); - dest.put(12, m.m30); - dest.put(13, m.m31); - dest.put(14, m.m32); - dest.put(15, m.m33); - } - - public float[] toFloatArray() { - float[] values = new float[16]; - values[0] = m00; - values[1] = m01; - values[2] = m02; - values[3] = m03; - values[4] = m10; - values[5] = m11; - values[6] = m12; - values[7] = m13; - values[8] = m20; - values[9] = m21; - values[10] = m22; - values[11] = m23; - values[12] = m30; - values[13] = m31; - values[14] = m32; - values[15] = m33; - - return values; - } -} diff --git a/src/main/java/weather2/client/shaderstest/Mesh.java b/src/main/java/weather2/client/shaderstest/Mesh.java deleted file mode 100644 index 78bfc486..00000000 --- a/src/main/java/weather2/client/shaderstest/Mesh.java +++ /dev/null @@ -1,262 +0,0 @@ -package weather2.client.shaderstest; - -import com.mojang.blaze3d.platform.GlStateManager; -import com.mojang.blaze3d.systems.RenderSystem; -import org.lwjgl.BufferUtils; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL15; -import org.lwjgl.opengl.GL20; - -import java.nio.FloatBuffer; -import java.nio.IntBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Random; - -/** - * Created by corosus on 08/05/17. - */ -public class Mesh { - - protected int vaoId; - - //private int posVboId; - - //private int colourVboId; - - //private int idxVboId; - - protected List vboIdList = new ArrayList<>(); - - private int vertexCount; - - public static final int MAX_WEIGHTS = 4; - - //public List posExtra = new ArrayList<>(); - - public static int extraRenders = 10; - - public Mesh(float[] positions, float[] textCoords, float[] normals, int[] indices) { - - float radius = 10; - Random rand = new Random(); - /*for (int i = 0; i < extraRenders; i++) { - Matrix4fe matOffset = new Matrix4fe(); - matOffset.identity(); - matOffset.translate(rand.nextFloat() * radius - rand.nextFloat() * radius, rand.nextFloat() * radius - rand.nextFloat() * radius, rand.nextFloat() * radius - rand.nextFloat() * radius); - posExtra.add(matOffset); - }*/ - - /*float[] normals = createEmptyFloatArray(MAX_WEIGHTS * positions.length / 3, 0); - int[] jointIndices = createEmptyIntArray(MAX_WEIGHTS * positions.length / 3, 0); - float[] weights = createEmptyFloatArray(MAX_WEIGHTS * positions.length / 3, 0);*/ - - vertexCount = indices.length; - - FloatBuffer verticesBuffer = null; - IntBuffer indicesBuffer = null; - FloatBuffer textCoordsBuffer = null; - FloatBuffer vecNormalsBuffer = null; - /*IntBuffer jointIndicesBuffer = null; - FloatBuffer weightsBuffer = null;*/ - try { - - - - // Create the VAO and bind to it - //if (true) throw new IllegalStateException(); - //vaoId = ShaderManager.glGenVertexArrays(); - RenderSystem.glGenVertexArrays((p_166881_) -> { - this.vaoId = p_166881_; - }); - //ShaderManager.glBindVertexArray(vaoId); - RenderSystem.glBindVertexArray(() -> this.vaoId); - - - - // Create the VBO and bind to it - //int posVboId = OpenGlHelper.glGenBuffers(); - int posVboId = GlStateManager._glGenBuffers(); - vboIdList.add(posVboId); - verticesBuffer = BufferUtils.createFloatBuffer(positions.length);//MemoryUtil.memAllocFloat(vertices.length); - verticesBuffer.put(positions).flip(); - GlStateManager._glBindBuffer(GL15.GL_ARRAY_BUFFER, posVboId); - GL15.glBufferData(GL15.GL_ARRAY_BUFFER, verticesBuffer, GL15.GL_STATIC_DRAW); - // Define structure of the data - GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0); - //might not be needed, but added when downgrading to GLSL 120 - //glEnableVertexAttribArray(0); - - //tex vbo - int texVboId = GlStateManager._glGenBuffers(); - vboIdList.add(texVboId); - textCoordsBuffer = BufferUtils.createFloatBuffer(textCoords.length); - textCoordsBuffer.put(textCoords).flip(); - GlStateManager._glBindBuffer(GL15.GL_ARRAY_BUFFER, texVboId); - GL15.glBufferData(GL15.GL_ARRAY_BUFFER, textCoordsBuffer, GL15.GL_STATIC_DRAW); - GL20.glVertexAttribPointer(1, 2, GL11.GL_FLOAT, false, 0, 0); - - //???? - //glEnableVertexAttribArray(1); - - // Vertex normals VBO - int vboId = GlStateManager._glGenBuffers(); - vboIdList.add(vboId); - vecNormalsBuffer = BufferUtils.createFloatBuffer(normals.length); - vecNormalsBuffer.put(normals).flip(); - GlStateManager._glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId); - GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vecNormalsBuffer, GL15.GL_STATIC_DRAW); - GL20.glVertexAttribPointer(2, 3, GL11.GL_FLOAT, false, 0, 0); - - // Weights - /*vboId = glGenBuffers(); - vboIdList.add(vboId); - weightsBuffer = BufferUtils.createFloatBuffer(weights.length); - weightsBuffer.put(weights).flip(); - glBindBuffer(GL_ARRAY_BUFFER, vboId); - glBufferData(GL_ARRAY_BUFFER, weightsBuffer, GL_STATIC_DRAW); - glVertexAttribPointer(3, 4, GL_FLOAT, false, 0, 0);*/ - - // Joint indices - /*vboId = glGenBuffers(); - vboIdList.add(vboId); - jointIndicesBuffer = BufferUtils.createIntBuffer(jointIndices.length); - jointIndicesBuffer.put(jointIndices).flip(); - glBindBuffer(GL_ARRAY_BUFFER, vboId); - glBufferData(GL_ARRAY_BUFFER, jointIndicesBuffer, GL_STATIC_DRAW); - glVertexAttribPointer(4, 4, GL_FLOAT, false, 0, 0);*/ - - //index vbo - int idxVboId = GlStateManager._glGenBuffers(); - vboIdList.add(idxVboId); - indicesBuffer = BufferUtils.createIntBuffer(indices.length); - indicesBuffer.put(indices).flip(); - GlStateManager._glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, idxVboId); - GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesBuffer, GL15.GL_STATIC_DRAW); - - // Unbind the VBO - GlStateManager._glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); - - // Unbind the VAO - //ShaderManager.glBindVertexArray(0); - RenderSystem.glBindVertexArray(() -> 0); - } finally { - /** - * TODO: test if we need to actually free the memory since we have to use BufferUtils.createFloatBuffer instead of MemoryUtil.memAllocFloat - * "It's not trivial because I want to make it optional and using jemalloc requires explicit je_free calls to avoid leaking memory. - * Existing usages of BufferUtils do not have that requirement and will have to be adjusted accordingly." - * - * BufferUtils is more automatic, doesnt need freeing, but can be slower and risks memory fragmentation, MemoryUtil gives more control and responsibility - */ - if (verticesBuffer != null) { - //MemoryUtil.memFree(verticesBuffer); - } - } - } - - protected void initRender() { - /*Texture texture = material.getTexture(); - if (texture != null) { - // Activate first texture bank - glActiveTexture(GL_TEXTURE0); - // Bind the texture - glBindTexture(GL_TEXTURE_2D, texture.getId()); - } - Texture normalMap = material.getNormalMap(); - if ( normalMap != null ) { - // Activate first texture bank - glActiveTexture(GL_TEXTURE1); - // Bind the texture - glBindTexture(GL_TEXTURE_2D, normalMap.getId()); - }*/ - - // Draw the mesh - //ShaderManager.glBindVertexArray(getVaoId()); - RenderSystem.glBindVertexArray(() -> getVaoId()); - GlStateManager._enableVertexAttribArray(0); - GlStateManager._enableVertexAttribArray(1); - GlStateManager._enableVertexAttribArray(2); - //glEnableVertexAttribArray(2); - //glEnableVertexAttribArray(3); - //glEnableVertexAttribArray(4); - } - - protected void endRender() { - // Restore state - GlStateManager._disableVertexAttribArray(0); - GlStateManager._disableVertexAttribArray(1); - GlStateManager._disableVertexAttribArray(2); - //glDisableVertexAttribArray(2); - //glDisableVertexAttribArray(3); - //glDisableVertexAttribArray(4); - //ShaderManager.glBindVertexArray(0); - RenderSystem.glBindVertexArray(() -> 0); - - //glBindTexture(GL_TEXTURE_2D, 0); - } - - public void render() { - //System.out.println("render start"); - // Draw the mesh - /*glBindVertexArray(getVaoId()); - glEnableVertexAttribArray(0); - glEnableVertexAttribArray(1);*/ - initRender(); - - //glDrawElements(GL_TRIANGLES, getVertexCount(), GL_UNSIGNED_INT, 0); - - // Restore state - endRender(); - /*glDisableVertexAttribArray(0); - glDisableVertexAttribArray(1); - glBindVertexArray(0);*/ - //System.out.println("render end"); - } - - public int getVaoId() { - return vaoId; - } - - public void setVaoId(int vaoId) { - this.vaoId = vaoId; - } - - public int getVertexCount() { - return vertexCount; - } - - public void setVertexCount(int vertexCount) { - this.vertexCount = vertexCount; - } - - public void cleanup() { - //ShaderManager.glDisableVertexAttribArray(0); - GlStateManager._disableVertexAttribArray(0); - - // Delete the VBO - GlStateManager._glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); - for (int vboId : vboIdList) { - //OpenGlHelper.glDeleteBuffers(vboId); - GlStateManager._glDeleteBuffers(vboId); - } - - // Delete the VAO - //ShaderManager.glBindVertexArray(0); - RenderSystem.glBindVertexArray(() -> 0); - //ShaderManager.glDeleteVertexArrays(vaoId); - GlStateManager._glDeleteVertexArrays(vaoId); - } - - protected static float[] createEmptyFloatArray(int length, float defaultValue) { - float[] result = new float[length]; - Arrays.fill(result, defaultValue); - return result; - } - - protected static int[] createEmptyIntArray(int length, int defaultValue) { - int[] result = new int[length]; - Arrays.fill(result, defaultValue); - return result; - } -} diff --git a/src/main/java/weather2/client/shaderstest/MeshBufferManagerParticle.java b/src/main/java/weather2/client/shaderstest/MeshBufferManagerParticle.java deleted file mode 100644 index 9c2a0698..00000000 --- a/src/main/java/weather2/client/shaderstest/MeshBufferManagerParticle.java +++ /dev/null @@ -1,417 +0,0 @@ -package weather2.client.shaderstest; - -import com.mojang.math.Vector3f; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.world.phys.Vec3; -import weather2.weathersystem.sky.CloudRenderHandler; - -import java.util.HashMap; -import java.util.Map; -import java.util.Random; - -/** - * Created by corosus on 25/05/17. - */ -public class MeshBufferManagerParticle { - - //for prebuffering allowed max - public static int numInstances = 50000; - - private static HashMap lookupParticleToMesh = new HashMap<>(); - - public static void setupMeshForParticle(TextureAtlasSprite sprite) { - - //drawn in order of a U shape starting top left - float[] positions = null; - - /*positions = new float[]{ - -0.5f, 0.5f, 0.0f, - -0.5f, -0.5f, 0.0f, - 0.5f, -0.5f, 0.0f, - 0.5f, -0.5f, 0.0f - };*/ - - positions = new float[]{/* - 0.4619355201721193F,0.46193552017211914F,-3.462473154067993F, - 1.9617563486099239F,0.46193552017211914F,-3.0600118507347247F, - 0.46193552017211925F,0.461935520172119F,-3.462473154067993F,*/ - /*1.9617563486099239F,0.46193552017211914F,-3.0600118507347247F, - 0.46193552017211925F,0.461935520172119F,-3.462473154067993F, - 1.2119355201721191F,-1.761152916620261F,-3.0600118507347247F,*/ - 0.46193552017211925F,0.4619355201721193F,-3.462473154067993F, - 1.2119355201721191F,1.7607944542865819F,-3.0600118507347247F, - 0.4619355201721193F,0.46193552017211914F,-3.462473154067993F, - 1.2119355201721191F,1.7607944542865819F,-3.0600118507347247F, - 0.4619355201721193F,0.46193552017211914F,-3.462473154067993F, - 1.9617563486099239F,0.46193552017211914F,-3.0600118507347247F, - 0.46193552017211903F,0.4619355201721193F,-3.462473154067993F, - -0.2880644798278804F,1.760794454286582F,-3.0600118507347247F, - 0.46193552017211925F,0.4619355201721193F,-3.462473154067993F, - -0.2880644798278804F,1.760794454286582F,-3.0600118507347247F, - 0.46193552017211925F,0.4619355201721193F,-3.462473154067993F, - 1.2119355201721191F,1.7607944542865819F,-3.0600118507347247F, - 0.461935520172119F,0.46193552017211914F,-3.462473154067993F, - -1.962114810943603F,0.4619355201721193F,-3.0600118507347247F, - 0.46193552017211903F,0.4619355201721193F,-3.462473154067993F, - -1.962114810943603F,0.4619355201721193F,-3.0600118507347247F, - 0.46193552017211903F,0.4619355201721193F,-3.462473154067993F, - -0.2880644798278804F,1.760794454286582F,-3.0600118507347247F, - 0.46193552017211903F,0.461935520172119F,-3.462473154067993F, - -0.2880644798278813F,-1.7611529166202606F,-3.0600118507347247F, - 0.461935520172119F,0.46193552017211914F,-3.462473154067993F, - -0.2880644798278813F,-1.7611529166202606F,-3.0600118507347247F, - 0.461935520172119F,0.46193552017211914F,-3.462473154067993F, - -1.962114810943603F,0.4619355201721193F,-3.0600118507347247F, - 0.46193552017211925F,0.461935520172119F,-3.462473154067993F, - 1.2119355201721191F,-1.761152916620261F,-3.0600118507347247F, - 0.46193552017211903F,0.461935520172119F,-3.462473154067993F, - 1.2119355201721191F,-1.761152916620261F,-3.0600118507347247F, - 0.46193552017211903F,0.461935520172119F,-3.462473154067993F, - -0.2880644798278813F,-1.7611529166202606F,-3.0600118507347247F, - 1.9617563486099239F,0.46193552017211914F,-3.0600118507347247F, - 3.060370074649825F,0.46193552017211914F,-1.9621148109436035F, - 1.2119355201721191F,-1.761152916620261F,-3.0600118507347247F, - 3.060370074649825F,0.46193552017211914F,-1.9621148109436035F, - 1.2119355201721191F,-1.761152916620261F,-3.0600118507347247F, - 1.7607944542865825F,-2.7119356393814082F,-1.9621148109436035F, - 1.2119355201721191F,1.7607944542865819F,-3.0600118507347247F, - 1.7607944542865825F,2.7122938632965083F,-1.9621148109436035F, - 1.9617563486099239F,0.46193552017211914F,-3.0600118507347247F, - 1.7607944542865825F,2.7122938632965083F,-1.9621148109436035F, - 1.9617563486099239F,0.46193552017211914F,-3.0600118507347247F, - 3.060370074649825F,0.46193552017211914F,-1.9621148109436035F, - -0.2880644798278804F,1.760794454286582F,-3.0600118507347247F, - -1.7611529166202609F,2.712293863296509F,-1.9621148109436035F, - 1.2119355201721191F,1.7607944542865819F,-3.0600118507347247F, - -1.7611529166202609F,2.712293863296509F,-1.9621148109436035F, - 1.2119355201721191F,1.7607944542865819F,-3.0600118507347247F, - 1.7607944542865825F,2.7122938632965083F,-1.9621148109436035F, - -1.962114810943603F,0.4619355201721193F,-3.0600118507347247F, - -3.0600118507347247F,0.4619355201721195F,-1.9621148109436035F, - -0.2880644798278804F,1.760794454286582F,-3.0600118507347247F, - -3.0600118507347247F,0.4619355201721195F,-1.9621148109436035F, - -0.2880644798278804F,1.760794454286582F,-3.0600118507347247F, - -1.7611529166202609F,2.712293863296509F,-1.9621148109436035F, - -0.2880644798278813F,-1.7611529166202606F,-3.0600118507347247F, - -1.7611529166202626F,-2.711935639381408F,-1.9621148109436035F, - -1.962114810943603F,0.4619355201721193F,-3.0600118507347247F, - -1.7611529166202626F,-2.711935639381408F,-1.9621148109436035F, - -1.962114810943603F,0.4619355201721193F,-3.0600118507347247F, - -3.0600118507347247F,0.4619355201721195F,-1.9621148109436035F, - 1.2119355201721191F,-1.761152916620261F,-3.0600118507347247F, - 1.7607944542865825F,-2.7119356393814082F,-1.9621148109436035F, - -0.2880644798278813F,-1.7611529166202606F,-3.0600118507347247F, - 1.7607944542865825F,-2.7119356393814082F,-1.9621148109436035F, - -0.2880644798278813F,-1.7611529166202606F,-3.0600118507347247F, - -1.7611529166202626F,-2.711935639381408F,-1.9621148109436035F, - 3.060370074649825F,0.46193552017211914F,-1.9621148109436035F, - 3.462114691734314F,0.46193552017211914F,0.46193552017211914F, - 1.7607944542865825F,-2.7119356393814082F,-1.9621148109436035F, - 3.462114691734314F,0.46193552017211914F,0.46193552017211914F, - 1.7607944542865825F,-2.7119356393814082F,-1.9621148109436035F, - 1.9617563486099248F,-3.0600118507347247F,0.46193552017211914F, - 1.7607944542865825F,2.7122938632965083F,-1.9621148109436035F, - 1.9617563486099248F,3.060370074649825F,0.46193552017211914F, - 3.060370074649825F,0.46193552017211914F,-1.9621148109436035F, - 1.9617563486099248F,3.060370074649825F,0.46193552017211914F, - 3.060370074649825F,0.46193552017211914F,-1.9621148109436035F, - 3.462114691734314F,0.46193552017211914F,0.46193552017211914F, - -1.7611529166202609F,2.712293863296509F,-1.9621148109436035F, - -1.9621148109436028F,3.060370074649825F,0.46193552017211914F, - 1.7607944542865825F,2.7122938632965083F,-1.9621148109436035F, - -1.9621148109436028F,3.060370074649825F,0.46193552017211914F, - 1.7607944542865825F,2.7122938632965083F,-1.9621148109436035F, - 1.9617563486099248F,3.060370074649825F,0.46193552017211914F, - -3.0600118507347247F,0.4619355201721195F,-1.9621148109436035F, - -3.462473154067993F,0.46193552017211953F,0.46193552017211914F, - -1.7611529166202609F,2.712293863296509F,-1.9621148109436035F, - -3.462473154067993F,0.46193552017211953F,0.46193552017211914F, - -1.7611529166202609F,2.712293863296509F,-1.9621148109436035F, - -1.9621148109436028F,3.060370074649825F,0.46193552017211914F, - -1.7611529166202626F,-2.711935639381408F,-1.9621148109436035F, - -1.9621148109436048F,-3.060011850734724F,0.46193552017211914F, - -3.0600118507347247F,0.4619355201721195F,-1.9621148109436035F, - -1.9621148109436048F,-3.060011850734724F,0.46193552017211914F, - -3.0600118507347247F,0.4619355201721195F,-1.9621148109436035F, - -3.462473154067993F,0.46193552017211953F,0.46193552017211914F, - 1.7607944542865825F,-2.7119356393814082F,-1.9621148109436035F, - 1.9617563486099248F,-3.0600118507347247F,0.46193552017211914F, - -1.7611529166202626F,-2.711935639381408F,-1.9621148109436035F, - 1.9617563486099248F,-3.0600118507347247F,0.46193552017211914F, - -1.7611529166202626F,-2.711935639381408F,-1.9621148109436035F, - -1.9621148109436048F,-3.060011850734724F,0.46193552017211914F, - 3.462114691734314F,0.46193552017211914F,0.46193552017211914F, - 3.060370074649825F,0.46193552017211914F,1.9617563486099239F, - 1.9617563486099248F,-3.0600118507347247F,0.46193552017211914F, - 3.060370074649825F,0.46193552017211914F,1.9617563486099239F, - 1.9617563486099248F,-3.0600118507347247F,0.46193552017211914F, - 1.7607944542865828F,-2.7119356393814087F,1.9617563486099239F, - 1.9617563486099248F,3.060370074649825F,0.46193552017211914F, - 1.7607944542865828F,2.712293863296509F,1.9617563486099239F, - 3.462114691734314F,0.46193552017211914F,0.46193552017211914F, - 1.7607944542865828F,2.712293863296509F,1.9617563486099239F, - 3.462114691734314F,0.46193552017211914F,0.46193552017211914F, - 3.060370074649825F,0.46193552017211914F,1.9617563486099239F, - -1.9621148109436028F,3.060370074649825F,0.46193552017211914F, - -1.761152916620261F,2.7122938632965092F,1.9617563486099239F, - 1.9617563486099248F,3.060370074649825F,0.46193552017211914F, - -1.761152916620261F,2.7122938632965092F,1.9617563486099239F, - 1.9617563486099248F,3.060370074649825F,0.46193552017211914F, - 1.7607944542865828F,2.712293863296509F,1.9617563486099239F, - -3.462473154067993F,0.46193552017211953F,0.46193552017211914F, - -3.0600118507347247F,0.4619355201721195F,1.9617563486099239F, - -1.9621148109436028F,3.060370074649825F,0.46193552017211914F, - -3.0600118507347247F,0.4619355201721195F,1.9617563486099239F, - -1.9621148109436028F,3.060370074649825F,0.46193552017211914F, - -1.761152916620261F,2.7122938632965092F,1.9617563486099239F, - -1.9621148109436048F,-3.060011850734724F,0.46193552017211914F, - -1.7611529166202629F,-2.711935639381408F,1.9617563486099239F, - -3.462473154067993F,0.46193552017211953F,0.46193552017211914F, - -1.7611529166202629F,-2.711935639381408F,1.9617563486099239F, - -3.462473154067993F,0.46193552017211953F,0.46193552017211914F, - -3.0600118507347247F,0.4619355201721195F,1.9617563486099239F, - 1.9617563486099248F,-3.0600118507347247F,0.46193552017211914F, - 1.7607944542865828F,-2.7119356393814087F,1.9617563486099239F, - -1.9621148109436048F,-3.060011850734724F,0.46193552017211914F, - 1.7607944542865828F,-2.7119356393814087F,1.9617563486099239F, - -1.9621148109436048F,-3.060011850734724F,0.46193552017211914F, - -1.7611529166202629F,-2.711935639381408F,1.9617563486099239F, - 3.060370074649825F,0.46193552017211914F,1.9617563486099239F, - 1.9617563486099239F,0.46193552017211914F,3.060370074649825F, - 1.7607944542865828F,-2.7119356393814087F,1.9617563486099239F, - 1.9617563486099239F,0.46193552017211914F,3.060370074649825F, - 1.7607944542865828F,-2.7119356393814087F,1.9617563486099239F, - 1.2119355201721191F,-1.761152916620261F,3.060370074649825F, - 1.7607944542865828F,2.712293863296509F,1.9617563486099239F, - 1.2119355201721191F,1.7607944542865819F,3.060370074649825F, - 3.060370074649825F,0.46193552017211914F,1.9617563486099239F, - 1.2119355201721191F,1.7607944542865819F,3.060370074649825F, - 3.060370074649825F,0.46193552017211914F,1.9617563486099239F, - 1.9617563486099239F,0.46193552017211914F,3.060370074649825F, - -1.761152916620261F,2.7122938632965092F,1.9617563486099239F, - -0.2880644798278804F,1.760794454286582F,3.060370074649825F, - 1.7607944542865828F,2.712293863296509F,1.9617563486099239F, - -0.2880644798278804F,1.760794454286582F,3.060370074649825F, - 1.7607944542865828F,2.712293863296509F,1.9617563486099239F, - 1.2119355201721191F,1.7607944542865819F,3.060370074649825F, - -3.0600118507347247F,0.4619355201721195F,1.9617563486099239F, - -1.962114810943603F,0.4619355201721193F,3.060370074649825F, - -1.761152916620261F,2.7122938632965092F,1.9617563486099239F, - -1.962114810943603F,0.4619355201721193F,3.060370074649825F, - -1.761152916620261F,2.7122938632965092F,1.9617563486099239F, - -0.2880644798278804F,1.760794454286582F,3.060370074649825F, - -1.7611529166202629F,-2.711935639381408F,1.9617563486099239F, - -0.2880644798278813F,-1.7611529166202606F,3.060370074649825F, - -3.0600118507347247F,0.4619355201721195F,1.9617563486099239F, - -0.2880644798278813F,-1.7611529166202606F,3.060370074649825F, - -3.0600118507347247F,0.4619355201721195F,1.9617563486099239F, - -1.962114810943603F,0.4619355201721193F,3.060370074649825F, - 1.7607944542865828F,-2.7119356393814087F,1.9617563486099239F, - 1.2119355201721191F,-1.761152916620261F,3.060370074649825F, - -1.7611529166202629F,-2.711935639381408F,1.9617563486099239F, - 1.2119355201721191F,-1.761152916620261F,3.060370074649825F, - -1.7611529166202629F,-2.711935639381408F,1.9617563486099239F, - -0.2880644798278813F,-1.7611529166202606F,3.060370074649825F, - 1.9617563486099239F,0.46193552017211914F,3.060370074649825F, - 0.4619355201721193F,0.46193552017211914F,3.462114691734314F, - 1.2119355201721191F,-1.761152916620261F,3.060370074649825F, - 0.4619355201721193F,0.46193552017211914F,3.462114691734314F, - 1.2119355201721191F,-1.761152916620261F,3.060370074649825F, - 0.46193552017211925F,0.461935520172119F,3.462114691734314F, - 1.2119355201721191F,1.7607944542865819F,3.060370074649825F, - 0.46193552017211925F,0.4619355201721193F,3.462114691734314F, - 1.9617563486099239F,0.46193552017211914F,3.060370074649825F, - 0.46193552017211925F,0.4619355201721193F,3.462114691734314F, - 1.9617563486099239F,0.46193552017211914F,3.060370074649825F, - 0.4619355201721193F,0.46193552017211914F,3.462114691734314F, - -0.2880644798278804F,1.760794454286582F,3.060370074649825F, - 0.46193552017211903F,0.4619355201721193F,3.462114691734314F, - 1.2119355201721191F,1.7607944542865819F,3.060370074649825F, - 0.46193552017211903F,0.4619355201721193F,3.462114691734314F, - 1.2119355201721191F,1.7607944542865819F,3.060370074649825F, - 0.46193552017211925F,0.4619355201721193F,3.462114691734314F, - -1.962114810943603F,0.4619355201721193F,3.060370074649825F, - 0.461935520172119F,0.46193552017211914F,3.462114691734314F, - -0.2880644798278804F,1.760794454286582F,3.060370074649825F, - 0.461935520172119F,0.46193552017211914F,3.462114691734314F, - -0.2880644798278804F,1.760794454286582F,3.060370074649825F, - 0.46193552017211903F,0.4619355201721193F,3.462114691734314F, - -0.2880644798278813F,-1.7611529166202606F,3.060370074649825F, - 0.46193552017211903F,0.461935520172119F,3.462114691734314F, - -1.962114810943603F,0.4619355201721193F,3.060370074649825F, - 0.46193552017211903F,0.461935520172119F,3.462114691734314F, - -1.962114810943603F,0.4619355201721193F,3.060370074649825F, - 0.461935520172119F,0.46193552017211914F,3.462114691734314F, - 1.2119355201721191F,-1.761152916620261F,3.060370074649825F, - 0.46193552017211925F,0.461935520172119F,3.462114691734314F, - -0.2880644798278813F,-1.7611529166202606F,3.060370074649825F, - 0.46193552017211925F,0.461935520172119F,3.462114691734314F, - -0.2880644798278813F,-1.7611529166202606F,3.060370074649825F, - 0.46193552017211903F,0.461935520172119F,3.462114691734314F - }; - - Random rand = new Random(5); - - /*positions = new float[]{ - -0.5f, 0.5f, 0.0f, - -0.5f, -0.5f, 0.0f, - 0.5f, -0.5f, 0.0f - }; - - positions = new float[]{ - -rand.nextFloat(), rand.nextFloat(), 0.0f, - -rand.nextFloat(), -rand.nextFloat(), 0.0f, - rand.nextFloat(), -rand.nextFloat(), 0.0f, - };*/ - - int count = 9 * 30; - count = positions.length; - - int triangles = positions.length / 3; - - /*positions = new float[count]; - for (int i = 0; i < positions.length; i++) { - positions[i] = rand.nextFloat() - 0.5F; - }*/ - - /*positions = new float[]{ - 0.461935520172121F,0.46193552017211914F,-30.462652325630188F, - 15.460143923759457F,0.46193552017211914F,-26.444310177765033F, - 0.4619355201721201F,0.46193552017211753F,-30.462652325630188F - };*/ - - float[] texCoords = null; - - texCoords = new float[]{ - sprite.getU0(), sprite.getV0(), - sprite.getU0(), sprite.getV1(), - sprite.getU1(), sprite.getV1() - }; - - texCoords = new float[count]; - for (int i = 0; i < texCoords.length; i++) { - if (i % 6 == 0) { - texCoords[i] = sprite.getU0(); - } else if (i % 6 == 1) { - texCoords[i] = sprite.getV0(); - } else if (i % 6 == 2) { - texCoords[i] = sprite.getU0(); - } else if (i % 6 == 3) { - texCoords[i] = sprite.getV1(); - } else if (i % 6 == 4) { - texCoords[i] = sprite.getU1(); - } else if (i % 6 == 5) { - texCoords[i] = sprite.getV1(); - } - - } - - float[] normals = new float[count]; - for (int i = 0; i < positions.length; i+=1) { - normals[i] = rand.nextFloat() - rand.nextFloat(); - } - - - for (int i = 0; i < positions.length; i+=1) { - //System.out.println(normals[i]); - } - - //Model model = CloudRenderHandler.renderSphere(0, 0, 0, new Vec3(1, 1, 1), 0.1F); - Model model = CloudRenderHandler.renderCube(0, 0, 0, new Vec3(1, 1, 1), 1F); - - positions = new float[model.positions.size()]; - for(int i = 0; i < model.positions.size(); i++) positions[i] = model.positions.get(i); - - texCoords = new float[model.uv.size()]; - for(int i = 0; i < model.uv.size(); i++) texCoords[i] = model.uv.get(i); - - normals = new float[model.normals.size()]; - for(int i = 0; i < model.normals.size(); i++) normals[i] = model.normals.get(i); - - /*normals = new float[model.normals.size()]; - for(int i = 0; i < model.normals.size(); i++) normals[i] = 1;*/ - - boolean recalc = false; - if (recalc) { - for (int i = 0; i < positions.length; i += 9) { - //normals[i] = 0F; - int index = 0; - Vector3f pos0 = new Vector3f(positions[i + index++], positions[i + index++], positions[i + index++]); - Vector3f pos1 = new Vector3f(positions[i + index++], positions[i + index++], positions[i + index++]); - Vector3f pos2 = new Vector3f(positions[i + index++], positions[i + index++], positions[i + index++]); - - Vector3f a = pos2.copy(); - a.sub(pos0); - Vector3f b = pos1.copy(); - b.sub(pos0); - - a.cross(b); - - Vector3f normal = a; - /*normal = new Vector3f(rand.nextFloat() - rand.nextFloat(), rand.nextFloat() - rand.nextFloat(), rand.nextFloat() - rand.nextFloat()); - normal = new Vector3f(1, 1, 1); - normal = new Vector3f(0, 0, 0);*/ - - int index2 = 0; - normals[i + index2++] = normal.x(); - normals[i + index2++] = normal.y(); - normals[i + index2++] = normal.z(); - normals[i + index2++] = normal.x(); - normals[i + index2++] = normal.y(); - normals[i + index2++] = normal.z(); - normals[i + index2++] = normal.x(); - normals[i + index2++] = normal.y(); - normals[i + index2++] = normal.z(); - for (int ii = 0; ii < 9; ii += 3) { - /*normals[i+ii] = normal.x(); - normals[i+ii+1] = normal.y(); - normals[i+ii+2] = normal.z();*/ - } - } - } - - for (int i = 0; i < positions.length; i+=1) { - System.out.println(positions[i]); - } - - int[] indices = new int[] { - 0, 1, 3, 3, 1, 2 - }; - - indices = new int[positions.length / 3]; - for (int i = 0; i < positions.length / 3; i++) { - indices[i] = i; - } - - /*indices = new int[] { - 0, 1, 3, 3, 1, 2 - };*/ - - InstancedMeshParticle mesh = new InstancedMeshParticle(positions, texCoords, normals, indices, numInstances); - - if (!lookupParticleToMesh.containsKey(sprite)) { - lookupParticleToMesh.put(sprite, mesh); - } else { - System.out.println("WARNING: duplicate entry attempt for particle sprite, adding anyways: " + sprite); - lookupParticleToMesh.put(sprite, mesh); - } - } - - public static void cleanup() { - for (Map.Entry entry : lookupParticleToMesh.entrySet()) { - entry.getValue().cleanup(); - } - lookupParticleToMesh.clear(); - } - - public static InstancedMeshParticle getMesh(TextureAtlasSprite sprite) { - return lookupParticleToMesh.get(sprite); - } - - public static void setupMeshForParticleIfMissing(TextureAtlasSprite sprite) { - if (sprite == null) return; - if (!lookupParticleToMesh.containsKey(sprite)) { - setupMeshForParticle(sprite); - } - } -} diff --git a/src/main/java/weather2/client/shaderstest/Model.java b/src/main/java/weather2/client/shaderstest/Model.java deleted file mode 100644 index be48e3b5..00000000 --- a/src/main/java/weather2/client/shaderstest/Model.java +++ /dev/null @@ -1,12 +0,0 @@ -package weather2.client.shaderstest; - -import java.util.ArrayList; -import java.util.List; - -public class Model { - - public List positions = new ArrayList<>(); - public List uv = new ArrayList<>(); - public List normals = new ArrayList<>(); - -} diff --git a/src/main/java/weather2/command/WeatherCommand.java b/src/main/java/weather2/command/WeatherCommand.java index 44e46d45..2bb5690d 100644 --- a/src/main/java/weather2/command/WeatherCommand.java +++ b/src/main/java/weather2/command/WeatherCommand.java @@ -1,5 +1,6 @@ package weather2.command; +import com.corosus.coroutil.util.CoroUtilBlock; import com.mojang.brigadier.Command; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.FloatArgumentType; @@ -10,7 +11,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; import net.minecraft.world.phys.Vec3; import net.minecraftforge.fml.InterModComms; import weather2.ServerTickHandler; @@ -41,7 +41,7 @@ public static void register(final CommandDispatcher dispatch })) .then(literal("storm_chance").executes(c -> { WeatherManagerServer wm = ServerTickHandler.getWeatherManagerFor(c.getSource().getLevel().dimension()); - float chance = wm.getBiomeBasedStormSpawnChanceInArea(new BlockPos(c.getSource().getPosition().x, c.getSource().getPosition().y, c.getSource().getPosition().z)); + float chance = wm.getBiomeBasedStormSpawnChanceInArea(CoroUtilBlock.blockPos(c.getSource().getPosition().x, c.getSource().getPosition().y, c.getSource().getPosition().z)); c.getSource().sendSuccess(() -> Component.literal("Likelyhood of storms to spawn here within 1024 blocks: " + (chance * 100)), true); return Command.SINGLE_SUCCESS; diff --git a/src/main/java/weather2/data/WeatherRecipeProvider.java b/src/main/java/weather2/data/WeatherRecipeProvider.java index 33579697..821b4915 100644 --- a/src/main/java/weather2/data/WeatherRecipeProvider.java +++ b/src/main/java/weather2/data/WeatherRecipeProvider.java @@ -21,7 +21,8 @@ public WeatherRecipeProvider(PackOutput p_125973_) { @Override protected void buildRecipes(Consumer consumer) { - ShapedRecipeBuilder.shaped(WeatherItems.WEATHER_ITEM.get(), 1) + //TODO: 1.20 + /*ShapedRecipeBuilder.shaped(WeatherItems.WEATHER_ITEM.get(), 1) .pattern("X X").pattern("DID").pattern("X X") .define('D', Items.REDSTONE) .define('I', Items.GOLD_INGOT) @@ -61,6 +62,6 @@ protected void buildRecipes(Consumer consumer) { .pattern("DDD").pattern("D D").pattern("DDD") .define('D', Items.SAND) .unlockedBy("has_sand", has(Items.SAND)) - .save(consumer); + .save(consumer);*/ } } diff --git a/src/main/java/weather2/item/WeatherItem.java b/src/main/java/weather2/item/WeatherItem.java index 2616549b..f8d06149 100644 --- a/src/main/java/weather2/item/WeatherItem.java +++ b/src/main/java/weather2/item/WeatherItem.java @@ -7,10 +7,11 @@ public class WeatherItem extends Item { public WeatherItem(Item.Properties properties, CreativeModeTab itemGroup) { - super(properties.tab(itemGroup)); + //TODO: 1.20 + super(properties/*.tab(itemGroup)*/); } - public void fillItemCategory(CreativeModeTab group, NonNullList items) { + /*public void fillItemCategory(CreativeModeTab group, NonNullList items) { super.fillItemCategory(group, items); - } + }*/ } diff --git a/src/main/java/weather2/mixin/client/RenderParticlesOverride.java b/src/main/java/weather2/mixin/client/RenderParticlesOverride.java index fe3aa478..96235fa0 100644 --- a/src/main/java/weather2/mixin/client/RenderParticlesOverride.java +++ b/src/main/java/weather2/mixin/client/RenderParticlesOverride.java @@ -1,19 +1,16 @@ package weather2.mixin.client; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Matrix4f; import net.minecraft.client.Camera; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.ParticleEngine; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraftforge.client.ICloudRenderHandler; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; import weather2.ClientTickHandler; -import weather2.weathersystem.sky.CloudRenderHandler; import javax.annotation.Nullable; @@ -38,7 +35,7 @@ public void renderSnowAndRain(LevelRenderer worldRenderer, LightTexture lightmap //stopping vanilla from running renderRainSnow } - @Redirect(method = "renderLevel", + /*@Redirect(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;renderClouds(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/math/Matrix4f;FDDD)V")) public void renderClouds(LevelRenderer instance, PoseStack poseStack, Matrix4f l, float i1, double f1, double f2, double d0) { @@ -50,5 +47,5 @@ public void renderClouds(LevelRenderer instance, PoseStack poseStack, Matrix4f l } else { instance.renderClouds(poseStack, l, i1, f1, f2, d0); } - } + }*/ } \ No newline at end of file diff --git a/src/main/java/weather2/util/WeatherUtil.java b/src/main/java/weather2/util/WeatherUtil.java index 56068788..8ac196e1 100644 --- a/src/main/java/weather2/util/WeatherUtil.java +++ b/src/main/java/weather2/util/WeatherUtil.java @@ -14,7 +14,8 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.*; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MapColor; +import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.server.ServerLifecycleHooks; import org.joml.Vector3d; import org.joml.Vector3f; @@ -54,7 +55,7 @@ public static void testAllBlocks() { //if (!ConfigTornado.Storm_Tornado_GrabList.equals(lastConfigChecked)) { lastConfigChecked = ConfigTornado.Storm_Tornado_GrabList; CULog.log("PRINTING OUT ALL WEATHER2 TORNADO GRABBABLE BLOCKS WITH CURRENT CONFIG: "); - Registry.BLOCK.forEach(block -> { + ForgeRegistries.BLOCKS.forEach(block -> { List list = block.getStateDefinition().getPossibleStates(); for (BlockState state : list) { boolean result = canGrabViaLists(state); @@ -89,12 +90,12 @@ public static boolean isStateInListOfTags(BlockState state) { } public static TagKey getTagKeyFor(String str) { - return TagKey.create(Registry.BLOCK_REGISTRY, new ResourceLocation(str)); + return TagKey.create(ForgeRegistries.BLOCKS.getRegistryKey(), new ResourceLocation(str)); } public static boolean canGrabViaLists(BlockState state) { boolean returnVal = !ConfigTornado.Storm_Tornado_GrabListBlacklistMode; - ResourceLocation registeredName = state.getBlock().getRegistryName(); + ResourceLocation registeredName = ForgeRegistries.BLOCKS.getKey(state.getBlock()); if (listGrabBlockCache.containsKey(registeredName)) { return listGrabBlockCache.get(registeredName); } @@ -142,7 +143,7 @@ public static boolean isAprilFoolsDay() { public static boolean shouldRemoveBlock(BlockState blockID) { //water no - if (blockID.getMaterial() == Material.WATER) + if (blockID.getBlock().defaultMapColor() == MapColor.WATER) { return false; } @@ -198,9 +199,9 @@ public static boolean shouldGrabBlock(Level parWorld, BlockState state) //System.out.println(strVsBlock); if (/*block.getHardness() <= 10000.6*/ (strVsBlock <= strMax && strVsBlock >= strMin) || - (state.getMaterial() == Material.WOOD) || - state.getMaterial() == Material.WOOL || - state.getMaterial() == Material.PLANT ||/* + (state.getBlock().defaultMapColor() == MapColor.WOOD) || + state.getBlock().defaultMapColor() == MapColor.WOOL || + state.getBlock().defaultMapColor() == MapColor.PLANT ||/* state.getMaterial() == Material.VINE ||*/ block instanceof TallGrassBlock) { if (!safetyCheck(state)) { @@ -214,7 +215,7 @@ public static boolean shouldGrabBlock(Level parWorld, BlockState state) } if (ConfigTornado.Storm_Tornado_RefinedGrabRules) { - if (block == Blocks.DIRT || block == Blocks.COARSE_DIRT || block == Blocks.ROOTED_DIRT || block == Blocks.GRASS_BLOCK || block == Blocks.DIRT_PATH || block == Blocks.SAND || block == Blocks.RED_SAND || (block instanceof RotatedPillarBlock && state.getMaterial() == Material.WOOD)) { + if (block == Blocks.DIRT || block == Blocks.COARSE_DIRT || block == Blocks.ROOTED_DIRT || block == Blocks.GRASS_BLOCK || block == Blocks.DIRT_PATH || block == Blocks.SAND || block == Blocks.RED_SAND || (block instanceof RotatedPillarBlock && state.getBlock().defaultMapColor() == MapColor.WOOD)) { result = false; } if (!canTornadoGrabBlockRefinedRules(state)) { @@ -255,7 +256,7 @@ public static ServerLevel getWorld(ResourceKey levelResourceKey) { } public static boolean canTornadoGrabBlockRefinedRules(BlockState state) { - ResourceLocation registeredName = state.getBlock().getRegistryName(); + ResourceLocation registeredName = ForgeRegistries.BLOCKS.getKey(state.getBlock()); if (registeredName.getNamespace().equals("dynamictrees")) { if (registeredName.getPath().contains("rooty") || registeredName.getPath().contains("branch")) { return false; diff --git a/src/main/java/weather2/util/WeatherUtilBlock.java b/src/main/java/weather2/util/WeatherUtilBlock.java index 8d1170ed..be4ea499 100644 --- a/src/main/java/weather2/util/WeatherUtilBlock.java +++ b/src/main/java/weather2/util/WeatherUtilBlock.java @@ -11,7 +11,7 @@ import net.minecraft.world.level.block.SnowLayerBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.Heightmap; -import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MapColor; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.BooleanOp; @@ -122,12 +122,12 @@ public static void fillAgainstWallSmoothly(Level world, Vec3 posSource, float di }*/ //if solid ground we can place on - if (state.getMaterial() != Material.AIR && state.getMaterial() != Material.PLANT && + if (!state.isAir() && state.getBlock().defaultMapColor() == MapColor.PLANT && /*(!state.getBlock().isReplaceable(world, pos) && */collided) { BlockPos posUp = new BlockPos(x, y + 1, z); BlockState stateUp = world.getBlockState(posUp); //if above it is air - if (stateUp.getMaterial() == Material.AIR) { + if (stateUp.isAir()) { int height = getHeightForAnyBlock(state); //if height of block minus block we are on/comparing against is short enough, we can continue onto it @@ -186,7 +186,7 @@ public static void fillAgainstWallSmoothly(Level world, Vec3 posSource, float di BlockPos pos2 = CoroUtilBlock.blockPos(posLastNonWall.x, posLastNonWall.y, posLastNonWall.z); BlockState state2 = world.getBlockState(pos2); - if (state2.getMaterial() == Material.WATER || state2.getMaterial() == Material.LAVA) { + if (state2.getBlock().defaultMapColor() == MapColor.WATER || state2.getBlock().defaultMapColor() == MapColor.FIRE) { return; } @@ -213,7 +213,7 @@ public static int trySpreadOnPos2(Level world, BlockPos posSpreadTo, int amount, //must have clear air above first spots //TODO: might need special case so we can fill up a partially layered snow block - if (world.getBlockState(posSpreadTo.offset(0, 1, 0)).getMaterial() != Material.AIR) { + if (!world.getBlockState(posSpreadTo.offset(0, 1, 0)).isAir()) { return amount; } @@ -225,7 +225,7 @@ public static int trySpreadOnPos2(Level world, BlockPos posSpreadTo, int amount, int depth = 0; //find first non air - while (stateCheckNonAir.getMaterial() == Material.AIR) { + while (stateCheckNonAir.isAir()) { posCheckNonAir = posCheckNonAir.offset(0, -1, 0); stateCheckNonAir = world.getBlockState(posCheckNonAir); depth++; @@ -275,7 +275,7 @@ public static int trySpreadOnPos2(Level world, BlockPos posSpreadTo, int amount, //TODO: isReplaceable would require a fake player, see if we can avoid using isReplaceable, it let us place into things like grass? maybe? - if (stateCheckPlaceable.getBlock() != blockLayerable && /*stateCheckPlaceable.getBlock().isReplaceable(world, posCheckPlaceable) && */!collided && !stateCheckPlaceable.getMaterial().isLiquid()) { + if (stateCheckPlaceable.getBlock() != blockLayerable && /*stateCheckPlaceable.getBlock().isReplaceable(world, posCheckPlaceable) && */!collided && !stateCheckPlaceable.liquid()) { posCheckPlaceable = posCheckPlaceable.offset(0, -1, 0); stateCheckPlaceable = world.getBlockState(posCheckPlaceable); distForPlaceableBlocks++; @@ -320,7 +320,7 @@ public static int trySpreadOnPos2(Level world, BlockPos posSpreadTo, int amount, //just place while stuff to add and air above - while (amountAllowedToAdd > 0 && world.getBlockState(posPlaceLayerable.offset(0, 1, 0)).getMaterial() == Material.AIR) { + while (amountAllowedToAdd > 0 && world.getBlockState(posPlaceLayerable.offset(0, 1, 0)).isAir()) { //if no more layers to add if (amountAllowedToAdd <= 0) { break; @@ -356,7 +356,7 @@ public static int trySpreadOnPos2(Level world, BlockPos posSpreadTo, int amount, posPlaceLayerable = posPlaceLayerable.offset(0, 1, 0); statePlaceLayerable = world.getBlockState(posPlaceLayerable); //air - } else if (statePlaceLayerable.getMaterial() == Material.AIR) { + } else if (statePlaceLayerable.isAir()) { //copypasta, refactor/reduce once things work int height = amountAllowedToAdd; if (height > layerableHeightPropMax) { diff --git a/src/main/java/weather2/util/WeatherUtilDim.java b/src/main/java/weather2/util/WeatherUtilDim.java index d85a12d4..b64b0148 100644 --- a/src/main/java/weather2/util/WeatherUtilDim.java +++ b/src/main/java/weather2/util/WeatherUtilDim.java @@ -16,7 +16,7 @@ public static boolean canBlockSeeSky(Level world, BlockPos pos) { } else { for(BlockPos blockpos1 = blockpos.below(); blockpos1.getY() > pos.getY(); blockpos1 = blockpos1.below()) { BlockState blockstate = world.getBlockState(blockpos1); - if (blockstate.getLightBlock(world, blockpos1) > 0 && !blockstate.getMaterial().isLiquid()) { + if (blockstate.getLightBlock(world, blockpos1) > 0 && !blockstate.liquid()) { return false; } } diff --git a/src/main/java/weather2/weathersystem/WeatherManagerClient.java b/src/main/java/weather2/weathersystem/WeatherManagerClient.java index c1843edd..2cf1f390 100644 --- a/src/main/java/weather2/weathersystem/WeatherManagerClient.java +++ b/src/main/java/weather2/weathersystem/WeatherManagerClient.java @@ -1,10 +1,8 @@ package weather2.weathersystem; -import com.corosus.coroutil.util.CULog; -import extendedrenderer.particle.ParticleRegistry; import extendedrenderer.particle.entity.ParticleCube; import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtUtils; import net.minecraft.resources.ResourceKey; @@ -12,21 +10,18 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.ICloudRenderHandler; -import net.minecraftforge.client.IWeatherParticleRenderHandler; import weather2.ClientTickHandler; import weather2.Weather; import weather2.client.SceneEnhancer; -import weather2.client.shaderstest.Cloud; -import weather2.client.shaderstest.CloudManager; -import weather2.weathersystem.sky.CloudRenderHandler; -import weather2.weathersystem.sky.WeatherParticleRenderHandler; -import weather2.weathersystem.storm.*; +import weather2.weathersystem.storm.EnumWeatherObjectType; +import weather2.weathersystem.storm.StormObject; +import weather2.weathersystem.storm.WeatherObject; +import weather2.weathersystem.storm.WeatherObjectParticleStorm; @OnlyIn(Dist.CLIENT) public class WeatherManagerClient extends WeatherManager { - public CloudManager cloudManager = new CloudManager(); + //public CloudManager cloudManager = new CloudManager(); public WeatherManagerClient(ResourceKey dimension) { super(dimension); @@ -36,18 +31,19 @@ public WeatherManagerClient(ResourceKey dimension) { public void tick() { super.tick(); if (!Weather.isLoveTropicsInstalled()) { - ICloudRenderHandler cloudRenderHandler = ((ClientLevel) getWorld()).effects().getCloudRenderHandler(); + //TODO: disabled for 1.20, might need to go mixin from here + /*ICloudRenderHandler cloudRenderHandler = ((ClientLevel) getWorld()).effects().getCloudRenderHandler(); if (cloudRenderHandler == null) { ((ClientLevel) getWorld()).effects().setCloudRenderHandler(new CloudRenderHandler()); } IWeatherParticleRenderHandler handler = ((ClientLevel) getWorld()).effects().getWeatherParticleRenderHandler(); if (handler == null) { ((ClientLevel) getWorld()).effects().setWeatherParticleRenderHandler(new WeatherParticleRenderHandler()); - } + }*/ boolean cloudTest = false; if (cloudTest) { - cloudManager.tick(); + //cloudManager.tick(); } } //((ClientLevel)getWorld()).effects().setCloudRenderHandler(null); @@ -150,7 +146,7 @@ public void nbtSyncFromServer(CompoundTag parNBT) { int posY = nbt.getInt("posY") + 1; int posZ = nbt.getInt("posZ"); - BlockState state = NbtUtils.readBlockState(nbt.getCompound("blockstate")); + BlockState state = NbtUtils.readBlockState(getWorld().holderLookup(Registries.BLOCK), nbt.getCompound("blockstate")); long ownerID = nbt.getLong("ownerID"); diff --git a/src/main/java/weather2/weathersystem/WeatherManagerServer.java b/src/main/java/weather2/weathersystem/WeatherManagerServer.java index 43ea0396..56ef1be0 100644 --- a/src/main/java/weather2/weathersystem/WeatherManagerServer.java +++ b/src/main/java/weather2/weathersystem/WeatherManagerServer.java @@ -249,7 +249,8 @@ public void tick() { } } - public Optional findWeatherDeflector(ServerLevel level, BlockPos p_143249_, int range) { + //TODO: 1.20 + /*public Optional findWeatherDeflector(ServerLevel level, BlockPos p_143249_, int range) { Optional optional = level.getPoiManager().findClosest((p_184069_) -> { return p_184069_ == WeatherBlocks.POI_DEFLECTOR; }, (p_184055_) -> { @@ -258,7 +259,7 @@ public Optional findWeatherDeflector(ServerLevel level, BlockPos p_143 return optional.map((p_184053_) -> { return p_184053_.above(1); }); - } + }*/ public void tickStormBlockBuildup(StormState stormState, Block block) { Level world = getWorld(); @@ -634,7 +635,7 @@ public void syncStormNew(WeatherObject parStorm, @Nullable ServerPlayer entP) { if (entP == null) { WeatherNetworking.HANDLER.send(PacketDistributor.DIMENSION.with(() -> getWorld().dimension()), new PacketNBTFromServer(data)); } else { - WeatherNetworking.HANDLER.sendTo(new PacketNBTFromServer(data), entP.connection.getConnection(), NetworkDirection.PLAY_TO_CLIENT); + WeatherNetworking.HANDLER.sendTo(new PacketNBTFromServer(data), entP.connection.connection, NetworkDirection.PLAY_TO_CLIENT); } } diff --git a/src/main/java/weather2/weathersystem/sky/CloudRenderHandler.java b/src/main/java/weather2/weathersystem/sky/CloudRenderHandler.java deleted file mode 100644 index 7ca684cb..00000000 --- a/src/main/java/weather2/weathersystem/sky/CloudRenderHandler.java +++ /dev/null @@ -1,1257 +0,0 @@ -package weather2.weathersystem.sky; - -import com.mojang.blaze3d.platform.GlStateManager; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.*; -import com.mojang.math.Matrix4f; -import com.mojang.math.Quaternion; -import com.mojang.math.Vector3f; -import extendedrenderer.particle.ParticleRegistry; -import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.client.renderer.FogRenderer; -import net.minecraft.client.renderer.culling.Frustum; -import net.minecraft.client.renderer.texture.TextureAtlas; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.core.Direction; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.phys.Vec3; -import net.minecraftforge.client.ICloudRenderHandler; -import org.lwjgl.opengl.GL15; -import org.lwjgl.opengl.GL20; -import org.lwjgl.opengl.GL31; -import weather2.ClientTickHandler; -import weather2.client.shaders.ShaderInstanceExtended; -import weather2.client.shaders.VertexBufferInstanced; -import weather2.client.shaders.WeatherShaders; -import weather2.client.shaderstest.CloudPiece; -import weather2.client.shaderstest.InstancedMeshParticle; -import weather2.client.shaderstest.MeshBufferManagerParticle; -import weather2.client.shaderstest.Model; - -import java.util.Iterator; -import java.util.Map; -import java.util.Random; - -import static org.lwjgl.opengl.GL11.GL_TRIANGLES; -import static org.lwjgl.opengl.GL11.GL_UNSIGNED_INT; -import static org.lwjgl.opengl.GL15.GL_DYNAMIC_DRAW; - -public class CloudRenderHandler implements ICloudRenderHandler { - - private boolean cloudsNeedUpdate = true; - private VertexBufferInstanced cloudsVBOOld; - private VertexBufferInstanced cloudsVBO; - //private VertexBuffer cloudVBO; - - private int sphereIndex = 0; - - private Random rand = new Random(); - private Random rand2 = new Random(); - - private boolean mode_triangles = true; - public Frustum cullingFrustum; - - @Override - public void render(int ticks, float partialTicks, PoseStack matrixStackIn, ClientLevel world, Minecraft mc, double viewEntityX, double viewEntityY, double viewEntityZ) { - //dont use until interface is fixed to add projection matrix - //this.render(ticks, partialTicks, matrixStackIn, null, world, mc, viewEntityX, viewEntityY, viewEntityZ); - } - //PoseStack matrixStackIn, Matrix4f projectionMatrix, float p_172957_, double p_172958_, double viewEntityY, double p_172960_ - - //public void render(int ticks, float partialTicks, PoseStack matrixStackIn, Matrix4f projectionMatrix, ClientLevel world, Minecraft mc, double viewEntityX, double viewEntityY, double viewEntityZ) { - - public void prepareCullFrustum(PoseStack p_172962_, Vec3 p_172963_, Matrix4f p_172964_) { - Matrix4f matrix4f = p_172962_.last().pose(); - double d0 = p_172963_.x(); - double d1 = p_172963_.y(); - double d2 = p_172963_.z(); - this.cullingFrustum = new Frustum(matrix4f, p_172964_); - this.cullingFrustum.prepare(d0, d1, d2); - } - - public void renderNewShaderTest(PoseStack matrixStackIn, Matrix4f projectionMatrix, float partialTicks, double viewEntityX, double viewEntityY, double viewEntityZ) { - ClientLevel level = Minecraft.getInstance().level; - if (level == null) return; - - MeshBufferManagerParticle.setupMeshForParticleIfMissing(ParticleRegistry.cloud_square); - if (level.getGameTime() % 40 == 0) { - //MeshBufferManagerParticle.setupMeshForParticle(ParticleRegistry.cloud_square); - } - - prepareCullFrustum(matrixStackIn, Minecraft.getInstance().gameRenderer.getMainCamera().getPosition(), projectionMatrix); - - GL20.glUseProgram(WeatherShaders.getShaderExtended().getId()); - - InstancedMeshParticle mesh = MeshBufferManagerParticle.getMesh(ParticleRegistry.cloud_square); - - mesh.initRender(); - mesh.initRenderVBO1(); - - boolean updateBuffer = true; - //updateBuffer = false; - - int counter = 0; - /*while (ClientTickHandler.weatherManager.cloudManager.listCloudPieces.size() < 50000) { - CloudPiece cloudPiece = new CloudPiece(); - cloudPiece.index = counter; - cloudPiece.indexMax = 50000; - ClientTickHandler.weatherManager.cloudManager.listCloudPieces.add(cloudPiece); - counter++; - }*/ - - - - if (updateBuffer) { - - mesh.instanceDataBuffer.clear(); - mesh.curBufferPos = 0; - - counter = 0; - - /*Iterator> it = ClientTickHandler.weatherManager.cloudManager.getLookupPosToCloudPiece().entrySet().iterator(); - while (it.hasNext()) { - CloudPiece cloudPiece = it.next().getValue();*/ - for (CloudPiece cloudPiece : ClientTickHandler.weatherManager.cloudManager.listCloudPieces) { - matrixStackIn.pushPose(); - cloudPiece.renderParticleForShader(mesh, cullingFrustum, matrixStackIn.last().pose(), null, partialTicks, viewEntityX, viewEntityY, viewEntityZ); - matrixStackIn.popPose(); - //break; - counter++; - //if (counter > 25000) break; - //if (counter > 0) break; - } - - mesh.instanceDataBuffer.limit(mesh.curBufferPos * mesh.INSTANCE_SIZE_FLOATS); - } - - /*GlStateManager._glBindBuffer(GL_ARRAY_BUFFER, mesh.instanceDataVBO); - ShaderManager.glBufferData(GL_ARRAY_BUFFER, mesh.instanceDataBuffer, GL_DYNAMIC_DRAW);*/ - - GlStateManager._glBindBuffer(GL15.GL_ARRAY_BUFFER, mesh.instanceDataVBO); - if (updateBuffer) GL15.glBufferData(GL15.GL_ARRAY_BUFFER, mesh.instanceDataBuffer, GL_DYNAMIC_DRAW); - //GL15.glBufferSubData(GL15.GL_ARRAY_BUFFER, mesh.instanceDataBuffer, GL_DYNAMIC_DRAW); - - /*RenderSystem.colorMask(true, true, true, true); - RenderSystem.depthMask(true);*/ - GL31.glDrawElementsInstanced(GL_TRIANGLES, mesh.getVertexCount(), GL_UNSIGNED_INT, 0, mesh.curBufferPos); - /*RenderSystem.colorMask(false, false, false, false); - RenderSystem.depthMask(true); - GL31.glDrawElementsInstanced(GL_TRIANGLES, mesh.getVertexCount(), GL_UNSIGNED_INT, 0, mesh.curBufferPos); - RenderSystem.colorMask(true, true, true, true);*/ - - //GL31.glDrawElementsInstanced(GL_TRIANGLES, mesh.getVertexCount(), GL_UNSIGNED_INT, 0, 50000); - //GL31.glDrawArraysInstanced(GL_TRIANGLES, 0, mesh.getVertexCount(), mesh.curBufferPos); - - GlStateManager._glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); - - mesh.endRenderVBO1(); - //mesh.endRenderVBO2(); - mesh.endRender(); - } - - public void render(PoseStack matrixStackIn, Matrix4f projectionMatrix, float partialTicks, double viewEntityX, double viewEntityY, double viewEntityZ) { - if (true) return; - ClientLevel level = Minecraft.getInstance().level; - if (level == null) return; - int ticks = (int) level.getGameTime() % Integer.MAX_VALUE; - - mode_triangles = true; - - //RenderSystem.disableCull(); - RenderSystem.enableBlend(); - //RenderSystem.disableBlend(); - RenderSystem.enableDepthTest(); - //RenderSystem.disableDepthTest(); - RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); - RenderSystem.depthMask(true); - - //RenderSystem.setShader(WeatherShaders.CustomRenderTypes::getCloudShader); - - ShaderInstanceExtended shaderinstance = WeatherShaders.getShaderExtended(); - if (shaderinstance.CUSTOM_TIME != null) { - float smoothTicks = (ticks + partialTicks) * 0.005F; - shaderinstance.CUSTOM_TIME.set((float)(smoothTicks % 360)); - } - - RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_PARTICLES); - FogRenderer.levelFogColor(); - RenderSystem.colorMask(true, true, true, true); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - - //do things - - cloudsNeedUpdate = false; - - if (cloudsVBO == null || cloudsNeedUpdate || ticks % 40 == 0) { - - this.cloudsNeedUpdate = false; - if (this.cloudsVBO != null) { - this.cloudsVBO.close(); - } - - this.cloudsVBO = new VertexBufferInstanced(); - - Player player = Minecraft.getInstance().player; - double playerX = player.getX();// - ((player.getPosX() - player.prevPosX) * partialTicks); - //playerX = (MathHelper.lerp(partialTicks, player.prevPosX, player.getPosX()) - player.getPosX()); - double playerY = player.getY(); - double playerZ = player.getZ(); - //playerZ = (MathHelper.lerp(partialTicks, player.prevPosZ, player.getPosZ()) - player.getPosZ()); - - double x = 5911 - (playerX); - double y = 250 - viewEntityY + 0.001; - double z = 6972 - (playerZ); - - x = 336 - (playerX); - y = 128 - viewEntityY + 0.001; - z = -50 - (playerZ); - - x = 0; - y = 0; - z = 0; - - rand = new Random(33); - rand2 = new Random(33); - - double scalecluster = 4.0; - - int randRangeY = 40; - int randRange = (int) (250 * scalecluster); - - int randRangeY2 = (int) (16 * scalecluster); - int randRange2 = (int) (50 * scalecluster); - - int clusters = 50; - int clusterDensity = (int) (75 * scalecluster); - - clusters = 1; - clusterDensity = 1; - - //bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR_NORMAL); - - //this.cloudsVBO.bind(); - //DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL.setupBufferState(); - - BufferBuilder bufferbuilder = Tesselator.getInstance().getBuilder(); - if (mode_triangles) { - bufferbuilder.begin(VertexFormat.Mode.TRIANGLES, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL); - } else { - bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL); - } - - RenderSystem.colorMask(true, true, true, true); - - sphereIndex = 0; - - for (int i = 0; i < clusters; i++) { - double xx = rand.nextInt(randRange) - rand.nextInt(randRange); - double yy = rand.nextInt(randRangeY) - rand.nextInt(randRangeY); - double zz = rand.nextInt(randRange) - rand.nextInt(randRange); - - float index = 0; - float indexMax = 50; - float tickShift = (((float)ticks * 0.05F)) % indexMax; - for (int ii = 0; ii < clusterDensity; ii++) { - double xxx = rand.nextInt(randRange2) - rand.nextInt(randRange2); - //double yyy = rand.nextInt(randRangeY2)/* - rand.nextInt(randRangeY2)*/; - double yyy = rand.nextInt(randRange2) - rand.nextInt(1); - //double yyy = rand.nextInt(randRange2); - double zzz = rand.nextInt(randRange2) - rand.nextInt(randRange2); - - double subX = xxx+xx; - double subY = yyy+yy; - double subZ = zzz+zz; - - double snapResPos = 30; - /*subX = Math.round(subX * snapResPos) / snapResPos; - subY = Math.round(subY * snapResPos) / snapResPos; - subZ = Math.round(subZ * snapResPos) / snapResPos;*/ - subX = Math.round(subX / snapResPos) * snapResPos; - subY = Math.round(subY / snapResPos) * snapResPos; - subZ = Math.round(subZ / snapResPos) * snapResPos; - - double vecX = (subX) - xx; - double vecY = (subY) - yy; - double vecZ = (subZ) - zz; - double dist = Math.sqrt(vecX * vecX + vecY * vecY + vecZ * vecZ); - double distPct = Math.max(1D - (dist / randRange2), 0.3D); - - //snap the scaling to specific sizes - double snapResScale = 4; - distPct = Math.round(distPct * snapResScale) / snapResScale; - //distPct = Math.round(distPct / snapResScale) * snapResScale; - //distPct = 0.3; - - double r = 0.8 + rand.nextDouble() * 0.2; - r = 0.97 + (yyy / (randRangeY2 * 2)) * 0.03; - r = 0.9; - //r += rand.nextFloat() * 0.03F; - r += rand.nextFloat() * 0.08F; - r = Math.min(1F, r); - //double g = 0.8 + rand.nextDouble() * 0.2; - //double b = 0.8 + rand.nextDouble() * 0.2; - float scale = (float)((index*1F + tickShift) % indexMax) / (float)indexMax; - if (scale > 0.5F) { - scale = 0.5F - (scale-0.5F); - } - scale *= 5F; - - scale = (float) (30F * (distPct)); - - //z fix - scale += rand.nextFloat() * 0.1F; - - //cut off the lil stragglers for our current formula - if (dist > randRange2 / 2.2) { - scale = 0; - } - - - //renderSphere(bufferbuilder, x + xx + xxx, y + 10 + yy + yyy, z + zz + zzz, new Vector3d(r, r, r), scale); - - //matrixStackIn.pushPose(); - //matrixStackIn.translate(x + xx + xxx, y + 10 + yy + yyy, z + zz + zzz); - /*if (index % 2 == 0) matrixStackIn.mulPose(Vector3f.ZP.rotationDegrees(((index + tickShift) * 2) % 3600)); - if (index % 3 == 0) matrixStackIn.mulPose(Vector3f.YP.rotationDegrees(((index + tickShift) * 5) % 3600)); - if (index % 5 == 0) matrixStackIn.mulPose(Vector3f.XP.rotationDegrees(((index + tickShift) * 7) % 3600));*/ - //matrixStackIn.scale(scale, scale, scale); - - //this.cloudsVBO.draw(matrixStackIn.last().pose(), GL11.GL_QUADS); - //ShaderInstance shaderinstance = RenderSystem.getShader(); - - //matrixStackIn.popPose(); - - //if (scale > 0) renderSphere(bufferbuilder, x + subX, y + 10 + subY, z + subZ, new Vec3(r * 0.9F, r * 0.9F, r * 0.9F), 0.5F); - //renderSphere(bufferbuilder, 0, 0, 0, new Vec3(r * 0.9F, r * 0.9F, r * 0.9F), 0.5F); - renderSphere(bufferbuilder, 0, 0, 0, new Vec3(r * 0.9F, r * 0.9F, r * 0.9F), 0.05F); - //if (scale > 0) renderSphere(bufferbuilder, x + subX, y + 10 + subY, z + subZ, new Vec3(r * 0.9F, r * 0.9F, r * 0.9F), 0.49F); - //renderSphere(bufferbuilder, x + subX, y + 10 + subY, z + subZ, new Vec3(r, r, r), scale * 0.03F); - //renderCube(bufferbuilder, x + subX, y + 10 + subY, z + subZ, new Vec3(r, r, r), scale); - //renderCube(bufferbuilder, x + subX, y + 10 + subY, z + subZ, new Vec3(r, r, r), 0); - index++; - sphereIndex++; - } - } - - bufferbuilder.end(); - this.cloudsVBO.upload(bufferbuilder); - } - - matrixStackIn.pushPose();/* - double playerX = player.getX(); - double playerY = player.getY(); - double playerZ = player.getZ();*/ - double x = 336 - (viewEntityX); - double y = 220 - viewEntityY + 0.001; - double z = -50 - (viewEntityZ); - //matrixStackIn.translate(x, y, z); - matrixStackIn.translate(0, 0, 0); - //matrixStackIn.translate(0, 40, 0); - this.cloudsVBO._drawWithShaderDummyStart(matrixStackIn.last().pose(), projectionMatrix, shaderinstance); - - - //matrixStackIn.popPose(); - - //matrixStackIn.pushPose(); - //matrixStackIn.translate(0, 130, 0); - //matrixStackIn.translate(0, 30, 0); - renderNewShaderTest(matrixStackIn, projectionMatrix, partialTicks, viewEntityX, viewEntityY, viewEntityZ); - matrixStackIn.popPose(); - - //if (true) return; - - //RenderSystem.disableAlphaTest(); - RenderSystem.enableCull(); - RenderSystem.disableBlend(); - } - - public void renderOld(PoseStack matrixStackIn, Matrix4f projectionMatrix, float p_172957_, double p_172958_, double viewEntityY, double p_172960_) { - - ClientLevel level = Minecraft.getInstance().level; - if (level == null) return; - int ticks = (int) level.getGameTime() % Integer.MAX_VALUE; - - boolean customShader = true; - - int method = 3; - if (method == 3) { - - RenderSystem.disableCull(); - RenderSystem.enableBlend(); - RenderSystem.enableDepthTest(); - RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); - RenderSystem.depthMask(true); - //RenderSystem.enableFog(); - BufferBuilder buffer = Tesselator.getInstance().getBuilder(); - - //Minecraft.getInstance().getTextureManager().bindForSetup(TextureAtlas.LOCATION_PARTICLES); - /*if (!customShader) { - RenderSystem.setShader(GameRenderer::getPositionTexColorNormalShader); - } else { - RenderSystem.setShader(WeatherShaders.CustomRenderTypes::getCloudShader); - }*/ - - ShaderInstanceExtended shaderinstance = WeatherShaders.getShaderExtended(); - if (shaderinstance.CUSTOM_TIME != null) { - shaderinstance.CUSTOM_TIME.set(2F); - } - - RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_PARTICLES); - //WeatherShaders.clouds(TextureAtlas.LOCATION_PARTICLES); - - FogRenderer.levelFogColor(); - //GlStateManager.disableTexture(); - - //this.cloudsNeedUpdate = true; - BufferBuilder bufferbuilder = Tesselator.getInstance().getBuilder(); - - boolean force = true; - - /*if (this.cloudVBO == null || force) { - if (this.cloudVBO != null) { - this.cloudVBO.close(); - } - this.cloudVBO = new VertexBuffer(); - bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL); - renderSphere(bufferbuilder, 0, 0, 0, new Vec3(1, 1, 1), 0.1F); - bufferbuilder.end(); - this.cloudVBO.upload(bufferbuilder); - }*/ - - boolean uhh = true; - this.cloudsNeedUpdate = true; - - if (uhh && this.cloudsNeedUpdate) { - this.cloudsNeedUpdate = false; - if (this.cloudsVBOOld != null) { - this.cloudsVBOOld.close(); - } - - this.cloudsVBOOld = new VertexBufferInstanced(); - - //this.drawClouds(bufferbuilder, d2, d3, d4, vector3d); - Player player = Minecraft.getInstance().player; - double playerX = player.getX();// - ((player.getPosX() - player.prevPosX) * partialTicks); - //playerX = (MathHelper.lerp(partialTicks, player.prevPosX, player.getPosX()) - player.getPosX()); - double playerY = player.getY(); - double playerZ = player.getZ(); - //playerZ = (MathHelper.lerp(partialTicks, player.prevPosZ, player.getPosZ()) - player.getPosZ()); - - double x = 5911 - (playerX); - double y = 128 - viewEntityY + 0.001; - double z = 6972 - (playerZ); - - Random rand = new Random(3); - - int randRangeY = 40; - int randRange = 250; - - int randRangeY2 = 16; - int randRange2 = 20; - - int clusters = 50; - int clusterDensity = 50; - - /*if (!customShader) { - RenderSystem.setShader(GameRenderer::getPositionTexColorNormalShader); - } else { - RenderSystem.setShader(WeatherShaders.CustomRenderTypes::getCloudShader); - }*/ - bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL); - - for (int i = 0; i < 1; i++) { - double xx = rand.nextInt(randRange) - rand.nextInt(randRange); - double yy = rand.nextInt(randRangeY) - rand.nextInt(randRangeY); - double zz = rand.nextInt(randRange) - rand.nextInt(randRange); - - float index = 0; - float indexMax = clusters; - float tickShift = (((float)ticks * 0.05F)) % indexMax; - for (int ii = 0; ii < 1; ii++) { - double xxx = rand.nextInt(randRange2) - rand.nextInt(randRange2); - double yyy = rand.nextInt(randRangeY2) - rand.nextInt(randRangeY2); - double zzz = rand.nextInt(randRange2) - rand.nextInt(randRange2); - double r = 0.8 + rand.nextDouble() * 0.2; - r = 0.7 + (yyy / (randRangeY2 * 2)) * 0.3; - r = 0.8; - //double g = 0.8 + rand.nextDouble() * 0.2; - //double b = 0.8 + rand.nextDouble() * 0.2; - float scale = (float)((index*1F + tickShift) % indexMax) / (float)indexMax; - //renderSphere(bufferbuilder, x + xx + xxx, y + 10 + yy + yyy, z + zz + zzz, new Vector3d(r, r, r), scale); - renderSphere(bufferbuilder, 0, 0, 0, new Vec3(r, r, r), 0.3F); - index++; - } - } - - bufferbuilder.end(); - this.cloudsVBOOld.upload(bufferbuilder); - } - - /*if (!customShader) { - RenderSystem.setShader(GameRenderer::getPositionTexColorNormalShader); - } else { - RenderSystem.setShader(WeatherShaders.CustomRenderTypes::getCloudShader); - }*/ - RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_PARTICLES); - //WeatherShaders.clouds(TextureAtlas.LOCATION_PARTICLES); - FogRenderer.levelFogColor(); - - /*matrixStackIn.push();*/ - //matrixStackIn.scale(12.0F, 1.0F, 12.0F); - //matrixStackIn.translate((double)(-f3), (double)f4, (double)(-f5)); - if (this.cloudsVBOOld != null && uhh && false) { - /*this.cloudsVBO.bind(); - DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL.setupBufferState(0L); - - this.cloudsVBO.draw(matrixStackIn.last().pose(), GL11.GL_QUADS); - - VertexBuffer.unbind(); - DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL.clearBufferState();*/ - - RenderSystem.colorMask(true, true, true, true); - - //ShaderInstance shaderinstance = RenderSystem.getShader(); - this.cloudsVBOOld.drawWithShader(matrixStackIn.last().pose(), projectionMatrix, shaderinstance); - } - - /*matrixStackIn.pop(); - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - RenderSystem.disableAlphaTest(); - RenderSystem.enableCull(); - RenderSystem.disableBlend(); - RenderSystem.disableFog();*/ - - boolean vboEachCloud = true; - - if (vboEachCloud) { - Player player = Minecraft.getInstance().player; - double playerX = player.getX();// - ((player.getPosX() - player.prevPosX) * partialTicks); - //playerX = (MathHelper.lerp(partialTicks, player.prevPosX, player.getPosX()) - player.getPosX()); - double playerY = player.getY(); - double playerZ = player.getZ(); - //playerZ = (MathHelper.lerp(partialTicks, player.prevPosZ, player.getPosZ()) - player.getPosZ()); - - double x = 5911 - (playerX); - double y = 250 - viewEntityY + 0.001; - double z = 6972 - (playerZ); - - x = 336 - (playerX); - y = 128 - viewEntityY + 0.001; - z = -50 - (playerZ); - - Random rand = new Random(3); - - int randRangeY = 40; - int randRange = 250; - - int randRangeY2 = 16; - int randRange2 = 20; - - int clusters = 50; - int clusterDensity = 50; - - //bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR_NORMAL); - - //this.cloudsVBO.bind(); - //DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL.setupBufferState(); - - RenderSystem.colorMask(true, true, true, true); - - for (int i = 0; i < clusters; i++) { - double xx = rand.nextInt(randRange) - rand.nextInt(randRange); - double yy = rand.nextInt(randRangeY) - rand.nextInt(randRangeY); - double zz = rand.nextInt(randRange) - rand.nextInt(randRange); - - float index = 0; - float indexMax = 50; - float tickShift = (((float)ticks * 0.05F)) % indexMax; - for (int ii = 0; ii < clusterDensity; ii++) { - double xxx = rand.nextInt(randRange2) - rand.nextInt(randRange2); - double yyy = rand.nextInt(randRangeY2)/* - rand.nextInt(randRangeY2)*/; - double zzz = rand.nextInt(randRange2) - rand.nextInt(randRange2); - double r = 0.8 + rand.nextDouble() * 0.2; - r = 0.7 + (yyy / (randRangeY2 * 2)) * 0.3; - //double g = 0.8 + rand.nextDouble() * 0.2; - //double b = 0.8 + rand.nextDouble() * 0.2; - float scale = (float)((index*1F + tickShift) % indexMax) / (float)indexMax; - if (scale > 0.5F) { - scale = 0.5F - (scale-0.5F); - } - scale *= 2F; - //renderSphere(bufferbuilder, x + xx + xxx, y + 10 + yy + yyy, z + zz + zzz, new Vector3d(r, r, r), scale); - - matrixStackIn.pushPose(); - matrixStackIn.translate(x + xx + xxx, y + 10 + yy + yyy, z + zz + zzz); - /*if (index % 2 == 0) matrixStackIn.mulPose(Vector3f.ZP.rotationDegrees(((index + tickShift) * 2) % 3600)); - if (index % 3 == 0) matrixStackIn.mulPose(Vector3f.YP.rotationDegrees(((index + tickShift) * 5) % 3600)); - if (index % 5 == 0) matrixStackIn.mulPose(Vector3f.XP.rotationDegrees(((index + tickShift) * 7) % 3600));*/ - matrixStackIn.scale(scale, scale, scale); - - //this.cloudsVBO.draw(matrixStackIn.last().pose(), GL11.GL_QUADS); - //ShaderInstance shaderinstance = RenderSystem.getShader(); - this.cloudsVBOOld.drawWithShader(matrixStackIn.last().pose(), projectionMatrix, shaderinstance); - - matrixStackIn.popPose(); - - index++; - } - } - - //VertexBuffer.unbind(); - //DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL.clearBufferState(); - - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - //RenderSystem.disableAlphaTest(); - RenderSystem.enableCull(); - RenderSystem.disableBlend(); - //RenderSystem.disableFog(); - } - } - } - - private void renderCube(BufferBuilder bufferIn, double cloudsX, double cloudsY, double cloudsZ, Vec3 cloudsColor, float scale) { - Random rand = rand2; - - Quaternion q2 = new Quaternion(0, 0, 0, 1); - int range = 5; - range = 180; - q2.mul(Vector3f.XP.rotationDegrees(rand.nextInt(range))); - q2.mul(Vector3f.YP.rotationDegrees(rand.nextInt(range))); - //q2.mul(Vector3f.YP.rotationDegrees(rand.nextInt(45))); - q2.mul(Vector3f.ZP.rotationDegrees(rand.nextInt(range))); - - boolean randRotate = false; - - for (Direction dir : Direction.values()) { - Quaternion quaternion = dir.getRotation(); - - Vector3f[] avector3f3 = new Vector3f[]{ - new Vector3f(-1.0F, 0.0F, -1.0F), - new Vector3f(-1.0F, 0.0F, 1.0F), - new Vector3f(1.0F, 0.0F, 1.0F), - new Vector3f(1.0F, 0.0F, -1.0F)}; - - - Vector3f normal = new Vector3f(dir.getNormal().getX(), dir.getNormal().getY(), dir.getNormal().getZ()); - if (randRotate) normal.transform(q2); - float normalRange = 0.1F; - normal.mul(normalRange); - //normal.add(1-normalRange, 1-normalRange, 1-normalRange); - float uh = 0.55F; - normal.add(uh, uh, uh); - - for(int i = 0; i < 4; ++i) { - Vector3f vector3f = avector3f3[i]; - vector3f.transform(quaternion); - vector3f.add((float) dir.getStepX(), (float) dir.getStepY(), (float) dir.getStepZ()); - if (randRotate) vector3f.transform(q2); - vector3f.mul(scale); - vector3f.add((float) cloudsX + 0.5F, (float) cloudsY, (float) cloudsZ + 0.5F); - } - - TextureAtlasSprite sprite = ParticleRegistry.cloud_square; - - float f7 = sprite.getU0(); - float f8 = sprite.getU1(); - float f5 = sprite.getV0(); - float f6 = sprite.getV1(); - - - float particleRed = (float) cloudsColor.x; - float particleGreen = (float) cloudsColor.y; - float particleBlue = (float) cloudsColor.z; - float particleAlpha = 1; - - if (mode_triangles) { - bufferIn.vertex(avector3f3[0].x(), avector3f3[0].y(), avector3f3[0].z()).uv(f8, f6).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(normal.x(), normal.y(), normal.z()).endVertex(); - bufferIn.vertex(avector3f3[3].x(), avector3f3[3].y(), avector3f3[3].z()).uv(f7, f6).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(normal.x(), normal.y(), normal.z()).endVertex(); - bufferIn.vertex(avector3f3[1].x(), avector3f3[1].y(), avector3f3[1].z()).uv(f8, f5).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(normal.x(), normal.y(), normal.z()).endVertex(); - - bufferIn.vertex(avector3f3[3].x(), avector3f3[3].y(), avector3f3[3].z()).uv(f7, f6).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(normal.x(), normal.y(), normal.z()).endVertex(); - bufferIn.vertex(avector3f3[1].x(), avector3f3[1].y(), avector3f3[1].z()).uv(f8, f5).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(normal.x(), normal.y(), normal.z()).endVertex(); - bufferIn.vertex(avector3f3[2].x(), avector3f3[2].y(), avector3f3[2].z()).uv(f7, f5).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(normal.x(), normal.y(), normal.z()).endVertex(); - } else { - bufferIn.vertex(avector3f3[0].x(), avector3f3[0].y(), avector3f3[0].z()).uv(f8, f6).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(normal.x(), normal.y(), normal.z()).endVertex(); - bufferIn.vertex(avector3f3[1].x(), avector3f3[1].y(), avector3f3[1].z()).uv(f8, f5).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(normal.x(), normal.y(), normal.z()).endVertex(); - bufferIn.vertex(avector3f3[2].x(), avector3f3[2].y(), avector3f3[2].z()).uv(f7, f5).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(normal.x(), normal.y(), normal.z()).endVertex(); - bufferIn.vertex(avector3f3[3].x(), avector3f3[3].y(), avector3f3[3].z()).uv(f7, f6).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(normal.x(), normal.y(), normal.z()).endVertex(); - } - - } - - } - - private void renderSphere(BufferBuilder bufferIn, double cloudsX, double cloudsY, double cloudsZ, Vec3 cloudsColor, float scale) { - TextureAtlasSprite sprite = ParticleRegistry.cloud_square; - - float f7 = sprite.getU0(); - float f8 = sprite.getU1(); - float f5 = sprite.getV0(); - float f6 = sprite.getV1(); - - float uRange = f8 - f7; - float yRange = f6 - f5; - - float particleRed = (float) cloudsColor.x; - float particleGreen = (float) cloudsColor.y; - float particleBlue = (float) cloudsColor.z; - float particleAlpha = 1; - - boolean alt = false; - Random rand = new Random(555); - - int nSegments = 6; - int nSlices = 6; - float radius = 30; - - int iter = 0; - int iter2 = 0; - - float lengthInv = 1.0f / radius; - - rand = new Random(555); - - String verts = ""; - boolean outputVerts = false; - - for (double slice = 1.0; slice <= nSlices/* && iter <= 100*/; slice += 1.0) { - double lat0 = Math.PI * (((slice - 1) / nSlices) - 0.5); - double z0 = Math.sin(lat0); - double zr0 = Math.cos(lat0); - - double lat1 = Math.PI * ((slice / nSlices) - 0.5); - double z1 = Math.sin(lat1); - double zr1 = Math.cos(lat1); - - //glBegin(GL_QUADS); - //bufferIn.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); - - for (double segment = 0.0; segment < nSegments/* && iter2 <= 408*/; segment += 1.0) { - double long0 = 2 * Math.PI * ((segment -1 ) / nSegments); - double x0 = Math.cos(long0); - double y0 = Math.sin(long0); - - double long1 = 2 * Math.PI * (segment / nSegments); - double x1 = Math.cos(long1); - double y1 = Math.sin(long1); - - /*glVertex3f(x0 * zr0, y0 * zr0, z0); - glVertex3f(x1 * zr1, y1 * zr1, z0); - glVertex3f(x0 * zr0, y0 * zr0, z1); - glVertex3f(x1 * zr1, y1 * zr1, z1);*/ - - /*bufferIn.pos(x0 * zr0 * radius + cloudsX, y0 * zr0 * radius + cloudsY, z0 * radius + cloudsZ).tex(f8, f6).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(1, 1, 1).endVertex();; - bufferIn.pos(x1 * zr1 * radius + cloudsX, y1 * zr1 * radius + cloudsY, z0 * radius + cloudsZ).tex(f8, f5).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(1, 1, 1).endVertex(); - bufferIn.pos(x0 * zr0 * radius + cloudsX, y0 * zr0 * radius + cloudsY, z1 * radius + cloudsZ).tex(f7, f5).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(1, 1, 1).endVertex(); - bufferIn.pos(x1 * zr1 * radius + cloudsX, y1 * zr1 * radius + cloudsY, z1 * radius + cloudsZ).tex(f7, f6).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(1, 1, 1).endVertex();*/ - - /*particleRed = rand.nextFloat(); - particleGreen = rand.nextFloat(); - particleBlue = rand.nextFloat();*/ - particleAlpha = 1F; - float radius2 = radius; - if (scale > 0.5F) { - float scale2 = (1F - scale) * 2F; - radius2 = radius * scale2;//(1F - scale2); - //particleAlpha = scale2; - } else { - radius2 = radius * scale * 2F; - } - - //particleAlpha = 0.9F; - - float n1 = 1; - float n2 = 1; - float n3 = 1; - - double x = x1 * zr0 * radius2; - double y = y1 * zr0 * radius2; - double z = z0 * radius2; - - float randAmt = 2F; - /*double randX = (rand.nextFloat() - rand.nextFloat()) * randAmt; - double randY = (rand.nextFloat() - rand.nextFloat()) * randAmt; - double randZ = (rand.nextFloat() - rand.nextFloat()) * randAmt;*/ - - - float extraLight = 0.3F; - - n1 = (float) (x * lengthInv) * extraLight + (1F-extraLight); - n2 = (float) (y * lengthInv) * extraLight + (1F-extraLight); - n3 = (float) (z * lengthInv) * extraLight + (1F-extraLight); - - if (mode_triangles) { - /** render shape - * . . - * . - */ - bufferIn.vertex(x1 * zr0 * radius2 + ((new Random((long) (x1 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX, y1 * zr0 * radius2 + ((new Random((long) (y1 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY, z0 * radius2 + ((new Random((long) (z0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ).uv(f7, f5).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(n1, n2, n3).endVertex(); - bufferIn.vertex(x1 * zr1 * radius2 + ((new Random((long) (x1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX, y1 * zr1 * radius2 + ((new Random((long) (y1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY, z1 * radius2 + ((new Random((long) (z1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ).uv(f7, f6).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(n1, n2, n3).endVertex(); - bufferIn.vertex(x0 * zr0 * radius2 + ((new Random((long) (x0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX, y0 * zr0 * radius2 + ((new Random((long) (y0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY, z0 * radius2 + ((new Random((long) (z0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ).uv(f8, f6).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(n1, n2, n3).endVertex();; - - if (outputVerts) { - verts += x1 * zr0 * radius2 + ((new Random((long) (x1 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX + "F,"; - verts += y1 * zr0 * radius2 + ((new Random((long) (y1 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY + "F,"; - verts += z0 * radius2 + ((new Random((long) (z0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ + "F," - + System.getProperty("line.separator"); - - verts += x1 * zr1 * radius2 + ((new Random((long) (x1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX + "F,"; - verts += y1 * zr1 * radius2 + ((new Random((long) (y1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY + "F,"; - verts += z1 * radius2 + ((new Random((long) (z1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ + "F," - + System.getProperty("line.separator"); - - verts += x0 * zr0 * radius2 + ((new Random((long) (x0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX + "F,"; - verts += y0 * zr0 * radius2 + ((new Random((long) (y0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY + "F,"; - verts += z0 * radius2 + ((new Random((long) (z0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ + "F," - + System.getProperty("line.separator"); - } - - /** render shape - * . - * . . - */ - bufferIn.vertex( - x1 * zr1 * radius2 + ((new Random((long) (x1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX, - y1 * zr1 * radius2 + ((new Random((long) (y1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY, - z1 * radius2 + ((new Random((long) (z1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ) - .uv(f7, f6).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(n1, n2, n3).endVertex(); - - bufferIn.vertex( - x0 * zr0 * radius2 + ((new Random((long) (x0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX, - y0 * zr0 * radius2 + ((new Random((long) (y0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY, - z0 * radius2 + ((new Random((long) (z0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ) - .uv(f8, f6).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(n1, n2, n3).endVertex();; - - bufferIn.vertex(x0 * zr1 * radius2 + ((new Random((long) (x0 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX, - y0 * zr1 * radius2 + ((new Random((long) (y0 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY, - z1 * radius2 + ((new Random((long) (z1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ) - .uv(f8, f5).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(n1, n2, n3).endVertex(); - - if (outputVerts) { - verts += x1 * zr1 * radius2 + ((new Random((long) (x1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX + "F,"; - verts += y1 * zr1 * radius2 + ((new Random((long) (y1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY + "F,"; - verts += z1 * radius2 + ((new Random((long) (z1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ + "F," - + System.getProperty("line.separator"); - - verts += x0 * zr0 * radius2 + ((new Random((long) (x0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX + "F,"; - verts += y0 * zr0 * radius2 + ((new Random((long) (y0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY + "F,"; - verts += z0 * radius2 + ((new Random((long) (z0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ + "F," - + System.getProperty("line.separator"); - - verts += x0 * zr1 * radius2 + ((new Random((long) (x0 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX + "F,"; - verts += y0 * zr1 * radius2 + ((new Random((long) (y0 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY + "F,"; - verts += z1 * radius2 + ((new Random((long) (z1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ + "F," - + System.getProperty("line.separator"); - } - - } else { - // render shape = U ? - bufferIn.vertex(x1 * zr0 * radius2 + ((new Random((long) (x1 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX, y1 * zr0 * radius2 + ((new Random((long) (y1 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY, z0 * radius2 + ((new Random((long) (z0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ).uv(f7, f5).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(n1, n2, n3).endVertex(); - bufferIn.vertex(x0 * zr0 * radius2 + ((new Random((long) (x0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX, y0 * zr0 * radius2 + ((new Random((long) (y0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY, z0 * radius2 + ((new Random((long) (z0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ).uv(f8, f6).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(n1, n2, n3).endVertex();; - bufferIn.vertex(x0 * zr1 * radius2 + ((new Random((long) (x0 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX, y0 * zr1 * radius2 + ((new Random((long) (y0 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY, z1 * radius2 + ((new Random((long) (z1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ).uv(f8, f5).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(n1, n2, n3).endVertex(); - bufferIn.vertex(x1 * zr1 * radius2 + ((new Random((long) (x1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX, y1 * zr1 * radius2 + ((new Random((long) (y1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY, z1 * radius2 + ((new Random((long) (z1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ).uv(f7, f6).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(n1, n2, n3).endVertex(); - } - - - - iter2++; - } - - /*Tessellator tessellator = Tessellator.getInstance(); - tessellator.draw();*/ - - iter++; - - //glEnd(); - } - - if (outputVerts) { - System.out.println("VERTS:"); - System.out.println(verts); - } - } - - public static Model renderSphere(double cloudsX, double cloudsY, double cloudsZ, Vec3 cloudsColor, float scale) { - TextureAtlasSprite sprite = ParticleRegistry.cloud_square; - - int sphereIndex = 0; - boolean mode_triangles = true; - - float f7 = sprite.getU0(); - float f8 = sprite.getU1(); - float f5 = sprite.getV0(); - float f6 = sprite.getV1(); - - float uRange = f8 - f7; - float yRange = f6 - f5; - - float particleRed = (float) cloudsColor.x; - float particleGreen = (float) cloudsColor.y; - float particleBlue = (float) cloudsColor.z; - float particleAlpha = 1; - - boolean alt = false; - Random rand = new Random(555); - - int nSegments = 6; - int nSlices = 6; - - nSegments = 4; - nSlices = 4; - - float radius = 10; - - int iter = 0; - int iter2 = 0; - - float lengthInv = 1.0f / radius; - - rand = new Random(555); - - String verts = ""; - boolean outputVerts = false; - - Model model = new Model(); - - for (double slice = 1.0; slice <= nSlices/* && iter <= 100*/; slice += 1.0) { - double lat0 = Math.PI * (((slice - 1) / nSlices) - 0.5); - double z0 = Math.sin(lat0); - double zr0 = Math.cos(lat0); - - double lat1 = Math.PI * ((slice / nSlices) - 0.5); - double z1 = Math.sin(lat1); - double zr1 = Math.cos(lat1); - - //glBegin(GL_QUADS); - //bufferIn.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); - - for (double segment = 0.0; segment < nSegments/* && iter2 <= 408*/; segment += 1.0) { - double long0 = 2 * Math.PI * ((segment -1 ) / nSegments); - double x0 = Math.cos(long0); - double y0 = Math.sin(long0); - - double long1 = 2 * Math.PI * (segment / nSegments); - double x1 = Math.cos(long1); - double y1 = Math.sin(long1); - - /*glVertex3f(x0 * zr0, y0 * zr0, z0); - glVertex3f(x1 * zr1, y1 * zr1, z0); - glVertex3f(x0 * zr0, y0 * zr0, z1); - glVertex3f(x1 * zr1, y1 * zr1, z1);*/ - - /*bufferIn.pos(x0 * zr0 * radius + cloudsX, y0 * zr0 * radius + cloudsY, z0 * radius + cloudsZ).tex(f8, f6).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(1, 1, 1).endVertex();; - bufferIn.pos(x1 * zr1 * radius + cloudsX, y1 * zr1 * radius + cloudsY, z0 * radius + cloudsZ).tex(f8, f5).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(1, 1, 1).endVertex(); - bufferIn.pos(x0 * zr0 * radius + cloudsX, y0 * zr0 * radius + cloudsY, z1 * radius + cloudsZ).tex(f7, f5).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(1, 1, 1).endVertex(); - bufferIn.pos(x1 * zr1 * radius + cloudsX, y1 * zr1 * radius + cloudsY, z1 * radius + cloudsZ).tex(f7, f6).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(1, 1, 1).endVertex();*/ - - /*particleRed = rand.nextFloat(); - particleGreen = rand.nextFloat(); - particleBlue = rand.nextFloat();*/ - particleAlpha = 1F; - float radius2 = radius; - if (scale > 0.5F) { - float scale2 = (1F - scale) * 2F; - radius2 = radius * scale2;//(1F - scale2); - //particleAlpha = scale2; - } else { - radius2 = radius * scale * 2F; - } - - //particleAlpha = 0.9F; - - float n1 = 1; - float n2 = 1; - float n3 = 1; - - double x = x1 * zr0 * radius2; - double y = y1 * zr0 * radius2; - double z = z0 * radius2; - - float randAmt = 2F; - randAmt = 1F; - /*double randX = (rand.nextFloat() - rand.nextFloat()) * randAmt; - double randY = (rand.nextFloat() - rand.nextFloat()) * randAmt; - double randZ = (rand.nextFloat() - rand.nextFloat()) * randAmt;*/ - - - float extraLight = 0.3F; - - n1 = (float) (x * lengthInv) * extraLight + (1F-extraLight); - n2 = (float) (y * lengthInv) * extraLight + (1F-extraLight); - n3 = (float) (z * lengthInv) * extraLight + (1F-extraLight); - - if (mode_triangles) { - /** render shape - * . . - * . - */ - /*bufferIn.vertex(x1 * zr0 * radius2 + ((new Random((long) (x1 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX, y1 * zr0 * radius2 + ((new Random((long) (y1 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY, z0 * radius2 + ((new Random((long) (z0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ).uv(f7, f5).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(n1, n2, n3).endVertex(); - bufferIn.vertex(x1 * zr1 * radius2 + ((new Random((long) (x1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX, y1 * zr1 * radius2 + ((new Random((long) (y1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY, z1 * radius2 + ((new Random((long) (z1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ).uv(f7, f6).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(n1, n2, n3).endVertex(); - bufferIn.vertex(x0 * zr0 * radius2 + ((new Random((long) (x0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX, y0 * zr0 * radius2 + ((new Random((long) (y0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY, z0 * radius2 + ((new Random((long) (z0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ).uv(f8, f6).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(n1, n2, n3).endVertex();;*/ - - model.positions.add((float) (x1 * zr0 * radius2 + ((new Random((long) (x1 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX)); - model.positions.add((float) (y1 * zr0 * radius2 + ((new Random((long) (y1 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY)); - model.positions.add((float) (z0 * radius2 + ((new Random((long) (z0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ)); - - model.positions.add((float) (x1 * zr1 * radius2 + ((new Random((long) (x1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX)); - model.positions.add((float) (y1 * zr1 * radius2 + ((new Random((long) (y1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY)); - model.positions.add((float) (z1 * radius2 + ((new Random((long) (z1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ)); - - model.positions.add((float) (x0 * zr0 * radius2 + ((new Random((long) (x0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX)); - model.positions.add((float) (y0 * zr0 * radius2 + ((new Random((long) (y0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY)); - model.positions.add((float) (z0 * radius2 + ((new Random((long) (z0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ)); - - model.uv.add(f7); - model.uv.add(f5); - - model.uv.add(f7); - model.uv.add(f6); - - model.uv.add(f8); - model.uv.add(f6); - - for (int i = 0; i < 3; i++) { - model.normals.add(n1); - model.normals.add(n2); - model.normals.add(n3); - } - - if (outputVerts) { - verts += x1 * zr0 * radius2 + ((new Random((long) (x1 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX + "F,"; - verts += y1 * zr0 * radius2 + ((new Random((long) (y1 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY + "F,"; - verts += z0 * radius2 + ((new Random((long) (z0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ + "F," - + System.getProperty("line.separator"); - - verts += x1 * zr1 * radius2 + ((new Random((long) (x1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX + "F,"; - verts += y1 * zr1 * radius2 + ((new Random((long) (y1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY + "F,"; - verts += z1 * radius2 + ((new Random((long) (z1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ + "F," - + System.getProperty("line.separator"); - - verts += x0 * zr0 * radius2 + ((new Random((long) (x0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX + "F,"; - verts += y0 * zr0 * radius2 + ((new Random((long) (y0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY + "F,"; - verts += z0 * radius2 + ((new Random((long) (z0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ + "F," - + System.getProperty("line.separator"); - } - - /** render shape - * . - * . . - */ - /*bufferIn.vertex( - x1 * zr1 * radius2 + ((new Random((long) (x1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX, - y1 * zr1 * radius2 + ((new Random((long) (y1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY, - z1 * radius2 + ((new Random((long) (z1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ) - .uv(f7, f6).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(n1, n2, n3).endVertex(); - - bufferIn.vertex( - x0 * zr0 * radius2 + ((new Random((long) (x0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX, - y0 * zr0 * radius2 + ((new Random((long) (y0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY, - z0 * radius2 + ((new Random((long) (z0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ) - .uv(f8, f6).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(n1, n2, n3).endVertex();; - - bufferIn.vertex(x0 * zr1 * radius2 + ((new Random((long) (x0 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX, - y0 * zr1 * radius2 + ((new Random((long) (y0 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY, - z1 * radius2 + ((new Random((long) (z1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ) - .uv(f8, f5).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(n1, n2, n3).endVertex();*/ - - model.positions.add((float) (x1 * zr1 * radius2 + ((new Random((long) (x1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX)); - model.positions.add((float) (y1 * zr1 * radius2 + ((new Random((long) (y1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY)); - model.positions.add((float) (z1 * radius2 + ((new Random((long) (z1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ)); - - model.positions.add((float) (x0 * zr0 * radius2 + ((new Random((long) (x0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX)); - model.positions.add((float) (y0 * zr0 * radius2 + ((new Random((long) (y0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY)); - model.positions.add((float) (z0 * radius2 + ((new Random((long) (z0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ)); - - model.positions.add((float) (x0 * zr1 * radius2 + ((new Random((long) (x0 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX)); - model.positions.add((float) (y0 * zr1 * radius2 + ((new Random((long) (y0 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY)); - model.positions.add((float) (z1 * radius2 + ((new Random((long) (z1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ)); - - model.uv.add(f7); - model.uv.add(f6); - - model.uv.add(f8); - model.uv.add(f6); - - model.uv.add(f8); - model.uv.add(f5); - - for (int i = 0; i < 3; i++) { - model.normals.add(n1); - model.normals.add(n2); - model.normals.add(n3); - } - - if (outputVerts) { - verts += x1 * zr1 * radius2 + ((new Random((long) (x1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX + "F,"; - verts += y1 * zr1 * radius2 + ((new Random((long) (y1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY + "F,"; - verts += z1 * radius2 + ((new Random((long) (z1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ + "F," - + System.getProperty("line.separator"); - - verts += x0 * zr0 * radius2 + ((new Random((long) (x0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX + "F,"; - verts += y0 * zr0 * radius2 + ((new Random((long) (y0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY + "F,"; - verts += z0 * radius2 + ((new Random((long) (z0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ + "F," - + System.getProperty("line.separator"); - - verts += x0 * zr1 * radius2 + ((new Random((long) (x0 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX + "F,"; - verts += y0 * zr1 * radius2 + ((new Random((long) (y0 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY + "F,"; - verts += z1 * radius2 + ((new Random((long) (z1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ + "F," - + System.getProperty("line.separator"); - } - - } else { - // render shape = U ? - /*bufferIn.vertex(x1 * zr0 * radius2 + ((new Random((long) (x1 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX, y1 * zr0 * radius2 + ((new Random((long) (y1 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY, z0 * radius2 + ((new Random((long) (z0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ).uv(f7, f5).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(n1, n2, n3).endVertex(); - bufferIn.vertex(x0 * zr0 * radius2 + ((new Random((long) (x0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX, y0 * zr0 * radius2 + ((new Random((long) (y0 * zr0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY, z0 * radius2 + ((new Random((long) (z0 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ).uv(f8, f6).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(n1, n2, n3).endVertex();; - bufferIn.vertex(x0 * zr1 * radius2 + ((new Random((long) (x0 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX, y0 * zr1 * radius2 + ((new Random((long) (y0 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY, z1 * radius2 + ((new Random((long) (z1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ).uv(f8, f5).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(n1, n2, n3).endVertex(); - bufferIn.vertex(x1 * zr1 * radius2 + ((new Random((long) (x1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsX, y1 * zr1 * radius2 + ((new Random((long) (y1 * zr1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsY, z1 * radius2 + ((new Random((long) (z1 * radius2) + sphereIndex)).nextFloat() * randAmt - (randAmt / 2F)) + cloudsZ).uv(f7, f6).color(particleRed, particleGreen, particleBlue, particleAlpha).normal(n1, n2, n3).endVertex();*/ - } - - - - iter2++; - } - - /*Tessellator tessellator = Tessellator.getInstance(); - tessellator.draw();*/ - - iter++; - - //glEnd(); - } - - if (outputVerts) { - System.out.println("VERTS:"); - System.out.println(verts); - } - - return model; - } - - public static Model renderCube(double cloudsX, double cloudsY, double cloudsZ, Vec3 cloudsColor, float scale) { - TextureAtlasSprite sprite = ParticleRegistry.cloud_square; - - boolean mode_triangles = true; - - float f7 = sprite.getU0(); - float f8 = sprite.getU1(); - float f5 = sprite.getV0(); - float f6 = sprite.getV1(); - - float radius = 10; - - Model model = new Model(); - - for (Direction dir : Direction.values()) { - Quaternion quaternion = dir.getRotation(); - - Vector3f[] avector3f3 = new Vector3f[]{ - new Vector3f(-1.0F, 0.0F, -1.0F), - new Vector3f(-1.0F, 0.0F, 1.0F), - new Vector3f(1.0F, 0.0F, 1.0F), - new Vector3f(1.0F, 0.0F, -1.0F)}; - - - Vector3f normal = new Vector3f(dir.getNormal().getX(), dir.getNormal().getY(), dir.getNormal().getZ()); - - for(int i = 0; i < 4; ++i) { - Vector3f vector3f = avector3f3[i]; - vector3f.transform(quaternion); - vector3f.add((float) dir.getStepX(), (float) dir.getStepY(), (float) dir.getStepZ()); - //if (randRotate) vector3f.transform(q2); - //fix vectors being 2x - vector3f.mul(0.5F); - vector3f.mul(scale); - vector3f.add((float) cloudsX + 0.0F, (float) cloudsY, (float) cloudsZ + 0.0F); - } - - if (mode_triangles) { - - model.positions.add(avector3f3[1].x()); - model.positions.add(avector3f3[1].y()); - model.positions.add(avector3f3[1].z()); - - model.positions.add(avector3f3[3].x()); - model.positions.add(avector3f3[3].y()); - model.positions.add(avector3f3[3].z()); - - model.positions.add(avector3f3[0].x()); - model.positions.add(avector3f3[0].y()); - model.positions.add(avector3f3[0].z()); - - /*model.positions.add(avector3f3[0].x()); - model.positions.add(avector3f3[0].y()); - model.positions.add(avector3f3[0].z()); - - model.positions.add(avector3f3[3].x()); - model.positions.add(avector3f3[3].y()); - model.positions.add(avector3f3[3].z()); - - model.positions.add(avector3f3[1].x()); - model.positions.add(avector3f3[1].y()); - model.positions.add(avector3f3[1].z());*/ - - /*model.positions.add(avector3f3[0].x()); - model.positions.add(avector3f3[0].y()); - model.positions.add(avector3f3[0].z()); - - model.positions.add(avector3f3[3].x()); - model.positions.add(avector3f3[3].y()); - model.positions.add(avector3f3[3].z()); - - model.positions.add(avector3f3[1].x()); - model.positions.add(avector3f3[1].y()); - model.positions.add(avector3f3[1].z());*/ - - - model.positions.add(avector3f3[3].x()); - model.positions.add(avector3f3[3].y()); - model.positions.add(avector3f3[3].z()); - - model.positions.add(avector3f3[1].x()); - model.positions.add(avector3f3[1].y()); - model.positions.add(avector3f3[1].z()); - - model.positions.add(avector3f3[2].x()); - model.positions.add(avector3f3[2].y()); - model.positions.add(avector3f3[2].z()); - - /*model.positions.add(avector3f3[3].x()); - model.positions.add(avector3f3[3].y()); - model.positions.add(avector3f3[3].z()); - - model.positions.add(avector3f3[1].x()); - model.positions.add(avector3f3[1].y()); - model.positions.add(avector3f3[1].z()); - - model.positions.add(avector3f3[2].x()); - model.positions.add(avector3f3[2].y()); - model.positions.add(avector3f3[2].z());*/ - - model.uv.add(f8); - model.uv.add(f6); - model.uv.add(f7); - model.uv.add(f6); - model.uv.add(f8); - model.uv.add(f5); - - model.uv.add(f7); - model.uv.add(f6); - model.uv.add(f8); - model.uv.add(f5); - model.uv.add(f7); - model.uv.add(f5); - - for (int i = 0; i < 6; i++) { - model.normals.add(normal.x()); - model.normals.add(normal.y()); - model.normals.add(normal.z()); - } - - } - - } - - return model; - } -} diff --git a/src/main/java/weather2/weathersystem/sky/WeatherParticleRenderHandler.java b/src/main/java/weather2/weathersystem/sky/WeatherParticleRenderHandler.java deleted file mode 100644 index d3bd9b46..00000000 --- a/src/main/java/weather2/weathersystem/sky/WeatherParticleRenderHandler.java +++ /dev/null @@ -1,17 +0,0 @@ -package weather2.weathersystem.sky; - -import net.minecraft.client.Camera; -import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraftforge.client.IWeatherParticleRenderHandler; - -/** - * Dummy class, we override what this would do elsewhere already, just stop vanillas code so we can tweak it - */ -public class WeatherParticleRenderHandler implements IWeatherParticleRenderHandler { - - @Override - public void render(int ticks, ClientLevel level, Minecraft minecraft, Camera camera) { - - } -} diff --git a/src/main/java/weather2/weathersystem/storm/LightningBoltWeather.java b/src/main/java/weather2/weathersystem/storm/LightningBoltWeather.java index 62dfdfb5..323393b9 100644 --- a/src/main/java/weather2/weathersystem/storm/LightningBoltWeather.java +++ b/src/main/java/weather2/weathersystem/storm/LightningBoltWeather.java @@ -236,10 +236,6 @@ protected void readAdditionalSaveData(CompoundTag p_20873_) { protected void addAdditionalSaveData(CompoundTag p_20877_) { } - public Packet getAddEntityPacket() { - return new ClientboundAddEntityPacket(this); - } - public int getBlocksSetOnFire() { return this.blocksSetOnFire; } diff --git a/src/main/java/weather2/weathersystem/storm/LightningBoltWeatherNew.java b/src/main/java/weather2/weathersystem/storm/LightningBoltWeatherNew.java index f8d68c10..fbe67d43 100644 --- a/src/main/java/weather2/weathersystem/storm/LightningBoltWeatherNew.java +++ b/src/main/java/weather2/weathersystem/storm/LightningBoltWeatherNew.java @@ -242,10 +242,6 @@ protected void readAdditionalSaveData(CompoundTag p_20873_) { protected void addAdditionalSaveData(CompoundTag p_20877_) { } - public Packet getAddEntityPacket() { - return new ClientboundAddEntityPacket(this); - } - public int getBlocksSetOnFire() { return this.blocksSetOnFire; } diff --git a/src/main/java/weather2/weathersystem/storm/StormObject.java b/src/main/java/weather2/weathersystem/storm/StormObject.java index e0a5e919..2008eb74 100644 --- a/src/main/java/weather2/weathersystem/storm/StormObject.java +++ b/src/main/java/weather2/weathersystem/storm/StormObject.java @@ -26,7 +26,6 @@ import net.minecraft.world.level.block.LiquidBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.Heightmap; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.Shapes; @@ -34,6 +33,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.LogicalSide; import net.minecraftforge.fml.util.thread.EffectiveSide; +import net.minecraftforge.registries.ForgeRegistries; import weather2.EntityRegistry; import weather2.ServerTickHandler; import weather2.Weather; @@ -990,7 +990,8 @@ public void tickMovement() { } if (levelCurIntensityStage >= STATE_FORMING) { - Optional optional = ((WeatherManagerServer) manager).findWeatherDeflector((ServerLevel) manager.getWorld(), CoroUtilBlock.blockPos(posGround), 128); + //TODO: 1.20 + /*Optional optional = ((WeatherManagerServer) manager).findWeatherDeflector((ServerLevel) manager.getWorld(), CoroUtilBlock.blockPos(posGround), 128); if (optional.isPresent()) { isBeingDeflectedCached = true; //CULog.dbg("optional.get(): " + optional.get()); @@ -998,7 +999,7 @@ public void tickMovement() { ((ServerLevel) this.manager.getWorld()).sendParticles(DustParticleOptions.REDSTONE, optional.get().getX() + 0.5D, optional.get().getY() + 0.5D, optional.get().getZ() + 0.5D, 1, 0.3D, 0D, 0.3D, 1D); } else { isBeingDeflectedCached = false; - } + }*/ } else { isBeingDeflectedCached = false; } @@ -1035,7 +1036,7 @@ public void tickWeatherEvents() { } } - LightningBoltWeatherNew ent = new LightningBoltWeatherNew(EntityRegistry.lightning_bolt, world); + LightningBoltWeatherNew ent = new LightningBoltWeatherNew(EntityRegistry.LIGHTNING_BOLT.get(), world); ent.setPos(x + 0.5, y, z + 0.5); addWeatherEffectLightning(ent, false); } @@ -1144,7 +1145,7 @@ public void tickProgression() { //temperature scan if (bgb != null) { - isInOcean = bgb.getRegistryName().toString().toLowerCase().contains("ocean"); + isInOcean = ForgeRegistries.BIOMES.getKey(bgb).toString().toLowerCase().contains("ocean"); //float biomeTempAdj = getTemperatureMCToWeatherSys(bgb.getFloatTemperature(new BlockPos(Mth.floor(pos.x), Mth.floor(pos.y), Mth.floor(pos.z)))); float biomeTempAdj = getTemperatureMCToWeatherSys(CoroUtilCompatibility.getAdjustedTemperature(manager.getWorld(), bgb, new BlockPos(Mth.floor(pos.x), Mth.floor(pos.y), Mth.floor(pos.z)))); @@ -1173,7 +1174,7 @@ public void tickProgression() { BlockState state = world.getBlockState(tryPos); if (!CoroUtilBlock.isAir(state.getBlock())) { //Block block = Block.blocksList[blockID]; - if (state.getMaterial() == Material.WATER) { + if (state.liquid()) { isOverWater = true; } } @@ -1186,7 +1187,7 @@ public void tickProgression() { } if (bgb != null) { - String biomecat = bgb.getRegistryName().toString(); + String biomecat = ForgeRegistries.BIOMES.getKey(bgb).toString().toLowerCase(); if (!performBuildup && (isInOcean || biomecat.contains("swamp") || biomecat.contains("jungle") || biomecat.contains("river"))) { performBuildup = true; @@ -2339,7 +2340,7 @@ public float getAvoidAngleIfTerrainAtOrAheadOfPosition(float angle, Vec3 pos) { double scanX = pos.x + (-Math.sin(Math.toRadians(angle + scanAngle)) * scanDistRange); double scanZ = pos.z + (Math.cos(Math.toRadians(angle + scanAngle)) * scanDistRange); - int height = WeatherUtilBlock.getPrecipitationHeightSafe(this.manager.getWorld(), new BlockPos(scanX, 0, scanZ)).getY(); + int height = WeatherUtilBlock.getPrecipitationHeightSafe(this.manager.getWorld(), CoroUtilBlock.blockPos(scanX, 0, scanZ)).getY(); if (pos.y < height) { if (scanAngle <= 0) { @@ -2393,7 +2394,7 @@ public void spinEntityv2(Entity entity) { entity.setYRot(rotationYaw); if (player.position().distanceTo(entity.position()) < 3 && entity.isAlive()) { - player.hurt(DamageSource.CACTUS, 1.5F); + player.hurt(manager.getWorld().damageSources().cactus(), 1.5F); entity.kill(); } @@ -2773,7 +2774,7 @@ else if (entity1 instanceof LivingEntity) //if player and not spout if (entity1 instanceof Player && conf.type != 0) { //System.out.println("grab: " + f5); - if (ent.isOnGround()) { + if (ent.onGround()) { f5 *= 10.5F; } else { f5 *= 5F; @@ -3019,7 +3020,7 @@ public int calculateTopYBlock() { BlockState state = world.getBlockState(CoroUtilBlock.blockPos(pos.x, y, pos.z)); //System.out.println("state: " + state); int iter = 0; - while ((state.is(BlockTags.LOGS) || state.is(BlockTags.LEAVES) || state.is(BlockTags.CAVE_VINES) || state.is(BlockTags.REPLACEABLE_PLANTS) || state.is(Blocks.COCOA) || state.is(Blocks.BAMBOO) || state.isAir()) && y > world.getMinBuildHeight()) { + while ((state.is(BlockTags.LOGS) || state.is(BlockTags.LEAVES) || state.is(BlockTags.CAVE_VINES) || state.is(BlockTags.REPLACEABLE_BY_TREES) || state.is(Blocks.COCOA) || state.is(Blocks.BAMBOO) || state.isAir()) && y > world.getMinBuildHeight()) { y--; state = world.getBlockState(CoroUtilBlock.blockPos(pos.x, y, pos.z)); //CULog.dbg("filter logs, found: " + state); diff --git a/src/main/java/weather2/weathersystem/storm/TornadoHelper.java b/src/main/java/weather2/weathersystem/storm/TornadoHelper.java index 98f70c61..f67a9c8b 100644 --- a/src/main/java/weather2/weathersystem/storm/TornadoHelper.java +++ b/src/main/java/weather2/weathersystem/storm/TornadoHelper.java @@ -26,7 +26,7 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.Heightmap; -import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MapColor; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; @@ -34,7 +34,6 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.FakePlayerFactory; import net.minecraftforge.event.level.BlockEvent; -import net.minecraftforge.event.world.BlockEvent; import weather2.ClientTickHandler; import weather2.Weather; import weather2.config.ClientConfigData; @@ -510,7 +509,7 @@ public boolean tryRip(Level parWorld, int tryX, int tryY, int tryZ/*, boolean no removeCount++; boolean shouldEntityify = blockCount <= ConfigTornado.Storm_Tornado_maxFlyingEntityBlocks; listBlockUpdateQueue.put(pos, new BlockUpdateSnapshot(parWorld.dimension(), Blocks.AIR.defaultBlockState(), state, pos, playerClose && shouldEntityify)); - if (playerClose && shouldEntityify && (state.canOcclude() || state.getMaterial().equals(Material.LEAVES))) { + if (playerClose && shouldEntityify && (state.canOcclude() || state.getBlock().defaultMapColor() == MapColor.PLANT)) { ((WeatherManagerServer) this.storm.manager).syncBlockParticleNew(pos, state, storm); } } diff --git a/src/main/java/weather2/weathersystem/storm/WeatherObjectParticleStorm.java b/src/main/java/weather2/weathersystem/storm/WeatherObjectParticleStorm.java index b97647cd..1d942b5a 100644 --- a/src/main/java/weather2/weathersystem/storm/WeatherObjectParticleStorm.java +++ b/src/main/java/weather2/weathersystem/storm/WeatherObjectParticleStorm.java @@ -10,6 +10,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.registries.ForgeRegistries; import weather2.WeatherBlocks; import weather2.client.SceneEnhancer; import weather2.config.ConfigSand; @@ -78,7 +79,7 @@ public static boolean isColdForStorm(Level world, Biome biome, boolean forSpawn, public static boolean isDesert(Biome biome, boolean forSpawn) { //TODO: make sure new comparison works - return biome.equals(Biomes.DESERT) || (!forSpawn && biome.equals(Biomes.RIVER)) || biome.getRegistryName().toString().toLowerCase().contains("desert"); + return biome.equals(Biomes.DESERT) || (!forSpawn && biome.equals(Biomes.RIVER)) || ForgeRegistries.BIOMES.getKey(biome).toString().toLowerCase().contains("desert"); } @Override diff --git a/src/main/java/weather2/weathersystem/storm/WeatherObjectSandstormOld.java b/src/main/java/weather2/weathersystem/storm/WeatherObjectSandstormOld.java index 8b4f718e..0da24e0f 100644 --- a/src/main/java/weather2/weathersystem/storm/WeatherObjectSandstormOld.java +++ b/src/main/java/weather2/weathersystem/storm/WeatherObjectSandstormOld.java @@ -10,6 +10,7 @@ import net.minecraft.world.level.biome.Biomes; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.registries.ForgeRegistries; import weather2.WeatherBlocks; import weather2.config.ConfigSand; import weather2.util.CachedNBTTagCompound; @@ -41,7 +42,7 @@ public static boolean isDesert(Biome biome) { public static boolean isDesert(Biome biome, boolean forSpawn) { //TODO: make sure new comparison works - return biome.equals(Biomes.DESERT) || (!forSpawn && biome.equals(Biomes.RIVER)) || biome.getRegistryName().toString().toLowerCase().contains("desert"); + return biome.equals(Biomes.DESERT) || (!forSpawn && biome.equals(Biomes.RIVER)) || ForgeRegistries.BIOMES.getKey(biome).toString().toLowerCase().contains("desert"); } public int getSize() { diff --git a/src/main/java/weather2/weathersystem/tornado/TornadoFunnel.java b/src/main/java/weather2/weathersystem/tornado/TornadoFunnel.java index 503b4b01..c47ae057 100644 --- a/src/main/java/weather2/weathersystem/tornado/TornadoFunnel.java +++ b/src/main/java/weather2/weathersystem/tornado/TornadoFunnel.java @@ -331,10 +331,10 @@ private void tickUpdateFunnel() { float yDiffDist = 2F; float curveAmp = 1F; - Quaternionf quaternionY = new Quaternionf(new Vector3f(0.0F, 1.0F, 0.0F), -y, true); - Quaternionf quaternionYCircle = new Quaternionf(new Vector3f(0.0F, 1.0F, 0.0F), -y2, true); + Quaternionf quaternionY = new Quaternionf(0.0F, 1.0F, 0.0F, Math.toRadians(-y)); + Quaternionf quaternionYCircle = new Quaternionf(0.0F, 1.0F, 0.0F, Math.toRadians(-y2)); - Quaternionf quatPitch = new Quaternionf(new Vector3f(1.0F, 0.0F, 0.0F), -pitchAngle, true); + Quaternionf quatPitch = new Quaternionf(1.0F, 0.0F, 0.0F, Math.toRadians(-pitchAngle)); Vector3f vecCurve = piece.bezierCurve.getValue((float)curvePoint); //Vector3f vecNew = new Vector3f((float)vecCurve.x * curveAmp, 1 + ((float)yDiff) * yDiffDist, (float)vecCurve.z * curveAmp); Vector3f vecNew = new Vector3f((float)vecCurve.x() * curveAmp, 1 + ((float)yDiff) * yDiffDist, (float)vecCurve.z() * curveAmp); @@ -344,12 +344,11 @@ private void tickUpdateFunnel() { float rotAroundPosY = 0; float rotAroundPosZ = 0; Matrix3f matrix = new Matrix3f(); - matrix.setIdentity(); - matrix.mul(quaternionY); - matrix.mul(quatPitch); + matrix.rotation(quaternionY); + matrix.rotation(quatPitch); //multiply in the radial shape of the tornado - matrix.mul(quaternionYCircle); - vecNew.transform(matrix); + matrix.rotation(quaternionYCircle); + vecNew.mulTranspose(matrix); rotAroundPosX = vecNew.x(); rotAroundPosY = vecNew.y(); diff --git a/src/main/java/weather2/weathersystem/tornado/TornadoManagerTodoRenameMe.java b/src/main/java/weather2/weathersystem/tornado/TornadoManagerTodoRenameMe.java index 500bd453..714c5067 100644 --- a/src/main/java/weather2/weathersystem/tornado/TornadoManagerTodoRenameMe.java +++ b/src/main/java/weather2/weathersystem/tornado/TornadoManagerTodoRenameMe.java @@ -8,6 +8,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec3; +import org.joml.Matrix3f; import org.joml.Quaternionf; import org.joml.Vector3d; import org.joml.Vector3f; @@ -269,11 +270,11 @@ public void tick(Level world) { } //Quaternionf quaternionY = new Quaternionf(new Vector3f(0.0F, 1.0F, 0.0F), -y, true); - Quaternionf quaternionY = new Quaternionf(new Vector3f(0.0F, 1.0F, 0.0F), -curvePointYawPitch.x - 90, true); + Quaternionf quaternionY = new Quaternionf(0.0F, 1.0F, 0.0F, Math.toRadians(-curvePointYawPitch.x - 90)); //adding quaternionY here cancels out the unwanted rotations from the bezier curve adjustments - Quaternionf quaternionYCircle = new Quaternionf(new Vector3f(0.0F, 1.0F, 0.0F), -y2 + (curvePointYawPitch.x - 90), true); + Quaternionf quaternionYCircle = new Quaternionf(0.0F, 1.0F, 0.0F, Math.toRadians(-y2 + (curvePointYawPitch.x - 90))); - Quaternionf quatPitch = new Quaternionf(new Vector3f(1.0F, 0.0F, 0.0F), curvePointYawPitch.y, true); + Quaternionf quatPitch = new Quaternionf(1.0F, 0.0F, 0.0F, Math.toRadians(curvePointYawPitch.y)); //Vector3f vecNew = new Vector3f(1F, 1 + ((float)yDiff) * yDiffDist, 0); //Vector3d vecCurve = bezierCurve.getValue(curvePoint); Vector3f vecCurve = getCurveValue(curvePoint); @@ -291,11 +292,10 @@ public void tick(Level world) { float rotAroundPosY = 0; float rotAroundPosZ = 0; Matrix3f matrix = new Matrix3f(); - matrix.setIdentity(); - matrix.mul(quaternionY); - matrix.mul(quatPitch); - matrix.mul(quaternionYCircle); - vecNew.transform(matrix); + matrix.rotation(quaternionY); + matrix.rotation(quatPitch); + matrix.rotation(quaternionYCircle); + vecNew.mulTranspose(matrix); rotAroundPosX = vecNew.x(); rotAroundPosY = vecNew.y(); diff --git a/src/main/java/weather2/weathersystem/wind/WindManager.java b/src/main/java/weather2/weathersystem/wind/WindManager.java index 949cfe9a..4a9f4161 100644 --- a/src/main/java/weather2/weathersystem/wind/WindManager.java +++ b/src/main/java/weather2/weathersystem/wind/WindManager.java @@ -478,11 +478,11 @@ public void applyWindForceNew(Object ent, float multiplier, float maxSpeed) { */ public Vec3 applyWindForceImpl(Vec3 pos, Vec3 motion, float weight, float multiplier, float maxSpeed) { float windSpeed = 0; - if (pos != null && false) { + /*if (pos != null && false) { windSpeed = getWindSpeedPerlinNoise(pos); - } else { + } else {*/ windSpeed = getWindSpeed(); - } + //} float windAngle = getWindAngle(pos); float windX = (float) -Math.sin(Math.toRadians(windAngle)) * windSpeed; @@ -610,10 +610,11 @@ public CompoundTag write(CompoundTag data) { return data; } - public float getWindSpeedPerlinNoise(Vec3 pos) { + //TODO: 1.20 + /*public float getWindSpeedPerlinNoise(Vec3 pos) { PerlinNoise perlinNoise = ClientTickHandler.weatherManager.cloudManager.getPerlinNoise(); - /*int indexX = index % xWide; - int indexZ = index / xWide;*/ + *//*int indexX = index % xWide; + int indexZ = index / xWide;*//* int indexX = (int)pos.x; int indexZ = (int)pos.z; double scale = 5; @@ -621,6 +622,6 @@ public float getWindSpeedPerlinNoise(Vec3 pos) { double posYAdj = 0; double noiseVal = perlinNoise.getValue(((indexX) * scale) + time, ((indexZ) * scale) + time, posYAdj) + 0.2F; return (float) noiseVal * 2F; - } + }*/ }