Forgot the rest.

This commit is contained in:
Waterpicker 2020-04-29 22:02:00 -05:00
parent e2a7928de9
commit e0ae426cab
8 changed files with 502 additions and 440 deletions

View file

@ -1,11 +1,27 @@
package org.dimdev.dimdoors.client; package org.dimdev.dimdoors.client;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.util.GlAllocationUtils;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import org.lwjgl.opengl.GL11;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import static com.mojang.blaze3d.platform.GlStateManager.TexCoord.*;
import static com.mojang.blaze3d.platform.GlStateManager.enableTexGen;
public final class DimensionalPortalRenderer { // TODO public final class DimensionalPortalRenderer { // TODO
// private static final FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16); private static final FloatBuffer buffer = GlAllocationUtils.allocateFloatBuffer(16);
// private static final Identifier warpPath = new Identifier("dimdoors" + ":textures/other/warp.png"); private static final Identifier warpPath = new Identifier("dimdoors" + ":textures/other/warp.png");
/** /**
* Renders a dimensional portal, for use in various situations. Code is mostly based * Renders a dimensional portal, for use in various situations. Code is mostly based
@ -22,165 +38,160 @@ public final class DimensionalPortalRenderer { // TODO
* @param colors An array containing the color to use on each pass. Its length determines the number of passes to do. * @param colors An array containing the color to use on each pass. Its length determines the number of passes to do.
*/ */
public static void renderDimensionalPortal(VertexConsumer vc, double x, double y, double z, Direction orientation, double width, double height, float[][] colors) { // TODO: Make this work at any angle public static void renderDimensionalPortal(VertexConsumer vc, double x, double y, double z, Direction orientation, double width, double height, float[][] colors) { // TODO: Make this work at any angle
// RenderSystem.disableLighting(); RenderSystem.disableLighting();
// RenderSystem.disableCull(); RenderSystem.disableCull();
//
// for (int pass = 0; pass < 16; pass++) { for (int pass = 0; pass < 16; pass++) {
// RenderSystem.pushMatrix(); RenderSystem.pushMatrix();
//
// float translationScale = 16 - pass; float translationScale = 16 - pass;
// float scale = 0.2625F; float scale = 0.2625F;
// float colorMultiplier = 1.0F / (translationScale + .80F); float colorMultiplier = 1.0F / (translationScale + .80F);
//
// MinecraftClient.getInstance().getTextureManager().bindTexture(warpPath); MinecraftClient.getInstance().getTextureManager().bindTexture(warpPath);
// RenderSystem.enableBlend(); RenderSystem.enableBlend();
//
// if (pass == 0) { if (pass == 0) {
// colorMultiplier = 0.1F; colorMultiplier = 0.1F;
// translationScale = 25.0F; translationScale = 25.0F;
// scale = 0.125F; scale = 0.125F;
//
// RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
// } }
//
// if (pass == 1) { if (pass == 1) {
// scale = 0.5F; scale = 0.5F;
// RenderSystem.blendFunc(GL11.GL_ONE, GL11.GL_ONE); RenderSystem.blendFunc(GL11.GL_ONE, GL11.GL_ONE);
// } }
//
// double offset = Minecraft.getSystemTime() % 200000L / 200000.0F; double offset = Util.getMeasuringTimeNano() % 200000L / 200000.0F;
// RenderSystem.translatef(offset, offset, offset); RenderSystem.translated(offset, offset, offset);
//
// RenderSystem.texGen(RenderSystem.TexGen.S, GL11.GL_OBJECT_LINEAR); GlStateManager.texGenMode(S, GL11.GL_OBJECT_LINEAR);
// RenderSystem.texGen(RenderSystem.TexGen.T, GL11.GL_OBJECT_LINEAR); GlStateManager.texGenMode(T, GL11.GL_OBJECT_LINEAR);
// RenderSystem.texGen(RenderSystem.TexGen.R, GL11.GL_OBJECT_LINEAR); GlStateManager.texGenMode(R, GL11.GL_OBJECT_LINEAR);
//
// if (orientation == Direction.UP || orientation == Direction.DOWN) { if (orientation == Direction.UP || orientation == Direction.DOWN) {
// RenderSystem.texGen(RenderSystem.TexGen.Q, GL11.GL_EYE_LINEAR); GlStateManager.texGenMode(Q, GL11.GL_EYE_LINEAR);
// } else { } else {
// RenderSystem.texGen(RenderSystem.TexGen.Q, GL11.GL_OBJECT_LINEAR); GlStateManager.texGenMode(Q, GL11.GL_OBJECT_LINEAR);
// } }
//
// switch (orientation) { // TODO: Why 0.15F? Is that a door's thickness? If yes, don't hardcode that. switch (orientation) { // TODO: Why 0.15F? Is that a door's thickness? If yes, don't hardcode that.
// case SOUTH: case SOUTH:
// RenderSystem.texGen(RenderSystem.TexGen.S, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F)); GlStateManager.texGenParam(S, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
// RenderSystem.texGen(RenderSystem.TexGen.T, GL11.GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, 0.0F)); GlStateManager.texGenParam(T, GL11.GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, 0.0F));
// RenderSystem.texGen(RenderSystem.TexGen.R, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 0.0F, 1.0F)); GlStateManager.texGenParam(R, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 0.0F, 1.0F));
// RenderSystem.texGen(RenderSystem.TexGen.Q, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 1.0F, -0.15F)); GlStateManager.texGenParam(Q, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 1.0F, -0.15F));
// break; break;
// case WEST: case WEST:
// RenderSystem.texGen(RenderSystem.TexGen.S, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F)); GlStateManager.texGenParam(S, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
// RenderSystem.texGen(RenderSystem.TexGen.T, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 1.0F, 0.0F)); GlStateManager.texGenParam(T, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 1.0F, 0.0F));
// RenderSystem.texGen(RenderSystem.TexGen.R, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 0.0F, 1.0F)); GlStateManager.texGenParam(R, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 0.0F, 1.0F));
// RenderSystem.texGen(RenderSystem.TexGen.Q, GL11.GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, 0.15F)); GlStateManager.texGenParam(Q, GL11.GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, 0.15F));
// break; break;
// case NORTH: case NORTH:
// RenderSystem.texGen(RenderSystem.TexGen.S, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F)); GlStateManager.texGenParam(S, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
// RenderSystem.texGen(RenderSystem.TexGen.T, GL11.GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, 0.0F)); GlStateManager.texGenParam(T, GL11.GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, 0.0F));
// RenderSystem.texGen(RenderSystem.TexGen.R, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 0.0F, 1.0F)); GlStateManager.texGenParam(R, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 0.0F, 1.0F));
// RenderSystem.texGen(RenderSystem.TexGen.Q, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 1.0F, 0.15F)); GlStateManager.texGenParam(Q, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 1.0F, 0.15F));
// break; break;
// case EAST: case EAST:
// RenderSystem.texGen(RenderSystem.TexGen.S, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F)); GlStateManager.texGenParam(S, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
// RenderSystem.texGen(RenderSystem.TexGen.T, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 1.0F, 0.0F)); GlStateManager.texGenParam(T, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 1.0F, 0.0F));
// RenderSystem.texGen(RenderSystem.TexGen.R, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 0.0F, 1.0F)); GlStateManager.texGenParam(R, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 0.0F, 1.0F));
// RenderSystem.texGen(RenderSystem.TexGen.Q, GL11.GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, -0.15F)); GlStateManager.texGenParam(Q, GL11.GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, -0.15F));
// break; break;
// case UP: case UP:
// RenderSystem.texGen(RenderSystem.TexGen.S, GL11.GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, 0.0F)); case DOWN:
// RenderSystem.texGen(RenderSystem.TexGen.T, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 1.0F, 0.0F)); GlStateManager.texGenParam(S, GL11.GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, 0.0F));
// RenderSystem.texGen(RenderSystem.TexGen.R, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 0.0F, 1.0F)); GlStateManager.texGenParam(T, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 1.0F, 0.0F));
// RenderSystem.texGen(RenderSystem.TexGen.Q, GL11.GL_EYE_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F)); GlStateManager.texGenParam(R, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 0.0F, 1.0F));
// break; GlStateManager.texGenParam(Q, GL11.GL_EYE_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
// case DOWN: break;
// RenderSystem.texGen(RenderSystem.TexGen.S, GL11.GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, 0.0F)); }
// RenderSystem.texGen(RenderSystem.TexGen.T, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 1.0F, 0.0F));
// RenderSystem.texGen(RenderSystem.TexGen.R, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 0.0F, 1.0F)); enableTexGen(S);
// RenderSystem.texGen(RenderSystem.TexGen.Q, GL11.GL_EYE_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F)); enableTexGen(T);
// break; enableTexGen(R);
// } enableTexGen(Q);
//
// RenderSystem.enableTexGenCoord(RenderSystem.TexGen.S); RenderSystem.popMatrix();
// RenderSystem.enableTexGenCoord(RenderSystem.TexGen.T);
// RenderSystem.enableTexGenCoord(RenderSystem.TexGen.R); RenderSystem.matrixMode(GL11.GL_TEXTURE);
// RenderSystem.enableTexGenCoord(RenderSystem.TexGen.Q); RenderSystem.pushMatrix();
// RenderSystem.loadIdentity();
// RenderSystem.popMatrix(); RenderSystem.translatef(0.0F, (float) (offset * translationScale), 0.0F);
// RenderSystem.scaled(scale, scale, scale);
// RenderSystem.matrixMode(GL11.GL_TEXTURE); RenderSystem.translatef(0.5F, 0.5F, 0.5F);
// RenderSystem.pushMatrix(); RenderSystem.rotatef((pass * pass * 4321 + pass * 9) * 2.0F, 0.0F, 0.0F, 1.0F);
// RenderSystem.loadIdentity(); RenderSystem.translatef(0.5F, 0.5F, 0.5F);
// RenderSystem.translatef(0.0F, offset * translationScale, 0.0F);
// RenderSystem.scaled(scale, scale, scale); Tessellator tessellator = Tessellator.getInstance();
// RenderSystem.translatef(0.5F, 0.5F, 0.5F); BufferBuilder worldRenderer = tessellator.getBuffer();
// RenderSystem.rotatef((pass * pass * 4321 + pass * 9) * 2.0F, 0.0F, 0.0F, 1.0F); worldRenderer.begin(GL11.GL_QUADS, VertexFormats.POSITION);
// RenderSystem.translatef(0.5F, 0.5F, 0.5F);
// float[] color = colors[pass];
// Tessellator tessellator = Tessellator.getInstance(); RenderSystem.color4f(color[0] * colorMultiplier, color[1] * colorMultiplier, color[2] * colorMultiplier, color[3]);
// BufferBuilder worldRenderer = tessellator.getBuffer();
// worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); switch (orientation) {
// case NORTH:
// RGBA color = colors[pass]; worldRenderer.vertex(x, y, z).next();
// RenderSystem.color(color.getRed() * colorMultiplier, color.getGreen() * colorMultiplier, color.getBlue() * colorMultiplier, color.getAlpha()); worldRenderer.vertex(x, y + height, z).next();
// worldRenderer.vertex(x + width, y + height, z).next();
// switch (orientation) { worldRenderer.vertex(x + width, y, z).next();
// case NORTH: break;
// worldRenderer.pos(x, y, z).endVertex(); case SOUTH:
// worldRenderer.pos(x, y + height, z).endVertex(); worldRenderer.vertex(x, y, z).next();
// worldRenderer.pos(x + width, y + height, z).endVertex(); worldRenderer.vertex(x + width, y, z).next();
// worldRenderer.pos(x + width, y, z).endVertex(); worldRenderer.vertex(x + width, y + height, z).next();
// break; worldRenderer.vertex(x, y + height, z).next();
// case SOUTH: break;
// worldRenderer.pos(x, y, z).endVertex(); case WEST:
// worldRenderer.pos(x + width, y, z).endVertex(); worldRenderer.vertex(x, y, z).next();
// worldRenderer.pos(x + width, y + height, z).endVertex(); worldRenderer.vertex(x, y, z + width).next();
// worldRenderer.pos(x, y + height, z).endVertex(); worldRenderer.vertex(x, y + height, z + width).next();
// break; worldRenderer.vertex(x, y + height, z).next();
// case WEST: break;
// worldRenderer.pos(x, y, z).endVertex(); case EAST:
// worldRenderer.pos(x, y, z + width).endVertex(); worldRenderer.vertex(x, y, z).next();
// worldRenderer.pos(x, y + height, z + width).endVertex(); worldRenderer.vertex(x, y + height, z).next();
// worldRenderer.pos(x, y + height, z).endVertex(); worldRenderer.vertex(x, y + height, z + width).next();
// break; worldRenderer.vertex(x, y, z + width).next();
// case EAST: break;
// worldRenderer.pos(x, y, z).endVertex(); case UP:
// worldRenderer.pos(x, y + height, z).endVertex(); worldRenderer.vertex(x, y, z).next();
// worldRenderer.pos(x, y + height, z + width).endVertex(); worldRenderer.vertex(x, y, z + width).next();
// worldRenderer.pos(x, y, z + width).endVertex(); worldRenderer.vertex(x + width, y, z + width).next();
// break; worldRenderer.vertex(x + width, y, z).next();
// case UP: break;
// worldRenderer.pos(x, y, z).endVertex(); case DOWN:
// worldRenderer.pos(x, y, z + width).endVertex(); worldRenderer.vertex(x, y, z).next();
// worldRenderer.pos(x + width, y, z + width).endVertex(); worldRenderer.vertex(x + width, y, z).next();
// worldRenderer.pos(x + width, y, z).endVertex(); worldRenderer.vertex(x + width, y, z + width).next();
// break; worldRenderer.vertex(x, y, z + width).next();
// case DOWN: break;
// worldRenderer.pos(x, y, z).endVertex(); }
// worldRenderer.pos(x + width, y, z).endVertex();
// worldRenderer.pos(x + width, y, z + width).endVertex(); tessellator.draw();
// worldRenderer.pos(x, y, z + width).endVertex();
// break; RenderSystem.popMatrix();
// } RenderSystem.matrixMode(GL11.GL_MODELVIEW);
// }
// tessellator.draw();
// RenderSystem.disableBlend();
// RenderSystem.popMatrix(); GlStateManager.disableTexGen(S);
// RenderSystem.matrixMode(GL11.GL_MODELVIEW); GlStateManager.disableTexGen(T);
// } GlStateManager.disableTexGen(R);
// GlStateManager.disableTexGen(Q);
// RenderSystem.disableBlend(); RenderSystem.enableCull();
// RenderSystem.disableTexGenCoord(RenderSystem.TexGen.S); RenderSystem.enableLighting();
// RenderSystem.disableTexGenCoord(RenderSystem.TexGen.T); }
// RenderSystem.disableTexGenCoord(RenderSystem.TexGen.R);
// RenderSystem.disableTexGenCoord(RenderSystem.TexGen.Q); private static FloatBuffer getBuffer(float f1, float f2, float f3, float f4) {
// RenderSystem.enableCull(); buffer.clear();
// RenderSystem.enableLighting(); buffer.put(f1).put(f2).put(f3).put(f4);
buffer.flip();
return buffer;
} }
//
// private static FloatBuffer getBuffer(float f1, float f2, float f3, float f4) {
// buffer.clear();
// buffer.put(f1).put(f2).put(f3).put(f4);
// buffer.flip();
// return buffer;
// }
} }

