Fix doors not having a blockentity

This commit is contained in:
SD 2021-03-22 22:51:36 +05:30
parent baf2bd2373
commit 1e947cd371
9 changed files with 40 additions and 17 deletions

View file

@ -96,6 +96,15 @@ public class DimensionalDoorsInitializer implements ModInitializer {
server = minecraftServer;
});
Targets.registerDefaultTargets();
VirtualTarget.VirtualTargetType.register();
VirtualSingularPocket.VirtualSingularPocketType.register();
Modifier.ModifierType.register();
PocketGenerator.PocketGeneratorType.register();
AbstractPocket.AbstractPocketType.register();
PocketAddon.PocketAddonType.register();
Condition.ConditionType.register();
ModBlocks.init();
ModItems.init();
ModFeatures.init();
@ -109,17 +118,6 @@ public class DimensionalDoorsInitializer implements ModInitializer {
ModSoundEvents.init();
ModParticleTypes.init();
Targets.registerDefaultTargets();
VirtualTarget.VirtualTargetType.register();
VirtualSingularPocket.VirtualSingularPocketType.register();
Modifier.ModifierType.register();
PocketGenerator.PocketGeneratorType.register();
AbstractPocket.AbstractPocketType.register();
PocketAddon.PocketAddonType.register();
Condition.ConditionType.register();
DoorDataReader.read();
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(PocketLoader.getInstance());
ResourceManagerHelper.registerBuiltinResourcePack(new Identifier("dimdoors", "default_pockets"), dimDoorsMod, ResourcePackActivationType.DEFAULT_ENABLED);

View file

@ -75,4 +75,9 @@ public class DimensionalPortalBlock extends Block implements RiftProvider<Entran
public VoxelShape getRaycastShape(BlockState state, BlockView world, BlockPos pos) {
return VoxelShapes.fullCube();
}
@Override
public boolean isTall(BlockState cachedState) {
return true;
}
}

View file

@ -6,6 +6,7 @@ import java.util.Map;
import com.google.common.collect.Maps;
import org.dimdev.dimdoors.block.door.DimensionalTrapdoorBlock;
import org.dimdev.dimdoors.block.door.data.DoorData;
import org.dimdev.dimdoors.block.door.data.DoorDataReader;
import org.dimdev.matrix.Matrix;
import org.dimdev.matrix.Registrar;
import org.dimdev.matrix.RegistryEntry;
@ -171,6 +172,7 @@ public final class ModBlocks {
public static void init() {
Matrix.register(ModBlocks.class, Registry.BLOCK);
DoorDataReader.read();
}
@Environment(EnvType.CLIENT)

View file

@ -9,4 +9,8 @@ import net.minecraft.world.World;
public interface RiftProvider<T extends RiftBlockEntity> extends BlockEntityProvider {
T getRift(World world, BlockPos pos, BlockState state);
default boolean isTall(BlockState cachedState) {
return false;
}
}

View file

@ -1,5 +1,6 @@
package org.dimdev.dimdoors.block.door;
import net.minecraft.block.BlockRenderType;
import net.minecraft.util.math.Vec3d;
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
@ -141,4 +142,9 @@ public class DimensionalDoorBlock extends DoorBlock implements RiftProvider<Entr
public boolean isExitFlipped() {
return true;
}
@Override
public boolean isTall(BlockState cachedState) {
return true;
}
}

View file

@ -5,6 +5,7 @@ import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
import org.jetbrains.annotations.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.TrapdoorBlock;
import net.minecraft.block.entity.BlockEntity;
@ -62,5 +63,4 @@ public class DimensionalTrapdoorBlock extends TrapdoorBlock implements RiftProvi
public VoxelShape getRaycastShape(BlockState state, BlockView world, BlockPos pos) {
return VoxelShapes.fullCube();
}
}

View file

@ -4,6 +4,7 @@ import java.util.Optional;
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
import org.dimdev.dimdoors.block.CoordinateTransformerBlock;
import org.dimdev.dimdoors.block.RiftProvider;
import org.dimdev.dimdoors.client.DefaultTransformation;
import org.dimdev.dimdoors.client.Transformer;
import org.dimdev.dimdoors.item.RiftKeyItem;
@ -135,7 +136,7 @@ public class EntranceRiftBlockEntity extends RiftBlockEntity {
* Specifies if the portal should be rendered two blocks tall
*/
public boolean isTall() {
return this.getCachedState().getBlock() instanceof DoorBlock;
return ((RiftProvider<?>) this.getCachedState().getBlock()).isTall(this.getCachedState());
}
@Override

View file

@ -1,6 +1,7 @@
package org.dimdev.dimdoors.client;
import java.util.Collections;
import java.util.Random;
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
@ -15,6 +16,7 @@ import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.block.entity.EndPortalBlockEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Matrix4f;
import net.fabricmc.api.EnvType;
@ -27,17 +29,22 @@ public class EntranceRiftBlockEntityRenderer implements BlockEntityRenderer<Entr
private static final RenderLayer RENDER_LAYER;
private static final ModelPart MODEL;
private static final ModelPart TALL_MODEL;
private static final Random RANDOM = new Random();
@Override
public void render(EntranceRiftBlockEntity blockEntity, float tickDelta, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, int overlay) {
float r = MathHelper.clamp((RANDOM.nextFloat() * 0.3F + 0.1F) * tickDelta, 0, 1);
float g = MathHelper.clamp((RANDOM.nextFloat() * 0.4F + 0.1F) * tickDelta, 0, 1);
float b = MathHelper.clamp((RANDOM.nextFloat() * 0.5F + 0.6F) * tickDelta, 0, 1);
blockEntity.getTransformer().transform(matrixStack);
if (blockEntity.isTall()) {
TALL_MODEL.render(matrixStack, vertexConsumerProvider.getBuffer(RENDER_LAYER), light, overlay);
TALL_MODEL.render(matrixStack, vertexConsumerProvider.getBuffer(RENDER_LAYER), light, overlay, r, g, b, 1);
} else {
MODEL.render(matrixStack, vertexConsumerProvider.getBuffer(RENDER_LAYER), light, overlay);
MODEL.render(matrixStack, vertexConsumerProvider.getBuffer(RENDER_LAYER), light, overlay, r, g, b, 1);
}
}
static {
WARP_PATH = new Identifier("dimdoors:textures/other/warp.png");
DIMENSIONAL_PORTAL_SHADER = new RenderPhase.class_5942(ModShaders::getDimensionalPortal);

View file

@ -4,8 +4,8 @@
"srcrgb": "srcalpha",
"dstrgb": "1-srcalpha"
},
"vertex": "rendertype_end_portal",
"fragment": "rendertype_end_portal",
"vertex": "dimensional_portal",
"fragment": "dimensional_portal",
"attributes": [],
"samplers": [
{ "name": "Sampler0" },