From 2a4ed3d8ca3345a82395d819d127c27e2e413ab4 Mon Sep 17 00:00:00 2001 From: SD Date: Sun, 19 Jul 2020 21:09:38 +0530 Subject: [PATCH] Registered BERs BERs go brrr On branch 1.16 Changes to be committed: modified: src/main/java/org/dimdev/dimdoors/DimensionalDoorsClientInitializer.java modified: src/main/java/org/dimdev/dimdoors/DimensionalDoorsInitializer.java modified: src/main/java/org/dimdev/dimdoors/block/DimensionalPortalBlock.java modified: src/main/java/org/dimdev/dimdoors/client/DimensionalPortalRenderer.java modified: src/main/java/org/dimdev/dimdoors/client/EntranceRiftBlockEntityRenderer.java --- .../DimensionalDoorsClientInitializer.java | 7 ++++ .../dimdoors/DimensionalDoorsInitializer.java | 2 ++ .../block/DimensionalPortalBlock.java | 21 +++++++++-- .../client/DimensionalPortalRenderer.java | 25 +++++++------ .../EntranceRiftBlockEntityRenderer.java | 36 +++++++++---------- 5 files changed, 57 insertions(+), 34 deletions(-) diff --git a/src/main/java/org/dimdev/dimdoors/DimensionalDoorsClientInitializer.java b/src/main/java/org/dimdev/dimdoors/DimensionalDoorsClientInitializer.java index 66010836..5189d447 100644 --- a/src/main/java/org/dimdev/dimdoors/DimensionalDoorsClientInitializer.java +++ b/src/main/java/org/dimdev/dimdoors/DimensionalDoorsClientInitializer.java @@ -7,6 +7,7 @@ import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandler; import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry; +import net.fabricmc.fabric.api.client.rendereregistry.v1.BlockEntityRendererRegistry; import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; import net.fabricmc.fabric.api.network.ClientSidePacketRegistry; import net.fabricmc.fabric.api.resource.ResourceManagerHelper; @@ -26,7 +27,10 @@ import net.minecraft.util.math.Vec3i; import net.minecraft.util.registry.Registry; import net.minecraft.world.BlockRenderView; import org.dimdev.dimdoors.block.ModBlocks; +import org.dimdev.dimdoors.block.entity.ModBlockEntityTypes; import org.dimdev.dimdoors.client.CustomSkyProvider; +import org.dimdev.dimdoors.client.DetachedRiftBlockEntityRenderer; +import org.dimdev.dimdoors.client.EntranceRiftBlockEntityRenderer; import org.dimdev.dimdoors.client.LimboSkyProvider; import org.dimdev.dimdoors.entity.ModEntityTypes; import org.dimdev.dimdoors.entity.MonolithEntity; @@ -54,6 +58,9 @@ public class DimensionalDoorsClientInitializer implements ClientModInitializer { OpenWorlds.registerSkyRenderer(ModDimensions.LIMBO_TYPE, new LimboSkyProvider()); ClientSidePacketRegistry.INSTANCE.register(DimensionalDoorsInitializer.MONOLITH_PARTICLE_PACKET, MonolithEntity::spawnParticles); + + BlockEntityRendererRegistry.INSTANCE.register(ModBlockEntityTypes.ENTRANCE_RIFT, EntranceRiftBlockEntityRenderer::new); + BlockEntityRendererRegistry.INSTANCE.register(ModBlockEntityTypes.DETACHED_RIFT, DetachedRiftBlockEntityRenderer::new); } private void putCutout(Block block) { diff --git a/src/main/java/org/dimdev/dimdoors/DimensionalDoorsInitializer.java b/src/main/java/org/dimdev/dimdoors/DimensionalDoorsInitializer.java index 2d21c841..ad3e1d8e 100644 --- a/src/main/java/org/dimdev/dimdoors/DimensionalDoorsInitializer.java +++ b/src/main/java/org/dimdev/dimdoors/DimensionalDoorsInitializer.java @@ -3,6 +3,7 @@ package org.dimdev.dimdoors; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback; import org.dimdev.dimdoors.block.ModBlocks; +import org.dimdev.dimdoors.block.entity.ModBlockEntityTypes; import org.dimdev.dimdoors.commands.CommandPocket; import org.dimdev.dimdoors.commands.CommandSaveSchem; import org.dimdev.dimdoors.commands.DimTeleportCommand; @@ -29,6 +30,7 @@ public class DimensionalDoorsInitializer implements ModInitializer { ModEntityTypes.init(); ModBiomes.init(); ModFeatures.init(); + ModBlockEntityTypes.init(); this.registerCommands(); diff --git a/src/main/java/org/dimdev/dimdoors/block/DimensionalPortalBlock.java b/src/main/java/org/dimdev/dimdoors/block/DimensionalPortalBlock.java index 482fdb9a..76cdb53f 100644 --- a/src/main/java/org/dimdev/dimdoors/block/DimensionalPortalBlock.java +++ b/src/main/java/org/dimdev/dimdoors/block/DimensionalPortalBlock.java @@ -1,9 +1,26 @@ package org.dimdev.dimdoors.block; -import net.minecraft.block.Block; +import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity; -public class DimensionalPortalBlock extends Block { // TODO +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.BlockView; +import net.minecraft.world.World; + +public class DimensionalPortalBlock extends Block implements RiftProvider { public DimensionalPortalBlock(Settings settings) { super(settings); } + + @Override + public EntranceRiftBlockEntity getRift(World world, BlockPos pos, BlockState state) { + return (EntranceRiftBlockEntity) this.createBlockEntity(world); + } + + @Override + public BlockEntity createBlockEntity(BlockView world) { + return new EntranceRiftBlockEntity(); + } } diff --git a/src/main/java/org/dimdev/dimdoors/client/DimensionalPortalRenderer.java b/src/main/java/org/dimdev/dimdoors/client/DimensionalPortalRenderer.java index 43b0249d..7d361775 100644 --- a/src/main/java/org/dimdev/dimdoors/client/DimensionalPortalRenderer.java +++ b/src/main/java/org/dimdev/dimdoors/client/DimensionalPortalRenderer.java @@ -3,25 +3,24 @@ 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.VertexFormats; +import net.minecraft.client.render.*; import net.minecraft.client.util.GlAllocationUtils; import net.minecraft.util.Identifier; import net.minecraft.util.Util; import net.minecraft.util.math.Direction; import org.lwjgl.opengl.GL11; -import java.nio.ByteBuffer; import java.nio.FloatBuffer; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import static com.mojang.blaze3d.platform.GlStateManager.TexCoord.*; import static com.mojang.blaze3d.platform.GlStateManager.enableTexGen; +@Environment(EnvType.CLIENT) public final class DimensionalPortalRenderer { // TODO - private static final FloatBuffer buffer = GlAllocationUtils.allocateFloatBuffer(16); - private static final Identifier warpPath = new Identifier("dimdoors" + ":textures/other/warp.png"); + private static final FloatBuffer BUFFER = GlAllocationUtils.allocateFloatBuffer(16); + private static final Identifier WARP_TEX = new Identifier("dimdoors", "textures/other/warp.png"); /** * Renders a dimensional portal, for use in various situations. Code is mostly based @@ -37,7 +36,7 @@ public final class DimensionalPortalRenderer { // TODO * @param height The height of the wall. * @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(VertexConsumerProvider 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.disableCull(); @@ -48,7 +47,7 @@ public final class DimensionalPortalRenderer { // TODO float scale = 0.2625F; float colorMultiplier = 1.0F / (translationScale + .80F); - MinecraftClient.getInstance().getTextureManager().bindTexture(warpPath); + MinecraftClient.getInstance().getTextureManager().bindTexture(WARP_TEX); RenderSystem.enableBlend(); if (pass == 0) { @@ -189,9 +188,9 @@ public final class DimensionalPortalRenderer { // TODO } 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; + BUFFER.clear(); + BUFFER.put(f1).put(f2).put(f3).put(f4); + BUFFER.flip(); + return BUFFER; } } diff --git a/src/main/java/org/dimdev/dimdoors/client/EntranceRiftBlockEntityRenderer.java b/src/main/java/org/dimdev/dimdoors/client/EntranceRiftBlockEntityRenderer.java index 6101a4f5..c75b7d4f 100644 --- a/src/main/java/org/dimdev/dimdoors/client/EntranceRiftBlockEntityRenderer.java +++ b/src/main/java/org/dimdev/dimdoors/client/EntranceRiftBlockEntityRenderer.java @@ -1,17 +1,18 @@ package org.dimdev.dimdoors.client; -import com.mojang.blaze3d.systems.RenderSystem; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; +import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity; + import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; import net.minecraft.client.render.block.entity.BlockEntityRenderer; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.server.world.ServerWorld; +import net.minecraft.client.util.math.Vector3f; 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 net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; @Environment(EnvType.CLIENT) public class EntranceRiftBlockEntityRenderer extends BlockEntityRenderer { @@ -24,23 +25,20 @@ public class EntranceRiftBlockEntityRenderer extends BlockEntityRenderer= 1) { - for (int i = 0; i < 1 + entrance.lockStatus; i++) { - renderKeyHole(entrance, x, y, z, i); - } - }*/ + 16, + 16, + entrance.getColors(16)); } }