View file

@ -1,12 +1,16 @@
package org.dimdev.dimdoors.client; package org.dimdev.dimdoors.client;
import com.mojang.blaze3d.systems.RenderSystem;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.block.entity.BlockEntityRenderer; import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity; import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
@ -20,26 +24,23 @@ public class EntranceRiftBlockEntityRenderer extends BlockEntityRenderer<Entranc
@Override @Override
public void render(EntranceRiftBlockEntity entrance, float f, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j) { public void render(EntranceRiftBlockEntity entrance, float f, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j) {
// Direction orientation = entrance.getOrientation(); /*Direction orientation = entrance.getOrientation();
// Vec3d offset = new Vec3d(orientation.getOpposite().getDirectionVec()).scale( Vec3d offset = new Vec3d(orientation.getOpposite().getUnitVector().scale(orientation == Direction.NORTH || orientation == Direction.WEST || orientation == Direction.UP ? entrance.pushIn : entrance.pushIn - 1));
// orientation == Direction.NORTH || DimensionalPortalRenderer.renderDimensionalPortal(
// orientation == Direction.WEST || x + offset.x,
// orientation == Direction.UP ? entrance.pushIn : entrance.pushIn - 1); y + offset.y,
// DimensionalPortalRenderer.renderDimensionalPortal( z + offset.z,
// x + offset.x, //entrance.orientation.getHorizontalAngle(),
// y + offset.y, //entrance.orientation.getDirectionVec().getY() * 90,
// z + offset.z, orientation,
// //entrance.orientation.getHorizontalAngle(), extendLeft + entrance.extendRight,
// //entrance.orientation.getDirectionVec().getY() * 90, extendDown + entrance.extendUp,
// orientation, entrance.getColors(16));*/
// extendLeft + entrance.extendRight,
// extendDown + entrance.extendUp, /*if (entrance.lockStatus >= 1) {
// getColors(16)); for (int i = 0; i < 1 + entrance.lockStatus; i++) {
// renderKeyHole(entrance, x, y, z, i);
// if (entrance.lockStatus >= 1) { }
// for (int i = 0; i < 1 + entrance.lockStatus; i++) { }*/
// renderKeyHole(entrance, x, y, z, i);
// }
// }
} }
} }

