Merge pull request #191 from DimensionalDevelopment/1.17-json-doors
Custom Dimensional Doors using Json
This commit is contained in:
commit
7852728336
51 changed files with 1329 additions and 498 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -30,3 +30,4 @@ remappedSrc
|
|||
logs
|
||||
*.hprof
|
||||
generated
|
||||
.vscode
|
||||
|
|
13
build.gradle
13
build.gradle
|
@ -11,7 +11,6 @@ targetCompatibility = 1.8
|
|||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
|
||||
maven {
|
||||
name = "Fabric maven"
|
||||
|
@ -81,7 +80,6 @@ sourceSets {
|
|||
main {
|
||||
java {
|
||||
srcDir "src/main/schematics"
|
||||
srcDir "src/main/registry"
|
||||
srcDir "src/main/config"
|
||||
}
|
||||
}
|
||||
|
@ -89,13 +87,14 @@ sourceSets {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:21w06a"
|
||||
mappings "net.fabricmc:yarn:21w06a+build.3:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:0.11.1"
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:0.30.2+1.17"
|
||||
minecraft "com.mojang:minecraft:21w08b"
|
||||
mappings "net.fabricmc:yarn:21w08b+build.8:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:0.11.2"
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:0.31.1+1.17"
|
||||
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")
|
||||
|
@ -158,7 +157,7 @@ curseforge {
|
|||
releaseType = 'alpha'
|
||||
addGameVersion '1.17'
|
||||
mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar")) {
|
||||
displayName = "[21w06a] Dimensional Doors ${version}"
|
||||
displayName = "[21w08b] Dimensional Doors ${version}"
|
||||
}
|
||||
afterEvaluate {
|
||||
uploadTask.dependsOn("remapJar")
|
||||
|
|
|
@ -48,21 +48,21 @@ public class AdvancementTab implements Consumer<Consumer<Advancement>> {
|
|||
.criterion("inventory_changed", InventoryChangedCriterion.Conditions.items(Items.ENDER_PEARL))
|
||||
.build(advancementConsumer, "dimdoors:dimdoors/root");
|
||||
|
||||
Advancement.Task.create()
|
||||
.display(makeDisplay(ModItems.IRON_DIMENSIONAL_DOOR, "public_pocket"))
|
||||
.criterion("changed_dimension", ChangedDimensionCriterion.Conditions.to(ModDimensions.PUBLIC))
|
||||
.parent(root)
|
||||
.build(advancementConsumer, "dimdoors:dimdoors/public_pocket");
|
||||
Advancement.Task.create()
|
||||
.display(makeDisplay(ModItems.QUARTZ_DIMENSIONAL_DOOR, "private_pocket"))
|
||||
.criterion("changed_dimension", ChangedDimensionCriterion.Conditions.to(ModDimensions.PERSONAL))
|
||||
.parent(root)
|
||||
.build(advancementConsumer, "dimdoors:dimdoors/private_pocket");
|
||||
Advancement.Task.create()
|
||||
.display(makeDisplay(ModItems.GOLD_DIMENSIONAL_DOOR, "dungeon"))
|
||||
.criterion("changed_dimension", ChangedDimensionCriterion.Conditions.to(ModDimensions.DUNGEON))
|
||||
.parent(root)
|
||||
.build(advancementConsumer, "dimdoors:dimdoors/dungeon");
|
||||
// Advancement.Task.create()
|
||||
// .display(makeDisplay(ModItems.IRON_DIMENSIONAL_DOOR, "public_pocket"))
|
||||
// .criterion("changed_dimension", ChangedDimensionCriterion.Conditions.to(ModDimensions.PUBLIC))
|
||||
// .parent(root)
|
||||
// .build(advancementConsumer, "dimdoors:dimdoors/public_pocket");
|
||||
// Advancement.Task.create()
|
||||
// .display(makeDisplay(ModItems.QUARTZ_DIMENSIONAL_DOOR, "private_pocket"))
|
||||
// .criterion("changed_dimension", ChangedDimensionCriterion.Conditions.to(ModDimensions.PERSONAL))
|
||||
// .parent(root)
|
||||
// .build(advancementConsumer, "dimdoors:dimdoors/private_pocket");
|
||||
// Advancement.Task.create()
|
||||
// .display(makeDisplay(ModItems.GOLD_DIMENSIONAL_DOOR, "dungeon"))
|
||||
// .criterion("changed_dimension", ChangedDimensionCriterion.Conditions.to(ModDimensions.DUNGEON))
|
||||
// .parent(root)
|
||||
// .build(advancementConsumer, "dimdoors:dimdoors/dungeon");
|
||||
Advancement limbo = Advancement.Task.create()
|
||||
.display(makeDisplay(ModItems.UNRAVELLED_FABRIC, "limbo"))
|
||||
.criterion("changed_dimension", ChangedDimensionCriterion.Conditions.to(ModDimensions.LIMBO))
|
||||
|
|
|
@ -25,10 +25,10 @@ public class LootTableProvider implements DataProvider {
|
|||
}
|
||||
LOOT_TABLE_CONSUMER.registerBlockDropSelf(ModBlocks.GOLD_DOOR);
|
||||
LOOT_TABLE_CONSUMER.registerBlockDropSelf(ModBlocks.QUARTZ_DOOR);
|
||||
LOOT_TABLE_CONSUMER.registerBlockDropSelf(ModBlocks.OAK_DIMENSIONAL_DOOR);
|
||||
LOOT_TABLE_CONSUMER.registerBlockDropSelf(ModBlocks.IRON_DIMENSIONAL_DOOR);
|
||||
LOOT_TABLE_CONSUMER.registerBlockDropSelf(ModBlocks.GOLD_DIMENSIONAL_DOOR);
|
||||
LOOT_TABLE_CONSUMER.registerBlockDropSelf(ModBlocks.QUARTZ_DIMENSIONAL_DOOR);
|
||||
// LOOT_TABLE_CONSUMER.registerBlockDropSelf(ModBlocks.OAK_DIMENSIONAL_DOOR);
|
||||
// LOOT_TABLE_CONSUMER.registerBlockDropSelf(ModBlocks.IRON_DIMENSIONAL_DOOR);
|
||||
// LOOT_TABLE_CONSUMER.registerBlockDropSelf(ModBlocks.GOLD_DIMENSIONAL_DOOR);
|
||||
// LOOT_TABLE_CONSUMER.registerBlockDropSelf(ModBlocks.QUARTZ_DIMENSIONAL_DOOR);
|
||||
LOOT_TABLE_CONSUMER.registerBlockDropSelf(ModBlocks.OAK_DIMENSIONAL_TRAPDOOR);
|
||||
LOOT_TABLE_CONSUMER.registerBlockDropSelf(ModBlocks.MARKING_PLATE);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.dimdev.dimdoors.block.entity.ModBlockEntityTypes;
|
|||
import org.dimdev.dimdoors.client.ModSkyRendering;
|
||||
import org.dimdev.dimdoors.entity.ModEntityTypes;
|
||||
import org.dimdev.dimdoors.entity.MonolithEntity;
|
||||
import org.dimdev.dimdoors.entity.ai.MonolithAggroGoal;
|
||||
import org.dimdev.dimdoors.fluid.ModFluids;
|
||||
import org.dimdev.dimdoors.network.ExtendedClientPlayNetworkHandler;
|
||||
import org.dimdev.dimdoors.particle.ModParticleTypes;
|
||||
|
@ -26,7 +27,7 @@ public class DimensionalDoorsClientInitializer implements ClientModInitializer {
|
|||
ModBlocks.initClient();
|
||||
ModParticleTypes.initClient();
|
||||
|
||||
ClientPlayNetworking.registerGlobalReceiver(DimensionalDoorsInitializer.MONOLITH_PARTICLE_PACKET, (client, networkHandler, buf, sender) -> MonolithEntity.spawnParticles(buf, client));
|
||||
ClientPlayNetworking.registerGlobalReceiver(MonolithAggroGoal.MONOLITH_PARTICLE_PACKET, (client, networkHandler, buf, sender) -> MonolithEntity.spawnParticles(buf, client));
|
||||
|
||||
registerListeners();
|
||||
}
|
||||
|
|
|
@ -1,21 +1,13 @@
|
|||
package org.dimdev.dimdoors;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.ConfigHolder;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
|
||||
import net.fabricmc.fabric.api.event.player.AttackBlockCallback;
|
||||
import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents;
|
||||
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
|
||||
import net.fabricmc.fabric.api.event.player.UseItemCallback;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||
|
||||
import me.sargunvohra.mcmods.autoconfig1u.serializer.JanksonConfigSerializer;
|
||||
|
||||
import net.fabricmc.fabric.api.resource.ResourcePackActivationType;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.minecraft.resource.ResourceType;
|
||||
import org.dimdev.dimdoors.block.ModBlocks;
|
||||
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;
|
||||
|
@ -25,16 +17,21 @@ import org.dimdev.dimdoors.fluid.ModFluids;
|
|||
import org.dimdev.dimdoors.item.ModItems;
|
||||
import org.dimdev.dimdoors.listener.AttackBlockCallbackListener;
|
||||
import org.dimdev.dimdoors.listener.ChunkLoadListener;
|
||||
import org.dimdev.dimdoors.listener.pocket.*;
|
||||
import org.dimdev.dimdoors.listener.pocket.PlayerBlockBreakEventBeforeListener;
|
||||
import org.dimdev.dimdoors.listener.pocket.PocketAttackBlockCallbackListener;
|
||||
import org.dimdev.dimdoors.listener.pocket.UseBlockCallbackListener;
|
||||
import org.dimdev.dimdoors.listener.pocket.UseItemCallbackListener;
|
||||
import org.dimdev.dimdoors.listener.pocket.UseItemOnBlockCallbackListener;
|
||||
import org.dimdev.dimdoors.network.ExtendedServerPlayNetworkHandler;
|
||||
import org.dimdev.dimdoors.particle.ModParticleTypes;
|
||||
import org.dimdev.dimdoors.pockets.PocketLoader;
|
||||
import org.dimdev.dimdoors.pockets.generator.PocketGenerator;
|
||||
import org.dimdev.dimdoors.pockets.virtual.VirtualSingularPocket;
|
||||
import org.dimdev.dimdoors.pockets.modifier.Modifier;
|
||||
import org.dimdev.dimdoors.pockets.virtual.VirtualSingularPocket;
|
||||
import org.dimdev.dimdoors.rift.targets.Targets;
|
||||
import org.dimdev.dimdoors.rift.targets.VirtualTarget;
|
||||
import org.dimdev.dimdoors.sound.ModSoundEvents;
|
||||
import org.dimdev.dimdoors.util.SubRootJanksonConfigSerializer;
|
||||
import org.dimdev.dimdoors.world.ModBiomes;
|
||||
import org.dimdev.dimdoors.world.ModDimensions;
|
||||
import org.dimdev.dimdoors.world.feature.ModFeatures;
|
||||
|
@ -42,6 +39,7 @@ import org.dimdev.dimdoors.world.pocket.type.AbstractPocket;
|
|||
import org.dimdev.dimdoors.world.pocket.type.addon.PocketAddon;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import net.minecraft.resource.ResourceType;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
@ -49,12 +47,21 @@ import net.minecraft.util.registry.RegistryKey;
|
|||
import net.minecraft.world.World;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.fabricmc.fabric.api.event.player.AttackBlockCallback;
|
||||
import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents;
|
||||
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
|
||||
import net.fabricmc.fabric.api.event.player.UseItemCallback;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
|
||||
import net.fabricmc.fabric.api.resource.ResourcePackActivationType;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
|
||||
public class DimensionalDoorsInitializer implements ModInitializer {
|
||||
public static final Identifier MONOLITH_PARTICLE_PACKET = new Identifier("dimdoors", "monolith_particle_packet");
|
||||
public static final ConfigHolder<ModConfig> CONFIG_MANAGER = AutoConfig.register(ModConfig.class, JanksonConfigSerializer::new);
|
||||
private static final Supplier<Path> CONFIG_ROOT = () -> FabricLoader.getInstance().getConfigDir().resolve("dimdoors").toAbsolutePath();
|
||||
public static final ConfigHolder<ModConfig> CONFIG_MANAGER = AutoConfig.register(ModConfig.class, SubRootJanksonConfigSerializer::new);
|
||||
private static MinecraftServer server;
|
||||
private static ModContainer dimDoorsMod;
|
||||
|
||||
|
@ -78,10 +85,14 @@ public class DimensionalDoorsInitializer implements ModInitializer {
|
|||
return dimDoorsMod;
|
||||
}
|
||||
|
||||
public static Path getConfigRoot() {
|
||||
return CONFIG_ROOT.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
dimDoorsMod = FabricLoader.getInstance().getModContainer("dimdoors").orElseThrow(RuntimeException::new);
|
||||
ServerLifecycleEvents.SERVER_STARTING.register((minecraftServer) -> {
|
||||
ServerLifecycleEvents.SERVER_STARTING.register((minecraftServer) -> {
|
||||
server = minecraftServer;
|
||||
});
|
||||
|
||||
|
@ -105,6 +116,9 @@ public class DimensionalDoorsInitializer implements ModInitializer {
|
|||
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);
|
||||
|
|
|
@ -4,8 +4,14 @@ import java.util.HashMap;
|
|||
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.matrix.Matrix;
|
||||
import org.dimdev.matrix.Registrar;
|
||||
import org.dimdev.matrix.RegistryEntry;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.MapColor;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
|
@ -18,94 +24,159 @@ 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.of(Material.WOOD, MapColor.OAK_TAN).strength(3.0F).breakByTool(FabricToolTags.AXES).breakByHand(true).nonOpaque().luminance(state -> 10)));
|
||||
public static final Block IRON_DIMENSIONAL_DOOR = register("dimdoors:iron_dimensional_door", new DimensionalDoorBlock(FabricBlockSettings.of(Material.METAL, MapColor.IRON_GRAY).strength(5.0F).breakByHand(false).breakByTool(FabricToolTags.PICKAXES).nonOpaque().luminance(state -> 10)));
|
||||
public static final Block GOLD_DIMENSIONAL_DOOR = register("dimdoors:gold_dimensional_door", new DimensionalDoorBlock(FabricBlockSettings.of(Material.METAL, MapColor.GOLD).strength(5.0F).breakByHand(false).breakByTool(FabricToolTags.PICKAXES).nonOpaque().luminance(state -> 10)));
|
||||
public static final Block QUARTZ_DIMENSIONAL_DOOR = register("dimdoors:quartz_dimensional_door", new DimensionalDoorBlock(FabricBlockSettings.of(Material.STONE, MapColor.OFF_WHITE).strength(5.0F).breakByHand(false).breakByTool(FabricToolTags.PICKAXES).nonOpaque().luminance(state -> 10)));
|
||||
public static final Block OAK_DIMENSIONAL_TRAPDOOR = register("dimdoors:wood_dimensional_trapdoor", new DimensionalTrapdoorBlock(FabricBlockSettings.of(Material.WOOD, MapColor.OAK_TAN).strength(3.0F).breakByTool(FabricToolTags.AXES).breakByHand(true).nonOpaque()));
|
||||
@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)
|
||||
public static void initClient() {
|
||||
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(),
|
||||
ModBlocks.OAK_DIMENSIONAL_DOOR,
|
||||
ModBlocks.GOLD_DIMENSIONAL_DOOR,
|
||||
ModBlocks.IRON_DIMENSIONAL_DOOR,
|
||||
ModBlocks.OAK_DIMENSIONAL_TRAPDOOR,
|
||||
ModBlocks.QUARTZ_DIMENSIONAL_DOOR,
|
||||
ModBlocks.QUARTZ_DOOR);
|
||||
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(), ModBlocks.QUARTZ_DOOR, ModBlocks.GOLD_DOOR);
|
||||
DoorData.DOORS.forEach(door -> BlockRenderLayerMap.INSTANCE.putBlock(door, RenderLayer.getCutout()));
|
||||
}
|
||||
|
||||
public static Block ancientFabricFromDye(DyeColor color) {
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package org.dimdev.dimdoors.block;
|
||||
package org.dimdev.dimdoors.block.door;
|
||||
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
|
||||
import org.dimdev.dimdoors.block.CoordinateTransformerBlock;
|
||||
import org.dimdev.dimdoors.block.ModBlocks;
|
||||
import org.dimdev.dimdoors.block.RiftProvider;
|
||||
import org.dimdev.dimdoors.block.entity.DetachedRiftBlockEntity;
|
||||
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
|
||||
import org.dimdev.dimdoors.util.math.MathUtil;
|
|
@ -1,5 +1,6 @@
|
|||
package org.dimdev.dimdoors.block;
|
||||
package org.dimdev.dimdoors.block.door;
|
||||
|
||||
import org.dimdev.dimdoors.block.RiftProvider;
|
||||
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
178
src/main/java/org/dimdev/dimdoors/block/door/data/DoorData.java
Normal file
178
src/main/java/org/dimdev/dimdoors/block/door/data/DoorData.java
Normal file
|
@ -0,0 +1,178 @@
|
|||
package org.dimdev.dimdoors.block.door.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
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;
|
||||
import org.dimdev.dimdoors.item.ModItems;
|
||||
import org.dimdev.dimdoors.util.OptionalBool;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Rarity;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
||||
public final class DoorData implements AutoCloseable {
|
||||
public static final List<Block> DOORS = new ArrayList<>();
|
||||
private final String id;
|
||||
private final UnbakedItemSettings itemSettings;
|
||||
private final UnbakedBlockSettings blockSettings;
|
||||
private final RiftDataList riftDataList;
|
||||
private boolean closed = false;
|
||||
|
||||
public static DoorData fromJson(JsonObject json) {
|
||||
String id = json.get("id").getAsString();
|
||||
UnbakedItemSettings itemSettings = UnbakedItemSettings.fromJson(json.getAsJsonObject("itemSettings"));
|
||||
UnbakedBlockSettings blockSettings = UnbakedBlockSettings.fromJson(json.getAsJsonObject("blockSettings"));
|
||||
RiftDataList riftDataList = RiftDataList.fromJson(json.getAsJsonArray("riftData"));
|
||||
return new DoorData(id, itemSettings, blockSettings, riftDataList);
|
||||
}
|
||||
|
||||
public DoorData(String id, UnbakedItemSettings itemSettings, UnbakedBlockSettings blockSettings, RiftDataList riftDataList) {
|
||||
this.id = id;
|
||||
this.itemSettings = itemSettings;
|
||||
this.blockSettings = blockSettings;
|
||||
this.riftDataList = riftDataList;
|
||||
}
|
||||
|
||||
public JsonObject toJson(JsonObject json) {
|
||||
json.addProperty("id", this.id);
|
||||
json.add("itemSettings", this.itemSettings.toJson(new JsonObject()));
|
||||
json.add("blockSettings", this.blockSettings.toJson(new JsonObject()));
|
||||
json.add("riftData", this.riftDataList.toJson());
|
||||
return json;
|
||||
}
|
||||
|
||||
private Consumer<? super EntranceRiftBlockEntity> createSetupFunction() {
|
||||
RiftDataList riftDataList = this.riftDataList;
|
||||
|
||||
return rift -> {
|
||||
RiftDataList.OptRiftData riftData = riftDataList.getRiftData(rift);
|
||||
riftData.getDestination().ifPresent(rift::setDestination);
|
||||
riftData.getProperties().ifPresent(rift::setProperties);
|
||||
};
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public UnbakedItemSettings getItemSettings() {
|
||||
return itemSettings;
|
||||
}
|
||||
|
||||
public UnbakedBlockSettings getBlockSettings() {
|
||||
return blockSettings;
|
||||
}
|
||||
|
||||
public RiftDataList getRiftDataList() {
|
||||
return riftDataList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
if (closed) {
|
||||
throw new UnsupportedOperationException("Already Closed");
|
||||
}
|
||||
|
||||
Item.Settings itemSettings;
|
||||
if (this.itemSettings.parent.isPresent()) {
|
||||
itemSettings = ItemExtensions.getSettings(Registry.ITEM.get(new Identifier(this.itemSettings.parent.get())));
|
||||
} else {
|
||||
itemSettings = new Item.Settings().group(ModItems.DIMENSIONAL_DOORS);
|
||||
}
|
||||
this.itemSettings.maxCount.ifPresent(itemSettings::maxCount);
|
||||
this.itemSettings.maxDamage.ifPresent(itemSettings::maxDamageIfAbsent);
|
||||
this.itemSettings.rarity.ifPresent(itemSettings::rarity);
|
||||
this.itemSettings.fireproof.ifPresentAndTrue(itemSettings::fireproof);
|
||||
|
||||
FabricBlockSettings blockSettings = FabricBlockSettings.copyOf(Registry.BLOCK.get(new Identifier(this.blockSettings.parent)));
|
||||
this.blockSettings.luminance.ifPresent(blockSettings::luminance);
|
||||
Identifier id = new Identifier(this.id);
|
||||
Block doorBlock = new DimensionalDoorBlock(blockSettings);
|
||||
Item doorItem = new DimensionalDoorItem(doorBlock, itemSettings, createSetupFunction());
|
||||
Registry.register(Registry.BLOCK, id, doorBlock);
|
||||
Registry.register(Registry.ITEM, id, doorItem);
|
||||
DOORS.add(doorBlock);
|
||||
Item.BLOCK_ITEMS.put(doorBlock, doorItem);
|
||||
this.closed = true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
||||
public static final class UnbakedItemSettings {
|
||||
private static final Map<String, Rarity> RARITIES = Util.make(ImmutableMap.<String, Rarity>builder(), b -> {
|
||||
for (Rarity rarity : Rarity.values()) {
|
||||
b.put(rarity.name().toLowerCase(), rarity);
|
||||
}
|
||||
}).build();
|
||||
private final Optional<String> parent;
|
||||
private final OptionalInt maxCount;
|
||||
private final OptionalInt maxDamage;
|
||||
private final Optional<Rarity> rarity;
|
||||
private final OptionalBool fireproof;
|
||||
|
||||
public static UnbakedItemSettings fromJson(JsonObject json) {
|
||||
Optional<String> parent = Optional.ofNullable(json.get("parent")).map(JsonElement::getAsString);
|
||||
OptionalInt maxCount = Optional.ofNullable(json.get("maxCount")).map(JsonElement::getAsInt).map(OptionalInt::of).orElse(OptionalInt.empty());
|
||||
OptionalInt maxDamage = Optional.ofNullable(json.get("maxDamage")).map(JsonElement::getAsInt).map(OptionalInt::of).orElse(OptionalInt.empty());
|
||||
Optional<Rarity> rarity = Optional.ofNullable(json.get("rarity")).map(JsonElement::getAsString).map(String::toLowerCase).map(RARITIES::get).map(Objects::requireNonNull);
|
||||
OptionalBool fireproof = Optional.ofNullable(json.get("fireproof")).map(JsonElement::getAsBoolean).map(OptionalBool::of).orElse(OptionalBool.empty());
|
||||
return new UnbakedItemSettings(parent, maxCount, maxDamage, rarity, fireproof);
|
||||
}
|
||||
|
||||
public UnbakedItemSettings(Optional<String> parent, OptionalInt maxCount, OptionalInt maxDamage, Optional<Rarity> rarity, OptionalBool fireproof) {
|
||||
this.parent = parent;
|
||||
this.maxCount = maxCount;
|
||||
this.maxDamage = maxDamage;
|
||||
this.rarity = rarity;
|
||||
this.fireproof = fireproof;
|
||||
}
|
||||
|
||||
public JsonObject toJson(JsonObject json) {
|
||||
parent.ifPresent(s -> json.addProperty("parent", s));
|
||||
maxCount.ifPresent(s -> json.addProperty("maxCount", s));
|
||||
maxDamage.ifPresent(s -> json.addProperty("maxDamage", s));
|
||||
rarity.ifPresent(s -> json.addProperty("rarity", s.name().toLowerCase()));
|
||||
fireproof.ifPresent(s -> json.addProperty("fireproof", s));
|
||||
return json;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
||||
public static final class UnbakedBlockSettings {
|
||||
private final String parent;
|
||||
private final OptionalInt luminance;
|
||||
|
||||
public static UnbakedBlockSettings fromJson(JsonObject json) {
|
||||
String parent = Optional.ofNullable(json.get("parent")).map(JsonElement::getAsString).orElseThrow(() -> new RuntimeException("Missing parent block"));
|
||||
OptionalInt luminance = Optional.ofNullable(json.get("luminance")).map(JsonElement::getAsInt).map(OptionalInt::of).orElse(OptionalInt.empty());
|
||||
return new UnbakedBlockSettings(parent, luminance);
|
||||
}
|
||||
|
||||
public UnbakedBlockSettings(String parent, OptionalInt luminance) {
|
||||
this.parent = parent;
|
||||
this.luminance = luminance;
|
||||
}
|
||||
|
||||
public JsonObject toJson(JsonObject json) {
|
||||
json.addProperty("parent", parent);
|
||||
luminance.ifPresent(s -> json.addProperty("luminance", s));
|
||||
return json;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,187 @@
|
|||
package org.dimdev.dimdoors.block.door.data;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
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.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;
|
||||
import org.dimdev.dimdoors.rift.targets.PublicPocketTarget;
|
||||
import org.dimdev.dimdoors.rift.targets.RandomTarget;
|
||||
import org.dimdev.dimdoors.rift.targets.UnstableTarget;
|
||||
import org.dimdev.dimdoors.util.OptionalBool;
|
||||
import org.dimdev.dimdoors.world.ModDimensions;
|
||||
|
||||
import net.minecraft.util.Pair;
|
||||
import net.minecraft.util.Rarity;
|
||||
import net.minecraft.util.Util;
|
||||
|
||||
public class DoorDataReader {
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().setLenient().create();
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final DoorData DEFAULT_IRON_DIMENSIONAL_DOOR = new DoorData(
|
||||
"dimdoors:iron_dimensional_door",
|
||||
new DoorData.UnbakedItemSettings(
|
||||
Optional.empty(),
|
||||
OptionalInt.of(1),
|
||||
OptionalInt.empty(),
|
||||
Optional.of(Rarity.UNCOMMON),
|
||||
OptionalBool.FALSE
|
||||
),
|
||||
new DoorData.UnbakedBlockSettings(
|
||||
"minecraft:iron_door",
|
||||
OptionalInt.of(10)
|
||||
), new RiftDataList(Util.make(new LinkedList<>(), list -> list.add(new Pair<>(new RiftDataList.OptRiftData(Optional.of(new PublicPocketTarget()), Optional.empty()), AlwaysTrueCondition.INSTANCE)))
|
||||
));
|
||||
private static final DoorData DEFAULT_GOLD_DIMENSIONAL_DOOR = new DoorData(
|
||||
"dimdoors:gold_dimensional_door",
|
||||
new DoorData.UnbakedItemSettings(
|
||||
Optional.empty(),
|
||||
OptionalInt.of(1),
|
||||
OptionalInt.empty(),
|
||||
Optional.of(Rarity.UNCOMMON),
|
||||
OptionalBool.FALSE
|
||||
),
|
||||
new DoorData.UnbakedBlockSettings(
|
||||
"dimdoors:gold_door",
|
||||
OptionalInt.of(10)
|
||||
), new RiftDataList(Util.make(new LinkedList<>(), list -> list.add(new Pair<>(new RiftDataList.OptRiftData(Optional.of(RandomTarget.builder().acceptedGroups(Collections.singleton(0)).coordFactor(1).negativeDepthFactor(10000).positiveDepthFactor(80).weightMaximum(100).noLink(false).noLinkBack(false).newRiftWeight(1).build()), Optional.of(LinkProperties.builder().groups(new HashSet<>(Arrays.asList(0, 1))).linksRemaining(1).build())), AlwaysTrueCondition.INSTANCE)))
|
||||
));
|
||||
private static final DoorData DEFAULT_OAK_DIMENSIONAL_DOOR = new DoorData(
|
||||
"dimdoors:oak_dimensional_door",
|
||||
new DoorData.UnbakedItemSettings(
|
||||
Optional.empty(),
|
||||
OptionalInt.of(1),
|
||||
OptionalInt.empty(),
|
||||
Optional.of(Rarity.UNCOMMON),
|
||||
OptionalBool.FALSE
|
||||
),
|
||||
new DoorData.UnbakedBlockSettings(
|
||||
"minecraft:oak_door",
|
||||
OptionalInt.of(10)
|
||||
), new RiftDataList(Util.make(new LinkedList<>(), list -> list.add(new Pair<>(new RiftDataList.OptRiftData(Optional.of(RandomTarget.builder().acceptedGroups(Collections.singleton(0)).coordFactor(1).negativeDepthFactor(80).positiveDepthFactor(Double.MAX_VALUE).weightMaximum(100).noLink(false).newRiftWeight(0).build()), Optional.empty()), AlwaysTrueCondition.INSTANCE)))
|
||||
));
|
||||
private static final DoorData DEFAULT_QUARTZ_DIMENSIONAL_DOOR = new DoorData(
|
||||
"dimdoors:quartz_dimensional_door",
|
||||
new DoorData.UnbakedItemSettings(
|
||||
Optional.empty(),
|
||||
OptionalInt.of(1),
|
||||
OptionalInt.empty(),
|
||||
Optional.of(Rarity.UNCOMMON),
|
||||
OptionalBool.FALSE
|
||||
),
|
||||
new DoorData.UnbakedBlockSettings(
|
||||
"dimdoors:quartz_door",
|
||||
OptionalInt.of(10)
|
||||
), new RiftDataList(Util.make(new LinkedList<>(), list -> {
|
||||
WorldMatchCondition condition = new WorldMatchCondition(ModDimensions.PERSONAL);
|
||||
list.add(new Pair<>(new RiftDataList.OptRiftData(Optional.of(new PrivatePocketExitTarget()), Optional.empty()), condition));
|
||||
list.add(new Pair<>(new RiftDataList.OptRiftData(Optional.of(new PrivatePocketTarget()), Optional.empty()), new InverseCondition(condition)));
|
||||
})
|
||||
));
|
||||
private static final DoorData DEFAULT_UNSTABLE_DIMENSIONAL_DOOR = new DoorData(
|
||||
"dimdoors:unstable_dimensional_door",
|
||||
new DoorData.UnbakedItemSettings(
|
||||
Optional.empty(),
|
||||
OptionalInt.of(1),
|
||||
OptionalInt.empty(),
|
||||
Optional.of(Rarity.UNCOMMON),
|
||||
OptionalBool.FALSE
|
||||
),
|
||||
new DoorData.UnbakedBlockSettings(
|
||||
"minecraft:iron_door",
|
||||
OptionalInt.of(10)
|
||||
), new RiftDataList(Util.make(new LinkedList<>(), list -> list.add(new Pair<>(new RiftDataList.OptRiftData(Optional.of(new UnstableTarget()), Optional.of(LinkProperties.builder().linksRemaining(1).groups(IntStream.of(0, 1).boxed().collect(Collectors.toSet())).build())), AlwaysTrueCondition.INSTANCE)))
|
||||
));
|
||||
|
||||
public static void read() {
|
||||
Path doorDir = DimensionalDoorsInitializer.getConfigRoot().resolve("doors");
|
||||
|
||||
if (Files.exists(doorDir) && !Files.isDirectory(doorDir)) {
|
||||
try {
|
||||
Files.delete(doorDir);
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("Error deleting " + doorDir, e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Files.notExists(doorDir)) {
|
||||
try {
|
||||
Files.createDirectory(doorDir);
|
||||
writeDefault(doorDir);
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("Error creating directory " + doorDir, e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Files.isDirectory(doorDir)) {
|
||||
List<Path> paths;
|
||||
try {
|
||||
paths = Files.list(doorDir).collect(Collectors.toList());
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("Error retrieving paths in directory " + doorDir, e);
|
||||
return;
|
||||
}
|
||||
for (Path p : paths) {
|
||||
if (!Files.isDirectory(p) && Files.isRegularFile(p)) {
|
||||
String jsonStr;
|
||||
try {
|
||||
jsonStr = new String(Files.readAllBytes(p), StandardCharsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("Error reading " + p, e);
|
||||
return;
|
||||
}
|
||||
JsonObject json = GSON.fromJson(jsonStr, JsonObject.class);
|
||||
try (DoorData ignored = DoorData.fromJson(json)) {
|
||||
LOGGER.info("Loaded door json from {} with id {}", p.toAbsolutePath().toString(), ignored.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeDefault(Path root) throws IOException {
|
||||
writeDefault(root.resolve("iron_dimensional_door.json"), DEFAULT_IRON_DIMENSIONAL_DOOR);
|
||||
writeDefault(root.resolve("gold_dimensional_door.json"), DEFAULT_GOLD_DIMENSIONAL_DOOR);
|
||||
writeDefault(root.resolve("oak_dimensional_door.json"), DEFAULT_OAK_DIMENSIONAL_DOOR);
|
||||
writeDefault(root.resolve("quartz_dimensional_door.json"), DEFAULT_QUARTZ_DIMENSIONAL_DOOR);
|
||||
// writeDefault(root.resolve("unstable_dimensional_door.json"), DEFAULT_UNSTABLE_DIMENSIONAL_DOOR);
|
||||
}
|
||||
|
||||
private static void writeDefault(Path path, DoorData doorData) {
|
||||
try {
|
||||
Files.createFile(path);
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("Error creating " + path, e);
|
||||
return;
|
||||
}
|
||||
String json = GSON.toJson(doorData.toJson(new JsonObject()));
|
||||
try {
|
||||
Files.write(path, json.getBytes(StandardCharsets.UTF_8));
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("Error writing to " + path, e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package org.dimdev.dimdoors.block.door.data;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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.data.condition.Condition;
|
||||
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
|
||||
import org.dimdev.dimdoors.rift.registry.LinkProperties;
|
||||
import org.dimdev.dimdoors.rift.targets.VirtualTarget;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.util.Pair;
|
||||
|
||||
public class RiftDataList {
|
||||
private final LinkedList<Pair<OptRiftData, Condition>> riftDataConditions;
|
||||
|
||||
public static RiftDataList fromJson(JsonArray jsonArray) {
|
||||
LinkedList<Pair<OptRiftData, Condition>> riftDataConditions = new LinkedList<>();
|
||||
for (JsonElement json : jsonArray) {
|
||||
JsonObject jsonObject = json.getAsJsonObject();
|
||||
OptRiftData riftData = OptRiftData.fromJson(jsonObject.getAsJsonObject("data"));
|
||||
Condition condition = Condition.fromJson(jsonObject.getAsJsonObject("condition"));
|
||||
riftDataConditions.add(new Pair<>(riftData, condition));
|
||||
}
|
||||
return new RiftDataList(riftDataConditions);
|
||||
}
|
||||
|
||||
public RiftDataList(LinkedList<Pair<OptRiftData, Condition>> riftDataConditions) {
|
||||
this.riftDataConditions = riftDataConditions;
|
||||
}
|
||||
|
||||
public OptRiftData getRiftData(EntranceRiftBlockEntity rift) {
|
||||
return riftDataConditions.stream().filter(pair -> pair.getRight().matches(rift)).findFirst().orElseThrow(() -> new RuntimeException("Could not find any matching rift data")).getLeft();
|
||||
}
|
||||
|
||||
public JsonArray toJson() {
|
||||
JsonArray jsonArray = new JsonArray();
|
||||
for (Map.Entry<OptRiftData, Condition> entry : this.riftDataConditions.stream().collect(Collectors.toMap(Pair::getLeft, Pair::getRight)).entrySet()) {
|
||||
OptRiftData riftData = entry.getKey();
|
||||
Condition condition = entry.getValue();
|
||||
JsonObject jsonInner = new JsonObject();
|
||||
jsonInner.add("data", riftData.toJson(new JsonObject()));
|
||||
jsonInner.add("condition", condition.toJson(new JsonObject()));
|
||||
jsonArray.add(jsonInner);
|
||||
}
|
||||
return jsonArray;
|
||||
}
|
||||
|
||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
||||
public static class OptRiftData {
|
||||
private final Optional<VirtualTarget> destination;
|
||||
private final Optional<LinkProperties> linkProperties;
|
||||
|
||||
public static OptRiftData fromJson(JsonObject json) {
|
||||
Optional<VirtualTarget> destination = Optional.ofNullable(json.get("destination")).map(JsonElement::getAsJsonObject).map(j -> JsonOps.INSTANCE.convertTo(NbtOps.INSTANCE, j)).map(CompoundTag.class::cast).map(VirtualTarget::fromTag);
|
||||
Optional<LinkProperties> linkProperties = Optional.ofNullable(json.get("properties")).map(JsonElement::getAsJsonObject).map(j -> JsonOps.INSTANCE.convertTo(NbtOps.INSTANCE, j)).map(CompoundTag.class::cast).map(LinkProperties::fromTag);
|
||||
return new OptRiftData(destination, linkProperties);
|
||||
}
|
||||
|
||||
public OptRiftData(Optional<VirtualTarget> destination, Optional<LinkProperties> linkProperties) {
|
||||
this.destination = destination;
|
||||
this.linkProperties = linkProperties;
|
||||
}
|
||||
|
||||
public JsonObject toJson(JsonObject json) {
|
||||
this.destination.ifPresent(s -> json.add("destination", NbtOps.INSTANCE.convertTo(JsonOps.INSTANCE, VirtualTarget.toTag(s))));
|
||||
this.linkProperties.ifPresent(s -> json.add("properties", NbtOps.INSTANCE.convertTo(JsonOps.INSTANCE, LinkProperties.toTag(s))));
|
||||
return json;
|
||||
}
|
||||
|
||||
public Optional<LinkProperties> getProperties() {
|
||||
return linkProperties;
|
||||
}
|
||||
|
||||
public Optional<VirtualTarget> getDestination() {
|
||||
return destination;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package org.dimdev.dimdoors.block.door.data.condition;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
|
||||
|
||||
public class AllCondition extends MultipleCondition {
|
||||
public AllCondition(List<Condition> conditions) {
|
||||
super(conditions);
|
||||
}
|
||||
|
||||
public static AllCondition fromJson(JsonObject json) {
|
||||
JsonArray conditions = json.getAsJsonArray("conditions");
|
||||
return new AllCondition(StreamSupport.stream(conditions.spliterator(), false).map(JsonElement::getAsJsonObject).map(Condition::fromJson).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConditionType<?> getType() {
|
||||
return ConditionType.ALL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EntranceRiftBlockEntity rift) {
|
||||
return this.conditions.stream().allMatch(c -> c.matches(rift));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package org.dimdev.dimdoors.block.door.data.condition;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
|
||||
|
||||
public enum AlwaysTrueCondition implements Condition {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public boolean matches(EntranceRiftBlockEntity rift) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toJsonInner(JsonObject json) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Condition.ConditionType<?> getType() {
|
||||
return ConditionType.ALWAYS_TRUE;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package org.dimdev.dimdoors.block.door.data.condition;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
|
||||
|
||||
public class AnyCondition extends MultipleCondition {
|
||||
public AnyCondition(List<Condition> conditions) {
|
||||
super(conditions);
|
||||
}
|
||||
|
||||
public static AnyCondition fromJson(JsonObject json) {
|
||||
JsonArray conditions = json.getAsJsonArray("conditions");
|
||||
return new AnyCondition(StreamSupport.stream(conditions.spliterator(), false).map(JsonElement::getAsJsonObject).map(Condition::fromJson).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConditionType<?> getType() {
|
||||
return ConditionType.ANY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EntranceRiftBlockEntity rift) {
|
||||
return this.conditions.stream().anyMatch(c -> c.matches(rift));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package org.dimdev.dimdoors.block.door.data.condition;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.util.registry.SimpleRegistry;
|
||||
|
||||
import net.fabricmc.fabric.api.event.registry.FabricRegistryBuilder;
|
||||
|
||||
public interface Condition {
|
||||
Registry<ConditionType<?>> REGISTRY = FabricRegistryBuilder.<ConditionType<?>, SimpleRegistry<ConditionType<?>>>from(new SimpleRegistry<>(RegistryKey.ofRegistry(new Identifier("dimdoors", "rift_data_condition")), Lifecycle.stable())).buildAndRegister();
|
||||
|
||||
boolean matches(EntranceRiftBlockEntity rift);
|
||||
|
||||
default JsonObject toJson(JsonObject json) {
|
||||
json.addProperty("type", getType().getId());
|
||||
this.toJsonInner(json);
|
||||
return json;
|
||||
}
|
||||
|
||||
void toJsonInner(JsonObject json);
|
||||
|
||||
ConditionType<?> getType();
|
||||
|
||||
static Condition fromJson(JsonObject json) {
|
||||
Identifier type = new Identifier(json.getAsJsonPrimitive("type").getAsString());
|
||||
return Objects.requireNonNull(REGISTRY.get(type)).fromJson(json);
|
||||
}
|
||||
|
||||
interface ConditionType<T extends Condition> {
|
||||
ConditionType<AlwaysTrueCondition> ALWAYS_TRUE = register("always_true", j -> AlwaysTrueCondition.INSTANCE);
|
||||
ConditionType<AllCondition> ALL = register("all", AllCondition::fromJson);
|
||||
ConditionType<AnyCondition> ANY = register("any", AnyCondition::fromJson);
|
||||
ConditionType<InverseCondition> INVERSE = register("inverse", InverseCondition::fromJson);
|
||||
ConditionType<WorldMatchCondition> WORLD_MATCH = register("world_match", WorldMatchCondition::fromJson);
|
||||
|
||||
T fromJson(JsonObject json);
|
||||
|
||||
JsonObject toJson(T t, JsonObject json);
|
||||
|
||||
default String getId() {
|
||||
return String.valueOf(REGISTRY.getId(this));
|
||||
}
|
||||
|
||||
static void register() {
|
||||
}
|
||||
|
||||
static <T extends Condition> ConditionType<T> register(String name, Function<JsonObject, T> fromJson) {
|
||||
return Registry.register(REGISTRY, new Identifier("dimdoors", name), new ConditionType<T>() {
|
||||
@Override
|
||||
public T fromJson(JsonObject json) {
|
||||
return fromJson.apply(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonObject toJson(T t, JsonObject json) {
|
||||
return t.toJson(json);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package org.dimdev.dimdoors.block.door.data.condition;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
|
||||
|
||||
public class InverseCondition implements Condition {
|
||||
private final Condition condition;
|
||||
|
||||
public InverseCondition(Condition condition) {
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toJsonInner(JsonObject json) {
|
||||
json.add("condition", condition.toJson(new JsonObject()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConditionType<?> getType() {
|
||||
return ConditionType.INVERSE;
|
||||
}
|
||||
|
||||
public static InverseCondition fromJson(JsonObject json) {
|
||||
return new InverseCondition(Condition.fromJson(json.getAsJsonObject("condition")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EntranceRiftBlockEntity rift) {
|
||||
return !this.condition.matches(rift);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package org.dimdev.dimdoors.block.door.data.condition;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
public abstract class MultipleCondition implements Condition {
|
||||
protected final List<Condition> conditions;
|
||||
|
||||
protected MultipleCondition(List<Condition> conditions) {
|
||||
this.conditions = conditions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toJsonInner(JsonObject json) {
|
||||
JsonArray conditionsJson = new JsonArray();
|
||||
conditions.forEach(c -> conditionsJson.add(c.toJson( new JsonObject())));
|
||||
json.add("conditions", conditionsJson);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package org.dimdev.dimdoors.block.door.data.condition;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class WorldMatchCondition implements Condition {
|
||||
private final RegistryKey<World> world;
|
||||
|
||||
public WorldMatchCondition(RegistryKey<World> world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public static WorldMatchCondition fromJson(JsonObject json) {
|
||||
RegistryKey<World> key = RegistryKey.of(Registry.DIMENSION, new Identifier(json.getAsJsonPrimitive("world").getAsString()));
|
||||
return new WorldMatchCondition(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EntranceRiftBlockEntity rift) {
|
||||
//noinspection ConstantConditions
|
||||
return rift.getWorld().getRegistryKey() == this.world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toJsonInner(JsonObject json) {
|
||||
json.addProperty("world", world.getValue().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConditionType<?> getType() {
|
||||
return ConditionType.WORLD_MATCH;
|
||||
}
|
||||
}
|
|
@ -26,14 +26,13 @@ public class EntranceRiftBlockEntity extends RiftBlockEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromTag(CompoundTag nbt) {
|
||||
super.fromTag(nbt);
|
||||
public void readNbt(CompoundTag nbt) {
|
||||
super.readNbt(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toTag(CompoundTag tag) {
|
||||
tag = super.toTag(tag);
|
||||
return tag;
|
||||
public CompoundTag writeNbt(CompoundTag tag) {
|
||||
return super.writeNbt(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package org.dimdev.dimdoors.block.entity;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.dimdev.dimdoors.block.ModBlocks;
|
||||
import org.dimdev.dimdoors.block.door.data.DoorData;
|
||||
import org.dimdev.dimdoors.client.DetachedRiftBlockEntityRenderer;
|
||||
import org.dimdev.dimdoors.client.EntranceRiftBlockEntityRenderer;
|
||||
|
||||
|
@ -23,7 +25,7 @@ public class ModBlockEntityTypes {
|
|||
public static final BlockEntityType<EntranceRiftBlockEntity> ENTRANCE_RIFT = register(
|
||||
"dimdoors:entrance_rift",
|
||||
EntranceRiftBlockEntity::new,
|
||||
ModBlocks.OAK_DIMENSIONAL_DOOR, ModBlocks.IRON_DIMENSIONAL_DOOR, ModBlocks.GOLD_DIMENSIONAL_DOOR, ModBlocks.QUARTZ_DIMENSIONAL_DOOR, ModBlocks.DIMENSIONAL_PORTAL);
|
||||
ArrayUtils.add(DoorData.DOORS.toArray(new Block[0]), ModBlocks.DIMENSIONAL_PORTAL));
|
||||
|
||||
private static <E extends BlockEntity> BlockEntityType<E> register(String id, FabricBlockEntityTypeBuilder.Factory<E> factory, Block... blocks) {
|
||||
return Registry.register(Registry.BLOCK_ENTITY_TYPE, id, FabricBlockEntityTypeBuilder.create(factory, blocks).build());
|
||||
|
|
|
@ -49,8 +49,8 @@ public abstract class RiftBlockEntity extends BlockEntity implements BlockEntity
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromTag(CompoundTag nbt) {
|
||||
super.fromTag(nbt);
|
||||
public void readNbt(CompoundTag nbt) {
|
||||
super.readNbt(nbt);
|
||||
this.deserialize(nbt);
|
||||
}
|
||||
|
||||
|
@ -59,8 +59,8 @@ public abstract class RiftBlockEntity extends BlockEntity implements BlockEntity
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toTag(CompoundTag tag) {
|
||||
super.toTag(tag);
|
||||
public CompoundTag writeNbt(CompoundTag tag) {
|
||||
super.writeNbt(tag);
|
||||
return this.serialize(tag);
|
||||
}
|
||||
|
||||
|
@ -171,8 +171,7 @@ public abstract class RiftBlockEntity extends BlockEntity implements BlockEntity
|
|||
}
|
||||
}
|
||||
|
||||
public boolean
|
||||
teleport(Entity entity) {
|
||||
public boolean teleport(Entity entity) {
|
||||
this.riftStateChanged = false;
|
||||
|
||||
// Attempt a teleport
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
package org.dimdev.dimdoors.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.dimdev.dimdoors.entity.RiftEntity;
|
||||
|
||||
import net.minecraft.client.render.TexturedRenderLayers;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.render.entity.EntityRenderer;
|
||||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
|
||||
|
||||
public class RiftRenderer extends EntityRenderer<RiftEntity> {
|
||||
public RiftRenderer(EntityRendererFactory.Context ctx) {
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getTexture(RiftEntity entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(RiftEntity entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) {
|
||||
VertexConsumer vc = vertexConsumers.getBuffer(TexturedRenderLayers.getEntitySolid());
|
||||
ArrayList<RiftCurves.Point> points = RiftCurves.CURVES.get(0).points;
|
||||
|
||||
for (RiftCurves.Point point : points) {
|
||||
vc.vertex(point.x, point.y, 0).color(0, 0, 0, 0).next();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ package org.dimdev.dimdoors.client.wthit;
|
|||
import mcp.mobius.waila.api.IRegistrar;
|
||||
import mcp.mobius.waila.api.IWailaPlugin;
|
||||
import mcp.mobius.waila.api.TooltipPosition;
|
||||
import org.dimdev.dimdoors.block.DimensionalDoorBlock;
|
||||
import org.dimdev.dimdoors.block.door.DimensionalDoorBlock;
|
||||
|
||||
public class WthitPlugin implements IWailaPlugin {
|
||||
@Override
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.dimdev.dimdoors.entity;
|
|||
|
||||
import org.dimdev.dimdoors.client.MaskRenderer;
|
||||
import org.dimdev.dimdoors.client.MonolithRenderer;
|
||||
import org.dimdev.dimdoors.client.RiftRenderer;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityDimensions;
|
||||
|
@ -28,11 +27,6 @@ public class ModEntityTypes {
|
|||
MaskEntity::new,
|
||||
1, 1
|
||||
);
|
||||
public static final EntityType<RiftEntity> RIFT = register(
|
||||
"dimdoors:rift",
|
||||
RiftEntity::new,
|
||||
1, 1
|
||||
);
|
||||
|
||||
public static void init() {
|
||||
FabricDefaultAttributeRegistry.register(MONOLITH, MonolithEntity.createMobAttributes());
|
||||
|
@ -43,7 +37,6 @@ public class ModEntityTypes {
|
|||
public static void initClient() {
|
||||
EntityRendererRegistry.INSTANCE.register(MONOLITH, MonolithRenderer::new);
|
||||
EntityRendererRegistry.INSTANCE.register(MASK, MaskRenderer::new);
|
||||
EntityRendererRegistry.INSTANCE.register(RIFT, RiftRenderer::new);
|
||||
}
|
||||
|
||||
private static <E extends Entity> EntityType<E> register(String id, EntityType.EntityFactory<E> factory, int width, int height) {
|
||||
|
|
|
@ -266,15 +266,15 @@ public class MonolithEntity extends MobEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toTag(CompoundTag tag) {
|
||||
super.toTag(tag);
|
||||
public CompoundTag writeNbt(CompoundTag tag) {
|
||||
super.writeNbt(tag);
|
||||
tag.putInt("Aggro", this.aggro);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromTag(CompoundTag nbt) {
|
||||
super.fromTag(nbt);
|
||||
public void readNbt(CompoundTag nbt) {
|
||||
super.readNbt(nbt);
|
||||
this.aggro = nbt.getInt("Aggro");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
package org.dimdev.dimdoors.entity;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class RiftEntity extends Entity {
|
||||
public RiftEntity(EntityType<?> type, World world) {
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
public RiftEntity(World world) {
|
||||
super(null, world); //TODO: register entity type
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDataTracker() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readCustomDataFromTag(CompoundTag tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeCustomDataToTag(CompoundTag tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet<?> createSpawnPacket() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -8,9 +8,6 @@ import org.dimdev.dimdoors.DimensionalDoorsInitializer;
|
|||
import org.dimdev.dimdoors.entity.MonolithEntity;
|
||||
import org.dimdev.dimdoors.item.ModItems;
|
||||
import org.dimdev.dimdoors.sound.ModSoundEvents;
|
||||
import org.dimdev.dimdoors.util.Location;
|
||||
import org.dimdev.dimdoors.util.TeleportUtil;
|
||||
import org.dimdev.dimdoors.world.ModDimensions;
|
||||
|
||||
import net.minecraft.entity.ai.TargetPredicate;
|
||||
import net.minecraft.entity.ai.goal.Goal;
|
||||
|
@ -18,16 +15,17 @@ import net.minecraft.entity.player.PlayerEntity;
|
|||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import net.fabricmc.fabric.api.network.ServerSidePacketRegistry;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||
|
||||
import static net.minecraft.predicate.entity.EntityPredicates.EXCEPT_SPECTATOR;
|
||||
import static org.dimdev.dimdoors.entity.MonolithEntity.MAX_AGGRO;
|
||||
|
||||
public class MonolithAggroGoal extends Goal {
|
||||
protected final MonolithEntity mob;
|
||||
public static final Identifier MONOLITH_PARTICLE_PACKET = new Identifier("dimdoors", "monolith_particle_packet");
|
||||
protected final MonolithEntity mob;
|
||||
protected PlayerEntity target;
|
||||
protected final float range;
|
||||
protected final TargetPredicate targetPredicate;
|
||||
|
@ -96,7 +94,7 @@ public class MonolithAggroGoal extends Goal {
|
|||
|
||||
PacketByteBuf data = new PacketByteBuf(Unpooled.buffer());
|
||||
data.writeInt(this.mob.getAggro());
|
||||
ServerPlayNetworking.send((ServerPlayerEntity) this.target, DimensionalDoorsInitializer.MONOLITH_PARTICLE_PACKET, data);
|
||||
ServerPlayNetworking.send((ServerPlayerEntity) this.target, MONOLITH_PARTICLE_PACKET, data);
|
||||
}
|
||||
|
||||
// Teleport the target player if various conditions are met
|
||||
|
|
16
src/main/java/org/dimdev/dimdoors/item/ItemExtensions.java
Normal file
16
src/main/java/org/dimdev/dimdoors/item/ItemExtensions.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package org.dimdev.dimdoors.item;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public interface ItemExtensions {
|
||||
Item.Settings dimdoors_getSettings();
|
||||
|
||||
static Item.Settings getSettings(Item item) {
|
||||
Item.Settings settings = ((ItemExtensions) item).dimdoors_getSettings();
|
||||
return ((SettingsExtensions) settings).clone();
|
||||
}
|
||||
|
||||
interface SettingsExtensions extends Cloneable {
|
||||
Item.Settings clone();
|
||||
}
|
||||
}
|
|
@ -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,67 +28,67 @@ 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;
|
||||
|
||||
public static final ItemGroup DIMENSIONAL_DOORS = FabricItemGroupBuilder
|
||||
.create(new Identifier("dimdoors", "dimensional_doors"))
|
||||
.icon(() -> new ItemStack(ModItems.IRON_DIMENSIONAL_DOOR))
|
||||
.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")
|
||||
public static final Item QUARTZ_DIMENSIONAL_DOOR = create(new DimensionalDoorItem(
|
||||
ModBlocks.QUARTZ_DIMENSIONAL_DOOR,
|
||||
new Item.Settings().group(DIMENSIONAL_DOORS).maxCount(1),
|
||||
rift -> {
|
||||
if (ModDimensions.isPrivatePocketDimension(rift.getWorld())) {
|
||||
rift.setDestination(new PrivatePocketExitTarget()); // exit
|
||||
} else {
|
||||
rift.setDestination(new PrivatePocketTarget()); // entrances
|
||||
}
|
||||
}
|
||||
));
|
||||
// @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),
|
||||
// rift -> {
|
||||
// if (ModDimensions.isPrivatePocketDimension(rift.getWorld())) {
|
||||
// rift.setDestination(new PrivatePocketExitTarget()); // exit
|
||||
// } else {
|
||||
// rift.setDestination(new PrivatePocketTarget()); // entrances
|
||||
// }
|
||||
// }
|
||||
// ));
|
||||
|
||||
@RegistryObject("gold_door")
|
||||
@RegistryEntry("gold_door")
|
||||
public static final Item GOLD_DOOR = create(ModBlocks.GOLD_DOOR);
|
||||
|
||||
@RegistryObject("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),
|
||||
rift -> {
|
||||
rift.setProperties(LinkProperties.builder()
|
||||
.groups(new HashSet<>(Arrays.asList(0, 1)))
|
||||
.linksRemaining(1).build());
|
||||
|
||||
rift.setDestination(RandomTarget.builder()
|
||||
.acceptedGroups(Collections.singleton(0))
|
||||
.coordFactor(1)
|
||||
.negativeDepthFactor(10000)
|
||||
.positiveDepthFactor(80)
|
||||
.weightMaximum(100)
|
||||
.noLink(false)
|
||||
.noLinkBack(false)
|
||||
.newRiftWeight(1).build());
|
||||
}
|
||||
));
|
||||
|
||||
@RegistryObject("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),
|
||||
rift -> {
|
||||
PublicPocketTarget destination = new PublicPocketTarget();
|
||||
rift.setDestination(destination);
|
||||
}
|
||||
));
|
||||
/*
|
||||
@RegistryObject("unstable_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),
|
||||
// rift -> {
|
||||
// rift.setProperties(LinkProperties.builder()
|
||||
// .groups(new HashSet<>(Arrays.asList(0, 1)))
|
||||
// .linksRemaining(1).build());
|
||||
//
|
||||
// rift.setDestination(RandomTarget.builder()
|
||||
// .acceptedGroups(Collections.singleton(0))
|
||||
// .coordFactor(1)
|
||||
// .negativeDepthFactor(10000)
|
||||
// .positiveDepthFactor(80)
|
||||
// .weightMaximum(100)
|
||||
// .noLink(false)
|
||||
// .noLinkBack(false)
|
||||
// .newRiftWeight(1).build());
|
||||
// }
|
||||
// ));
|
||||
//
|
||||
// @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),
|
||||
// rift -> {
|
||||
// PublicPocketTarget destination = new PublicPocketTarget();
|
||||
// rift.setDestination(destination);
|
||||
// }
|
||||
// ));
|
||||
/* TODO
|
||||
@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,24 +103,24 @@ public final class ModItems {
|
|||
.newRiftWeight(0.5F).build())
|
||||
));
|
||||
*/
|
||||
@RegistryObject("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),
|
||||
rift -> rift.setDestination(
|
||||
RandomTarget.builder()
|
||||
.acceptedGroups(Collections.singleton(0))
|
||||
.coordFactor(1)
|
||||
.negativeDepthFactor(80)
|
||||
.positiveDepthFactor(Double.MAX_VALUE)
|
||||
.weightMaximum(100)
|
||||
.noLink(false)
|
||||
.newRiftWeight(0)
|
||||
.build()
|
||||
)
|
||||
));
|
||||
// @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),
|
||||
// rift -> rift.setDestination(
|
||||
// RandomTarget.builder()
|
||||
// .acceptedGroups(Collections.singleton(0))
|
||||
// .coordFactor(1)
|
||||
// .negativeDepthFactor(80)
|
||||
// .positiveDepthFactor(Double.MAX_VALUE)
|
||||
// .weightMaximum(100)
|
||||
// .noLink(false)
|
||||
// .newRiftWeight(0)
|
||||
// .build()
|
||||
// )
|
||||
// ));
|
||||
|
||||
@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 {
|
||||
|
|
38
src/main/java/org/dimdev/dimdoors/mixin/ItemMixin.java
Normal file
38
src/main/java/org/dimdev/dimdoors/mixin/ItemMixin.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
package org.dimdev.dimdoors.mixin;
|
||||
|
||||
import org.dimdev.dimdoors.item.ItemExtensions;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
@Mixin(Item.class)
|
||||
public class ItemMixin implements ItemExtensions {
|
||||
@Unique
|
||||
private Item.Settings settings;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
public void cacheSettings(Item.Settings settings, CallbackInfo ci) {
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item.Settings dimdoors_getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
@Mixin(Item.Settings.class)
|
||||
public static class SettingsMixin implements ItemExtensions.SettingsExtensions {
|
||||
@Override
|
||||
public Item.Settings clone() {
|
||||
try {
|
||||
return (Item.Settings) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new AssertionError(e); // Cant happen, we are Cloneable
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package org.dimdev.dimdoors.mixin.accessor;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.world.gen.chunk.ChunkGeneratorSettings;
|
||||
import net.minecraft.world.gen.chunk.GenerationShapeConfig;
|
||||
import net.minecraft.world.gen.chunk.StructuresConfig;
|
||||
|
||||
@Mixin(ChunkGeneratorSettings.class)
|
||||
public interface ChunkGeneratorSettingsAccessor {
|
||||
@Invoker("<init>")
|
||||
static ChunkGeneratorSettings invokeInit(StructuresConfig structuresConfig, GenerationShapeConfig generationShapeConfig, BlockState defaultBlock, BlockState defaultFluid, int bedrockCeilingY, int bedrockFloorY, int seaLevel, boolean mobGenerationDisabled, boolean bl, boolean bl2) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
|
@ -1,25 +1,5 @@
|
|||
package org.dimdev.dimdoors.network;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketSender;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.World;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dimdev.dimdoors.network.c2s.NetworkHandlerInitializedC2SPacket;
|
||||
import org.dimdev.dimdoors.network.s2c.PlayerInventorySlotUpdateS2CPacket;
|
||||
import org.dimdev.dimdoors.network.s2c.SyncPocketAddonsS2CPacket;
|
||||
import org.dimdev.dimdoors.world.pocket.type.addon.AutoSyncedAddon;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
@ -27,6 +7,27 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dimdev.dimdoors.network.c2s.NetworkHandlerInitializedC2SPacket;
|
||||
import org.dimdev.dimdoors.network.s2c.PlayerInventorySlotUpdateS2CPacket;
|
||||
import org.dimdev.dimdoors.network.s2c.SyncPocketAddonsS2CPacket;
|
||||
import org.dimdev.dimdoors.world.pocket.type.addon.AutoSyncedAddon;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketSender;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class ClientPacketHandler {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
|
|
@ -50,7 +50,7 @@ public class TemplateUtils {
|
|||
monolith.setPos(x, y, z);
|
||||
monolith.yaw = yaw;
|
||||
monolith.pitch = pitch;
|
||||
newTag = monolith.toTag(new CompoundTag());
|
||||
newTag = monolith.writeNbt(new CompoundTag());
|
||||
} else {
|
||||
throw new RuntimeException("Unknown entity placeholder: " + entityTag.getString("placeholder"));
|
||||
}
|
||||
|
@ -136,27 +136,27 @@ public class TemplateUtils {
|
|||
case "deeper_depth_door":
|
||||
rift.setProperties(DefaultDungeonDestinations.POCKET_LINK_PROPERTIES);
|
||||
rift.setDestination(DefaultDungeonDestinations.DEEPER_DUNGEON_DESTINATION);
|
||||
newTag = rift.toTag(newTag);
|
||||
newTag = rift.writeNbt(newTag);
|
||||
break;
|
||||
case "less_deep_depth_door":
|
||||
rift.setProperties(DefaultDungeonDestinations.POCKET_LINK_PROPERTIES);
|
||||
rift.setDestination(DefaultDungeonDestinations.SHALLOWER_DUNGEON_DESTINATION);
|
||||
newTag = rift.toTag(newTag);
|
||||
newTag = rift.writeNbt(newTag);
|
||||
break;
|
||||
case "overworld_door":
|
||||
rift.setProperties(DefaultDungeonDestinations.POCKET_LINK_PROPERTIES);
|
||||
rift.setDestination(DefaultDungeonDestinations.OVERWORLD_DESTINATION);
|
||||
newTag = rift.toTag(newTag);
|
||||
newTag = rift.writeNbt(newTag);
|
||||
break;
|
||||
case "entrance_door":
|
||||
rift.setProperties(DefaultDungeonDestinations.POCKET_LINK_PROPERTIES);
|
||||
rift.setDestination(DefaultDungeonDestinations.TWO_WAY_POCKET_ENTRANCE);
|
||||
newTag = rift.toTag(newTag);
|
||||
newTag = rift.writeNbt(newTag);
|
||||
break;
|
||||
case "gateway_portal":
|
||||
rift.setProperties(DefaultDungeonDestinations.OVERWORLD_LINK_PROPERTIES);
|
||||
rift.setDestination(DefaultDungeonDestinations.GATEWAY_DESTINATION);
|
||||
newTag = rift.toTag(newTag);
|
||||
newTag = rift.writeNbt(newTag);
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Unknown block entity placeholder: " + blockEntityTag.getString("placeholder"));
|
||||
|
|
|
@ -49,7 +49,7 @@ public class AbsoluteRiftBlockEntityModifier implements LazyModifier {
|
|||
|
||||
ListTag riftsTag;
|
||||
if (rifts != null) {
|
||||
riftsTag = rifts.values().parallelStream().unordered().map(rift -> rift.toTag(new CompoundTag())).collect(Collectors.toCollection(ListTag::new));
|
||||
riftsTag = rifts.values().parallelStream().unordered().map(rift -> rift.writeNbt(new CompoundTag())).collect(Collectors.toCollection(ListTag::new));
|
||||
} else {
|
||||
riftsTag = new ListTag();
|
||||
riftsTag.addAll(serializedRifts.values());
|
||||
|
@ -97,7 +97,7 @@ public class AbsoluteRiftBlockEntityModifier implements LazyModifier {
|
|||
serializedRifts.entrySet().stream().unordered().filter(entry -> chunkBox.contains(entry.getKey())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))
|
||||
.forEach((pos, riftTag) -> {
|
||||
rifts.remove(pos);
|
||||
chunk.setBlockEntity(BlockEntity.createFromTag(pos, chunk.getBlockState(pos), riftTag));
|
||||
chunk.setBlockEntity(BlockEntity.createFromNbt(pos, chunk.getBlockState(pos), riftTag));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraft.util.registry.Registry;
|
|||
import com.google.common.base.MoreObjects;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dimdev.dimdoors.block.DimensionalDoorBlock;
|
||||
import org.dimdev.dimdoors.block.door.DimensionalDoorBlock;
|
||||
import org.dimdev.dimdoors.block.ModBlocks;
|
||||
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
|
||||
import org.dimdev.dimdoors.block.entity.ModBlockEntityTypes;
|
||||
|
@ -56,15 +56,13 @@ public class DimensionalDoorModifier implements LazyCompatibleModifier {
|
|||
String facingString = tag.getString("facing");
|
||||
facing = Direction.byName(tag.getString("facing"));
|
||||
if (facing == null || facing.getAxis().isVertical()) {
|
||||
LOGGER.error("Could not interpret facing direction \"" + facingString + "\"");
|
||||
facing = Direction.NORTH;
|
||||
throw new RuntimeException("Could not interpret facing direction \"" + facingString + "\"");
|
||||
}
|
||||
|
||||
doorTypeString = tag.getString("door_type");
|
||||
Block doorBlock = Registry.BLOCK.get(Identifier.tryParse(doorTypeString));
|
||||
if (!(doorBlock instanceof DimensionalDoorBlock)) {
|
||||
LOGGER.error("Could not interpret door type \"" + doorTypeString + "\"");
|
||||
doorBlock = ModBlocks.IRON_DIMENSIONAL_DOOR;
|
||||
throw new RuntimeException("Could not interpret door type \"" + doorTypeString + "\"");
|
||||
}
|
||||
doorType = (DimensionalDoorBlock) doorBlock;
|
||||
|
||||
|
|
|
@ -56,11 +56,11 @@ public interface Modifier {
|
|||
static void register() {
|
||||
}
|
||||
|
||||
static <U extends Modifier> ModifierType<U> register(Identifier id, Supplier<U> constructor) {
|
||||
static <U extends Modifier> ModifierType<U> register(Identifier id, Supplier<U> factory) {
|
||||
return Registry.register(REGISTRY, id, new ModifierType<U>() {
|
||||
@Override
|
||||
public Modifier fromTag(CompoundTag tag) {
|
||||
return constructor.get().fromTag(tag);
|
||||
return factory.get().fromTag(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,8 +16,6 @@ import org.dimdev.dimdoors.world.pocket.PocketDirectory;
|
|||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
|
||||
//import net.fabricmc.fabric.api.dimension.v1.FabricDimensions;
|
||||
|
||||
public class PrivatePocketExitTarget extends VirtualTarget implements EntityTarget {
|
||||
public static final RGBA COLOR = new RGBA(0, 1, 0, 1);
|
||||
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package org.dimdev.dimdoors.rift.targets;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.EulerAngle;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public class UnstableTarget extends VirtualTarget implements EntityTarget {
|
||||
private static final Random RANDOM = new Random();
|
||||
|
||||
@Override
|
||||
public VirtualTargetType<? extends VirtualTarget> getType() {
|
||||
return VirtualTargetType.UNSTABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean receiveEntity(Entity entity, Vec3d relativePos, EulerAngle relativeAngle, Vec3d relativeVelocity) {
|
||||
if (RANDOM.nextBoolean()) {
|
||||
return RandomTarget.builder()
|
||||
.acceptedGroups(Collections.singleton(0))
|
||||
.coordFactor(1)
|
||||
.negativeDepthFactor(10000)
|
||||
.positiveDepthFactor(80)
|
||||
.weightMaximum(100)
|
||||
.noLink(false)
|
||||
.noLinkBack(false)
|
||||
.newRiftWeight(1)
|
||||
.build()
|
||||
.as(Targets.ENTITY)
|
||||
.receiveEntity(entity, relativePos, relativeAngle, relativeVelocity);
|
||||
}
|
||||
|
||||
return LimboTarget.INSTANCE.receiveEntity(entity, relativePos, relativeAngle, relativeVelocity);
|
||||
}
|
||||
}
|
|
@ -26,7 +26,8 @@ public abstract class VirtualTarget implements Target {
|
|||
protected Location location;
|
||||
|
||||
public static VirtualTarget fromTag(CompoundTag nbt) {
|
||||
return Objects.requireNonNull(REGISTRY.get(new Identifier(nbt.getString("type")))).fromTag(nbt);
|
||||
Identifier id = new Identifier(nbt.getString("type"));
|
||||
return Objects.requireNonNull(REGISTRY.get(id), "Unknown virtual target type " + id.toString()).fromTag(nbt);
|
||||
}
|
||||
|
||||
public static CompoundTag toTag(VirtualTarget virtualTarget) {
|
||||
|
@ -93,7 +94,7 @@ public abstract class VirtualTarget implements Target {
|
|||
VirtualTargetType<PrivatePocketExitTarget> PRIVATE_POCKET_EXIT = register("dimdoors:private_pocket_exit", a -> new PrivatePocketExitTarget(), a -> new CompoundTag(), PrivatePocketExitTarget.COLOR);
|
||||
VirtualTargetType<RelativeReference> RELATIVE = register("dimdoors:relative", RelativeReference::fromTag, RelativeReference::toTag, VirtualTarget.COLOR);
|
||||
VirtualTargetType<IdMarker> ID_MARKER = register("dimdoors:id_marker", IdMarker::fromTag, IdMarker::toTag, VirtualTarget.COLOR);
|
||||
//VirtualTargetType<UnstableTarget> UNSTABLE = register("dimdoors:unstable", tag -> new UnstableTarget(), t -> new CompoundTag(), VirtualTarget.COLOR);
|
||||
VirtualTargetType<UnstableTarget> UNSTABLE = register("dimdoors:unstable", tag -> new UnstableTarget(), t -> new CompoundTag(), VirtualTarget.COLOR);
|
||||
VirtualTargetType<NoneTarget> NONE = register("dimdoors:none", tag -> NoneTarget.INSTANCE, i -> new CompoundTag(), COLOR);
|
||||
|
||||
T fromTag(CompoundTag tag);
|
||||
|
@ -126,6 +127,7 @@ public abstract class VirtualTarget implements Target {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
|
||||
public static class NoneTarget extends VirtualTarget {
|
||||
public static final NoneTarget INSTANCE = new NoneTarget();
|
||||
|
||||
|
|
81
src/main/java/org/dimdev/dimdoors/util/OptionalBool.java
Normal file
81
src/main/java/org/dimdev/dimdoors/util/OptionalBool.java
Normal file
|
@ -0,0 +1,81 @@
|
|||
package org.dimdev.dimdoors.util;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.function.IntConsumer;
|
||||
import java.util.function.IntSupplier;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import it.unimi.dsi.fastutil.booleans.BooleanConsumer;
|
||||
|
||||
public final class OptionalBool {
|
||||
private static final OptionalBool EMPTY = new OptionalBool();
|
||||
public static final OptionalBool TRUE = new OptionalBool(true);
|
||||
public static final OptionalBool FALSE = new OptionalBool(false);
|
||||
private final boolean present;
|
||||
private final boolean value;
|
||||
|
||||
private OptionalBool() {
|
||||
this.present = false;
|
||||
this.value = false;
|
||||
}
|
||||
|
||||
public static OptionalBool empty() {
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
private OptionalBool(boolean value) {
|
||||
this.present = true;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static OptionalBool of(boolean value) {
|
||||
return value ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
public boolean getAsBool() {
|
||||
if (!present) {
|
||||
throw new NoSuchElementException("No value present");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean isPresent() {
|
||||
return present;
|
||||
}
|
||||
|
||||
public void ifPresent(BooleanConsumer action) {
|
||||
if (present) {
|
||||
action.accept(value);
|
||||
}
|
||||
}
|
||||
|
||||
public void ifPresentAndTrue(Runnable action) {
|
||||
if (present && value) action.run();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(obj instanceof OptionalBool)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
OptionalBool other = (OptionalBool) obj;
|
||||
return (present && other.present) ? value == other.value : present == other.present;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return present ? Boolean.hashCode(value) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return present ? String.format("OptionalBool[%s]", value) : "OptionalBool.empty";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package org.dimdev.dimdoors.util;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import blue.endless.jankson.Jankson;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.ConfigData;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.annotation.Config;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.serializer.ConfigSerializer;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.util.Utils;
|
||||
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
|
||||
|
||||
public class SubRootJanksonConfigSerializer<T extends ConfigData> implements ConfigSerializer<T> {
|
||||
private static final Jankson JANKSON = Jankson.builder().build();
|
||||
private final Config definition;
|
||||
private final Class<T> configClass;
|
||||
|
||||
public SubRootJanksonConfigSerializer(Config definition, Class<T> configClass) {
|
||||
this.definition = definition;
|
||||
this.configClass = configClass;
|
||||
}
|
||||
|
||||
private Path getConfigPath() {
|
||||
return DimensionalDoorsInitializer.getConfigRoot().resolve(definition.name() + "-config.json5");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(T config) throws SerializationException {
|
||||
Path configPath = getConfigPath();
|
||||
try {
|
||||
Files.createDirectories(configPath.getParent());
|
||||
BufferedWriter writer = Files.newBufferedWriter(configPath);
|
||||
writer.write(JANKSON.toJson(config).toJson(true, true));
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
throw new SerializationException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public T deserialize() throws SerializationException {
|
||||
Path configPath = getConfigPath();
|
||||
if (Files.exists(configPath)) {
|
||||
try {
|
||||
return JANKSON.fromJson(JANKSON.load(getConfigPath().toFile()), configClass);
|
||||
} catch (Throwable e) {
|
||||
throw new SerializationException(e);
|
||||
}
|
||||
} else {
|
||||
return createDefault();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public T createDefault() {
|
||||
return Utils.constructUnsafely(configClass);
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ public class LimboGatewayFeature extends Feature<DefaultFeatureConfig> {
|
|||
|
||||
@Override
|
||||
public boolean generate(FeatureContext<DefaultFeatureConfig> context) {
|
||||
LimboGateway.INSTANCE.generate(context.getWorld(), context.getPos());
|
||||
LimboGateway.INSTANCE.generate(context.getWorld(), context.getOrigin());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,8 @@ public class SchematicV2GatewayFeature extends Feature<SchematicV2GatewayFeature
|
|||
|
||||
@Override
|
||||
public boolean generate(FeatureContext<SchematicV2GatewayFeatureConfig> featureContext) {
|
||||
if (featureContext.getWorld().getBlockState(featureContext.getPos()).getBlock() instanceof AirBlock && featureContext.getConfig().getGateway().test(featureContext.getWorld(), featureContext.getPos())) {
|
||||
featureContext.getConfig().getGateway().generate(featureContext.getWorld(), featureContext.getPos());
|
||||
if (featureContext.getWorld().getBlockState(featureContext.getOrigin()).getBlock() instanceof AirBlock && featureContext.getConfig().getGateway().test(featureContext.getWorld(), featureContext.getOrigin())) {
|
||||
featureContext.getConfig().getGateway().generate(featureContext.getWorld(), featureContext.getOrigin());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -17,9 +17,11 @@ import com.google.gson.JsonObject;
|
|||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import com.mojang.serialization.codecs.UnboundedMapCodec;
|
||||
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.data.DoorData;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -29,8 +31,6 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
import static net.minecraft.block.Blocks.ACACIA_LOG;
|
||||
import static net.minecraft.block.Blocks.ACACIA_PLANKS;
|
||||
import static net.minecraft.block.Blocks.ACACIA_WOOD;
|
||||
|
@ -86,12 +86,8 @@ import static net.minecraft.block.Blocks.SPRUCE_WOOD;
|
|||
import static net.minecraft.block.Blocks.STONE;
|
||||
import static net.minecraft.block.Blocks.STONE_BRICKS;
|
||||
import static org.dimdev.dimdoors.block.ModBlocks.DETACHED_RIFT;
|
||||
import static org.dimdev.dimdoors.block.ModBlocks.DIMENSIONAL_PORTAL;
|
||||
import static org.dimdev.dimdoors.block.ModBlocks.ETERNAL_FLUID;
|
||||
import static org.dimdev.dimdoors.block.ModBlocks.GOLD_DIMENSIONAL_DOOR;
|
||||
import static org.dimdev.dimdoors.block.ModBlocks.GOLD_DOOR;
|
||||
import static org.dimdev.dimdoors.block.ModBlocks.IRON_DIMENSIONAL_DOOR;
|
||||
import static org.dimdev.dimdoors.block.ModBlocks.OAK_DIMENSIONAL_DOOR;
|
||||
import static org.dimdev.dimdoors.block.ModBlocks.QUARTZ_DOOR;
|
||||
import static org.dimdev.dimdoors.block.ModBlocks.UNRAVELLED_FABRIC;
|
||||
|
||||
|
@ -106,7 +102,7 @@ public final class LimboDecay {
|
|||
private static final Map<Block, Block> DECAY_SEQUENCE = new HashMap<>();
|
||||
private static final Map<Block, Block> DEFAULT_VALUES;
|
||||
private static final Gson GSON = new GsonBuilder().setLenient().setPrettyPrinting().create();
|
||||
private static final Path CONFIG_PATH = FabricLoader.getInstance().getConfigDir().resolve("dimdoors_limbo_decay.json");
|
||||
private static final Path CONFIG_PATH = DimensionalDoorsInitializer.getConfigRoot().resolve("limbo_decay.json");
|
||||
|
||||
public static void init() {
|
||||
try {
|
||||
|
@ -136,7 +132,7 @@ public final class LimboDecay {
|
|||
}
|
||||
}
|
||||
|
||||
private static final Random random = new Random();
|
||||
private static final Random RANDOM = new Random();
|
||||
private static Block[] blocksImmuneToDecay = null;
|
||||
|
||||
public static Map<Block, Block> getDecaySequence() {
|
||||
|
@ -145,17 +141,7 @@ public final class LimboDecay {
|
|||
|
||||
public static Block[] getBlocksImmuneToDecay() {
|
||||
if (blocksImmuneToDecay == null) {
|
||||
blocksImmuneToDecay = new Block[]{
|
||||
UNRAVELLED_FABRIC,
|
||||
ETERNAL_FLUID,
|
||||
DIMENSIONAL_PORTAL,
|
||||
IRON_DIMENSIONAL_DOOR,
|
||||
OAK_DIMENSIONAL_DOOR,
|
||||
DETACHED_RIFT,
|
||||
GOLD_DOOR,
|
||||
QUARTZ_DOOR,
|
||||
GOLD_DIMENSIONAL_DOOR
|
||||
};
|
||||
blocksImmuneToDecay = ArrayUtils.addAll(DoorData.DOORS.toArray(new Block[0]), UNRAVELLED_FABRIC, ETERNAL_FLUID, DETACHED_RIFT, GOLD_DOOR, QUARTZ_DOOR);
|
||||
}
|
||||
|
||||
return blocksImmuneToDecay;
|
||||
|
@ -168,7 +154,7 @@ public final class LimboDecay {
|
|||
public static void applySpreadDecay(World world, BlockPos pos) {
|
||||
//Check if we randomly apply decay spread or not. This can be used to moderate the frequency of
|
||||
//full spread decay checks, which can also shift its performance impact on the game.
|
||||
if (random.nextDouble() < DimensionalDoorsInitializer.getConfig().getLimboConfig().decaySpreadChance) {
|
||||
if (RANDOM.nextDouble() < DimensionalDoorsInitializer.getConfig().getLimboConfig().decaySpreadChance) {
|
||||
//Apply decay to the blocks above, below, and on all four sides.
|
||||
//World.getBlockId() implements bounds checking, so we don't have to worry about reaching out of the world
|
||||
boolean flag = decayBlock(world, pos.up());
|
||||
|
|
|
@ -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";
|
||||
}
|
|
@ -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();
|
||||
}
|
|
@ -5,6 +5,8 @@
|
|||
"mixins": [
|
||||
"DefaultBiomeFeaturesMixin",
|
||||
"ExtendedServerPlayNetworkhandlerMixin",
|
||||
"ItemMixin",
|
||||
"ItemMixin$SettingsMixin",
|
||||
"PlayerEntityMixin",
|
||||
"RecipesProviderAccessor",
|
||||
"RegistryKeyMixin",
|
||||
|
@ -12,7 +14,6 @@
|
|||
"ServerPlayerInteractionManagerMixin",
|
||||
"accessor.BuiltinBiomesAccessor",
|
||||
"accessor.ChunkGeneratorAccessor",
|
||||
"accessor.ChunkGeneratorSettingsAccessor",
|
||||
"accessor.DefaultParticleTypeAccessor",
|
||||
"accessor.DirectionAccessor",
|
||||
"accessor.EntityAccessor",
|
||||
|
|
|
@ -119,7 +119,7 @@ public class RelativeBlockSample implements BlockView, ModifiableWorld {
|
|||
tag.remove("Id");
|
||||
}
|
||||
|
||||
BlockEntity blockEntity = BlockEntity.createFromTag(actualPos, this.getBlockState(pos), tag);
|
||||
BlockEntity blockEntity = BlockEntity.createFromNbt(actualPos, this.getBlockState(pos), tag);
|
||||
if (blockEntity != null) {
|
||||
world.toServerWorld().addBlockEntity(blockEntity);
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ public class RelativeBlockSample implements BlockView, ModifiableWorld {
|
|||
doubles.set(1, NbtOps.INSTANCE.createDouble(vec.y));
|
||||
doubles.set(2, NbtOps.INSTANCE.createDouble(vec.z));
|
||||
tag.put("Pos", doubles);
|
||||
Entity entity = EntityType.getEntityFromTag(tag, world.toServerWorld()).orElseThrow(NoSuchElementException::new);
|
||||
Entity entity = EntityType.getEntityFromNbt(tag, world.toServerWorld()).orElseThrow(NoSuchElementException::new);
|
||||
world.spawnEntity(entity);
|
||||
}
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ public class RelativeBlockSample implements BlockView, ModifiableWorld {
|
|||
tag.remove("Id");
|
||||
}
|
||||
|
||||
BlockEntity blockEntity = BlockEntity.createFromTag(actualPos, this.getBlockState(blockPos), tag);
|
||||
BlockEntity blockEntity = BlockEntity.createFromNbt(actualPos, this.getBlockState(blockPos), tag);
|
||||
if (blockEntity != null && !(blockEntity instanceof RiftBlockEntity)) {
|
||||
chunk.setBlockEntity(blockEntity);
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ public class RelativeBlockSample implements BlockView, ModifiableWorld {
|
|||
doubles.set(2, NbtOps.INSTANCE.createDouble(vec.z));
|
||||
tag.put("Pos", doubles);
|
||||
|
||||
Entity entity = EntityType.getEntityFromTag(tag, world.toServerWorld()).orElseThrow(NoSuchElementException::new);
|
||||
Entity entity = EntityType.getEntityFromNbt(tag, world.toServerWorld()).orElseThrow(NoSuchElementException::new);
|
||||
world.spawnEntity(entity);
|
||||
}
|
||||
}));
|
||||
|
@ -224,7 +224,7 @@ public class RelativeBlockSample implements BlockView, ModifiableWorld {
|
|||
tag.remove("Id");
|
||||
}
|
||||
BlockState state = getBlockState(blockPos);
|
||||
BlockEntity blockEntity = BlockEntity.createFromTag(actualPos, state, tag);
|
||||
BlockEntity blockEntity = BlockEntity.createFromNbt(actualPos, state, tag);
|
||||
if (blockEntity instanceof RiftBlockEntity) {
|
||||
rifts.put(actualPos, (RiftBlockEntity) blockEntity);
|
||||
}
|
||||
|
|
|
@ -101,11 +101,11 @@ public final class SchematicPlacer {
|
|||
ListTag listTag = Objects.requireNonNull(tag.getList("Pos", 6), "Entity in schematic \"" + schematic.getMetadata().getName() + "\" did not have a Pos tag!");
|
||||
SchematicPlacer.processPos(listTag, originX, originY, originZ, tag);
|
||||
|
||||
EntityType<?> entityType = EntityType.fromTag(tag).orElseThrow(AssertionError::new);
|
||||
EntityType<?> entityType = EntityType.fromNbt(tag).orElseThrow(AssertionError::new);
|
||||
Entity e = entityType.create(world.toServerWorld());
|
||||
// TODO: fail with an exception
|
||||
if (e != null) {
|
||||
e.fromTag(tag);
|
||||
e.readNbt(tag);
|
||||
world.spawnEntityAndPassengers(e);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue