Use matrix

This commit is contained in:
SD 2021-03-03 22:25:16 +05:30
parent 9f9813ec8c
commit 18c5689779
19 changed files with 221 additions and 220 deletions

View file

@ -80,7 +80,6 @@ sourceSets {
main {
java {
srcDir "src/main/schematics"
srcDir "src/main/registry"
srcDir "src/main/config"
}
}
@ -95,6 +94,7 @@ dependencies {
includeCompile("com.flowpowered", "flow-math", "1.0.3")
includeCompile("org.jgrapht", "jgrapht-core", "1.1.0")
includeCompile("com.github.DimensionalDevelopment", "poly2tri.java", "0.1.1")
includeCompile("com.github.DimensionalDevelopment", "Matrix", "1.0.0")
includeCompile("io.github.BoogieMonster1O1", "OpenWorlds", "c57e3ef")
includeCompile("io.github.cottonmc", "LibGui", "3.3.2+1.16.4")
includeCompile("me.shedaniel.cloth", "config-2", "5.0.0")

View file

@ -6,8 +6,8 @@ import java.util.function.Supplier;
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
import me.sargunvohra.mcmods.autoconfig1u.ConfigHolder;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.block.door.DoorDataReader;
import org.dimdev.dimdoors.block.door.condition.Condition;
import org.dimdev.dimdoors.block.door.data.DoorDataReader;
import org.dimdev.dimdoors.block.door.data.condition.Condition;
import org.dimdev.dimdoors.block.entity.ModBlockEntityTypes;
import org.dimdev.dimdoors.command.ModCommands;
import org.dimdev.dimdoors.entity.ModEntityTypes;

View file

@ -4,10 +4,11 @@ import java.util.HashMap;
import java.util.Map;
import com.google.common.collect.Maps;
import org.dimdev.dimdoors.block.door.DimensionalDoorBlock;
import org.dimdev.dimdoors.block.door.DimensionalTrapdoorBlock;
import org.dimdev.dimdoors.block.door.DoorData;
import org.dimdev.dimdoors.block.door.DoorDataReader;
import org.dimdev.dimdoors.block.door.data.DoorData;
import org.dimdev.matrix.Matrix;
import org.dimdev.matrix.Registrar;
import org.dimdev.matrix.RegistryEntry;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
@ -23,83 +24,153 @@ import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
@Registrar(element = Block.class, modid = "dimdoors")
public final class ModBlocks {
private static final Map<String, Block> BLOCKS = Maps.newLinkedHashMap();
public static final Map<DyeColor, Block> FABRIC_BLOCKS = new HashMap<>();
private static final Map<DyeColor, Block> ANCIENT_FABRIC_BLOCKS = new HashMap<>();
public static final Block GOLD_DOOR = register("dimdoors:gold_door", new DoorBlock(FabricBlockSettings.of(Material.METAL, MapColor.GOLD).strength(5.0F).breakByHand(false).breakByTool(FabricToolTags.PICKAXES).nonOpaque()));
public static final Block QUARTZ_DOOR = register("dimdoors:quartz_door", new DoorBlock(FabricBlockSettings.of(Material.STONE, MapColor.OFF_WHITE).strength(5.0F).breakByHand(false).breakByTool(FabricToolTags.PICKAXES).nonOpaque()));
// public static final Block OAK_DIMENSIONAL_DOOR = register("dimdoors:oak_dimensional_door", new DimensionalDoorBlock(FabricBlockSettings.copyOf(Blocks.OAK_DOOR).luminance(state -> 10)));
// public static final Block IRON_DIMENSIONAL_DOOR = register("dimdoors:iron_dimensional_door", new DimensionalDoorBlock(FabricBlockSettings.copyOf(Blocks.IRON_DOOR).luminance(state -> 10)));
// public static final Block GOLD_DIMENSIONAL_DOOR = register("dimdoors:gold_dimensional_door", new DimensionalDoorBlock(FabricBlockSettings.copyOf(GOLD_DOOR).luminance(state -> 10)));
// public static final Block QUARTZ_DIMENSIONAL_DOOR = register("dimdoors:quartz_dimensional_door", new DimensionalDoorBlock(FabricBlockSettings.copy(QUARTZ_DOOR).luminance(state -> 10)));
public static final Block OAK_DIMENSIONAL_TRAPDOOR = register("dimdoors:wood_dimensional_trapdoor", new DimensionalTrapdoorBlock(FabricBlockSettings.copyOf(Blocks.OAK_TRAPDOOR).luminance(state -> 10)));
@RegistryEntry("gold_door")
public static final Block GOLD_DOOR = register(new DoorBlock(FabricBlockSettings.of(Material.METAL, MapColor.GOLD).strength(5.0F).breakByHand(false).breakByTool(FabricToolTags.PICKAXES).nonOpaque()));
public static final Block DIMENSIONAL_PORTAL = register("dimdoors:dimensional_portal", new DimensionalPortalBlock(FabricBlockSettings.of(Material.AIR).collidable(false).strength(-1.0F, 3600000.0F).nonOpaque().dropsNothing().luminance(10)));
public static final Block DETACHED_RIFT = register("dimdoors:detached_rift", new DetachedRiftBlock(FabricBlockSettings.of(Material.AIR).strength(-1.0F, 3600000.0F).noCollision().nonOpaque()));
@RegistryEntry("quartz_door")
public static final Block QUARTZ_DOOR = register(new DoorBlock(FabricBlockSettings.of(Material.STONE, MapColor.OFF_WHITE).strength(5.0F).breakByHand(false).breakByTool(FabricToolTags.PICKAXES).nonOpaque()));
public static final Block WHITE_FABRIC = registerFabric("dimdoors:white_fabric", DyeColor.WHITE);
public static final Block ORANGE_FABRIC = registerFabric("dimdoors:orange_fabric", DyeColor.ORANGE);
public static final Block MAGENTA_FABRIC = registerFabric("dimdoors:magenta_fabric", DyeColor.MAGENTA);
public static final Block LIGHT_BLUE_FABRIC = registerFabric("dimdoors:light_blue_fabric", DyeColor.LIGHT_BLUE);
public static final Block YELLOW_FABRIC = registerFabric("dimdoors:yellow_fabric", DyeColor.YELLOW);
public static final Block LIME_FABRIC = registerFabric("dimdoors:lime_fabric", DyeColor.LIME);
public static final Block PINK_FABRIC = registerFabric("dimdoors:pink_fabric", DyeColor.PINK);
public static final Block GRAY_FABRIC = registerFabric("dimdoors:gray_fabric", DyeColor.GRAY);
public static final Block LIGHT_GRAY_FABRIC = registerFabric("dimdoors:light_gray_fabric", DyeColor.LIGHT_GRAY);
public static final Block CYAN_FABRIC = registerFabric("dimdoors:cyan_fabric", DyeColor.CYAN);
public static final Block PURPLE_FABRIC = registerFabric("dimdoors:purple_fabric", DyeColor.PURPLE);
public static final Block BLUE_FABRIC = registerFabric("dimdoors:blue_fabric", DyeColor.BLUE);
public static final Block BROWN_FABRIC = registerFabric("dimdoors:brown_fabric", DyeColor.BROWN);
public static final Block GREEN_FABRIC = registerFabric("dimdoors:green_fabric", DyeColor.GREEN);
public static final Block RED_FABRIC = registerFabric("dimdoors:red_fabric", DyeColor.RED);
public static final Block BLACK_FABRIC = registerFabric("dimdoors:black_fabric", DyeColor.BLACK);
@RegistryEntry("wood_dimensional_trapdoor")
public static final Block OAK_DIMENSIONAL_TRAPDOOR = register(new DimensionalTrapdoorBlock(FabricBlockSettings.copyOf(Blocks.OAK_TRAPDOOR).luminance(state -> 10)));
public static final Block WHITE_ANCIENT_FABRIC = registerAncientFabric("dimdoors:white_ancient_fabric", DyeColor.WHITE);
public static final Block ORANGE_ANCIENT_FABRIC = registerAncientFabric("dimdoors:orange_ancient_fabric", DyeColor.ORANGE);
public static final Block MAGENTA_ANCIENT_FABRIC = registerAncientFabric("dimdoors:magenta_ancient_fabric", DyeColor.MAGENTA);
public static final Block LIGHT_BLUE_ANCIENT_FABRIC = registerAncientFabric("dimdoors:light_blue_ancient_fabric", DyeColor.LIGHT_BLUE);
public static final Block YELLOW_ANCIENT_FABRIC = registerAncientFabric("dimdoors:yellow_ancient_fabric", DyeColor.YELLOW);
public static final Block LIME_ANCIENT_FABRIC = registerAncientFabric("dimdoors:lime_ancient_fabric", DyeColor.LIME);
public static final Block PINK_ANCIENT_FABRIC = registerAncientFabric("dimdoors:pink_ancient_fabric", DyeColor.PINK);
public static final Block GRAY_ANCIENT_FABRIC = registerAncientFabric("dimdoors:gray_ancient_fabric", DyeColor.GRAY);
public static final Block LIGHT_GRAY_ANCIENT_FABRIC = registerAncientFabric("dimdoors:light_gray_ancient_fabric", DyeColor.LIGHT_GRAY);
public static final Block CYAN_ANCIENT_FABRIC = registerAncientFabric("dimdoors:cyan_ancient_fabric", DyeColor.CYAN);
public static final Block PURPLE_ANCIENT_FABRIC = registerAncientFabric("dimdoors:purple_ancient_fabric", DyeColor.PURPLE);
public static final Block BLUE_ANCIENT_FABRIC = registerAncientFabric("dimdoors:blue_ancient_fabric", DyeColor.BLUE);
public static final Block BROWN_ANCIENT_FABRIC = registerAncientFabric("dimdoors:brown_ancient_fabric", DyeColor.BROWN);
public static final Block GREEN_ANCIENT_FABRIC = registerAncientFabric("dimdoors:green_ancient_fabric", DyeColor.GREEN);
public static final Block RED_ANCIENT_FABRIC = registerAncientFabric("dimdoors:red_ancient_fabric", DyeColor.RED);
public static final Block BLACK_ANCIENT_FABRIC = registerAncientFabric("dimdoors:black_ancient_fabric", DyeColor.BLACK);
public static final Block ETERNAL_FLUID = register("dimdoors:eternal_fluid", new EternalFluidBlock(FabricBlockSettings.of(Material.STONE, MapColor.RED).luminance(15)));
public static final Block UNRAVELLED_FABRIC = register("dimdoors:unravelled_fabric", new UnravelledFabricBlock(FabricBlockSettings.of(Material.STONE, MapColor.BLACK).ticksRandomly().luminance(15)));
@RegistryEntry("dimensional_portal")
public static final Block DIMENSIONAL_PORTAL = register(new DimensionalPortalBlock(FabricBlockSettings.of(Material.AIR).collidable(false).strength(-1.0F, 3600000.0F).nonOpaque().dropsNothing().luminance(10)));
public static final Block MARKING_PLATE = register("dimdoors:marking_plate", new MarkingPlateBlock(FabricBlockSettings.of(Material.METAL, DyeColor.BLACK).nonOpaque()));
@RegistryEntry("detached_rift")
public static final Block DETACHED_RIFT = register(new DetachedRiftBlock(FabricBlockSettings.of(Material.AIR).strength(-1.0F, 3600000.0F).noCollision().nonOpaque()));
private static Block register(String string, Block block) {
BLOCKS.put(string, block);
@RegistryEntry("white_fabric")
public static final Block WHITE_FABRIC = registerFabric(DyeColor.WHITE);
@RegistryEntry("orange_fabric")
public static final Block ORANGE_FABRIC = registerFabric(DyeColor.ORANGE);
@RegistryEntry("magenta_fabric")
public static final Block MAGENTA_FABRIC = registerFabric(DyeColor.MAGENTA);
@RegistryEntry("light_blue_fabric")
public static final Block LIGHT_BLUE_FABRIC = registerFabric(DyeColor.LIGHT_BLUE);
@RegistryEntry("yellow_fabric")
public static final Block YELLOW_FABRIC = registerFabric(DyeColor.YELLOW);
@RegistryEntry("lime_fabric")
public static final Block LIME_FABRIC = registerFabric(DyeColor.LIME);
@RegistryEntry("pink_fabric")
public static final Block PINK_FABRIC = registerFabric(DyeColor.PINK);
@RegistryEntry("gray_fabric")
public static final Block GRAY_FABRIC = registerFabric(DyeColor.GRAY);
@RegistryEntry("light_gray_fabric")
public static final Block LIGHT_GRAY_FABRIC = registerFabric(DyeColor.LIGHT_GRAY);
@RegistryEntry("cyan_fabric")
public static final Block CYAN_FABRIC = registerFabric(DyeColor.CYAN);
@RegistryEntry("purple_fabric")
public static final Block PURPLE_FABRIC = registerFabric(DyeColor.PURPLE);
@RegistryEntry("blue_fabric")
public static final Block BLUE_FABRIC = registerFabric(DyeColor.BLUE);
@RegistryEntry("brown_fabric")
public static final Block BROWN_FABRIC = registerFabric(DyeColor.BROWN);
@RegistryEntry("green_fabric")
public static final Block GREEN_FABRIC = registerFabric(DyeColor.GREEN);
@RegistryEntry("red_fabric")
public static final Block RED_FABRIC = registerFabric(DyeColor.RED);
@RegistryEntry("black_fabric")
public static final Block BLACK_FABRIC = registerFabric(DyeColor.BLACK);
@RegistryEntry("white_ancient_fabric")
public static final Block WHITE_ANCIENT_FABRIC = registerAncientFabric(DyeColor.WHITE);
@RegistryEntry("orange_ancient_fabric")
public static final Block ORANGE_ANCIENT_FABRIC = registerAncientFabric(DyeColor.ORANGE);
@RegistryEntry("magenta_ancient_fabric")
public static final Block MAGENTA_ANCIENT_FABRIC = registerAncientFabric(DyeColor.MAGENTA);
@RegistryEntry("light_blue_ancient_fabric")
public static final Block LIGHT_BLUE_ANCIENT_FABRIC = registerAncientFabric(DyeColor.LIGHT_BLUE);
@RegistryEntry("yellow_ancient_fabric")
public static final Block YELLOW_ANCIENT_FABRIC = registerAncientFabric(DyeColor.YELLOW);
@RegistryEntry("lime_ancient_fabric")
public static final Block LIME_ANCIENT_FABRIC = registerAncientFabric(DyeColor.LIME);
@RegistryEntry("pink_ancient_fabric")
public static final Block PINK_ANCIENT_FABRIC = registerAncientFabric(DyeColor.PINK);
@RegistryEntry("gray_ancient_fabric")
public static final Block GRAY_ANCIENT_FABRIC = registerAncientFabric(DyeColor.GRAY);
@RegistryEntry("light_gray_ancient_fabric")
public static final Block LIGHT_GRAY_ANCIENT_FABRIC = registerAncientFabric(DyeColor.LIGHT_GRAY);
@RegistryEntry("cyan_ancient_fabric")
public static final Block CYAN_ANCIENT_FABRIC = registerAncientFabric(DyeColor.CYAN);
@RegistryEntry("purple_ancient_fabric")
public static final Block PURPLE_ANCIENT_FABRIC = registerAncientFabric(DyeColor.PURPLE);
@RegistryEntry("blue_ancient_fabric")
public static final Block BLUE_ANCIENT_FABRIC = registerAncientFabric(DyeColor.BLUE);
@RegistryEntry("brown_ancient_fabric")
public static final Block BROWN_ANCIENT_FABRIC = registerAncientFabric(DyeColor.BROWN);
@RegistryEntry("green_ancient_fabric")
public static final Block GREEN_ANCIENT_FABRIC = registerAncientFabric(DyeColor.GREEN);
@RegistryEntry("red_ancient_fabric")
public static final Block RED_ANCIENT_FABRIC = registerAncientFabric(DyeColor.RED);
@RegistryEntry("black_ancient_fabric")
public static final Block BLACK_ANCIENT_FABRIC = registerAncientFabric(DyeColor.BLACK);
@RegistryEntry("eternal_fluid")
public static final Block ETERNAL_FLUID = register(new EternalFluidBlock(FabricBlockSettings.of(Material.STONE, MapColor.RED).luminance(15)));
@RegistryEntry("unravelled_fabric")
public static final Block UNRAVELLED_FABRIC = register(new UnravelledFabricBlock(FabricBlockSettings.of(Material.STONE, MapColor.BLACK).ticksRandomly().luminance(15)));
@RegistryEntry("marking_plate")
public static final Block MARKING_PLATE = register(new MarkingPlateBlock(FabricBlockSettings.of(Material.METAL, DyeColor.BLACK).nonOpaque()));
private static Block register(Block block) {
return block;
}
private static Block registerAncientFabric(String id, DyeColor color) {
private static Block registerAncientFabric(DyeColor color) {
Block block = new AncientFabricBlock(color);
ANCIENT_FABRIC_BLOCKS.put(color, block);
return register(id, block);
return register(block);
}
private static Block registerFabric(String id, DyeColor color) {
private static Block registerFabric(DyeColor color) {
Block block = new FabricBlock(color);
FABRIC_BLOCKS.put(color, block);
return register(id, block);
return register(block);
}
public static void init() {
BLOCKS.forEach((str, block) -> {
Registry.register(Registry.BLOCK, str, block);
});
BLOCKS.clear();
Matrix.register(ModBlocks.class, Registry.BLOCK);
}
@Environment(EnvType.CLIENT)

View file

@ -1,4 +1,4 @@
package org.dimdev.dimdoors.block.door;
package org.dimdev.dimdoors.block.door.data;
import java.util.ArrayList;
import java.util.List;
@ -11,6 +11,7 @@ import java.util.function.Consumer;
import com.google.common.collect.ImmutableMap;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import org.dimdev.dimdoors.block.door.DimensionalDoorBlock;
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
import org.dimdev.dimdoors.item.DimensionalDoorItem;
import org.dimdev.dimdoors.item.ItemExtensions;
@ -108,6 +109,7 @@ public final class DoorData implements AutoCloseable {
Registry.register(Registry.BLOCK, id, doorBlock);
Registry.register(Registry.ITEM, id, doorItem);
DOORS.add(doorBlock);
Item.BLOCK_ITEMS.put(doorBlock, doorItem);
this.closed = true;
}

View file

@ -1,4 +1,4 @@
package org.dimdev.dimdoors.block.door;
package org.dimdev.dimdoors.block.door.data;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@ -12,7 +12,6 @@ import java.util.List;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@ -20,9 +19,9 @@ import com.google.gson.JsonObject;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
import org.dimdev.dimdoors.block.door.condition.AlwaysTrueCondition;
import org.dimdev.dimdoors.block.door.condition.InverseCondition;
import org.dimdev.dimdoors.block.door.condition.WorldMatchCondition;
import org.dimdev.dimdoors.block.door.data.condition.AlwaysTrueCondition;
import org.dimdev.dimdoors.block.door.data.condition.InverseCondition;
import org.dimdev.dimdoors.block.door.data.condition.WorldMatchCondition;
import org.dimdev.dimdoors.rift.registry.LinkProperties;
import org.dimdev.dimdoors.rift.targets.PrivatePocketExitTarget;
import org.dimdev.dimdoors.rift.targets.PrivatePocketTarget;

View file

@ -1,4 +1,4 @@
package org.dimdev.dimdoors.block.door;
package org.dimdev.dimdoors.block.door.data;
import java.util.LinkedList;
import java.util.Map;
@ -9,7 +9,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.mojang.serialization.JsonOps;
import org.dimdev.dimdoors.block.door.condition.Condition;
import org.dimdev.dimdoors.block.door.data.condition.Condition;
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
import org.dimdev.dimdoors.rift.registry.LinkProperties;
import org.dimdev.dimdoors.rift.targets.VirtualTarget;

View file

@ -1,4 +1,4 @@
package org.dimdev.dimdoors.block.door.condition;
package org.dimdev.dimdoors.block.door.data.condition;
import java.util.List;
import java.util.stream.Collectors;

View file

@ -1,4 +1,4 @@
package org.dimdev.dimdoors.block.door.condition;
package org.dimdev.dimdoors.block.door.data.condition;
import com.google.gson.JsonObject;
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;

View file

@ -1,4 +1,4 @@
package org.dimdev.dimdoors.block.door.condition;
package org.dimdev.dimdoors.block.door.data.condition;
import java.util.List;
import java.util.stream.Collectors;

View file

@ -1,4 +1,4 @@
package org.dimdev.dimdoors.block.door.condition;
package org.dimdev.dimdoors.block.door.data.condition;
import java.util.Objects;
import java.util.function.Function;

View file

@ -1,4 +1,4 @@
package org.dimdev.dimdoors.block.door.condition;
package org.dimdev.dimdoors.block.door.data.condition;
import com.google.gson.JsonObject;
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;

View file

@ -1,4 +1,4 @@
package org.dimdev.dimdoors.block.door.condition;
package org.dimdev.dimdoors.block.door.data.condition;
import java.util.List;

View file

@ -1,4 +1,4 @@
package org.dimdev.dimdoors.block.door.condition;
package org.dimdev.dimdoors.block.door.data.condition;
import com.google.gson.JsonObject;
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;

View file

@ -2,7 +2,7 @@ package org.dimdev.dimdoors.block.entity;
import org.apache.commons.lang3.ArrayUtils;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.block.door.DoorData;
import org.dimdev.dimdoors.block.door.data.DoorData;
import org.dimdev.dimdoors.client.DetachedRiftBlockEntityRenderer;
import org.dimdev.dimdoors.client.EntranceRiftBlockEntityRenderer;

View file

@ -34,19 +34,19 @@ public final class DimensionalPortalRenderer {
double squaredDistance = pos.getSquaredDistance(ENTITY_RENDER_DISPATCHER.camera.getPos(), true);
int offset = getOffset(squaredDistance);
transformer.transform(matrices);
renderModels(vertexConsumers, transformer, matrices, light, overlay, tall, offset);
renderModels(vertexConsumers, matrices, light, overlay, tall, offset);
matrices.pop();
}
private static void renderModels(VertexConsumerProvider vertexConsumers, Transformer transformer, MatrixStack matrices, int light, int overlay, boolean tall, int offset) {
renderSingleModel(vertexConsumers.getBuffer(RENDER_LAYERS.get(0)), transformer, matrices, light, overlay, 0.15F, tall);
private static void renderModels(VertexConsumerProvider vertexConsumers, MatrixStack matrices, int light, int overlay, boolean tall, int offset) {
renderSingleModel(vertexConsumers.getBuffer(RENDER_LAYERS.get(0)), matrices, light, overlay, 0.15F, tall);
for (int i = 1; i < offset; ++i) {
renderSingleModel(vertexConsumers.getBuffer(RENDER_LAYERS.get(i)), transformer, matrices, light, overlay, 2.0F / (float) (18 - i), tall);
renderSingleModel(vertexConsumers.getBuffer(RENDER_LAYERS.get(i)), matrices, light, overlay, 2.0F / (float) (18 - i), tall);
}
}
private static void renderSingleModel(VertexConsumer vertexConsumer, Transformer transformer, MatrixStack matrices, int light, int overlay, float v, boolean tall) {
private static void renderSingleModel(VertexConsumer vertexConsumer, MatrixStack matrices, int light, int overlay, float v, boolean tall) {
float r = MathHelper.clamp((RANDOM.nextFloat() * 0.3F + 0.1F) * v, 0, 1);
float g = MathHelper.clamp((RANDOM.nextFloat() * 0.4F + 0.1F) * v, 0, 1);
float b = MathHelper.clamp((RANDOM.nextFloat() * 0.5F + 0.6F) * v, 0, 1);

View file

@ -1,21 +1,15 @@
package org.dimdev.dimdoors.item;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.entity.ModEntityTypes;
import org.dimdev.dimdoors.fluid.ModFluids;
import org.dimdev.dimdoors.rift.registry.LinkProperties;
import org.dimdev.dimdoors.rift.targets.PrivatePocketExitTarget;
import org.dimdev.dimdoors.rift.targets.PrivatePocketTarget;
import org.dimdev.dimdoors.rift.targets.PublicPocketTarget;
import org.dimdev.dimdoors.rift.targets.RandomTarget;
import org.dimdev.dimdoors.sound.ModSoundEvents;
import org.dimdev.dimdoors.util.registry.Registrar;
import org.dimdev.dimdoors.util.registry.RegistryObject;
import org.dimdev.dimdoors.world.ModDimensions;
import org.dimdev.matrix.Matrix;
import org.dimdev.matrix.Registrar;
import org.dimdev.matrix.RegistryEntry;
import net.minecraft.block.Block;
import net.minecraft.entity.EquipmentSlot;
@ -34,7 +28,7 @@ import net.minecraft.util.registry.Registry;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
@SuppressWarnings("unused")
@Registrar(element = Item.class)
@Registrar(element = Item.class, modid = "dimdoors")
public final class ModItems {
// DO NOT REMOVE!!!
public static final Registry<Item> REGISTRY = Registry.ITEM;
@ -44,10 +38,10 @@ public final class ModItems {
.icon(() -> new ItemStack(ModItems.RIFT_BLADE))
.build();
@RegistryObject("quartz_door")
@RegistryEntry("quartz_door")
public static final Item QUARTZ_DOOR = create(ModBlocks.QUARTZ_DOOR);
// @RegistryObject("quartz_dimensional_door")
// @RegistryEntry("quartz_dimensional_door")
// public static final Item QUARTZ_DIMENSIONAL_DOOR = create(new DimensionalDoorItem(
// ModBlocks.QUARTZ_DIMENSIONAL_DOOR,
// new Item.Settings().group(DIMENSIONAL_DOORS).maxCount(1),
@ -60,10 +54,10 @@ public final class ModItems {
// }
// ));
@RegistryObject("gold_door")
@RegistryEntry("gold_door")
public static final Item GOLD_DOOR = create(ModBlocks.GOLD_DOOR);
// @RegistryObject("gold_dimensional_door")
// @RegistryEntry("gold_dimensional_door")
// public static final Item GOLD_DIMENSIONAL_DOOR = create(new DimensionalDoorItem(
// ModBlocks.GOLD_DIMENSIONAL_DOOR,
// new Item.Settings().group(DIMENSIONAL_DOORS).maxCount(1),
@ -84,7 +78,7 @@ public final class ModItems {
// }
// ));
//
// @RegistryObject("iron_dimensional_door")
// @RegistryEntry("iron_dimensional_door")
// public static final Item IRON_DIMENSIONAL_DOOR = create(new DimensionalDoorItem(
// ModBlocks.IRON_DIMENSIONAL_DOOR,
// new Item.Settings().group(DIMENSIONAL_DOORS).maxCount(1),
@ -94,7 +88,7 @@ public final class ModItems {
// }
// ));
/* TODO
@RegistryObject("unstable_dimensional_door")
@RegistryEntry("unstable_dimensional_door")
public static final Item UNSTABLE_DIMENSIONAL_DOOR = create(new DimensionalDoorItem(
ModBlocks.IRON_DIMENSIONAL_DOOR,
new Item.Settings().group(DIMENSIONAL_DOORS).maxCount(1),
@ -109,7 +103,7 @@ public final class ModItems {
.newRiftWeight(0.5F).build())
));
*/
// @RegistryObject("oak_dimensional_door")
// @RegistryEntry("oak_dimensional_door")
// public static final Item OAK_DIMENSIONAL_DOOR = create(new DimensionalDoorItem(
// ModBlocks.OAK_DIMENSIONAL_DOOR,
// new Item.Settings().group(DIMENSIONAL_DOORS).maxCount(1),
@ -126,7 +120,7 @@ public final class ModItems {
// )
// ));
@RegistryObject("wood_dimensional_trapdoor")
@RegistryEntry("wood_dimensional_trapdoor")
public static final Item OAK_DIMENSIONAL_TRAPDOOR = create(new DimensionalTrapdoorItem(
ModBlocks.OAK_DIMENSIONAL_TRAPDOOR,
new Item.Settings().group(DIMENSIONAL_DOORS).maxCount(1),
@ -142,165 +136,165 @@ public final class ModItems {
.build())
));
@RegistryObject("world_thread")
@RegistryEntry("world_thread")
public static final Item WORLD_THREAD = create(new Item(new Item.Settings().group(DIMENSIONAL_DOORS)));
@RegistryObject("rift_configuration_tool")
@RegistryEntry("rift_configuration_tool")
public static final Item RIFT_CONFIGURATION_TOOL = create(new RiftConfigurationToolItem());
@RegistryObject("rift_blade")
@RegistryEntry("rift_blade")
public static final Item RIFT_BLADE = create(new RiftBladeItem(new Item.Settings().maxDamage(100).group(DIMENSIONAL_DOORS)));
@RegistryObject("rift_remover")
@RegistryEntry("rift_remover")
public static final Item RIFT_REMOVER = create(new RiftRemoverItem(new Item.Settings().maxCount(1).maxDamage(100).group(DIMENSIONAL_DOORS)));
@RegistryObject("rift_signature")
@RegistryEntry("rift_signature")
public static final Item RIFT_SIGNATURE = create(new RiftSignatureItem(new Item.Settings().maxCount(1).maxDamage(1).group(DIMENSIONAL_DOORS)));
@RegistryObject("stabilized_rift_signature")
@RegistryEntry("stabilized_rift_signature")
public static final Item STABILIZED_RIFT_SIGNATURE = create(new StabilizedRiftSignatureItem(new Item.Settings().maxCount(1).maxDamage(20).group(DIMENSIONAL_DOORS)));
@RegistryObject("rift_stabilizer")
@RegistryEntry("rift_stabilizer")
public static final Item RIFT_STABILIZER = create(new RiftStabilizerItem(new Item.Settings().maxCount(1).maxDamage(6).group(DIMENSIONAL_DOORS)));
@RegistryObject("rift_key")
@RegistryEntry("rift_key")
public static final Item RIFT_KEY = create(new RiftKeyItem(new Item.Settings().group(DIMENSIONAL_DOORS).maxCount(1)));
@RegistryObject("dimensional_eraser")
@RegistryEntry("dimensional_eraser")
public static final Item DIMENSIONAL_ERASER = create(new DimensionalEraserItem(new Item.Settings().maxDamage(100).group(DIMENSIONAL_DOORS)));
@RegistryObject("monolith_spawner")
@RegistryEntry("monolith_spawner")
public static final Item MONOLITH_SPAWNER = new SpawnEggItem(ModEntityTypes.MONOLITH, 0xffffff, 0xffffff, new Item.Settings().group(ItemGroup.MISC));
@RegistryObject("world_thread_helmet")
@RegistryEntry("world_thread_helmet")
public static final Item WORLD_THREAD_HELMET = create(new ArmorItem(ModArmorMaterials.WORLD_THREAD, EquipmentSlot.HEAD, new Item.Settings().group(DIMENSIONAL_DOORS)));
@RegistryObject("world_thread_chestplate")
@RegistryEntry("world_thread_chestplate")
public static final Item WORLD_THREAD_CHESTPLATE = create(new ArmorItem(ModArmorMaterials.WORLD_THREAD, EquipmentSlot.CHEST, new Item.Settings().group(DIMENSIONAL_DOORS)));
@RegistryObject("world_thread_leggings")
@RegistryEntry("world_thread_leggings")
public static final Item WORLD_THREAD_LEGGINGS = create(new ArmorItem(ModArmorMaterials.WORLD_THREAD, EquipmentSlot.LEGS, new Item.Settings().group(DIMENSIONAL_DOORS)));
@RegistryObject("world_thread_boots")
@RegistryEntry("world_thread_boots")
public static final Item WORLD_THREAD_BOOTS = create(new ArmorItem(ModArmorMaterials.WORLD_THREAD, EquipmentSlot.FEET, new Item.Settings().group(DIMENSIONAL_DOORS)));
@RegistryObject("stable_fabric")
@RegistryEntry("stable_fabric")
public static final Item STABLE_FABRIC = create(new Item(new Item.Settings().group(DIMENSIONAL_DOORS)));
@RegistryObject("white_fabric")
@RegistryEntry("white_fabric")
public static final Item WHITE_FABRIC = create(ModBlocks.WHITE_FABRIC);
@RegistryObject("orange_fabric")
@RegistryEntry("orange_fabric")
public static final Item ORANGE_FABRIC = create(ModBlocks.ORANGE_FABRIC);
@RegistryObject("magenta_fabric")
@RegistryEntry("magenta_fabric")
public static final Item MAGENTA_FABRIC = create(ModBlocks.MAGENTA_FABRIC);
@RegistryObject("light_blue_fabric")
@RegistryEntry("light_blue_fabric")
public static final Item LIGHT_BLUE_FABRIC = create(ModBlocks.LIGHT_BLUE_FABRIC);
@RegistryObject("yellow_fabric")
@RegistryEntry("yellow_fabric")
public static final Item YELLOW_FABRIC = create(ModBlocks.YELLOW_FABRIC);
@RegistryObject("lime_fabric")
@RegistryEntry("lime_fabric")
public static final Item LIME_FABRIC = create(ModBlocks.LIME_FABRIC);
@RegistryObject("pink_fabric")
@RegistryEntry("pink_fabric")
public static final Item PINK_FABRIC = create(ModBlocks.PINK_FABRIC);
@RegistryObject("gray_fabric")
@RegistryEntry("gray_fabric")
public static final Item GRAY_FABRIC = create(ModBlocks.GRAY_FABRIC);
@RegistryObject("light_gray_fabric")
@RegistryEntry("light_gray_fabric")
public static final Item LIGHT_GRAY_FABRIC = create(ModBlocks.LIGHT_GRAY_FABRIC);
@RegistryObject("cyan_fabric")
@RegistryEntry("cyan_fabric")
public static final Item CYAN_FABRIC = create(ModBlocks.CYAN_FABRIC);
@RegistryObject("purple_fabric")
@RegistryEntry("purple_fabric")
public static final Item PURPLE_FABRIC = create(ModBlocks.PURPLE_FABRIC);
@RegistryObject("blue_fabric")
@RegistryEntry("blue_fabric")
public static final Item BLUE_FABRIC = create(ModBlocks.BLUE_FABRIC);
@RegistryObject("brown_fabric")
@RegistryEntry("brown_fabric")
public static final Item BROWN_FABRIC = create(ModBlocks.BROWN_FABRIC);
@RegistryObject("green_fabric")
@RegistryEntry("green_fabric")
public static final Item GREEN_FABRIC = create(ModBlocks.GREEN_FABRIC);
@RegistryObject("red_fabric")
@RegistryEntry("red_fabric")
public static final Item RED_FABRIC = create(ModBlocks.RED_FABRIC);
@RegistryObject("black_fabric")
@RegistryEntry("black_fabric")
public static final Item BLACK_FABRIC = create(ModBlocks.BLACK_FABRIC);
@RegistryObject("white_ancient_fabric")
@RegistryEntry("white_ancient_fabric")
public static final Item WHITE_ANCIENT_FABRIC = create(ModBlocks.WHITE_ANCIENT_FABRIC);
@RegistryObject("orange_ancient_fabric")
@RegistryEntry("orange_ancient_fabric")
public static final Item ORANGE_ANCIENT_FABRIC = create(ModBlocks.ORANGE_ANCIENT_FABRIC);
@RegistryObject("magenta_ancient_fabric")
@RegistryEntry("magenta_ancient_fabric")
public static final Item MAGENTA_ANCIENT_FABRIC = create(ModBlocks.MAGENTA_ANCIENT_FABRIC);
@RegistryObject("light_blue_ancient_fabric")
@RegistryEntry("light_blue_ancient_fabric")
public static final Item LIGHT_BLUE_ANCIENT_FABRIC = create(ModBlocks.LIGHT_BLUE_ANCIENT_FABRIC);
@RegistryObject("yellow_ancient_fabric")
@RegistryEntry("yellow_ancient_fabric")
public static final Item YELLOW_ANCIENT_FABRIC = create(ModBlocks.YELLOW_ANCIENT_FABRIC);
@RegistryObject("lime_ancient_fabric")
@RegistryEntry("lime_ancient_fabric")
public static final Item LIME_ANCIENT_FABRIC = create(ModBlocks.LIME_ANCIENT_FABRIC);
@RegistryObject("pink_ancient_fabric")
@RegistryEntry("pink_ancient_fabric")
public static final Item PINK_ANCIENT_FABRIC = create(ModBlocks.PINK_ANCIENT_FABRIC);
@RegistryObject("gray_ancient_fabric")
@RegistryEntry("gray_ancient_fabric")
public static final Item GRAY_ANCIENT_FABRIC = create(ModBlocks.GRAY_ANCIENT_FABRIC);
@RegistryObject("light_gray_ancient_fabric")
@RegistryEntry("light_gray_ancient_fabric")
public static final Item LIGHT_GRAY_ANCIENT_FABRIC = create(ModBlocks.LIGHT_GRAY_ANCIENT_FABRIC);
@RegistryObject("cyan_ancient_fabric")
@RegistryEntry("cyan_ancient_fabric")
public static final Item CYAN_ANCIENT_FABRIC = create(ModBlocks.CYAN_ANCIENT_FABRIC);
@RegistryObject("purple_ancient_fabric")
@RegistryEntry("purple_ancient_fabric")
public static final Item PURPLE_ANCIENT_FABRIC = create(ModBlocks.PURPLE_ANCIENT_FABRIC);
@RegistryObject("blue_ancient_fabric")
@RegistryEntry("blue_ancient_fabric")
public static final Item BLUE_ANCIENT_FABRIC = create(ModBlocks.BLUE_ANCIENT_FABRIC);
@RegistryObject("brown_ancient_fabric")
@RegistryEntry("brown_ancient_fabric")
public static final Item BROWN_ANCIENT_FABRIC = create(ModBlocks.BROWN_ANCIENT_FABRIC);
@RegistryObject("green_ancient_fabric")
@RegistryEntry("green_ancient_fabric")
public static final Item GREEN_ANCIENT_FABRIC = create(ModBlocks.GREEN_ANCIENT_FABRIC);
@RegistryObject("red_ancient_fabric")
@RegistryEntry("red_ancient_fabric")
public static final Item RED_ANCIENT_FABRIC = create(ModBlocks.RED_ANCIENT_FABRIC);
@RegistryObject("black_ancient_fabric")
@RegistryEntry("black_ancient_fabric")
public static final Item BLACK_ANCIENT_FABRIC = create(ModBlocks.BLACK_ANCIENT_FABRIC);
@RegistryObject("unravelled_fabric")
@RegistryEntry("unravelled_fabric")
public static final Item UNRAVELLED_FABRIC = create(ModBlocks.UNRAVELLED_FABRIC);
@RegistryObject("creepy_record")
@RegistryEntry("creepy_record")
public static final Item CREEPY_RECORD = create(new MusicDiscItem(10, ModSoundEvents.CREEPY, new Item.Settings().group(DIMENSIONAL_DOORS)));
@RegistryObject("white_void_record")
@RegistryEntry("white_void_record")
public static final Item WHITE_VOID_RECORD = create(new MusicDiscItem(10, ModSoundEvents.WHITE_VOID, new Item.Settings().group(DIMENSIONAL_DOORS)));
@RegistryObject("marking_plate")
@RegistryEntry("marking_plate")
public static final Item MARKING_PLATE = create(ModBlocks.MARKING_PLATE);
@RegistryObject("eternal_fluid")
@RegistryEntry("eternal_fluid")
public static final Item ETERNAL_FLUID = create(ModBlocks.ETERNAL_FLUID);
@RegistryObject("eternal_fluid_bucket")
@RegistryEntry("eternal_fluid_bucket")
public static final Item ETERNAL_FLUID_BUCKET = create(new BucketItem(ModFluids.ETERNAL_FLUID, new Item.Settings().group(DIMENSIONAL_DOORS).recipeRemainder(Items.BUCKET).maxCount(1)));
private static Item create(Block block) {
@ -324,7 +318,7 @@ public final class ModItems {
}
public static void init() {
Registrar.REGISTER.accept(ModItems.class);
Matrix.register(ModItems.class, Registry.ITEM);
}
private static class MusicDiscItem extends net.minecraft.item.MusicDiscItem {

View file

@ -21,7 +21,7 @@ import org.apache.commons.lang3.ArrayUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
import org.dimdev.dimdoors.block.door.DoorData;
import org.dimdev.dimdoors.block.door.data.DoorData;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;

View file

@ -1,53 +0,0 @@
package org.dimdev.dimdoors.util.registry;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.function.Consumer;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Registrar {
@SuppressWarnings({"unchecked", "rawtypes"})
Consumer<Class<?>> REGISTER = (clazz) -> {
Registrar registrar = clazz.getAnnotation(Registrar.class);
if (registrar == null) {
return;
}
String modid = registrar.modid();
Class<?> element = registrar.element();
Registry<?> registry;
try {
registry = (Registry<?>) clazz.getField("REGISTRY").get(null);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new AssertionError();
}
Arrays.stream(clazz.getFields())
.filter(field -> field.getType() == element
&& field.isAnnotationPresent(RegistryObject.class)
&& Modifier.isPublic(field.getModifiers())
&& Modifier.isStatic(field.getModifiers())
&& Modifier.isFinal(field.getModifiers())
)
.forEach(field -> {
try {
Object value = field.get(null);
Registry.register((Registry) registry, new Identifier(modid, field.getAnnotation(RegistryObject.class).value()), element.cast(value));
} catch (IllegalAccessException e) {
throw new AssertionError(e);
}
});
};
Class<?> element();
String modid() default "dimdoors";
}

View file

@ -1,12 +0,0 @@
package org.dimdev.dimdoors.util.registry;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface RegistryObject {
String value();
}