View file

@ -1,34 +1,37 @@
//package org.dimdev.dimdoors.client; package org.dimdev.dimdoors.client;
//
//import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
//import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
//import net.minecraft.client.model.Model; import net.minecraft.client.model.ModelPart;
//import net.minecraft.client.model.ModelBase; import net.minecraft.client.render.VertexConsumer;
//import net.minecraft.client.model.ModelPart; import net.minecraft.client.render.entity.model.EntityModel;
//import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.util.math.MatrixStack;
//import net.minecraft.client.renderer.RenderSystem; import org.dimdev.dimdoors.entity.MonolithEntity;
//import net.minecraft.entity.Entity;
//import org.dimdev.dimdoors.entity.MonolithEntity; @Environment(EnvType.CLIENT)
// public class MonolithModel extends EntityModel<MonolithEntity> {
//@Environment(EnvType.CLIENT) private final ModelPart body;
//public class MonolithModel extends Model {
// private final ModelPart body; public MonolithModel() {
// super();
// public MonolithModel() { textureWidth = 256;
// super(); textureHeight = 256;
// textureWidth = 256;
// textureHeight = 256; body = new ModelPart(this, 0, 0);
// body.addCuboid(-24F, -108F / 1.3F, -6F, 48, 108, 12);
// body = new ModelPart(this, 0, 0); }
// body.addBox(-24F, -108F / 1.3F, -6F, 48, 108, 12);
// } @Override
// public void setAngles(MonolithEntity entity, float f, float g, float h, float i, float j) {
// @Override
// public void render(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { }
// MonolithEntity monolith = (MonolithEntity) entity;
// @Override
// setRotationAngles(0, 0, 0, 0, 0, 0, monolith); public void animateModel(MonolithEntity entity, float f, float g, float h) {
// RenderSystem.scale(monolith.getRenderSizeModifier(), monolith.getRenderSizeModifier(), monolith.getRenderSizeModifier()); }
// this.body.render(scale);
// } @Override
//} public void render(MatrixStack matrixStack, VertexConsumer vertexConsumer, int i, int j, float f, float g, float h, float k) {
this.body.render(matrixStack, vertexConsumer, i, j, f, g, h, k);
}
}

View file

@ -1,8 +1,31 @@
package org.dimdev.dimdoors.entity; package org.dimdev.dimdoors.entity;
import com.flowpowered.math.vector.Vector3f;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.data.DataTracker;
import net.minecraft.entity.data.TrackedData;
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.sound.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.dimdev.dimdoors.ModConfig;
import org.dimdev.dimdoors.sound.ModSoundEvents;
import org.dimdev.dimdoors.world.limbo.LimboDimension;
import org.dimdev.dimdoors.world.pocketdimension.DungeonPocketDimension;
import org.dimdev.util.Location;
import org.dimdev.util.TeleportUtil;
import static net.minecraft.entity.attribute.EntityAttributes.MAX_HEALTH;
public class MonolithEntity extends MobEntity { public class MonolithEntity extends MobEntity {
private static final int MAX_AGGRO = 250; private static final int MAX_AGGRO = 250;
@ -11,230 +34,241 @@ public class MonolithEntity extends MobEntity {
private static final int MAX_TEXTURE_STATE = 18; private static final int MAX_TEXTURE_STATE = 18;
private static final int MAX_SOUND_COOLDOWN = 200; private static final int MAX_SOUND_COOLDOWN = 200;
private static final int MAX_AGGRO_RANGE = 35; private static final int MAX_AGGRO_RANGE = 35;
// private static final DataParameter<Integer> AGGRO = EntityDataManager.createKey(MonolithEntity.class, VARINT); private static final TrackedData<Integer> AGGRO = DataTracker.registerData(MonolithEntity.class, TrackedDataHandlerRegistry.INTEGER);
private static final float EYE_HEIGHT = 1.5f; private static final float EYE_HEIGHT = 1.5f;
public float pitchLevel; public float pitchLevel;
private int aggro = 0; private int aggro = 0;
private int soundTime = 0; private int soundTime = 0;
// private final int aggroCap; private final int aggroCap;
public MonolithEntity(EntityType<? extends MonolithEntity> type, World world) { public MonolithEntity(EntityType<? extends MonolithEntity> type, World world) {
super(type, world); super(type, world);
// noClip = true; noClip = true;
// aggroCap = MathHelper.getInt(rand, MIN_AGGRO_CAP, MAX_AGGRO_CAP); aggroCap = MathHelper.nextInt(getRandom(), MIN_AGGRO_CAP, MAX_AGGRO_CAP);
} }
//
// public boolean isDangerous() { public boolean isDangerous() {
// return ModConfig.MONOLITHS.monolithTeleportation && (world.dimension instanceof LimboDimension || ModConfig.MONOLITHS.dangerousLimboMonoliths); return false; //return ModConfig.MONOLITHS.monolithTeleportation && (world.dimension instanceof LimboDimension || ModConfig.MONOLITHS.dangerousLimboMonoliths);
// } }
//
// @Override @Override
// public boolean attackEntityFrom(DamageSource source, float amount) { public boolean damage(DamageSource source, float amount) {
// if (source != DamageSource.IN_WALL) { if (source != DamageSource.IN_WALL) {
// aggro = MAX_AGGRO; aggro = MAX_AGGRO;
// } }
// return false; return false;
// } }
//
// @Override @Override
// public boolean canBreatheUnderwater() { public int getMaxAir() {
// return true; return super.getMaxAir();
// } }
//
// @Override @Override
// public Box getCollisionBoundingBox() { protected int getNextAirUnderwater(int i) {
// return null; return 10;
// } }
//
// @Override @Override
// public Box getCollisionBox(Entity entity) { protected int getNextAirOnLand(int i) {
// return null; return 10;
// } }
//
// @Override @Override
// public boolean canDespawn() { public Box getCollisionBox() {
// return false; return null;
// } }
//
// @Override @Override
// protected void applyEntityAttributes() { public Box getHardCollisionBox(Entity entity) {
// super.applyEntityAttributes(); return null;
// getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(57005); }
// }
// @Override
public boolean cannotDespawn() {
return true;
}
@Override
protected void initAttributes() {
super.initAttributes();
getAttributes().get(MAX_HEALTH).setBaseValue(57005);
}
// @Override // @Override
// public boolean canBePushed() { // public boolean canBePushed() {
// return false; // return false;
// } // }
// //
// @Override
// public float getEyeHeight() {
// return EYE_HEIGHT; @Override
// } public double getEyeY() {
// return super.getEyeY();
// @Override }
// protected void entityInit() {
// super.entityInit(); @Override
// // Add a short for the aggro level protected void initDataTracker() {
// dataManager.register(AGGRO, 0); super.initDataTracker();
// } // Add a short for the aggro level
// dataTracker.startTracking(AGGRO, 0);
// @Override }
// public boolean isEntityAlive() {
// return false; @Override
// } public boolean isAlive() {
// return false;
// @Override }
// public void onEntityUpdate() {
// // Remove this Monolith if it's not in Limbo or in a pocket dungeon @Override
// if (!(world.dimension instanceof LimboDimension || world.dimension instanceof DungeonPocketDimension)) { protected void mobTick() {
// setDead(); // Remove this Monolith if it's not in Limbo or in a pocket dungeon
// super.onEntityUpdate(); if (!(world.dimension instanceof LimboDimension || world.dimension instanceof DungeonPocketDimension)) {
// return; remove();
// } super.mobTick();
// return;
// super.onEntityUpdate(); }
//
// // Check for players and update aggro levels even if there are no players in range super.mobTick();
// PlayerEntity player = world.getClosestPlayerToEntity(this, MAX_AGGRO_RANGE);
// boolean visibility = player != null && player.canEntityBeSeen(this); // Check for players and update aggro levels even if there are no players in range
// updateAggroLevel(player, visibility); PlayerEntity player = world.getClosestPlayer(this, MAX_AGGRO_RANGE);
// boolean visibility = player != null && player.canSee(this);
// // Change orientation and face a player if one is in range updateAggroLevel(player, visibility);
// if (player != null) {
// facePlayer(player); // Change orientation and face a player if one is in range
// if (!world.isClient && isDangerous()) { if (player != null) {
// // Play sounds on the server side, if the player isn't in Limbo. facePlayer(player);
// // Limbo is excluded to avoid drowning out its background music. if (!world.isClient && isDangerous()) {
// // Also, since it's a large open area with many Monoliths, some // Play sounds on the server side, if the player isn't in Limbo.
// // of the sounds that would usually play for a moment would // Limbo is excluded to avoid drowning out its background music.
// // keep playing constantly and would get very annoying. // Also, since it's a large open area with many Monoliths, some
// playSounds(player.getPosition()); // of the sounds that would usually play for a moment would
// } // keep playing constantly and would get very annoying.
// playSounds(player.getPos());
// if (visibility) { }
// // Only spawn particles on the client side and outside Limbo
// if (world.isClient && isDangerous()) { if (visibility) {
// spawnParticles(player); // Only spawn particles on the client side and outside Limbo
// } if (world.isClient && isDangerous()) {
// spawnParticles(player);
// // Teleport the target player if various conditions are met }
// if (aggro >= MAX_AGGRO && !world.isClient && ModConfig.MONOLITHS.monolithTeleportation && !player.isCreative() && isDangerous()) {
// aggro = 0; // Teleport the target player if various conditions are met
if (aggro >= MAX_AGGRO && !world.isClient && ModConfig.MONOLITHS.monolithTeleportation && !player.isCreative() && isDangerous()) {
aggro = 0;
// Location destination = LimboDimension.getLimboSkySpawn(player); // Location destination = LimboDimension.getLimboSkySpawn(player);
// TeleportUtil.teleport(player, destination, 0, 0); // TeleportUtil.teleport(player, destination, 0, 0);
// player.world.playSound(null, player.getPosition(), ModSoundEvents.CRACK, SoundCategory.HOSTILE, 13, 1); player.world.playSound(null, new BlockPos(player.getPos()), ModSoundEvents.CRACK, SoundCategory.HOSTILE, 13, 1);
// } }
// } }
// } }
// } }
//
// private void updateAggroLevel(PlayerEntity player, boolean visibility) { private void updateAggroLevel(PlayerEntity player, boolean visibility) {
// // If we're working on the server side, adjust aggro level // If we're working on the server side, adjust aggro level
// // If we're working on the client side, retrieve aggro level from dataWatcher // If we're working on the client side, retrieve aggro level from dataWatcher
// if (!world.isClient) { if (!world.isClient) {
// // Server side... // Server side...
// // Rapidly increase the aggro level if this Monolith can see the player // Rapidly increase the aggro level if this Monolith can see the player
// if (visibility) { if (visibility) {
// if (world.dimension instanceof LimboDimension) { if (world.dimension instanceof LimboDimension) {
// if (isDangerous()) { if (isDangerous()) {
// aggro++; aggro++;
// } else { } else {
// aggro += 36; aggro += 36;
// } }
// } else { } else {
// // Aggro increases faster outside of Limbo // Aggro increases faster outside of Limbo
// aggro += 3; aggro += 3;
// } }
// } else { } else {
// if (isDangerous()) { if (isDangerous()) {
// if (aggro > aggroCap) { if (aggro > aggroCap) {
// // Decrease aggro over time // Decrease aggro over time
// aggro--; aggro--;
// } else if (player != null && aggro < aggroCap) { } else if (player != null && aggro < aggroCap) {
// // Increase aggro if a player is within range and aggro < aggroCap // Increase aggro if a player is within range and aggro < aggroCap
// aggro++; aggro++;
// } }
// } else { } else {
// aggro -= 3; aggro -= 3;
// } }
// } }
// // Clamp the aggro level // Clamp the aggro level
// int maxAggro = isDangerous() ? MAX_AGGRO : 180; int maxAggro = isDangerous() ? MAX_AGGRO : 180;
// aggro = (short) MathHelper.clamp(aggro, 0, maxAggro); aggro = (short) MathHelper.clamp(aggro, 0, maxAggro);
// dataManager.set(AGGRO, aggro); dataTracker.set(AGGRO, aggro);
// } else { } else {
// // Client side... // Client side...
// aggro = dataManager.get(AGGRO); aggro = dataTracker.get(AGGRO);
// } }
// } }
//
// public int getTextureState() { public int getTextureState() {
// // Determine texture state from aggro progress // Determine texture state from aggro progress
// return MathHelper.clamp(MAX_TEXTURE_STATE * aggro / MAX_AGGRO, 0, MAX_TEXTURE_STATE); return MathHelper.clamp(MAX_TEXTURE_STATE * aggro / MAX_AGGRO, 0, MAX_TEXTURE_STATE);
// } }
//
// /** /**
// * Plays sounds at different levels of aggro, using soundTime to prevent too many sounds at once. * Plays sounds at different levels of aggro, using soundTime to prevent too many sounds at once.
// * *
// * @param pos The position to play the sounds at * @param pos The position to play the sounds at
// */ */
// private void playSounds(BlockPos pos) { private void playSounds(Vec3d pos) {
// float aggroPercent = getAggroProgress(); float aggroPercent = getAggroProgress();
// if (soundTime <= 0) { if (soundTime <= 0) {
// playSound(ModSoundEvents.MONK, 1F, 1F); playSound(ModSoundEvents.MONK, 1F, 1F);
// soundTime = 100; soundTime = 100;
// } }
// if (aggroPercent > 0.70 && soundTime < 100) { if (aggroPercent > 0.70 && soundTime < 100) {
// world.playSound(null, pos, ModSoundEvents.TEARING, SoundCategory.HOSTILE, 1F, (float) (1 + rand.nextGaussian())); world.playSound(null, new BlockPos(pos), ModSoundEvents.TEARING, SoundCategory.HOSTILE, 1F, (float) (1 + getRandom().nextGaussian()));
// soundTime = 100 + rand.nextInt(75); soundTime = 100 + getRandom().nextInt(75);
// } }
// if (aggroPercent > 0.80 && soundTime < MAX_SOUND_COOLDOWN) { if (aggroPercent > 0.80 && soundTime < MAX_SOUND_COOLDOWN) {
// world.playSound(null, pos, ModSoundEvents.TEARING, SoundCategory.HOSTILE, 7, 1F); world.playSound(null, new BlockPos(pos), ModSoundEvents.TEARING, SoundCategory.HOSTILE, 7, 1F);
// soundTime = 250; soundTime = 250;
// } }
// soundTime--; soundTime--;
// } }
//
// private void spawnParticles(PlayerEntity player) { private void spawnParticles(PlayerEntity player) {
// int count = 10 * aggro / MAX_AGGRO; int count = 10 * aggro / MAX_AGGRO;
// for (int i = 1; i < count; ++i) { for (int i = 1; i < count; ++i) {
// player.world.spawnParticle(EnumParticleTypes.PORTAL, player.posX + (rand.nextDouble() - 0.5D) * width, player.world.addParticle(ParticleTypes.PORTAL, player.getX() + (getRandom().nextDouble() - 0.5D) * getWidth(),
// player.posY + rand.nextDouble() * player.height - 0.75D, player.getY() + getRandom().nextDouble() * player.getHeight() - 0.75D,
// player.posZ + (rand.nextDouble() - 0.5D) * player.width, player.getZ() + (getRandom().nextDouble() - 0.5D) * player.getWidth(),
// (rand.nextDouble() - 0.5D) * 2.0D, -rand.nextDouble(), (getRandom().nextDouble() - 0.5D) * 2.0D, -getRandom().nextDouble(),
// (rand.nextDouble() - 0.5D) * 2.0D); (getRandom().nextDouble() - 0.5D) * 2.0D);
// } }
// } }
//
// public float getAggroProgress() { public float getAggroProgress() {
// return (float) aggro / MAX_AGGRO; return (float) aggro / MAX_AGGRO;
// } }
//
// private void facePlayer(PlayerEntity player) { private void facePlayer(PlayerEntity player) {
// double d0 = player.posX - posX; double d0 = player.getX() - getX();
// double d1 = player.posZ - posZ; double d1 = player.getZ() - getY();
// double d2 = player.posY + player.getEyeHeight() - (posY + EYE_HEIGHT); double d2 = player.getY() + player.getEyeHeight(player.getPose()) - (getY() + EYE_HEIGHT);
// double d3 = MathHelper.sqrt(d0 * d0 + d1 * d1); double d3 = MathHelper.sqrt(d0 * d0 + d1 * d1);
// float f2 = (float) (Math.atan2(d1, d0) * 180.0D / Math.PI) - 90.0F; float f2 = (float) (Math.atan2(d1, d0) * 180.0D / Math.PI) - 90.0F;
// pitchLevel = (float) -(Math.atan(d2 / d3) * 180.0D / Math.PI); setRotation((float) -(Math.atan(d2 / d3) * 180.0D / Math.PI), f2);
// rotationYaw = f2; setYaw(f2);
// rotationYawHead = f2; setHeadYaw(f2);
// renderYawOffset = rotationYaw; //renderYawOffset = rotationYaw;
// } }
//
// @Override
// @Override public CompoundTag toTag(CompoundTag tag) {
// public CompoundTag toTag(CompoundTag tag) { super.toTag(tag);
// super.toTag(tag); tag.putInt("Aggro", aggro);
// tag.putInt("Aggro", aggro); return tag;
// return tag; }
// }
// @Override
// @Override public void fromTag(CompoundTag nbt) {
// public void fromTag(CompoundTag nbt) { super.fromTag(nbt);
// super.readEntityFromNBT(nbt); aggro = nbt.getInt("Aggro");
// aggro = nbt.getInteger("Aggro"); }
// }
} }

View file

@ -1,16 +1,28 @@
package org.dimdev.dimdoors.entity; package org.dimdev.dimdoors.entity;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry; import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.EntityRenderer; import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import org.dimdev.dimdoors.client.MonolithModel;
public class MonolithRenderer extends EntityRenderer<MonolithEntity> { public class MonolithRenderer extends EntityRenderer<MonolithEntity> {
private final EntityRendererRegistry.Context context; private MonolithModel model = new MonolithModel();
protected MonolithRenderer(EntityRenderDispatcher dispatcher, EntityRendererRegistry.Context context) { protected MonolithRenderer(EntityRenderDispatcher dispatcher, EntityRendererRegistry.Context context) {
super(dispatcher); super(dispatcher);
this.context = context; }
@Override
public void render(MonolithEntity entity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) {
super.render(entity, f, g, matrixStack, vertexConsumerProvider, i);
matrixStack.push();
//model.render(entity);
matrixStack.pop();
} }
@Override @Override

View file

@ -16,9 +16,9 @@ public class LimboBiome extends Biome {
.configureSurfaceBuilder( .configureSurfaceBuilder(
SurfaceBuilder.DEFAULT, SurfaceBuilder.DEFAULT,
new TernarySurfaceConfig( new TernarySurfaceConfig(
ModBlocks.BLACK_FABRIC.getDefaultState(), ModBlocks.UNRAVELLED_FABRIC.getDefaultState(),
ModBlocks.BLACK_FABRIC.getDefaultState(), ModBlocks.UNRAVELLED_FABRIC.getDefaultState(),
ModBlocks.BLACK_FABRIC.getDefaultState() ModBlocks.ETERNAL_FLUID.getDefaultState()
) )
) )
.precipitation(Biome.Precipitation.NONE).category(Biome.Category.NETHER) .precipitation(Biome.Precipitation.NONE).category(Biome.Category.NETHER)
@ -39,6 +39,6 @@ public class LimboBiome extends Biome {
.noises(ImmutableList.of(new Biome.MixedNoisePoint(0.0F, 0.0F, 0.0F, -0.5F, 1.0F)))); .noises(ImmutableList.of(new Biome.MixedNoisePoint(0.0F, 0.0F, 0.0F, -0.5F, 1.0F))));
addSpawn(EntityCategory.MONSTER, new Biome.SpawnEntry(ModEntityTypes.MONOLITH, 100, 1, 1)); //addSpawn(EntityCategory.MONSTER, new Biome.SpawnEntry(ModEntityTypes.MONOLITH, 100, 1, 1));
} }
} }

View file

@ -15,22 +15,22 @@ public class LimboChunkGenerator extends SurfaceChunkGenerator<LimboChunkGenerat
private final double[] noiseFalloff = buildNoiseFalloff(); private final double[] noiseFalloff = buildNoiseFalloff();
public LimboChunkGenerator(IWorld world, BiomeSource biomeSource, LimboChunkGeneratorConfig config) { public LimboChunkGenerator(IWorld world, BiomeSource biomeSource, LimboChunkGeneratorConfig config) {
super(world, biomeSource, 4, 8, 128, config, false); super(world, biomeSource, 4, 8, 256, config, false);
} }
@Override @Override
protected void sampleNoiseColumn(double[] ds, int i, int j) { protected void sampleNoiseColumn(double[] buffer, int x, int z) {
sampleNoiseColumn(ds, i, j, 684.412D, 2053.236D, 8.555150000000001D, 34.2206D, 3, -10); sampleNoiseColumn(buffer, x, z, 884.412D, 9740.421D, 8.555150000000001D, 20.2206D, 3, -10);
} }
@Override @Override
protected double[] computeNoiseRange(int i, int j) { protected double[] computeNoiseRange(int i, int j) {
return new double[]{0.0D, 0.0D}; return new double[] {-0.80118735, 5.4635482};
} }
@Override @Override
protected double computeNoiseFalloff(double d, double e, int i) { protected double computeNoiseFalloff(double d, double e, int i) {
return noiseFalloff[i]; return noiseFalloff[i]/8000d;
} }
private double[] buildNoiseFalloff() { private double[] buildNoiseFalloff() {

View file

@ -1,6 +1,7 @@
package org.dimdev.dimdoors.world.limbo; package org.dimdev.dimdoors.world.limbo;
import net.minecraft.world.gen.chunk.CavesChunkGeneratorConfig;
import net.minecraft.world.gen.chunk.ChunkGeneratorConfig; import net.minecraft.world.gen.chunk.ChunkGeneratorConfig;
public class LimboChunkGeneratorConfig extends ChunkGeneratorConfig { public class LimboChunkGeneratorConfig extends CavesChunkGeneratorConfig {
} }