From e3c1f9535b29591a152f2ff457fef581665073c3 Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Sat, 10 Jun 2023 15:19:13 -0500 Subject: [PATCH] It builds! --- .../fusionflux/portalcubed/PortalCubed.java | 28 +- .../portalcubed/accessor/LevelExt.java | 7 + .../portalcubed/blocks/NeurotoxinBlock.java | 10 +- .../blocks/PortalBlocksLoader.java | 30 +- .../portalcubed/blocks/PortalCubedBlocks.java | 227 +++++----- .../portalcubed/blocks/PropulsionGel.java | 9 +- .../portalcubed/blocks/RepulsionGel.java | 7 +- ...DualExcursionFunnelEmitterBlockEntity.java | 12 +- .../ExcursionFunnelEmitterBlockEntity.java | 6 +- .../HardLightBridgeEmitterBlockEntity.java | 16 +- .../LaserEmitterBlockEntity.java | 25 +- .../blockentities/LaserNodeBlockEntity.java | 4 +- ...rsedExcursionFunnelEmitterBlockEntity.java | 6 +- .../blocks/fizzler/AbstractFizzlerBlock.java | 7 +- .../portalcubed/client/PortalCubedClient.java | 34 +- .../client/gui/FaithPlateScreen.java | 4 +- .../client/gui/VelocityHelperScreen.java | 28 +- .../client/particle/DecalParticle.java | 12 +- .../portalcubed/client/render/PortalHud.java | 3 +- .../render/block/EmissiveBakedModel.java | 12 +- .../entity/EntityLikeBlockEntityRenderer.java | 4 +- .../block/entity/LaserEmitterRenderer.java | 8 +- .../block/entity/RocketTurretRenderer.java | 10 +- .../block/entity/VelocityHelperRenderer.java | 4 +- .../entity/ExperimentalPortalRenderer.java | 8 +- .../client/render/entity/GelBlobRenderer.java | 16 +- .../client/render/entity/RocketRenderer.java | 8 +- .../compat/create/CreateIntegration.java | 14 +- .../portalcubed/compat/create/PCPonder.java | 410 +++++++++--------- .../compat/rayon/RayonIntegration.java | 2 +- .../rayon/absent/RayonIntegrationAbsent.java | 7 +- .../present/RayonIntegrationPresent.java | 4 +- .../entity/AdventureCoreEntity.java | 2 +- .../portalcubed/entity/AngerCoreEntity.java | 2 +- .../portalcubed/entity/BeansEntity.java | 2 +- .../portalcubed/entity/CakeCoreEntity.java | 2 +- .../portalcubed/entity/ChairEntity.java | 2 +- .../entity/CompanionCubeEntity.java | 2 +- .../portalcubed/entity/ComputerEntity.java | 2 +- .../portalcubed/entity/CoreFrameEntity.java | 2 +- .../portalcubed/entity/CorePhysicsEntity.java | 10 +- .../entity/CuriosityCoreEntity.java | 2 +- .../entity/EnergyPelletEntity.java | 13 +- .../entity/ExperimentalPortal.java | 10 +- .../portalcubed/entity/FactCoreEntity.java | 2 +- .../portalcubed/entity/GelBlobEntity.java | 23 +- .../portalcubed/entity/HoopyEntity.java | 2 +- .../portalcubed/entity/JugEntity.java | 2 +- .../entity/LilPineappleEntity.java | 2 +- .../entity/MoralityCoreEntity.java | 2 +- .../portalcubed/entity/MugEntity.java | 2 +- .../portalcubed/entity/OldApCubeEntity.java | 2 +- .../entity/Portal1CompanionCubeEntity.java | 7 +- .../entity/Portal1StorageCubeEntity.java | 7 +- .../entity/PortalCubedEntities.java | 71 +-- .../PortalCubedTrackedDataHandlers.java | 14 +- .../portalcubed/entity/RadioEntity.java | 2 +- .../entity/RedirectionCubeEntity.java | 2 +- .../portalcubed/entity/RocketEntity.java | 13 +- .../portalcubed/entity/SpaceCoreEntity.java | 2 +- .../portalcubed/entity/StorageCubeEntity.java | 2 +- .../portalcubed/fluids/PortalCubedFluids.java | 12 +- .../portalcubed/fluids/ToxicGooFluid.java | 16 +- .../portalcubed/items/PortalArmor.java | 13 +- .../portalcubed/items/PortalCubedItems.java | 179 ++++---- .../portalcubed/items/PortalGun.java | 4 +- .../portalcubed/items/PortalTabsLoader.java | 19 +- .../mechanics/PortalCubedDamageSources.java | 57 ++- .../mechanics/PortalCubedDamageTypes.java | 15 + .../portalcubed/mixin/EntityMixin.java | 5 +- .../portalcubed/mixin/LevelMixin.java | 38 +- .../portalcubed/mixin/PlayerMixin.java | 23 +- .../mixin/client/ItemInHandRendererMixin.java | 10 +- .../mixin/client/LocalPlayerMixin.java | 26 +- .../mixin/client/SoundEngineMixin.java | 9 +- .../portalcubed/optionslist/ButtonEntry.java | 5 +- .../optionslist/OptionsListScreen.java | 18 +- .../particle/DecalParticleEffect.java | 9 +- .../particle/PortalCubedParticleTypes.java | 5 +- .../portalcubed/sound/PortalCubedSounds.java | 294 ++++++------- .../util/BlockEntityWrapperEntity.java | 7 +- .../util/PortalDirectionUtils.java | 2 +- .../tags/damage_type/bypasses_armor.json | 9 + .../tags/damage_type/damages_helmet.json | 6 + .../minecraft/tags/damage_type/is_fire.json | 6 + .../data/portalcubed/damage_type/acid.json | 6 + .../data/portalcubed/damage_type/cube.json | 5 + .../data/portalcubed/damage_type/fizzle.json | 5 + .../data/portalcubed/damage_type/laser.json | 6 + .../portalcubed/damage_type/vaporization.json | 5 + 90 files changed, 1097 insertions(+), 907 deletions(-) create mode 100644 src/main/java/com/fusionflux/portalcubed/accessor/LevelExt.java create mode 100644 src/main/java/com/fusionflux/portalcubed/mechanics/PortalCubedDamageTypes.java create mode 100644 src/main/resources/data/minecraft/tags/damage_type/bypasses_armor.json create mode 100644 src/main/resources/data/minecraft/tags/damage_type/damages_helmet.json create mode 100644 src/main/resources/data/minecraft/tags/damage_type/is_fire.json create mode 100644 src/main/resources/data/portalcubed/damage_type/acid.json create mode 100644 src/main/resources/data/portalcubed/damage_type/cube.json create mode 100644 src/main/resources/data/portalcubed/damage_type/fizzle.json create mode 100644 src/main/resources/data/portalcubed/damage_type/laser.json create mode 100644 src/main/resources/data/portalcubed/damage_type/vaporization.json diff --git a/src/main/java/com/fusionflux/portalcubed/PortalCubed.java b/src/main/java/com/fusionflux/portalcubed/PortalCubed.java index ec9e4b18..cc913b60 100644 --- a/src/main/java/com/fusionflux/portalcubed/PortalCubed.java +++ b/src/main/java/com/fusionflux/portalcubed/PortalCubed.java @@ -12,7 +12,6 @@ import com.fusionflux.portalcubed.client.PortalCubedClient; import com.fusionflux.portalcubed.client.packet.PortalCubedClientPackets; import com.fusionflux.portalcubed.commands.PortalCubedCommands; -import com.fusionflux.portalcubed.compat.create.CreateIntegration; import com.fusionflux.portalcubed.compat.rayon.RayonIntegration; import com.fusionflux.portalcubed.entity.CorePhysicsEntity; import com.fusionflux.portalcubed.entity.ExperimentalPortal; @@ -36,6 +35,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -47,8 +47,6 @@ import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; import net.minecraft.world.inventory.MenuType; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec3; @@ -59,9 +57,8 @@ import org.quiltmc.qsl.block.content.registry.api.BlockContentRegistries; import org.quiltmc.qsl.block.content.registry.api.FlammableBlockEntry; import org.quiltmc.qsl.command.api.CommandRegistrationCallback; -import org.quiltmc.qsl.entity_events.api.EntityWorldChangeEvents; -import org.quiltmc.qsl.entity_events.api.ServerPlayerEntityCopyCallback; -import org.quiltmc.qsl.item.group.api.QuiltItemGroup; +import org.quiltmc.qsl.entity.event.api.EntityWorldChangeEvents; +import org.quiltmc.qsl.entity.event.api.ServerPlayerEntityCopyCallback; import org.quiltmc.qsl.networking.api.PacketByteBufs; import org.quiltmc.qsl.networking.api.ServerPlayConnectionEvents; import org.quiltmc.qsl.networking.api.ServerPlayNetworking; @@ -76,20 +73,16 @@ public class PortalCubed implements ModInitializer { public static final Logger LOGGER = LogUtils.getLogger(); - public static final CreativeModeTab TESTING_ELEMENTS_GROUP = QuiltItemGroup.createWithIcon( - id("testing_elements"), - () -> new ItemStack(PortalCubedItems.PORTAL_GUN)); - public static final MenuType FAITH_PLATE_SCREEN_HANDLER = Registry.register( - Registry.MENU, id("faith_plate_screen"), + BuiltInRegistries.MENU, id("faith_plate_screen"), new ExtendedScreenHandlerType<>(FaithPlateScreenHandler::new) ); public static final MenuType VELOCITY_HELPER_SCREEN_HANDLER = Registry.register( - Registry.MENU, id("velocity_helper"), + BuiltInRegistries.MENU, id("velocity_helper"), new ExtendedScreenHandlerType<>(VelocityHelperScreenHandler::new) ); public static final MenuType OPTIONS_LIST_SCREEN_HANDLER = Registry.register( - Registry.MENU, id("options_list"), + BuiltInRegistries.MENU, id("options_list"), new ExtendedScreenHandlerType<>(OptionsListScreenHandler::new) ); @@ -134,7 +127,9 @@ public void onInitialize(ModContainer mod) { } Direction portalFacing = portal.getFacingDirection(); Direction otherDirec = Direction.fromNormal((int) portal.getOtherFacing().x(), (int) portal.getOtherFacing().y(), (int) portal.getOtherFacing().z()); - Direction portalVertFacing = Direction.fromNormal(new BlockPos(portal.getAxisH().orElseThrow().x, portal.getAxisH().orElseThrow().y, portal.getAxisH().orElseThrow().z)); + Direction portalVertFacing = Direction.fromNormal(BlockPos.containing( + portal.getAxisH().orElseThrow().x, portal.getAxisH().orElseThrow().y, portal.getAxisH().orElseThrow().z + )); IPQuaternion rotationW = IPQuaternion.getRotationBetween(portal.getAxisW().orElseThrow().scale(-1), portal.getOtherAxisW(), (portal.getAxisH().orElseThrow())); IPQuaternion rotationH = IPQuaternion.getRotationBetween((portal.getAxisH().orElseThrow()), (portal.getOtherAxisH()), portal.getAxisW().orElseThrow().scale(-1)); @@ -297,13 +292,14 @@ public void onInitialize(ModContainer mod) { PortalCubedSounds.registerSounds(); PortalCubedGameRules.register(); PortalCubedParticleTypes.register(); - BlockContentRegistries.FLAMMABLE_BLOCK.put(PortalCubedBlocks.NEUROTOXIN_BLOCK, new FlammableBlockEntry(10000, 10000)); + BlockContentRegistries.FLAMMABLE.put(PortalCubedBlocks.NEUROTOXIN_BLOCK, new FlammableBlockEntry(10000, 10000)); GravityChannel.UPDATE_GRAVITY.getVerifierRegistry().register(AdhesionGravityVerifier.FIELD_GRAVITY_SOURCE, AdhesionGravityVerifier::check); CommandRegistrationCallback.EVENT.register(new PortalCubedCommands()); if (QuiltLoader.isModLoaded("create")) { - CreateIntegration.init(); + LOGGER.warn("Create is out for this game version! Go poke the Portal Cubed developers on Discord to re-enable this integration."); +// CreateIntegration.init(); } RayonIntegration.INSTANCE.init(); diff --git a/src/main/java/com/fusionflux/portalcubed/accessor/LevelExt.java b/src/main/java/com/fusionflux/portalcubed/accessor/LevelExt.java new file mode 100644 index 00000000..e3e38b81 --- /dev/null +++ b/src/main/java/com/fusionflux/portalcubed/accessor/LevelExt.java @@ -0,0 +1,7 @@ +package com.fusionflux.portalcubed.accessor; + +import com.fusionflux.portalcubed.mechanics.PortalCubedDamageSources; + +public interface LevelExt { + PortalCubedDamageSources pcDamageSources(); +} diff --git a/src/main/java/com/fusionflux/portalcubed/blocks/NeurotoxinBlock.java b/src/main/java/com/fusionflux/portalcubed/blocks/NeurotoxinBlock.java index 8b91064a..af03be30 100644 --- a/src/main/java/com/fusionflux/portalcubed/blocks/NeurotoxinBlock.java +++ b/src/main/java/com/fusionflux/portalcubed/blocks/NeurotoxinBlock.java @@ -4,7 +4,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.RandomSource; -import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; @@ -18,6 +17,7 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class NeurotoxinBlock extends BaseEntityBlock { @@ -26,6 +26,7 @@ public NeurotoxinBlock(Properties settings) { super(settings); } + @NotNull @Override @SuppressWarnings("deprecation") public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { @@ -47,6 +48,7 @@ public boolean propagatesSkylightDown(BlockState state, BlockGetter world, Block return true; } + @NotNull @Override public RenderShape getRenderShape(BlockState state) { return RenderShape.MODEL; @@ -54,9 +56,9 @@ public RenderShape getRenderShape(BlockState state) { @Override @SuppressWarnings("deprecation") - public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { - if (!world.isClientSide) { - entity.hurt(DamageSource.DROWN, 1); + public void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + if (!level.isClientSide) { + entity.hurt(level.damageSources().drown(), 1); } } diff --git a/src/main/java/com/fusionflux/portalcubed/blocks/PortalBlocksLoader.java b/src/main/java/com/fusionflux/portalcubed/blocks/PortalBlocksLoader.java index c4e69d06..cc73f046 100644 --- a/src/main/java/com/fusionflux/portalcubed/blocks/PortalBlocksLoader.java +++ b/src/main/java/com/fusionflux/portalcubed/blocks/PortalBlocksLoader.java @@ -1,21 +1,18 @@ package com.fusionflux.portalcubed.blocks; import com.fusionflux.portalcubed.PortalCubed; -import com.fusionflux.portalcubed.items.PortalCubedItems; import com.google.common.collect.ImmutableMap; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import net.fabricmc.api.EnvType; -import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; import net.minecraft.client.renderer.RenderType; import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; import net.minecraft.util.GsonHelper; import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.RotatedPillarBlock; import net.minecraft.world.level.block.SoundType; @@ -52,11 +49,6 @@ public final class PortalBlocksLoader { @ClientOnly private static Map renderLayers; private static final Map BLOCK_DATA = new LinkedHashMap<>(); - ItemGroupEvents - private static final CreativeModeTab ITEM_GROUP = QuiltItemGroup.createWithIcon( - id("portal_blocks"), - () -> new ItemStack(PortalCubedItems.BLOCK_ITEM_ICON) - ); static { if (MinecraftQuiltLoader.getEnvironmentType() == EnvType.CLIENT) { @@ -87,8 +79,8 @@ public static void initCommon() { BLOCK_DATA.forEach((key, value) -> { if (value.block == null) return; final ResourceLocation id = id(key); - Registry.register(Registry.BLOCK, id, value.block); - Registry.register(Registry.ITEM, id, new BlockItem(value.block, new Item.Properties().tab(ITEM_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id, value.block); + Registry.register(BuiltInRegistries.ITEM, id, new BlockItem(value.block, new Item.Properties())); }); } @@ -103,7 +95,7 @@ public static void initClient() { } BlockRenderLayerMap.put( renderLayer, - Registry.BLOCK.getOptional(id) + BuiltInRegistries.BLOCK.getOptional(id) .orElseThrow(() -> new IllegalArgumentException("Unknown block in portal_blocks.json " + id)) ); } @@ -123,7 +115,7 @@ private static BlockData parseBlock(JsonObject json) { } json.remove("type"); final QuiltBlockSettings settings = json.has("inherit") - ? Registry.BLOCK.getOptional(new ResourceLocation(GsonHelper.getAsString(json, "inherit"))) + ? BuiltInRegistries.BLOCK.getOptional(new ResourceLocation(GsonHelper.getAsString(json, "inherit"))) .map(QuiltBlockSettings::copyOf) .orElseThrow(() -> new IllegalArgumentException("Unknown block " + json.get("inherit"))) : QuiltBlockSettings.of(Material.STONE) @@ -149,7 +141,7 @@ private static BlockData parseBlock(JsonObject json) { private static SoundType parseBlockSounds(JsonElement sounds) { if (sounds.isJsonPrimitive()) { - return Registry.BLOCK.getOptional(new ResourceLocation(GsonHelper.convertToString(sounds, "sounds"))) + return BuiltInRegistries.BLOCK.getOptional(new ResourceLocation(GsonHelper.convertToString(sounds, "sounds"))) .map(b -> b.getSoundType(b.defaultBlockState())) .orElseThrow(() -> new IllegalArgumentException("Unknown block " + sounds)); } @@ -157,11 +149,11 @@ private static SoundType parseBlockSounds(JsonElement sounds) { return new SoundType( GsonHelper.getAsFloat(object, "volume", 1f), GsonHelper.getAsFloat(object, "pitch", 1f), - new SoundEvent(new ResourceLocation(GsonHelper.getAsString(object, "break"))), - new SoundEvent(new ResourceLocation(GsonHelper.getAsString(object, "step"))), - new SoundEvent(new ResourceLocation(GsonHelper.getAsString(object, "place"))), - new SoundEvent(new ResourceLocation(GsonHelper.getAsString(object, "hit"))), - new SoundEvent(new ResourceLocation(GsonHelper.getAsString(object, "fall"))) + SoundEvent.createVariableRangeEvent(new ResourceLocation(GsonHelper.getAsString(object, "break"))), + SoundEvent.createVariableRangeEvent(new ResourceLocation(GsonHelper.getAsString(object, "step"))), + SoundEvent.createVariableRangeEvent(new ResourceLocation(GsonHelper.getAsString(object, "place"))), + SoundEvent.createVariableRangeEvent(new ResourceLocation(GsonHelper.getAsString(object, "hit"))), + SoundEvent.createVariableRangeEvent(new ResourceLocation(GsonHelper.getAsString(object, "fall"))) ); } diff --git a/src/main/java/com/fusionflux/portalcubed/blocks/PortalCubedBlocks.java b/src/main/java/com/fusionflux/portalcubed/blocks/PortalCubedBlocks.java index f2c485ce..c0341aa1 100644 --- a/src/main/java/com/fusionflux/portalcubed/blocks/PortalCubedBlocks.java +++ b/src/main/java/com/fusionflux/portalcubed/blocks/PortalCubedBlocks.java @@ -1,11 +1,12 @@ package com.fusionflux.portalcubed.blocks; -import com.fusionflux.portalcubed.PortalCubed; import com.fusionflux.portalcubed.blocks.blockentities.*; import com.fusionflux.portalcubed.blocks.fizzler.*; import com.fusionflux.portalcubed.entity.PortalCubedEntities; import com.fusionflux.portalcubed.items.GelBlobItem; import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.sounds.SoundEvents; import net.minecraft.tags.TagKey; import net.minecraft.world.item.BlockItem; @@ -22,7 +23,7 @@ import static com.fusionflux.portalcubed.PortalCubed.id; public class PortalCubedBlocks { - public static final Item BASE_GEL = new Item(new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP).fireResistant()); + public static final Item BASE_GEL = new Item(new QuiltItemSettings().fireResistant()); public static final PropulsionGel PROPULSION_GEL = new PropulsionGel(QuiltBlockSettings.of(Material.PLANT).randomTicks().destroyTime(0f).noOcclusion().noCollission().sound(new SoundType(1, -1, SoundEvents.HONEY_BLOCK_BREAK, SoundEvents.HONEY_BLOCK_STEP, SoundEvents.HONEY_BLOCK_PLACE, SoundEvents.HONEY_BLOCK_HIT, SoundEvents.HONEY_BLOCK_FALL))); public static final RepulsionGel REPULSION_GEL = new RepulsionGel(QuiltBlockSettings.copyOf(PROPULSION_GEL)); public static final AdhesionGel ADHESION_GEL = new AdhesionGel(QuiltBlockSettings.copyOf(PROPULSION_GEL)); @@ -112,157 +113,157 @@ public class PortalCubedBlocks { public static final RocketTurretBlock ROCKET_TURRET = new RocketTurretBlock(QuiltBlockSettings.of(Material.STONE).strength(3.5f, 3.5f).requiresCorrectToolForDrops().sound(SoundType.STONE)); public static final BlockEntityType ROCKET_TURRET_BLOCK_ENTITY = QuiltBlockEntityTypeBuilder.create(RocketTurretBlockEntity::new, ROCKET_TURRET).build(); - public static final TagKey BULLET_HOLE_CONCRETE = TagKey.create(Registry.BLOCK_REGISTRY, id("bullet_hole_concrete")); - public static final TagKey BULLET_HOLE_GLASS = TagKey.create(Registry.BLOCK_REGISTRY, id("bullet_hole_glass")); - public static final TagKey BULLET_HOLE_METAL = TagKey.create(Registry.BLOCK_REGISTRY, id("bullet_hole_metal")); - public static final TagKey CANT_PLACE_PORTAL_ON = TagKey.create(Registry.BLOCK_REGISTRY, id("cant_place_portal_on")); - public static final TagKey PORTAL_NONSOLID = TagKey.create(Registry.BLOCK_REGISTRY, id("portal_nonsolid")); - public static final TagKey PORTAL_SOLID = TagKey.create(Registry.BLOCK_REGISTRY, id("portal_solid")); - public static final TagKey PORTALABLE_GELS = TagKey.create(Registry.BLOCK_REGISTRY, id("portalable_gels")); + public static final TagKey BULLET_HOLE_CONCRETE = TagKey.create(Registries.BLOCK, id("bullet_hole_concrete")); + public static final TagKey BULLET_HOLE_GLASS = TagKey.create(Registries.BLOCK, id("bullet_hole_glass")); + public static final TagKey BULLET_HOLE_METAL = TagKey.create(Registries.BLOCK, id("bullet_hole_metal")); + public static final TagKey CANT_PLACE_PORTAL_ON = TagKey.create(Registries.BLOCK, id("cant_place_portal_on")); + public static final TagKey PORTAL_NONSOLID = TagKey.create(Registries.BLOCK, id("portal_nonsolid")); + public static final TagKey PORTAL_SOLID = TagKey.create(Registries.BLOCK, id("portal_solid")); + public static final TagKey PORTALABLE_GELS = TagKey.create(Registries.BLOCK, id("portalable_gels")); public static void registerBlocks() { - Registry.register(Registry.ITEM, id("base_gel"), BASE_GEL); + Registry.register(BuiltInRegistries.ITEM, id("base_gel"), BASE_GEL); - Registry.register(Registry.BLOCK, id("propulsion_gel"), PROPULSION_GEL); - Registry.register(Registry.ITEM, id("propulsion_gel"), new GelBlobItem(PROPULSION_GEL, PortalCubedEntities.PROPULSION_GEL_BLOB, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("propulsion_gel"), PROPULSION_GEL); + Registry.register(BuiltInRegistries.ITEM, id("propulsion_gel"), new GelBlobItem(PROPULSION_GEL, PortalCubedEntities.PROPULSION_GEL_BLOB, new Item.Properties())); - Registry.register(Registry.BLOCK, id("repulsion_gel"), REPULSION_GEL); - Registry.register(Registry.ITEM, id("repulsion_gel"), new GelBlobItem(REPULSION_GEL, PortalCubedEntities.REPULSION_GEL_BLOB, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("repulsion_gel"), REPULSION_GEL); + Registry.register(BuiltInRegistries.ITEM, id("repulsion_gel"), new GelBlobItem(REPULSION_GEL, PortalCubedEntities.REPULSION_GEL_BLOB, new Item.Properties())); - Registry.register(Registry.BLOCK, id("adhesion_gel"), ADHESION_GEL); - Registry.register(Registry.ITEM, id("adhesion_gel"), new GelBlobItem(ADHESION_GEL, PortalCubedEntities.ADHESION_GEL_BLOB, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("adhesion_gel"), ADHESION_GEL); + Registry.register(BuiltInRegistries.ITEM, id("adhesion_gel"), new GelBlobItem(ADHESION_GEL, PortalCubedEntities.ADHESION_GEL_BLOB, new Item.Properties())); - Registry.register(Registry.BLOCK, id("conversion_gel"), CONVERSION_GEL); - Registry.register(Registry.ITEM, id("conversion_gel"), new GelBlobItem(CONVERSION_GEL, PortalCubedEntities.CONVERSION_GEL_BLOB, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("conversion_gel"), CONVERSION_GEL); + Registry.register(BuiltInRegistries.ITEM, id("conversion_gel"), new GelBlobItem(CONVERSION_GEL, PortalCubedEntities.CONVERSION_GEL_BLOB, new Item.Properties())); - Registry.register(Registry.BLOCK, id("reflection_gel"), REFLECTION_GEL); - Registry.register(Registry.ITEM, id("reflection_gel"), new GelBlobItem(REFLECTION_GEL, PortalCubedEntities.REFLECTION_GEL_BLOB, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("reflection_gel"), REFLECTION_GEL); + Registry.register(BuiltInRegistries.ITEM, id("reflection_gel"), new GelBlobItem(REFLECTION_GEL, PortalCubedEntities.REFLECTION_GEL_BLOB, new Item.Properties())); - Registry.register(Registry.BLOCK, id("portal_2_door"), PORTAL2DOOR); - Registry.register(Registry.ITEM, id("portal_2_door"), new BlockItem(PORTAL2DOOR, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("portal_2_door"), PORTAL2DOOR); + Registry.register(BuiltInRegistries.ITEM, id("portal_2_door"), new BlockItem(PORTAL2DOOR, new Item.Properties())); - Registry.register(Registry.BLOCK, id("octopus_door"), OCTOPUS_DOOR); - Registry.register(Registry.ITEM, id("octopus_door"), new BlockItem(OCTOPUS_DOOR, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("octopus_door"), OCTOPUS_DOOR); + Registry.register(BuiltInRegistries.ITEM, id("octopus_door"), new BlockItem(OCTOPUS_DOOR, new Item.Properties())); - Registry.register(Registry.BLOCK, id("old_ap_door"), OLD_AP_DOOR); - Registry.register(Registry.ITEM, id("old_ap_door"), new BlockItem(OLD_AP_DOOR, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("old_ap_door"), OLD_AP_DOOR); + Registry.register(BuiltInRegistries.ITEM, id("old_ap_door"), new BlockItem(OLD_AP_DOOR, new Item.Properties())); - Registry.register(Registry.BLOCK, id("portal_1_door"), PORTAL1DOOR); - Registry.register(Registry.ITEM, id("portal_1_door"), new BlockItem(PORTAL1DOOR, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("portal_1_door"), PORTAL1DOOR); + Registry.register(BuiltInRegistries.ITEM, id("portal_1_door"), new BlockItem(PORTAL1DOOR, new Item.Properties())); - Registry.register(Registry.BLOCK_ENTITY_TYPE, id("light_bridge_emitter_entity"), HLB_EMITTER_ENTITY); - Registry.register(Registry.BLOCK, id("light_bridge_emitter"), HLB_EMITTER_BLOCK); - Registry.register(Registry.ITEM, id("light_bridge_emitter"), new BlockItem(HLB_EMITTER_BLOCK, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); - Registry.register(Registry.BLOCK_ENTITY_TYPE, id("light_bridge_entity"), HLB_BLOCK_ENTITY); - Registry.register(Registry.BLOCK, id("light_bridge"), HLB_BLOCK); - Registry.register(Registry.BLOCK_ENTITY_TYPE, id("neurotoxin_entity"), NEUROTOXIN_BLOCK_ENTITY); - Registry.register(Registry.BLOCK, id("neurotoxin"), NEUROTOXIN_BLOCK); - Registry.register(Registry.BLOCK_ENTITY_TYPE, id("neurotoxin_emitter_entity"), NEUROTOXIN_EMITTER_ENTITY); - Registry.register(Registry.BLOCK, id("neurotoxin_emitter"), NEUROTOXIN_EMITTER); - Registry.register(Registry.ITEM, id("neurotoxin_emitter"), new BlockItem(NEUROTOXIN_EMITTER, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id("light_bridge_emitter_entity"), HLB_EMITTER_ENTITY); + Registry.register(BuiltInRegistries.BLOCK, id("light_bridge_emitter"), HLB_EMITTER_BLOCK); + Registry.register(BuiltInRegistries.ITEM, id("light_bridge_emitter"), new BlockItem(HLB_EMITTER_BLOCK, new Item.Properties())); + Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id("light_bridge_entity"), HLB_BLOCK_ENTITY); + Registry.register(BuiltInRegistries.BLOCK, id("light_bridge"), HLB_BLOCK); + Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id("neurotoxin_entity"), NEUROTOXIN_BLOCK_ENTITY); + Registry.register(BuiltInRegistries.BLOCK, id("neurotoxin"), NEUROTOXIN_BLOCK); + Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id("neurotoxin_emitter_entity"), NEUROTOXIN_EMITTER_ENTITY); + Registry.register(BuiltInRegistries.BLOCK, id("neurotoxin_emitter"), NEUROTOXIN_EMITTER); + Registry.register(BuiltInRegistries.ITEM, id("neurotoxin_emitter"), new BlockItem(NEUROTOXIN_EMITTER, new Item.Properties())); - Registry.register(Registry.BLOCK_ENTITY_TYPE, id("auto_portal_entity"), AUTO_PORTAL_BLOCK_ENTITY); - Registry.register(Registry.BLOCK, id("auto_portal"), AUTO_PORTAL_BLOCK); - Registry.register(Registry.ITEM, id("auto_portal"), new BlockItem(AUTO_PORTAL_BLOCK, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id("auto_portal_entity"), AUTO_PORTAL_BLOCK_ENTITY); + Registry.register(BuiltInRegistries.BLOCK, id("auto_portal"), AUTO_PORTAL_BLOCK); + Registry.register(BuiltInRegistries.ITEM, id("auto_portal"), new BlockItem(AUTO_PORTAL_BLOCK, new Item.Properties())); - Registry.register(Registry.BLOCK_ENTITY_TYPE, id("excursion_funnel_emitter_entity"), EXCURSION_FUNNEL_EMITTER_ENTITY); - Registry.register(Registry.BLOCK, id("excursion_funnel_emitter"), EXCURSION_FUNNEL_EMITTER); - Registry.register(Registry.ITEM, id("excursion_funnel_emitter"), new BlockItem(EXCURSION_FUNNEL_EMITTER, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); - Registry.register(Registry.BLOCK_ENTITY_TYPE, id("excursion_funnel_entity"), EXCURSION_FUNNEL_ENTITY); - Registry.register(Registry.BLOCK, id("excursion_funnel"), EXCURSION_FUNNEL); + Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id("excursion_funnel_emitter_entity"), EXCURSION_FUNNEL_EMITTER_ENTITY); + Registry.register(BuiltInRegistries.BLOCK, id("excursion_funnel_emitter"), EXCURSION_FUNNEL_EMITTER); + Registry.register(BuiltInRegistries.ITEM, id("excursion_funnel_emitter"), new BlockItem(EXCURSION_FUNNEL_EMITTER, new Item.Properties())); + Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id("excursion_funnel_entity"), EXCURSION_FUNNEL_ENTITY); + Registry.register(BuiltInRegistries.BLOCK, id("excursion_funnel"), EXCURSION_FUNNEL); - Registry.register(Registry.BLOCK_ENTITY_TYPE, id("reversed_excursion_funnel_emitter_entity"), REVERSED_EXCURSION_FUNNEL_EMITTER_ENTITY); - Registry.register(Registry.BLOCK, id("reversed_excursion_funnel_emitter"), REVERSED_EXCURSION_FUNNEL_EMITTER); - Registry.register(Registry.ITEM, id("reversed_excursion_funnel_emitter"), new BlockItem(REVERSED_EXCURSION_FUNNEL_EMITTER, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id("reversed_excursion_funnel_emitter_entity"), REVERSED_EXCURSION_FUNNEL_EMITTER_ENTITY); + Registry.register(BuiltInRegistries.BLOCK, id("reversed_excursion_funnel_emitter"), REVERSED_EXCURSION_FUNNEL_EMITTER); + Registry.register(BuiltInRegistries.ITEM, id("reversed_excursion_funnel_emitter"), new BlockItem(REVERSED_EXCURSION_FUNNEL_EMITTER, new Item.Properties())); - Registry.register(Registry.BLOCK_ENTITY_TYPE, id("duel_excursion_funnel_emitter_entity"), DUAL_EXCURSION_FUNNEL_EMITTER_ENTITY); - Registry.register(Registry.BLOCK, id("duel_excursion_funnel_emitter"), DUEL_EXCURSION_FUNNEL_EMITTER); - Registry.register(Registry.ITEM, id("duel_excursion_funnel_emitter"), new BlockItem(DUEL_EXCURSION_FUNNEL_EMITTER, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id("duel_excursion_funnel_emitter_entity"), DUAL_EXCURSION_FUNNEL_EMITTER_ENTITY); + Registry.register(BuiltInRegistries.BLOCK, id("duel_excursion_funnel_emitter"), DUEL_EXCURSION_FUNNEL_EMITTER); + Registry.register(BuiltInRegistries.ITEM, id("duel_excursion_funnel_emitter"), new BlockItem(DUEL_EXCURSION_FUNNEL_EMITTER, new Item.Properties())); - Registry.register(Registry.BLOCK_ENTITY_TYPE, id("faith_plate"), FAITH_PLATE_BLOCK_ENTITY); - Registry.register(Registry.BLOCK_ENTITY_TYPE, id("beta_faith_plate"), BETA_FAITH_PLATE_BLOCK_ENTITY); + Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id("faith_plate"), FAITH_PLATE_BLOCK_ENTITY); + Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id("beta_faith_plate"), BETA_FAITH_PLATE_BLOCK_ENTITY); - Registry.register(Registry.BLOCK, id("faith_plate"), FAITH_PLATE); - Registry.register(Registry.ITEM, id("faith_plate"), new BlockItem(FAITH_PLATE, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("faith_plate"), FAITH_PLATE); + Registry.register(BuiltInRegistries.ITEM, id("faith_plate"), new BlockItem(FAITH_PLATE, new Item.Properties())); - Registry.register(Registry.BLOCK, id("beta_faith_plate"), BETA_FAITH_PLATE); - Registry.register(Registry.ITEM, id("beta_faith_plate"), new BlockItem(BETA_FAITH_PLATE, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("beta_faith_plate"), BETA_FAITH_PLATE); + Registry.register(BuiltInRegistries.ITEM, id("beta_faith_plate"), new BlockItem(BETA_FAITH_PLATE, new Item.Properties())); - Registry.register(Registry.BLOCK, id("faith_plate_target"), FAITH_PLATE_TARGET); - Registry.register(Registry.ITEM, id("faith_plate_target"), new BlockItem(FAITH_PLATE_TARGET, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("faith_plate_target"), FAITH_PLATE_TARGET); + Registry.register(BuiltInRegistries.ITEM, id("faith_plate_target"), new BlockItem(FAITH_PLATE_TARGET, new Item.Properties())); - Registry.register(Registry.BLOCK_ENTITY_TYPE, id("laser_emitter_entity"), LASER_EMITTER_BLOCK_ENTITY); - Registry.register(Registry.BLOCK, id("laser_emitter"), LASER_EMITTER); - Registry.register(Registry.ITEM, id("laser_emitter"), new BlockItem(LASER_EMITTER, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id("laser_emitter_entity"), LASER_EMITTER_BLOCK_ENTITY); + Registry.register(BuiltInRegistries.BLOCK, id("laser_emitter"), LASER_EMITTER); + Registry.register(BuiltInRegistries.ITEM, id("laser_emitter"), new BlockItem(LASER_EMITTER, new Item.Properties())); - Registry.register(Registry.BLOCK, id("laser_catcher"), LASER_CATCHER); - Registry.register(Registry.ITEM, id("laser_catcher"), new BlockItem(LASER_CATCHER, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("laser_catcher"), LASER_CATCHER); + Registry.register(BuiltInRegistries.ITEM, id("laser_catcher"), new BlockItem(LASER_CATCHER, new Item.Properties())); - Registry.register(Registry.BLOCK, id("laser_relay"), LASER_RELAY); - Registry.register(Registry.ITEM, id("laser_relay"), new BlockItem(LASER_RELAY, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("laser_relay"), LASER_RELAY); + Registry.register(BuiltInRegistries.ITEM, id("laser_relay"), new BlockItem(LASER_RELAY, new Item.Properties())); - Registry.register(Registry.BLOCK_ENTITY_TYPE, id("laser_node"), LASER_NODE_BLOCK_ENTITY); + Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id("laser_node"), LASER_NODE_BLOCK_ENTITY); - Registry.register(Registry.BLOCK_ENTITY_TYPE, id("floor_button_block_entity"), FLOOR_BUTTON_BLOCK_ENTITY); - Registry.register(Registry.BLOCK, id("floor_button"), FLOOR_BUTTON); - Registry.register(Registry.ITEM, id("floor_button"), new BlockItem(FLOOR_BUTTON, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id("floor_button_block_entity"), FLOOR_BUTTON_BLOCK_ENTITY); + Registry.register(BuiltInRegistries.BLOCK, id("floor_button"), FLOOR_BUTTON); + Registry.register(BuiltInRegistries.ITEM, id("floor_button"), new BlockItem(FLOOR_BUTTON, new Item.Properties())); - Registry.register(Registry.BLOCK_ENTITY_TYPE, id("old_ap_floor_button_block_entity"), OLD_AP_FLOOR_BUTTON_BLOCK_ENTITY); - Registry.register(Registry.BLOCK, id("old_ap_floor_button"), OLD_AP_FLOOR_BUTTON); - Registry.register(Registry.ITEM, id("old_ap_floor_button"), new BlockItem(OLD_AP_FLOOR_BUTTON, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id("old_ap_floor_button_block_entity"), OLD_AP_FLOOR_BUTTON_BLOCK_ENTITY); + Registry.register(BuiltInRegistries.BLOCK, id("old_ap_floor_button"), OLD_AP_FLOOR_BUTTON); + Registry.register(BuiltInRegistries.ITEM, id("old_ap_floor_button"), new BlockItem(OLD_AP_FLOOR_BUTTON, new Item.Properties())); - Registry.register(Registry.BLOCK_ENTITY_TYPE, id("rocket_turret"), ROCKET_TURRET_BLOCK_ENTITY); - Registry.register(Registry.BLOCK, id("rocket_turret"), ROCKET_TURRET); - Registry.register(Registry.ITEM, id("rocket_turret"), new BlockItem(ROCKET_TURRET, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id("rocket_turret"), ROCKET_TURRET_BLOCK_ENTITY); + Registry.register(BuiltInRegistries.BLOCK, id("rocket_turret"), ROCKET_TURRET); + Registry.register(BuiltInRegistries.ITEM, id("rocket_turret"), new BlockItem(ROCKET_TURRET, new Item.Properties())); - Registry.register(Registry.BLOCK, id("power_block"), POWER_BLOCK); - Registry.register(Registry.ITEM, id("power_block"), new BlockItem(POWER_BLOCK, new Item.Properties().rarity(Rarity.EPIC).tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("power_block"), POWER_BLOCK); + Registry.register(BuiltInRegistries.ITEM, id("power_block"), new BlockItem(POWER_BLOCK, new Item.Properties().rarity(Rarity.EPIC))); - Registry.register(Registry.BLOCK, id("velocity_helper"), VELOCITY_HELPER); - Registry.register(Registry.ITEM, id("velocity_helper"), new BlockItem(VELOCITY_HELPER, new Item.Properties().rarity(Rarity.EPIC).tab(PortalCubed.TESTING_ELEMENTS_GROUP))); - Registry.register(Registry.BLOCK_ENTITY_TYPE, id("velocity_helper"), VELOCITY_HELPER_BLOCK_ENTITY); + Registry.register(BuiltInRegistries.BLOCK, id("velocity_helper"), VELOCITY_HELPER); + Registry.register(BuiltInRegistries.ITEM, id("velocity_helper"), new BlockItem(VELOCITY_HELPER, new Item.Properties().rarity(Rarity.EPIC))); + Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id("velocity_helper"), VELOCITY_HELPER_BLOCK_ENTITY); - Registry.register(Registry.BLOCK, id("catapult"), CATAPULT); - Registry.register(Registry.ITEM, id("catapult"), new BlockItem(CATAPULT, new Item.Properties().rarity(Rarity.EPIC).tab(PortalCubed.TESTING_ELEMENTS_GROUP))); - Registry.register(Registry.BLOCK_ENTITY_TYPE, id("catapult"), CATAPULT_BLOCK_ENTITY); + Registry.register(BuiltInRegistries.BLOCK, id("catapult"), CATAPULT); + Registry.register(BuiltInRegistries.ITEM, id("catapult"), new BlockItem(CATAPULT, new Item.Properties().rarity(Rarity.EPIC))); + Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, id("catapult"), CATAPULT_BLOCK_ENTITY); - Registry.register(Registry.BLOCK, id("fizzler"), FIZZLER); - Registry.register(Registry.BLOCK, id("fizzler_emitter"), FIZZLER_EMITTER); - Registry.register(Registry.ITEM, id("fizzler_emitter"), new BlockItem(FIZZLER_EMITTER, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("fizzler"), FIZZLER); + Registry.register(BuiltInRegistries.BLOCK, id("fizzler_emitter"), FIZZLER_EMITTER); + Registry.register(BuiltInRegistries.ITEM, id("fizzler_emitter"), new BlockItem(FIZZLER_EMITTER, new Item.Properties())); - Registry.register(Registry.BLOCK, id("portal_1_fizzler"), PORTAL_1_FIZZLER); - Registry.register(Registry.BLOCK, id("portal_1_fizzler_emitter"), PORTAL_1_FIZZLER_EMITTER); - Registry.register(Registry.ITEM, id("portal_1_fizzler_emitter"), new BlockItem(PORTAL_1_FIZZLER_EMITTER, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("portal_1_fizzler"), PORTAL_1_FIZZLER); + Registry.register(BuiltInRegistries.BLOCK, id("portal_1_fizzler_emitter"), PORTAL_1_FIZZLER_EMITTER); + Registry.register(BuiltInRegistries.ITEM, id("portal_1_fizzler_emitter"), new BlockItem(PORTAL_1_FIZZLER_EMITTER, new Item.Properties())); - Registry.register(Registry.BLOCK, id("old_aperture_fizzler"), OLD_APERTURE_FIZZLER); - Registry.register(Registry.BLOCK, id("old_aperture_fizzler_emitter"), OLD_APERTURE_FIZZLER_EMITTER); - Registry.register(Registry.ITEM, id("old_aperture_fizzler_emitter"), new BlockItem(OLD_APERTURE_FIZZLER_EMITTER, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("old_aperture_fizzler"), OLD_APERTURE_FIZZLER); + Registry.register(BuiltInRegistries.BLOCK, id("old_aperture_fizzler_emitter"), OLD_APERTURE_FIZZLER_EMITTER); + Registry.register(BuiltInRegistries.ITEM, id("old_aperture_fizzler_emitter"), new BlockItem(OLD_APERTURE_FIZZLER_EMITTER, new Item.Properties())); - Registry.register(Registry.BLOCK, id("laser_fizzler"), LASER_FIZZLER); - Registry.register(Registry.BLOCK, id("laser_fizzler_emitter"), LASER_FIZZLER_EMITTER); - Registry.register(Registry.ITEM, id("laser_fizzler_emitter"), new BlockItem(LASER_FIZZLER_EMITTER, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("laser_fizzler"), LASER_FIZZLER); + Registry.register(BuiltInRegistries.BLOCK, id("laser_fizzler_emitter"), LASER_FIZZLER_EMITTER); + Registry.register(BuiltInRegistries.ITEM, id("laser_fizzler_emitter"), new BlockItem(LASER_FIZZLER_EMITTER, new Item.Properties())); - Registry.register(Registry.BLOCK, id("death_fizzler"), DEATH_FIZZLER); - Registry.register(Registry.BLOCK, id("death_fizzler_emitter"), DEATH_FIZZLER_EMITTER); - Registry.register(Registry.ITEM, id("death_fizzler_emitter"), new BlockItem(DEATH_FIZZLER_EMITTER, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("death_fizzler"), DEATH_FIZZLER); + Registry.register(BuiltInRegistries.BLOCK, id("death_fizzler_emitter"), DEATH_FIZZLER_EMITTER); + Registry.register(BuiltInRegistries.ITEM, id("death_fizzler_emitter"), new BlockItem(DEATH_FIZZLER_EMITTER, new Item.Properties())); - Registry.register(Registry.BLOCK, id("old_aperture_death_fizzler"), OLD_APERTURE_DEATH_FIZZLER); - Registry.register(Registry.BLOCK, id("old_aperture_death_fizzler_emitter"), OLD_APERTURE_DEATH_FIZZLER_EMITTER); - Registry.register(Registry.ITEM, id("old_aperture_death_fizzler_emitter"), new BlockItem(OLD_APERTURE_DEATH_FIZZLER_EMITTER, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("old_aperture_death_fizzler"), OLD_APERTURE_DEATH_FIZZLER); + Registry.register(BuiltInRegistries.BLOCK, id("old_aperture_death_fizzler_emitter"), OLD_APERTURE_DEATH_FIZZLER_EMITTER); + Registry.register(BuiltInRegistries.ITEM, id("old_aperture_death_fizzler_emitter"), new BlockItem(OLD_APERTURE_DEATH_FIZZLER_EMITTER, new Item.Properties())); - Registry.register(Registry.BLOCK, id("matter_inquisition_field"), MATTER_INQUISITION_FIELD); - Registry.register(Registry.BLOCK, id("matter_inquisition_field_emitter"), MATTER_INQUISITION_FIELD_EMITTER); - Registry.register(Registry.ITEM, id("matter_inquisition_field_emitter"), new BlockItem(MATTER_INQUISITION_FIELD_EMITTER, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("matter_inquisition_field"), MATTER_INQUISITION_FIELD); + Registry.register(BuiltInRegistries.BLOCK, id("matter_inquisition_field_emitter"), MATTER_INQUISITION_FIELD_EMITTER); + Registry.register(BuiltInRegistries.ITEM, id("matter_inquisition_field_emitter"), new BlockItem(MATTER_INQUISITION_FIELD_EMITTER, new Item.Properties())); - Registry.register(Registry.BLOCK, id("physics_repulsion_field"), PHYSICS_REPULSION_FIELD); - Registry.register(Registry.BLOCK, id("physics_repulsion_field_emitter"), PHYSICS_REPULSION_FIELD_EMITTER); - Registry.register(Registry.ITEM, id("physics_repulsion_field_emitter"), new BlockItem(PHYSICS_REPULSION_FIELD_EMITTER, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("physics_repulsion_field"), PHYSICS_REPULSION_FIELD); + Registry.register(BuiltInRegistries.BLOCK, id("physics_repulsion_field_emitter"), PHYSICS_REPULSION_FIELD_EMITTER); + Registry.register(BuiltInRegistries.ITEM, id("physics_repulsion_field_emitter"), new BlockItem(PHYSICS_REPULSION_FIELD_EMITTER, new Item.Properties())); - Registry.register(Registry.BLOCK, id("pedestal_button"), TALL_BUTTON); - Registry.register(Registry.ITEM, id("pedestal_button"), new BlockItem(TALL_BUTTON, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("pedestal_button"), TALL_BUTTON); + Registry.register(BuiltInRegistries.ITEM, id("pedestal_button"), new BlockItem(TALL_BUTTON, new Item.Properties())); - Registry.register(Registry.BLOCK, id("old_ap_pedestal_button"), OLD_AP_PEDESTAL_BUTTON); - Registry.register(Registry.ITEM, id("old_ap_pedestal_button"), new BlockItem(OLD_AP_PEDESTAL_BUTTON, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP))); + Registry.register(BuiltInRegistries.BLOCK, id("old_ap_pedestal_button"), OLD_AP_PEDESTAL_BUTTON); + Registry.register(BuiltInRegistries.ITEM, id("old_ap_pedestal_button"), new BlockItem(OLD_AP_PEDESTAL_BUTTON, new Item.Properties())); PortalBlocksLoader.initCommon(); } diff --git a/src/main/java/com/fusionflux/portalcubed/blocks/PropulsionGel.java b/src/main/java/com/fusionflux/portalcubed/blocks/PropulsionGel.java index 38f82d04..b6ae2a33 100644 --- a/src/main/java/com/fusionflux/portalcubed/blocks/PropulsionGel.java +++ b/src/main/java/com/fusionflux/portalcubed/blocks/PropulsionGel.java @@ -5,7 +5,6 @@ import com.fusionflux.portalcubed.sound.PortalCubedSounds; import net.minecraft.core.BlockPos; import net.minecraft.sounds.SoundSource; -import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.Level; @@ -24,20 +23,20 @@ public void entityInside(BlockState state, Level world, BlockPos pos, Entity ent this.addCollisionEffects(world, entity); } - private void addCollisionEffects(Level world, Entity entity) { + private void addCollisionEffects(Level level, Entity entity) { if (entity.getType().equals(EntityType.BOAT)) { - entity.hurt(DamageSource.MAGIC, 200); + entity.hurt(level.damageSources().magic(), 200); } else { if (entity.isOnGround()) { if (!entity.isShiftKeyDown()) { - if (limiter.check(world, entity)) { + if (limiter.check(level, entity)) { if (Math.abs(entity.getDeltaMovement().x) < 2 && Math.abs(entity.getDeltaMovement().z) < 2) { entity.setDeltaMovement(entity.getDeltaMovement().multiply(1.7, 1.0D, 1.7)); } else if (Math.abs(entity.getDeltaMovement().x) > 2 && Math.abs(entity.getDeltaMovement().z) > 2) { entity.setDeltaMovement(entity.getDeltaMovement().multiply(1.01, 1.0D, 1.01)); } if (((EntityAttachments) entity).getMaxFallSpeed() == 0) { - world.playSound(null, entity.position().x(), entity.position().y(), entity.position().z(), PortalCubedSounds.GEL_RUN_EVENT, SoundSource.NEUTRAL, .3F, 1F); + level.playSound(null, entity.position().x(), entity.position().y(), entity.position().z(), PortalCubedSounds.GEL_RUN_EVENT, SoundSource.NEUTRAL, .3F, 1F); } ((EntityAttachments) entity).setMaxFallSpeed(10); } diff --git a/src/main/java/com/fusionflux/portalcubed/blocks/RepulsionGel.java b/src/main/java/com/fusionflux/portalcubed/blocks/RepulsionGel.java index b079ff8d..d8688be3 100644 --- a/src/main/java/com/fusionflux/portalcubed/blocks/RepulsionGel.java +++ b/src/main/java/com/fusionflux/portalcubed/blocks/RepulsionGel.java @@ -6,7 +6,6 @@ import com.fusionflux.portalcubed.accessor.LivingEntityAccessor; import com.fusionflux.portalcubed.entity.EntityAttachments; import net.minecraft.core.BlockPos; -import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; @@ -199,11 +198,11 @@ private void addCollisionEffects(Level world, Entity entity, BlockPos pos) { } @Override - public void fallOn(Level world, BlockState state, BlockPos pos, Entity entity, float fallDistance) { + public void fallOn(Level level, BlockState state, BlockPos pos, Entity entity, float fallDistance) { if (entity.isSuppressingBounce()) { - super.fallOn(world, state, pos, entity, fallDistance); + super.fallOn(level, state, pos, entity, fallDistance); } else { - entity.causeFallDamage(fallDistance, 0.0F, DamageSource.FALL); + entity.causeFallDamage(fallDistance, 0.0F, level.damageSources().fall()); } } } diff --git a/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/DualExcursionFunnelEmitterBlockEntity.java b/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/DualExcursionFunnelEmitterBlockEntity.java index 023da9ba..f16e5319 100644 --- a/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/DualExcursionFunnelEmitterBlockEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/DualExcursionFunnelEmitterBlockEntity.java @@ -77,9 +77,9 @@ public static void tick2(Level world, BlockPos pos, @SuppressWarnings("unused") for (ExperimentalPortal portal : list) { if (portal.getFacingDirection().getOpposite().equals(storedDirection)) { if (portal.getActive()) { - Direction otherPortalVertFacing = Direction.fromNormal(new BlockPos(portal.getOtherAxisH().x, portal.getOtherAxisH().y, portal.getOtherAxisH().z)); + Direction otherPortalVertFacing = Direction.fromNormal(BlockPos.containing(portal.getOtherAxisH().x, portal.getOtherAxisH().y, portal.getOtherAxisH().z)); int offset = (int)(((portal.blockPosition().getX() - translatedPos.getX()) * Math.abs(portal.getAxisH().get().x)) + ((portal.blockPosition().getY() - translatedPos.getY()) * Math.abs(portal.getAxisH().get().y)) + ((portal.blockPosition().getZ() - translatedPos.getZ()) * Math.abs(portal.getAxisH().get().z))); - Direction mainPortalVertFacing = Direction.fromNormal(new BlockPos(portal.getAxisH().get().x, portal.getAxisH().get().y, portal.getAxisH().get().z)); + Direction mainPortalVertFacing = Direction.fromNormal(BlockPos.containing(portal.getAxisH().get().x, portal.getAxisH().get().y, portal.getAxisH().get().z)); assert mainPortalVertFacing != null; if (mainPortalVertFacing.equals(Direction.SOUTH)) { offset = (Math.abs(offset) - 1) * -1; @@ -88,7 +88,7 @@ public static void tick2(Level world, BlockPos pos, @SuppressWarnings("unused") offset = (Math.abs(offset) - 1) * -1; } - translatedPos = new BlockPos(portal.getDestination().get().x, portal.getDestination().get().y, portal.getDestination().get().z).relative(otherPortalVertFacing, offset); + translatedPos = BlockPos.containing(portal.getDestination().get().x, portal.getDestination().get().y, portal.getDestination().get().z).relative(otherPortalVertFacing, offset); savedPos = translatedPos; assert otherPortalVertFacing != null; if (otherPortalVertFacing.equals(Direction.SOUTH)) { @@ -164,9 +164,9 @@ public static void tick2(Level world, BlockPos pos, @SuppressWarnings("unused") for (ExperimentalPortal portal : list) { if (portal.getFacingDirection().getOpposite().equals(storedDirection)) { if (portal.getActive()) { - Direction otherPortalVertFacing = Direction.fromNormal(new BlockPos(portal.getOtherAxisH().x, portal.getOtherAxisH().y, portal.getOtherAxisH().z)); + Direction otherPortalVertFacing = Direction.fromNormal(BlockPos.containing(portal.getOtherAxisH().x, portal.getOtherAxisH().y, portal.getOtherAxisH().z)); int offset = (int)(((portal.blockPosition().getX() - translatedPos.getX()) * Math.abs(portal.getAxisH().get().x)) + ((portal.blockPosition().getY() - translatedPos.getY()) * Math.abs(portal.getAxisH().get().y)) + ((portal.blockPosition().getZ() - translatedPos.getZ()) * Math.abs(portal.getAxisH().get().z))); - Direction mainPortalVertFacing = Direction.fromNormal(new BlockPos(portal.getAxisH().get().x, portal.getAxisH().get().y, portal.getAxisH().get().z)); + Direction mainPortalVertFacing = Direction.fromNormal(BlockPos.containing(portal.getAxisH().get().x, portal.getAxisH().get().y, portal.getAxisH().get().z)); assert mainPortalVertFacing != null; if (mainPortalVertFacing.equals(Direction.SOUTH)) { offset = (Math.abs(offset) - 1) * -1; @@ -175,7 +175,7 @@ public static void tick2(Level world, BlockPos pos, @SuppressWarnings("unused") offset = (Math.abs(offset) - 1) * -1; } - translatedPos = new BlockPos(portal.getDestination().get().x, portal.getDestination().get().y, portal.getDestination().get().z).relative(otherPortalVertFacing, offset); + translatedPos = BlockPos.containing(portal.getDestination().get().x, portal.getDestination().get().y, portal.getDestination().get().z).relative(otherPortalVertFacing, offset); savedPos = translatedPos; assert otherPortalVertFacing != null; if (otherPortalVertFacing.equals(Direction.SOUTH)) { diff --git a/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/ExcursionFunnelEmitterBlockEntity.java b/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/ExcursionFunnelEmitterBlockEntity.java index 998e01ff..a4c90fdb 100644 --- a/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/ExcursionFunnelEmitterBlockEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/ExcursionFunnelEmitterBlockEntity.java @@ -79,9 +79,9 @@ public static void tick1(Level world, BlockPos pos, @SuppressWarnings("unused") for (ExperimentalPortal portal : list) { if (portal.getFacingDirection().getOpposite().equals(storedDirection)) { if (portal.getActive()) { - Direction otherPortalVertFacing = Direction.fromNormal(new BlockPos(portal.getOtherAxisH().x, portal.getOtherAxisH().y, portal.getOtherAxisH().z)); + Direction otherPortalVertFacing = Direction.fromNormal(BlockPos.containing(portal.getOtherAxisH().x, portal.getOtherAxisH().y, portal.getOtherAxisH().z)); int offset = (int)(((portal.blockPosition().getX() - translatedPos.getX()) * Math.abs(portal.getAxisH().get().x)) + ((portal.blockPosition().getY() - translatedPos.getY()) * Math.abs(portal.getAxisH().get().y)) + ((portal.blockPosition().getZ() - translatedPos.getZ()) * Math.abs(portal.getAxisH().get().z))); - Direction mainPortalVertFacing = Direction.fromNormal(new BlockPos(portal.getAxisH().get().x, portal.getAxisH().get().y, portal.getAxisH().get().z)); + Direction mainPortalVertFacing = Direction.fromNormal(BlockPos.containing(portal.getAxisH().get().x, portal.getAxisH().get().y, portal.getAxisH().get().z)); assert mainPortalVertFacing != null; if (mainPortalVertFacing.equals(Direction.SOUTH)) { offset = (Math.abs(offset) - 1) * -1; @@ -90,7 +90,7 @@ public static void tick1(Level world, BlockPos pos, @SuppressWarnings("unused") offset = (Math.abs(offset) - 1) * -1; } - translatedPos = new BlockPos(portal.getDestination().get().x, portal.getDestination().get().y, portal.getDestination().get().z).relative(otherPortalVertFacing, offset); + translatedPos = BlockPos.containing(portal.getDestination().get().x, portal.getDestination().get().y, portal.getDestination().get().z).relative(otherPortalVertFacing, offset); savedPos = translatedPos; assert otherPortalVertFacing != null; if (otherPortalVertFacing.equals(Direction.SOUTH)) { diff --git a/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/HardLightBridgeEmitterBlockEntity.java b/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/HardLightBridgeEmitterBlockEntity.java index b5cb4b9f..2a4d7c28 100644 --- a/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/HardLightBridgeEmitterBlockEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/HardLightBridgeEmitterBlockEntity.java @@ -6,8 +6,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; -import net.minecraft.sounds.SoundEvent; -import net.minecraft.sounds.SoundSource; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; @@ -93,10 +91,10 @@ public static void tick(Level world, BlockPos pos, @SuppressWarnings("unused") B for (ExperimentalPortal portal : list) { if (portal.getFacingDirection().getOpposite().equals(storedDirection)) { if (portal.getActive()) { - Direction otherPortalFacing = Direction.fromNormal(new BlockPos(portal.getOtherFacing().x, portal.getOtherFacing().y, portal.getOtherFacing().z)); - Direction otherPortalVertFacing = Direction.fromNormal(new BlockPos(portal.getOtherAxisH().x, portal.getOtherAxisH().y, portal.getOtherAxisH().z)); + Direction otherPortalFacing = Direction.fromNormal(BlockPos.containing(portal.getOtherFacing().x, portal.getOtherFacing().y, portal.getOtherFacing().z)); + Direction otherPortalVertFacing = Direction.fromNormal(BlockPos.containing(portal.getOtherAxisH().x, portal.getOtherAxisH().y, portal.getOtherAxisH().z)); int offset = (int)(((portal.blockPosition().getX() - translatedPos.getX()) * Math.abs(portal.getAxisH().get().x)) + ((portal.blockPosition().getY() - translatedPos.getY()) * Math.abs(portal.getAxisH().get().y)) + ((portal.blockPosition().getZ() - translatedPos.getZ()) * Math.abs(portal.getAxisH().get().z))); - Direction mainPortalVertFacing = Direction.fromNormal(new BlockPos(portal.getAxisH().get().x, portal.getAxisH().get().y, portal.getAxisH().get().z)); + Direction mainPortalVertFacing = Direction.fromNormal(BlockPos.containing(portal.getAxisH().get().x, portal.getAxisH().get().y, portal.getAxisH().get().z)); assert mainPortalVertFacing != null; if (mainPortalVertFacing.equals(Direction.SOUTH)) { offset = (Math.abs(offset) - 1) * -1; @@ -105,7 +103,7 @@ public static void tick(Level world, BlockPos pos, @SuppressWarnings("unused") B offset = (Math.abs(offset) - 1) * -1; } - translatedPos = new BlockPos(portal.getDestination().get().x, portal.getDestination().get().y, portal.getDestination().get().z).relative(otherPortalVertFacing, offset); + translatedPos = BlockPos.containing(portal.getDestination().get().x, portal.getDestination().get().y, portal.getDestination().get().z).relative(otherPortalVertFacing, offset); savedPos = translatedPos; assert otherPortalVertFacing != null; if (otherPortalVertFacing.equals(Direction.SOUTH)) { @@ -148,12 +146,6 @@ public static void tick(Level world, BlockPos pos, @SuppressWarnings("unused") B } - @Override - public void playSound(SoundEvent soundEvent) { - assert this.level != null; - this.level.playSound(null, this.worldPosition, soundEvent, SoundSource.BLOCKS, 0.1F, 3.0F); - } - @Override public void saveAdditional(@NotNull CompoundTag tag) { super.saveAdditional(tag); diff --git a/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/LaserEmitterBlockEntity.java b/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/LaserEmitterBlockEntity.java index 226482ce..4edb86c2 100644 --- a/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/LaserEmitterBlockEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/LaserEmitterBlockEntity.java @@ -1,12 +1,11 @@ package com.fusionflux.portalcubed.blocks.blockentities; +import com.fusionflux.portalcubed.PortalCubedConfig; import com.fusionflux.portalcubed.blocks.LaserCatcherBlock; import com.fusionflux.portalcubed.blocks.LaserEmitterBlock; import com.fusionflux.portalcubed.blocks.PortalCubedBlocks; -import com.fusionflux.portalcubed.PortalCubedConfig; import com.fusionflux.portalcubed.entity.CorePhysicsEntity; import com.fusionflux.portalcubed.entity.RedirectionCubeEntity; -import com.fusionflux.portalcubed.mechanics.PortalCubedDamageSources; import com.fusionflux.portalcubed.sound.PortalCubedSounds; import com.fusionflux.portalcubed.util.AdvancedEntityRaycast; import com.fusionflux.portalcubed.util.GeneralUtil; @@ -42,6 +41,8 @@ import java.util.List; import java.util.Set; +import static com.fusionflux.portalcubed.mechanics.PortalCubedDamageSources.pcSources; + public class LaserEmitterBlockEntity extends BlockEntity { private record Target(@NotNull BlockPos pos, @Nullable Direction side) { } @@ -85,12 +86,12 @@ public void load(CompoundTag tag) { } } - public void tick(Level world, BlockPos pos, BlockState state) { + public void tick(Level level, BlockPos pos, BlockState state) { multiSegments.clear(); if (!state.getValue(LaserEmitterBlock.POWERED)) { - if (!world.isClientSide) { + if (!level.isClientSide) { for (final Target target : targets) { - world.getBlockEntity(target.pos, PortalCubedBlocks.LASER_NODE_BLOCK_ENTITY).ifPresent(LaserNodeBlockEntity::removeLaser); + level.getBlockEntity(target.pos, PortalCubedBlocks.LASER_NODE_BLOCK_ENTITY).ifPresent(LaserNodeBlockEntity::removeLaser); } targets.clear(); } @@ -104,7 +105,7 @@ public void tick(Level world, BlockPos pos, BlockState state) { do { //noinspection DataFlowIssue final AdvancedEntityRaycast.Result segments = AdvancedEntityRaycast.raycast( - world, + level, new ClipContext( start, start.add(direction.scale(lengthRemaining)), ClipContext.Block.VISUAL, ClipContext.Fluid.NONE, null @@ -132,7 +133,7 @@ public void tick(Level world, BlockPos pos, BlockState state) { lengthRemaining -= segments.length(); multiSegments.add(segments); if (segments.finalHit().getType() == HitResult.Type.BLOCK) { - hitState = world.getBlockState(segments.finalHit().getBlockPos()); + hitState = level.getBlockState(segments.finalHit().getBlockPos()); if (hitState.is(PortalCubedBlocks.REFLECTION_GEL)) { final Direction.Axis axis = segments.finalHit().getDirection().getAxis(); direction = direction.with(axis, -direction.get(axis)); @@ -142,12 +143,12 @@ public void tick(Level world, BlockPos pos, BlockState state) { } } while (hitState != null && (hitState.is(PortalCubedBlocks.LASER_RELAY) || hitState.is(PortalCubedBlocks.REFLECTION_GEL))); - if (world.isClientSide) { + if (level.isClientSide) { clientTick(); return; } - Entity owner = EntityType.MARKER.create(world); + Entity owner = EntityType.MARKER.create(level); assert owner != null; alreadyHit.clear(); for (final AdvancedEntityRaycast.Result result : multiSegments) { @@ -165,7 +166,7 @@ public void tick(Level world, BlockPos pos, BlockState state) { continue; // TODO: Turrets and chairs burn } if (!hitEntity.isOnGround()) continue; - hitEntity.hurt(PortalCubedDamageSources.LASER, PortalCubedConfig.laserDamage); + hitEntity.hurt(pcSources(level).laser(), PortalCubedConfig.laserDamage); final Vec3 velocity = GeneralUtil.calculatePerpendicularVector(ray.start(), ray.end(), hitEntity.position()) .normalize() .scale(1.25); @@ -183,7 +184,7 @@ public void tick(Level world, BlockPos pos, BlockState state) { for (final AdvancedEntityRaycast.Result result : multiSegments) { final BlockHitResult finalHit = result.finalHit(); if (finalHit.getType() == HitResult.Type.MISS) continue; - final BlockState hitState1 = world.getBlockState(finalHit.getBlockPos()); + final BlockState hitState1 = level.getBlockState(finalHit.getBlockPos()); if (hitState1.is(PortalCubedBlocks.LASER_CATCHER) && finalHit.getDirection() != hitState1.getValue(LaserCatcherBlock.FACING)) continue; final Target target = new Target( finalHit.getBlockPos(), @@ -204,7 +205,7 @@ public void tick(Level world, BlockPos pos, BlockState state) { for (final var entry : changes.object2IntEntrySet()) { if (entry.getIntValue() == 0) continue; - final LaserNodeBlockEntity entity = world.getBlockEntity(entry.getKey(), PortalCubedBlocks.LASER_NODE_BLOCK_ENTITY).orElse(null); + final LaserNodeBlockEntity entity = level.getBlockEntity(entry.getKey(), PortalCubedBlocks.LASER_NODE_BLOCK_ENTITY).orElse(null); if (entity == null) continue; if (entry.getIntValue() > 0) { for (int i = 0; i < entry.getIntValue(); i++) { diff --git a/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/LaserNodeBlockEntity.java b/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/LaserNodeBlockEntity.java index 82602d08..73262c9d 100644 --- a/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/LaserNodeBlockEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/LaserNodeBlockEntity.java @@ -21,6 +21,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.quiltmc.loader.api.minecraft.ClientOnly; @@ -83,6 +84,7 @@ public void load(CompoundTag nbt) { } } + @NotNull @Override public CompoundTag getUpdateTag() { return saveWithoutMetadata(); @@ -104,7 +106,7 @@ public static void tick(Level world, BlockPos pos, BlockState state, LaserNodeBl protected void clientTick(BlockState state) { if (musicInstance == null && level != null && state.getValue(BlockStateProperties.ENABLED)) { // The sounds played here may actually be stereo, so we may need to handle our own fadeout - musicInstance = new AbstractTickableSoundInstance(new SoundEvent(sound), SoundSource.BLOCKS, SoundInstance.createUnseededRandom()) { + musicInstance = new AbstractTickableSoundInstance(SoundEvent.createVariableRangeEvent(sound), SoundSource.BLOCKS, SoundInstance.createUnseededRandom()) { final ResourceLocation soundId = LaserNodeBlockEntity.this.sound; final boolean isCustomSound = !soundId.equals(PortalCubedSounds.LASER_NODE_MUSIC); diff --git a/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/ReversedExcursionFunnelEmitterBlockEntity.java b/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/ReversedExcursionFunnelEmitterBlockEntity.java index 5092f01c..91ea9202 100644 --- a/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/ReversedExcursionFunnelEmitterBlockEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/ReversedExcursionFunnelEmitterBlockEntity.java @@ -80,9 +80,9 @@ public static void tick3(Level world, BlockPos pos, @SuppressWarnings("unused") for (ExperimentalPortal portal : list) { if (portal.getFacingDirection().getOpposite().equals(storedDirection)) { if (portal.getActive()) { - Direction otherPortalVertFacing = Direction.fromNormal(new BlockPos(portal.getOtherAxisH().x, portal.getOtherAxisH().y, portal.getOtherAxisH().z)); + Direction otherPortalVertFacing = Direction.fromNormal(BlockPos.containing(portal.getOtherAxisH().x, portal.getOtherAxisH().y, portal.getOtherAxisH().z)); int offset = (int)(((portal.blockPosition().getX() - translatedPos.getX()) * Math.abs(portal.getAxisH().get().x)) + ((portal.blockPosition().getY() - translatedPos.getY()) * Math.abs(portal.getAxisH().get().y)) + ((portal.blockPosition().getZ() - translatedPos.getZ()) * Math.abs(portal.getAxisH().get().z))); - Direction mainPortalVertFacing = Direction.fromNormal(new BlockPos(portal.getAxisH().get().x, portal.getAxisH().get().y, portal.getAxisH().get().z)); + Direction mainPortalVertFacing = Direction.fromNormal(BlockPos.containing(portal.getAxisH().get().x, portal.getAxisH().get().y, portal.getAxisH().get().z)); assert mainPortalVertFacing != null; if (mainPortalVertFacing.equals(Direction.SOUTH)) { offset = (Math.abs(offset) - 1) * -1; @@ -91,7 +91,7 @@ public static void tick3(Level world, BlockPos pos, @SuppressWarnings("unused") offset = (Math.abs(offset) - 1) * -1; } - translatedPos = new BlockPos(portal.getDestination().get().x, portal.getDestination().get().y, portal.getDestination().get().z).relative(otherPortalVertFacing, offset); + translatedPos = BlockPos.containing(portal.getDestination().get().x, portal.getDestination().get().y, portal.getDestination().get().z).relative(otherPortalVertFacing, offset); savedPos = translatedPos; assert otherPortalVertFacing != null; if (otherPortalVertFacing.equals(Direction.SOUTH)) { diff --git a/src/main/java/com/fusionflux/portalcubed/blocks/fizzler/AbstractFizzlerBlock.java b/src/main/java/com/fusionflux/portalcubed/blocks/fizzler/AbstractFizzlerBlock.java index 3c12bb74..f76022e8 100644 --- a/src/main/java/com/fusionflux/portalcubed/blocks/fizzler/AbstractFizzlerBlock.java +++ b/src/main/java/com/fusionflux/portalcubed/blocks/fizzler/AbstractFizzlerBlock.java @@ -1,11 +1,10 @@ package com.fusionflux.portalcubed.blocks.fizzler; +import com.fusionflux.portalcubed.PortalCubedConfig; import com.fusionflux.portalcubed.accessor.BlockCollisionTrigger; import com.fusionflux.portalcubed.accessor.CalledValues; import com.fusionflux.portalcubed.client.packet.PortalCubedClientPackets; -import com.fusionflux.portalcubed.PortalCubedConfig; import com.fusionflux.portalcubed.entity.Fizzleable; -import com.fusionflux.portalcubed.mechanics.PortalCubedDamageSources; import com.fusionflux.portalcubed.sound.PortalCubedSounds; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -32,6 +31,8 @@ import java.util.List; import java.util.UUID; +import static com.fusionflux.portalcubed.mechanics.PortalCubedDamageSources.pcSources; + public abstract class AbstractFizzlerBlock extends Block implements BlockCollisionTrigger { public static final BooleanProperty NS = BooleanProperty.create("ns"); public static final BooleanProperty EW = BooleanProperty.create("ew"); @@ -129,7 +130,7 @@ protected final void fizzleLiving(Entity entity) { if (entity.level.isClientSide) return; // TODO: Fizzle players visually? if (entity instanceof LivingEntity || (entity instanceof Fizzleable fizzleable && fizzleable.getFizzleType() == Fizzleable.FizzleType.LIVING)) { - entity.hurt(PortalCubedDamageSources.FIZZLE, PortalCubedConfig.fizzlerDamage); + entity.hurt(pcSources(entity.level).fizzle(), PortalCubedConfig.fizzlerDamage); if (entity instanceof Fizzleable fizzleable && fizzleable.getFizzleType() != Fizzleable.FizzleType.NOT) { fizzleable.fizzle(); } diff --git a/src/main/java/com/fusionflux/portalcubed/client/PortalCubedClient.java b/src/main/java/com/fusionflux/portalcubed/client/PortalCubedClient.java index ba7905c0..b0c08901 100644 --- a/src/main/java/com/fusionflux/portalcubed/client/PortalCubedClient.java +++ b/src/main/java/com/fusionflux/portalcubed/client/PortalCubedClient.java @@ -1,6 +1,5 @@ package com.fusionflux.portalcubed.client; -import amymialee.visiblebarriers.VisibleBarriers; import com.fusionflux.portalcubed.PortalCubed; import com.fusionflux.portalcubed.PortalCubedConfig; import com.fusionflux.portalcubed.accessor.Accessors; @@ -36,12 +35,11 @@ import com.fusionflux.portalcubed.util.PortalCubedComponents; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.*; -import com.mojang.math.Matrix4f; import com.unascribed.lib39.recoil.api.RecoilEvents; import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry; import net.fabricmc.fabric.api.client.render.fluid.v1.SimpleFluidRenderHandler; import net.fabricmc.fabric.api.client.rendering.v1.*; -import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.DeathScreen; import net.minecraft.client.gui.screens.MenuScreens; @@ -62,12 +60,11 @@ import net.minecraft.util.Mth; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.inventory.ClickType; -import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.world.inventory.Slot; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.Items; +import net.minecraft.world.item.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.joml.Matrix4f; import org.lwjgl.opengl.GL11; import org.quiltmc.loader.api.ModContainer; import org.quiltmc.loader.api.QuiltLoader; @@ -77,6 +74,7 @@ import org.quiltmc.qsl.networking.api.PacketByteBufs; import org.quiltmc.qsl.networking.api.client.ClientLoginConnectionEvents; import org.quiltmc.qsl.networking.api.client.ClientPlayNetworking; +import xyz.amymialee.visiblebarriers.VisibleBarriers; import java.io.File; import java.io.IOException; @@ -84,6 +82,7 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.HashSet; +import java.util.List; import java.util.Set; import java.util.UUID; @@ -255,10 +254,11 @@ public void onInitializeClient(ModContainer mod) { final ResourceLocation toxicGooFlowSpriteId = id("block/toxic_goo_flow"); FluidRenderHandlerRegistry.INSTANCE.register(PortalCubedFluids.TOXIC_GOO.still, PortalCubedFluids.TOXIC_GOO.flowing, new SimpleFluidRenderHandler(toxicGooStillSpriteId, toxicGooFlowSpriteId)); - ClientSpriteRegistryCallback.event(InventoryMenu.BLOCK_ATLAS).register((atlasTexture, registry) -> { - registry.register(toxicGooStillSpriteId); - registry.register(toxicGooFlowSpriteId); - }); + // TODO: Remove this code if it's truly unnecessary +// ClientSpriteRegistryCallback.event(InventoryMenu.BLOCK_ATLAS).register((atlasTexture, registry) -> { +// registry.register(toxicGooStillSpriteId); +// registry.register(toxicGooFlowSpriteId); +// }); ItemProperties.register( PortalCubedBlocks.POWER_BLOCK.asItem(), @@ -431,6 +431,18 @@ Items.LIGHT, new ResourceLocation("level") PortalTabsLoader.load(mod); + //noinspection UnstableApiUsage + ItemGroupEvents.modifyEntriesEvent(CreativeModeTabs.TOOLS_AND_UTILITIES).register(e -> e.addAfter( + i -> i.getItem() instanceof RecordItem, + List.of( + new ItemStack(PortalCubedItems.STILL_ALIVE), + new ItemStack(PortalCubedItems.CARA_MIA_ADDIO), + new ItemStack(PortalCubedItems.WANT_YOU_GONE), + new ItemStack(PortalCubedItems.RECONSTRUCTING_MORE_SCIENCE) + ), + CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS + )); + try { final CompoundTag compound = NbtIo.readCompressed(GLOBAL_ADVANCEMENTS_FILE); for (final Tag element : compound.getList("Advancements", Tag.TAG_STRING)) { @@ -562,7 +574,7 @@ private void registerEntityRenderers() { private static final class VisibleBarriersCompat { static boolean isVisible() { - return VisibleBarriers.isVisible(); + return VisibleBarriers.isVisibilityEnabled(); } } diff --git a/src/main/java/com/fusionflux/portalcubed/client/gui/FaithPlateScreen.java b/src/main/java/com/fusionflux/portalcubed/client/gui/FaithPlateScreen.java index b5cee852..45eb5698 100644 --- a/src/main/java/com/fusionflux/portalcubed/client/gui/FaithPlateScreen.java +++ b/src/main/java/com/fusionflux/portalcubed/client/gui/FaithPlateScreen.java @@ -110,7 +110,7 @@ protected void init() { int x = this.width / 2; int y = this.height / 2; - addRenderableWidget(new Button(x - 50, y, 100, 20, Component.nullToEmpty("Done"), (button) -> { + addRenderableWidget(Button.builder(Component.nullToEmpty("Done"), (button) -> { FriendlyByteBuf buf = PacketByteBufs.create(); @@ -150,7 +150,7 @@ protected void init() { NetworkingSafetyWrapper.sendFromClient("configure_faith_plate", buf); this.onClose(); // ClientPlayNetworking.send("a", buf); - })); + }).width(100).pos(x - 50, y).build()); // Center the title titleLabelX = (imageWidth - font.width(title)) / 2; } diff --git a/src/main/java/com/fusionflux/portalcubed/client/gui/VelocityHelperScreen.java b/src/main/java/com/fusionflux/portalcubed/client/gui/VelocityHelperScreen.java index 571a6268..f24ca7ff 100644 --- a/src/main/java/com/fusionflux/portalcubed/client/gui/VelocityHelperScreen.java +++ b/src/main/java/com/fusionflux/portalcubed/client/gui/VelocityHelperScreen.java @@ -6,8 +6,6 @@ import com.fusionflux.portalcubed.gui.VelocityHelperScreenHandler; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.*; -import com.mojang.math.Matrix3f; -import com.mojang.math.Matrix4f; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.components.Button; @@ -20,6 +18,9 @@ import net.minecraft.util.Mth; import net.minecraft.world.entity.player.Inventory; import net.objecthunter.exp4j.Expression; +import org.joml.Math; +import org.joml.Matrix3f; +import org.joml.Matrix4f; import java.util.function.Consumer; @@ -123,21 +124,24 @@ protected void init() { w.setParser(s -> VelocityHelperBlockEntity.parseExpression(s, "x")); w.setExpression(entity.getInterpolationCurveString()); }); - addRenderableWidget(new Button( - width / 2 - 90, this.topPos + imageHeight + 5, 75, 20, CommonComponents.GUI_CANCEL, - w -> onClose() - )); - addRenderableWidget(doneButton = new Button( - width / 2 + 15, this.topPos + imageHeight + 5, 75, 20, CommonComponents.GUI_DONE, - w -> { + addRenderableWidget( + Button.builder(CommonComponents.GUI_CANCEL, w -> onClose()) + .width(width / 2 - 90) + .pos(this.topPos + imageHeight + 5, 75) + .build() + ); + doneButton = addRenderableWidget( + Button.builder(CommonComponents.GUI_DONE, w -> { VelocityHelperBlock.sendConfigurePacket(menu.getAt(), VelocityHelperBlock.CONFIG_OTHER, buf -> { buf.writeVarInt(Integer.parseInt(flightDurationWidget.getValue())); buf.writeUtf(conditionWidget.getValue()); buf.writeUtf(icWidget.getValue()); }); onClose(); - } - )); + }).width(width / 2 + 15) + .pos(this.topPos + imageHeight + 5, 75) + .build() + ); } private EditBox createTextField(int x, int y, int width, Consumer consumer) { @@ -168,7 +172,7 @@ protected void containerTick() { public static void drawLine(PoseStack matrices, float x0, float y0, float x1, float y1, int color) { final Matrix4f model = matrices.last().pose(); final Matrix3f normal = matrices.last().normal(); - final float mag = Mth.fastInvSqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)); + final float mag = Math.invsqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)); final float normalX = Math.abs(x1 - x0) * mag; final float normalY = Math.abs(y1 - y0) * mag; diff --git a/src/main/java/com/fusionflux/portalcubed/client/particle/DecalParticle.java b/src/main/java/com/fusionflux/portalcubed/client/particle/DecalParticle.java index 5dd9813b..374e0f58 100644 --- a/src/main/java/com/fusionflux/portalcubed/client/particle/DecalParticle.java +++ b/src/main/java/com/fusionflux/portalcubed/client/particle/DecalParticle.java @@ -5,8 +5,6 @@ import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.*; -import com.mojang.math.Quaternion; -import com.mojang.math.Vector3f; import net.fabricmc.fabric.api.client.particle.v1.FabricSpriteProvider; import net.minecraft.client.Camera; import net.minecraft.client.multiplayer.ClientLevel; @@ -20,6 +18,9 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.NotNull; +import org.joml.Quaternionf; +import org.joml.Vector3f; import org.quiltmc.loader.api.minecraft.ClientOnly; import java.util.HashMap; @@ -72,7 +73,7 @@ public void render(VertexConsumer vertexConsumer, Camera camera, float tickDelta final float x = (float)(Mth.lerp(tickDelta, xo, this.x) - cameraPos.x()); final float y = (float)(Mth.lerp(tickDelta, yo, this.y) - cameraPos.y()); final float z = (float)(Mth.lerp(tickDelta, zo, this.z) - cameraPos.z()); - final Quaternion rotation = direction.getRotation(); + final Quaternionf rotation = direction.getRotation(); final Vector3f[] vertices = { new Vector3f(-0.5f, 0f, -0.5f), @@ -82,7 +83,7 @@ public void render(VertexConsumer vertexConsumer, Camera camera, float tickDelta }; for (final Vector3f vertex : vertices) { - vertex.transform(rotation); + vertex.rotate(rotation); vertex.add(x, y, z); } @@ -119,6 +120,7 @@ public void render(VertexConsumer vertexConsumer, Camera camera, float tickDelta .endVertex(); } + @NotNull @Override public ParticleRenderType getRenderType() { return multiply ? PARTICLE_SHEET_MULTIPLY : ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT; @@ -151,7 +153,7 @@ private Map getSpriteCache() { cacheKey = sprites; spriteCache.clear(); for (final TextureAtlasSprite sprite : sprites) { - spriteCache.put(sprite.getName(), sprite); + spriteCache.put(sprite.atlasLocation(), sprite); } } return spriteCache; diff --git a/src/main/java/com/fusionflux/portalcubed/client/render/PortalHud.java b/src/main/java/com/fusionflux/portalcubed/client/render/PortalHud.java index f764b4a2..f70bb90f 100644 --- a/src/main/java/com/fusionflux/portalcubed/client/render/PortalHud.java +++ b/src/main/java/com/fusionflux/portalcubed/client/render/PortalHud.java @@ -99,7 +99,8 @@ public static void renderPortalRight(@SuppressWarnings("unused") PoseStack matri public static void texture(int x, int y, int z, int width, int height, float u, float v, float uw, float vh, float r, float g, float b, float a) { Tesselator tessellator = Tesselator.getInstance(); BufferBuilder bufferBuilder = tessellator.getBuilder(); - RenderSystem.enableTexture(); + // TODO: Investigate if this is needed anymore +// RenderSystem.enableTexture(); bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); bufferBuilder.vertex(x, y + height, z).uv(u, v + vh).color(r, g, b, a).endVertex(); bufferBuilder.vertex(x + width, y + height, z).uv(u + uw, v + vh).color(r, g, b, a).endVertex(); diff --git a/src/main/java/com/fusionflux/portalcubed/client/render/block/EmissiveBakedModel.java b/src/main/java/com/fusionflux/portalcubed/client/render/block/EmissiveBakedModel.java index 7228c24d..41c0e74e 100644 --- a/src/main/java/com/fusionflux/portalcubed/client/render/block/EmissiveBakedModel.java +++ b/src/main/java/com/fusionflux/portalcubed/client/render/block/EmissiveBakedModel.java @@ -10,6 +10,7 @@ import net.fabricmc.fabric.api.renderer.v1.model.ForwardingBakedModel; import net.fabricmc.fabric.api.renderer.v1.model.ModelHelper; import net.fabricmc.fabric.api.renderer.v1.render.RenderContext; +import net.fabricmc.fabric.api.util.TriState; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.resources.model.BakedModel; @@ -43,6 +44,7 @@ public static Optional wrap(ResourceLocation modelId, BakedModel mod return Optional.empty(); } + @SuppressWarnings("DataFlowIssue") private static final RenderMaterial DEFAULT_MATERIAL = RendererAccess.INSTANCE.getRenderer().materialById(RenderMaterial.MATERIAL_STANDARD); private static final RenderMaterial[] EMISSIVE_MATERIALS; static { @@ -51,10 +53,10 @@ public static Optional wrap(ResourceLocation modelId, BakedModel mod final var materialFinder = RendererAccess.INSTANCE.getRenderer().materialFinder(); for (BlendMode blendMode : blendModes) { EMISSIVE_MATERIALS[blendMode.ordinal()] = materialFinder - .emissive(0, true) - .disableDiffuse(0, true) - .disableAo(0, true) - .blendMode(0, blendMode) + .emissive(true) + .disableDiffuse(true) + .ambientOcclusion(TriState.FALSE) + .blendMode(blendMode) .find(); } } @@ -100,7 +102,7 @@ private void buildMesh(ModelObjects objects, @Nullable BlockState state, Supplie final List quads = wrapped.getQuads(state, cullFace, randomSupplier.get()); for (BakedQuad quad : quads) { - boolean isQuadEmissive = EmissiveSpriteRegistry.isEmissive(quad.getSprite().getName()); + boolean isQuadEmissive = EmissiveSpriteRegistry.isEmissive(quad.getSprite().atlasLocation()); BlendMode blendMode = BlendMode.DEFAULT; if (state != null) { diff --git a/src/main/java/com/fusionflux/portalcubed/client/render/block/entity/EntityLikeBlockEntityRenderer.java b/src/main/java/com/fusionflux/portalcubed/client/render/block/entity/EntityLikeBlockEntityRenderer.java index c9c2985e..c99a91ba 100644 --- a/src/main/java/com/fusionflux/portalcubed/client/render/block/entity/EntityLikeBlockEntityRenderer.java +++ b/src/main/java/com/fusionflux/portalcubed/client/render/block/entity/EntityLikeBlockEntityRenderer.java @@ -5,7 +5,7 @@ import com.fusionflux.portalcubed.util.BlockEntityWrapperEntity; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Vector3f; +import com.mojang.math.Axis; import it.unimi.dsi.fastutil.Pair; import net.minecraft.client.model.geom.EntityModelSet; import net.minecraft.client.model.geom.ModelLayerLocation; @@ -39,7 +39,7 @@ private Pair, M> createWrapperModelPair(T entity) { public void render(T entity, float tickDelta, PoseStack matrices, MultiBufferSource vertexConsumers, int light, int overlay) { matrices.pushPose(); - matrices.mulPose(Vector3f.YP.rotationDegrees(180)); + matrices.mulPose(Axis.YP.rotationDegrees(180)); matrices.scale(-1, -1, 1); matrices.translate(0.5, -1.501, -0.5); diff --git a/src/main/java/com/fusionflux/portalcubed/client/render/block/entity/LaserEmitterRenderer.java b/src/main/java/com/fusionflux/portalcubed/client/render/block/entity/LaserEmitterRenderer.java index 77e532e9..b40cf327 100644 --- a/src/main/java/com/fusionflux/portalcubed/client/render/block/entity/LaserEmitterRenderer.java +++ b/src/main/java/com/fusionflux/portalcubed/client/render/block/entity/LaserEmitterRenderer.java @@ -1,16 +1,16 @@ package com.fusionflux.portalcubed.client.render.block.entity; -import com.fusionflux.portalcubed.blocks.blockentities.LaserEmitterBlockEntity; import com.fusionflux.portalcubed.PortalCubedConfig; +import com.fusionflux.portalcubed.blocks.blockentities.LaserEmitterBlockEntity; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Vector3f; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; +import org.joml.Vector3f; public class LaserEmitterRenderer implements BlockEntityRenderer { public LaserEmitterRenderer(BlockEntityRendererProvider.Context ctx) { @@ -33,8 +33,8 @@ public void render(LaserEmitterBlockEntity entity, float tickDelta, @NotNull Pos final PoseStack.Pose matrix = matrices.last(); for (final var segments : entity.getMultiSegments()) { for (final var aimDestInfo : segments.rays()) { - final Vector3f start = new Vector3f(aimDestInfo.start().subtract(Vec3.atLowerCornerOf(entity.getBlockPos()))); - final Vector3f end = new Vector3f(aimDestInfo.end().subtract(Vec3.atLowerCornerOf(entity.getBlockPos()))); + final Vector3f start = aimDestInfo.start().subtract(Vec3.atLowerCornerOf(entity.getBlockPos())).toVector3f(); + final Vector3f end = aimDestInfo.end().subtract(Vec3.atLowerCornerOf(entity.getBlockPos())).toVector3f(); drawSegments(vertexConsumer, matrix, start, end, 0.1f, 0f, 0f, 0.05f, 0.0f); drawSegments(vertexConsumer, matrix, start, end, 1f, 0f, 0f, 0.02f, 0.01f); drawSegments(vertexConsumer, matrix, start, end, 1f, 0.5f, 0.5f, 0.01f, 0.02f); diff --git a/src/main/java/com/fusionflux/portalcubed/client/render/block/entity/RocketTurretRenderer.java b/src/main/java/com/fusionflux/portalcubed/client/render/block/entity/RocketTurretRenderer.java index 83bcf072..8f9ae17c 100644 --- a/src/main/java/com/fusionflux/portalcubed/client/render/block/entity/RocketTurretRenderer.java +++ b/src/main/java/com/fusionflux/portalcubed/client/render/block/entity/RocketTurretRenderer.java @@ -3,12 +3,12 @@ import com.fusionflux.portalcubed.blocks.blockentities.RocketTurretBlockEntity; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Vector3f; import net.minecraft.client.model.geom.ModelLayerLocation; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.world.phys.Vec3; +import org.joml.Vector3f; import static com.fusionflux.portalcubed.PortalCubed.id; @@ -37,11 +37,9 @@ public void render(RocketTurretBlockEntity entity, float tickDelta, PoseStack ma final VertexConsumer vertexConsumer = vertexConsumers.getBuffer(RenderType.lines()); final PoseStack.Pose matrix = matrices.last(); for (final var aimDestInfo : entity.aimDests) { - final Vector3f origin = new Vector3f(aimDestInfo.getA().subtract(Vec3.atLowerCornerOf(entity.getBlockPos()))); - final Vector3f offset = new Vector3f(aimDestInfo.getB().subtract(Vec3.atLowerCornerOf(entity.getBlockPos()))); - final Vector3f normal = offset.copy(); - normal.sub(origin); - normal.normalize(); + final Vector3f origin = aimDestInfo.getA().subtract(Vec3.atLowerCornerOf(entity.getBlockPos())).toVector3f(); + final Vector3f offset = aimDestInfo.getB().subtract(Vec3.atLowerCornerOf(entity.getBlockPos())).toVector3f(); + final Vector3f normal = new Vector3f(offset).sub(origin).normalize(); vertexConsumer .vertex(matrix.pose(), origin.x(), origin.y(), origin.z()) .color(130 / 255f, 200 / 255f, 230 / 255f, 0.25f) diff --git a/src/main/java/com/fusionflux/portalcubed/client/render/block/entity/VelocityHelperRenderer.java b/src/main/java/com/fusionflux/portalcubed/client/render/block/entity/VelocityHelperRenderer.java index 8f829483..6dd43fb2 100644 --- a/src/main/java/com/fusionflux/portalcubed/client/render/block/entity/VelocityHelperRenderer.java +++ b/src/main/java/com/fusionflux/portalcubed/client/render/block/entity/VelocityHelperRenderer.java @@ -4,13 +4,13 @@ import com.fusionflux.portalcubed.client.PortalCubedClient; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Vector3f; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.core.BlockPos; import net.minecraft.world.phys.Vec3; +import org.joml.Vector3f; public class VelocityHelperRenderer implements BlockEntityRenderer { public VelocityHelperRenderer(BlockEntityRendererProvider.Context ctx) { @@ -28,7 +28,7 @@ public void render(VelocityHelperBlockEntity entity, float tickDelta, PoseStack final BlockPos offset = entity.getDestination().subtract(entity.getBlockPos()); final VertexConsumer vertexConsumer = vertexConsumers.getBuffer(RenderType.lines()); final PoseStack.Pose matrix = matrices.last(); - final Vector3f normal = new Vector3f(Vec3.atLowerCornerOf(offset).normalize()); + final Vector3f normal = Vec3.atLowerCornerOf(offset).normalize().toVector3f(); vertexConsumer .vertex(matrix.pose(), 0.5f, 0.5f, 0.5f) .color(0.0f, 0.5f, 1.0f, 1.0f) diff --git a/src/main/java/com/fusionflux/portalcubed/client/render/entity/ExperimentalPortalRenderer.java b/src/main/java/com/fusionflux/portalcubed/client/render/entity/ExperimentalPortalRenderer.java index 583e4f09..152809ce 100644 --- a/src/main/java/com/fusionflux/portalcubed/client/render/entity/ExperimentalPortalRenderer.java +++ b/src/main/java/com/fusionflux/portalcubed/client/render/entity/ExperimentalPortalRenderer.java @@ -7,7 +7,7 @@ import com.fusionflux.portalcubed.entity.ExperimentalPortal; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Vector3f; +import com.mojang.math.Axis; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -37,9 +37,9 @@ public ExperimentalPortalRenderer(EntityRendererProvider.Context dispatcher) { public void render(@NotNull ExperimentalPortal entity, float yaw, float tickDelta, @NotNull PoseStack matrices, @NotNull MultiBufferSource vertexConsumers, int light) { super.render(entity, yaw, tickDelta, matrices, vertexConsumers, light); matrices.pushPose(); - matrices.mulPose(Vector3f.XP.rotationDegrees(entity.getYRot())); - matrices.mulPose(Vector3f.YP.rotationDegrees(entity.getXRot())); - matrices.mulPose(Vector3f.ZN.rotationDegrees(entity.getRoll())); + matrices.mulPose(Axis.XP.rotationDegrees(entity.getYRot())); + matrices.mulPose(Axis.YP.rotationDegrees(entity.getXRot())); + matrices.mulPose(Axis.ZN.rotationDegrees(entity.getRoll())); int color = entity.getColor() * -1; if (color == -16383998) { diff --git a/src/main/java/com/fusionflux/portalcubed/client/render/entity/GelBlobRenderer.java b/src/main/java/com/fusionflux/portalcubed/client/render/entity/GelBlobRenderer.java index 7036566e..b8420f8c 100644 --- a/src/main/java/com/fusionflux/portalcubed/client/render/entity/GelBlobRenderer.java +++ b/src/main/java/com/fusionflux/portalcubed/client/render/entity/GelBlobRenderer.java @@ -3,16 +3,20 @@ import com.fusionflux.portalcubed.entity.GelBlobEntity; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Quaternion; -import com.mojang.math.Vector3f; import net.minecraft.client.model.geom.ModelPart; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; +import org.jetbrains.annotations.NotNull; +import org.joml.Quaternionf; +import org.joml.Vector3f; + +import java.util.EnumSet; public class GelBlobRenderer extends EntityRenderer { private final ModelPart.Cube cube; @@ -25,7 +29,8 @@ public GelBlobRenderer(EntityRendererProvider.Context context) { 16, 16, 16, // XS, YS, ZS 0, 0, 0, // Extra XS, Extra YS, Extra ZS false, // Mirror - 1, 1 // U width, V height + 1, 1, // U width, V height + EnumSet.allOf(Direction.class) ); } @@ -35,14 +40,14 @@ public void render(GelBlobEntity entity, float yaw, float tickDelta, PoseStack m final VertexConsumer consumer = vertexConsumers.getBuffer(RenderType.entitySolid(getTextureLocation(entity))); matrices.pushPose(); - final Vector3f vel = new Vector3f(entity.getDeltaMovement()); + final Vector3f vel = entity.getDeltaMovement().toVector3f(); final float y = (vel.y() - 0.04f * tickDelta) * 0.98f; float speed = (float)Math.sqrt(vel.x() * vel.x() + y * y + vel.z() * vel.z()); vel.normalize(); final float angle = (float)Math.acos(Mth.clamp(y, -1, 1)); vel.set(-1 * vel.z(), 0, vel.x()); vel.normalize(); - final Quaternion rot = new Quaternion(vel, -angle, false); + final Quaternionf rot = new Quaternionf().setAngleAxis(-angle, vel.x, vel.y, vel.z); matrices.translate(0, 0.5, 0); matrices.mulPose(rot); speed += 0.75f; @@ -60,6 +65,7 @@ public void render(GelBlobEntity entity, float yaw, float tickDelta, PoseStack m super.render(entity, yaw, tickDelta, matrices, vertexConsumers, light); } + @NotNull @Override public ResourceLocation getTextureLocation(GelBlobEntity entity) { return entity.getTexture(); diff --git a/src/main/java/com/fusionflux/portalcubed/client/render/entity/RocketRenderer.java b/src/main/java/com/fusionflux/portalcubed/client/render/entity/RocketRenderer.java index ab2a2b0c..1c94273c 100644 --- a/src/main/java/com/fusionflux/portalcubed/client/render/entity/RocketRenderer.java +++ b/src/main/java/com/fusionflux/portalcubed/client/render/entity/RocketRenderer.java @@ -5,7 +5,7 @@ import com.fusionflux.portalcubed.entity.RocketEntity; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Vector3f; +import com.mojang.math.Axis; import net.minecraft.client.model.geom.ModelLayerLocation; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -14,6 +14,7 @@ import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; +import org.jetbrains.annotations.NotNull; import static com.fusionflux.portalcubed.PortalCubed.id; @@ -36,8 +37,8 @@ public void render(RocketEntity entity, float yaw2, float tickDelta, PoseStack m final float yaw = Mth.rotLerp(tickDelta, entity.yRotO, entity.getYRot()); final float pitch = Mth.rotLerp(tickDelta, entity.xRotO, entity.getXRot()); - matrices.mulPose(Vector3f.XP.rotationDegrees(-pitch)); - matrices.mulPose(Vector3f.YP.rotationDegrees(180 - yaw)); + matrices.mulPose(Axis.XP.rotationDegrees(-pitch)); + matrices.mulPose(Axis.YP.rotationDegrees(180 - yaw)); matrices.scale(-1, -1, 1); matrices.translate(0.0, -1.501, 0.0); @@ -54,6 +55,7 @@ public void render(RocketEntity entity, float yaw2, float tickDelta, PoseStack m matrices.popPose(); } + @NotNull @Override public ResourceLocation getTextureLocation(RocketEntity entity) { return RocketTurretModel.TEXTURE_ACTIVE; diff --git a/src/main/java/com/fusionflux/portalcubed/compat/create/CreateIntegration.java b/src/main/java/com/fusionflux/portalcubed/compat/create/CreateIntegration.java index 39bd97f1..f92c1a95 100644 --- a/src/main/java/com/fusionflux/portalcubed/compat/create/CreateIntegration.java +++ b/src/main/java/com/fusionflux/portalcubed/compat/create/CreateIntegration.java @@ -1,7 +1,7 @@ -package com.fusionflux.portalcubed.compat.create; - -public class CreateIntegration { - public static void init() { - PCPonder.register(); - } -} +//package com.fusionflux.portalcubed.compat.create; +// +//public class CreateIntegration { +// public static void init() { +// PCPonder.register(); +// } +//} diff --git a/src/main/java/com/fusionflux/portalcubed/compat/create/PCPonder.java b/src/main/java/com/fusionflux/portalcubed/compat/create/PCPonder.java index 3c8ae9eb..3507bbc7 100644 --- a/src/main/java/com/fusionflux/portalcubed/compat/create/PCPonder.java +++ b/src/main/java/com/fusionflux/portalcubed/compat/create/PCPonder.java @@ -1,205 +1,205 @@ -package com.fusionflux.portalcubed.compat.create; - -import com.fusionflux.portalcubed.PortalCubed; -import com.fusionflux.portalcubed.blocks.AutoPortalBlock; -import com.fusionflux.portalcubed.blocks.blockentities.AutoPortalBlockEntity; -import com.fusionflux.portalcubed.items.PortalCubedItems; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonObject; -import com.simibubi.create.foundation.ponder.*; -import com.simibubi.create.foundation.ponder.element.InputWindowElement; -import com.simibubi.create.foundation.utility.Pointing; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; - -import java.io.FileWriter; -import java.io.IOException; -import java.io.Writer; -import java.nio.charset.StandardCharsets; - -import static com.fusionflux.portalcubed.PortalCubed.id; - -public class PCPonder { - private static final PonderRegistrationHelper HELPER = new PonderRegistrationHelper(PortalCubed.MOD_ID); - - public static final PonderTag PORTAL_CUBED = new PonderTag(id("portal_cubed")) - .item(PortalCubedItems.BLOCK_ITEM_ICON, true, false) - .addToIndex(); - - private static final boolean GENERATE_TRANSLATIONS = false; - - public static void register() { - HELPER.addStoryBoard( - id("auto_portal"), - "auto_portal", - PCPonder::autoPortal, - PORTAL_CUBED - ); - - if (GENERATE_TRANSLATIONS) { - PonderLocalization.generateSceneLang(); - final JsonObject translation = new JsonObject(); - PonderLocalization.record("portalcubed", translation); - try (Writer writer = new FileWriter("create_ponder_portalcubed.json", StandardCharsets.UTF_8)) { - new GsonBuilder().setPrettyPrinting().create().toJson(translation, writer); - } catch (IOException e) { - PortalCubed.LOGGER.error("Failed to save file", e); - } - } - } - - public static void autoPortal(SceneBuilder scene, SceneBuildingUtil util) { - scene.title("auto_portal", "Using the Auto Portal"); - scene.configureBasePlate(0, 0, 4); - scene.showBasePlate(); - scene.idle(5); - - scene.world.showSection(util.select.position(2, 1, 2), Direction.DOWN); - scene.idle(5); - scene.world.showSection(util.select.position(2, 2, 2), Direction.DOWN); - scene.idle(5); - scene.world.showSection(util.select.fromTo(2, 1, 1, 2, 2, 1), Direction.SOUTH); - scene.idle(5); - scene.world.showSection(util.select.position(1, 2, 2), Direction.EAST); - scene.idle(5); - - scene.overlay.showText(80) - .text("Power an Auto Portal with redstone to open it.") - .placeNearTarget() - .pointAt(util.vector.centerOf(1, 2, 2)); - scene.idle(60); - - scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); - var portalLink = scene.world.createEntity(world -> AutoPortalBlock.openOrClosePortal( - world, new BlockPos(2, 1, 1), Direction.NORTH, false, false, false - )); - - scene.idle(20); - scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); - scene.idle(20); - - scene.overlay.showText(80) - .text("Power an Auto Portal with redstone again to close it.") - .placeNearTarget() - .pointAt(util.vector.centerOf(1, 2, 2)); - scene.idle(60); - - scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); - scene.world.modifyEntity(portalLink, Entity::kill); - - scene.idle(20); - scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); - - scene.overlay.showControls( - new InputWindowElement(util.vector.centerOf(2, 2, 1), Pointing.RIGHT) - .rightClick() - .withItem(new ItemStack(PortalCubedItems.HAMMER)), - 70 - ); - scene.idle(10); - scene.overlay.showText(60) - .text("Right-click with a hammer to switch between primary and secondary modes.") - .attachKeyFrame() - .placeNearTarget() - .pointAt(util.vector.centerOf(2, 1, 1)); - scene.world.cycleBlockProperty(new BlockPos(2, 1, 1), AutoPortalBlock.TYPE); - scene.world.cycleBlockProperty(new BlockPos(2, 2, 1), AutoPortalBlock.TYPE); - scene.idle(90); - - scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); - portalLink = scene.world.createEntity(world -> AutoPortalBlock.openOrClosePortal( - world, new BlockPos(2, 1, 1), Direction.NORTH, false, false, false - )); - scene.idle(20); - scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); - scene.idle(30); - scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); - scene.world.modifyEntity(portalLink, Entity::kill); - scene.idle(20); - scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); - - scene.idle(10); - scene.overlay.showControls( - new InputWindowElement(util.vector.centerOf(2, 2, 1), Pointing.RIGHT) - .rightClick() - .withItem(new ItemStack(Items.PURPLE_DYE)), - 70 - ); - scene.idle(10); - scene.overlay.showText(60) - .text("Right-click with dye to change the portal's base color.") - .attachKeyFrame() - .placeNearTarget() - .pointAt(util.vector.centerOf(2, 1, 1)); - scene.world.modifyTileNBT( - util.select.position(2, 1, 1), - AutoPortalBlockEntity.class, - nbt -> nbt.putInt("Color", 0x8932b8) - ); - scene.world.modifyTileNBT( - util.select.position(2, 2, 1), - AutoPortalBlockEntity.class, - nbt -> nbt.putInt("Color", 0x8932b8) - ); - scene.idle(90); - - scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); - portalLink = scene.world.createEntity(world -> AutoPortalBlock.openOrClosePortal( - world, new BlockPos(2, 1, 1), Direction.NORTH, false, false, false - )); - scene.idle(20); - scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); - - scene.overlay.showText(60) - .text("This portal is green because the Auto Portal is still set to secondary.") - .placeNearTarget() - .pointAt(util.vector.centerOf(2, 2, 1)); - scene.idle(80); - - scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); - scene.world.modifyEntity(portalLink, Entity::kill); - scene.idle(20); - scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); - - scene.idle(10); - scene.overlay.showControls( - new InputWindowElement(util.vector.centerOf(2, 2, 1), Pointing.RIGHT) - .rightClick() - .withItem(new ItemStack(PortalCubedItems.HAMMER)) - .whileSneaking(), - 70 - ); - scene.idle(10); - scene.overlay.showText(60) - .text("Sneak right-click with a hammer to reset the portal's base color.") - .attachKeyFrame() - .placeNearTarget() - .pointAt(util.vector.centerOf(2, 1, 1)); - scene.world.modifyTileNBT( - util.select.position(2, 1, 1), - AutoPortalBlockEntity.class, - nbt -> nbt.putInt("Color", 0x1d86db) - ); - scene.world.modifyTileNBT( - util.select.position(2, 2, 1), - AutoPortalBlockEntity.class, - nbt -> nbt.putInt("Color", 0x1d86db) - ); - scene.idle(90); - - scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); - portalLink = scene.world.createEntity(world -> AutoPortalBlock.openOrClosePortal( - world, new BlockPos(2, 1, 1), Direction.NORTH, false, false, false - )); - scene.idle(20); - scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); - scene.idle(30); - scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); - scene.world.modifyEntity(portalLink, Entity::kill); - scene.idle(20); - scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); - } -} +//package com.fusionflux.portalcubed.compat.create; +// +//import com.fusionflux.portalcubed.PortalCubed; +//import com.fusionflux.portalcubed.blocks.AutoPortalBlock; +//import com.fusionflux.portalcubed.blocks.blockentities.AutoPortalBlockEntity; +//import com.fusionflux.portalcubed.items.PortalCubedItems; +//import com.google.gson.GsonBuilder; +//import com.google.gson.JsonObject; +//import com.simibubi.create.foundation.ponder.*; +//import com.simibubi.create.foundation.ponder.element.InputWindowElement; +//import com.simibubi.create.foundation.utility.Pointing; +//import net.minecraft.core.BlockPos; +//import net.minecraft.core.Direction; +//import net.minecraft.world.entity.Entity; +//import net.minecraft.world.item.ItemStack; +//import net.minecraft.world.item.Items; +// +//import java.io.FileWriter; +//import java.io.IOException; +//import java.io.Writer; +//import java.nio.charset.StandardCharsets; +// +//import static com.fusionflux.portalcubed.PortalCubed.id; +// +//public class PCPonder { +// private static final PonderRegistrationHelper HELPER = new PonderRegistrationHelper(PortalCubed.MOD_ID); +// +// public static final PonderTag PORTAL_CUBED = new PonderTag(id("portal_cubed")) +// .item(PortalCubedItems.BLOCK_ITEM_ICON, true, false) +// .addToIndex(); +// +// private static final boolean GENERATE_TRANSLATIONS = false; +// +// public static void register() { +// HELPER.addStoryBoard( +// id("auto_portal"), +// "auto_portal", +// PCPonder::autoPortal, +// PORTAL_CUBED +// ); +// +// if (GENERATE_TRANSLATIONS) { +// PonderLocalization.generateSceneLang(); +// final JsonObject translation = new JsonObject(); +// PonderLocalization.record("portalcubed", translation); +// try (Writer writer = new FileWriter("create_ponder_portalcubed.json", StandardCharsets.UTF_8)) { +// new GsonBuilder().setPrettyPrinting().create().toJson(translation, writer); +// } catch (IOException e) { +// PortalCubed.LOGGER.error("Failed to save file", e); +// } +// } +// } +// +// public static void autoPortal(SceneBuilder scene, SceneBuildingUtil util) { +// scene.title("auto_portal", "Using the Auto Portal"); +// scene.configureBasePlate(0, 0, 4); +// scene.showBasePlate(); +// scene.idle(5); +// +// scene.world.showSection(util.select.position(2, 1, 2), Direction.DOWN); +// scene.idle(5); +// scene.world.showSection(util.select.position(2, 2, 2), Direction.DOWN); +// scene.idle(5); +// scene.world.showSection(util.select.fromTo(2, 1, 1, 2, 2, 1), Direction.SOUTH); +// scene.idle(5); +// scene.world.showSection(util.select.position(1, 2, 2), Direction.EAST); +// scene.idle(5); +// +// scene.overlay.showText(80) +// .text("Power an Auto Portal with redstone to open it.") +// .placeNearTarget() +// .pointAt(util.vector.centerOf(1, 2, 2)); +// scene.idle(60); +// +// scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); +// var portalLink = scene.world.createEntity(world -> AutoPortalBlock.openOrClosePortal( +// world, new BlockPos(2, 1, 1), Direction.NORTH, false, false, false +// )); +// +// scene.idle(20); +// scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); +// scene.idle(20); +// +// scene.overlay.showText(80) +// .text("Power an Auto Portal with redstone again to close it.") +// .placeNearTarget() +// .pointAt(util.vector.centerOf(1, 2, 2)); +// scene.idle(60); +// +// scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); +// scene.world.modifyEntity(portalLink, Entity::kill); +// +// scene.idle(20); +// scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); +// +// scene.overlay.showControls( +// new InputWindowElement(util.vector.centerOf(2, 2, 1), Pointing.RIGHT) +// .rightClick() +// .withItem(new ItemStack(PortalCubedItems.HAMMER)), +// 70 +// ); +// scene.idle(10); +// scene.overlay.showText(60) +// .text("Right-click with a hammer to switch between primary and secondary modes.") +// .attachKeyFrame() +// .placeNearTarget() +// .pointAt(util.vector.centerOf(2, 1, 1)); +// scene.world.cycleBlockProperty(new BlockPos(2, 1, 1), AutoPortalBlock.TYPE); +// scene.world.cycleBlockProperty(new BlockPos(2, 2, 1), AutoPortalBlock.TYPE); +// scene.idle(90); +// +// scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); +// portalLink = scene.world.createEntity(world -> AutoPortalBlock.openOrClosePortal( +// world, new BlockPos(2, 1, 1), Direction.NORTH, false, false, false +// )); +// scene.idle(20); +// scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); +// scene.idle(30); +// scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); +// scene.world.modifyEntity(portalLink, Entity::kill); +// scene.idle(20); +// scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); +// +// scene.idle(10); +// scene.overlay.showControls( +// new InputWindowElement(util.vector.centerOf(2, 2, 1), Pointing.RIGHT) +// .rightClick() +// .withItem(new ItemStack(Items.PURPLE_DYE)), +// 70 +// ); +// scene.idle(10); +// scene.overlay.showText(60) +// .text("Right-click with dye to change the portal's base color.") +// .attachKeyFrame() +// .placeNearTarget() +// .pointAt(util.vector.centerOf(2, 1, 1)); +// scene.world.modifyTileNBT( +// util.select.position(2, 1, 1), +// AutoPortalBlockEntity.class, +// nbt -> nbt.putInt("Color", 0x8932b8) +// ); +// scene.world.modifyTileNBT( +// util.select.position(2, 2, 1), +// AutoPortalBlockEntity.class, +// nbt -> nbt.putInt("Color", 0x8932b8) +// ); +// scene.idle(90); +// +// scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); +// portalLink = scene.world.createEntity(world -> AutoPortalBlock.openOrClosePortal( +// world, new BlockPos(2, 1, 1), Direction.NORTH, false, false, false +// )); +// scene.idle(20); +// scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); +// +// scene.overlay.showText(60) +// .text("This portal is green because the Auto Portal is still set to secondary.") +// .placeNearTarget() +// .pointAt(util.vector.centerOf(2, 2, 1)); +// scene.idle(80); +// +// scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); +// scene.world.modifyEntity(portalLink, Entity::kill); +// scene.idle(20); +// scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); +// +// scene.idle(10); +// scene.overlay.showControls( +// new InputWindowElement(util.vector.centerOf(2, 2, 1), Pointing.RIGHT) +// .rightClick() +// .withItem(new ItemStack(PortalCubedItems.HAMMER)) +// .whileSneaking(), +// 70 +// ); +// scene.idle(10); +// scene.overlay.showText(60) +// .text("Sneak right-click with a hammer to reset the portal's base color.") +// .attachKeyFrame() +// .placeNearTarget() +// .pointAt(util.vector.centerOf(2, 1, 1)); +// scene.world.modifyTileNBT( +// util.select.position(2, 1, 1), +// AutoPortalBlockEntity.class, +// nbt -> nbt.putInt("Color", 0x1d86db) +// ); +// scene.world.modifyTileNBT( +// util.select.position(2, 2, 1), +// AutoPortalBlockEntity.class, +// nbt -> nbt.putInt("Color", 0x1d86db) +// ); +// scene.idle(90); +// +// scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); +// portalLink = scene.world.createEntity(world -> AutoPortalBlock.openOrClosePortal( +// world, new BlockPos(2, 1, 1), Direction.NORTH, false, false, false +// )); +// scene.idle(20); +// scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); +// scene.idle(30); +// scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); +// scene.world.modifyEntity(portalLink, Entity::kill); +// scene.idle(20); +// scene.world.toggleRedstonePower(util.select.position(1, 2, 2)); +// } +//} diff --git a/src/main/java/com/fusionflux/portalcubed/compat/rayon/RayonIntegration.java b/src/main/java/com/fusionflux/portalcubed/compat/rayon/RayonIntegration.java index 50bb0e03..d0b24719 100644 --- a/src/main/java/com/fusionflux/portalcubed/compat/rayon/RayonIntegration.java +++ b/src/main/java/com/fusionflux/portalcubed/compat/rayon/RayonIntegration.java @@ -3,10 +3,10 @@ import com.fusionflux.portalcubed.compat.rayon.absent.RayonIntegrationAbsent; import com.fusionflux.portalcubed.compat.rayon.present.RayonIntegrationPresent; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Vector3f; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.MoverType; import net.minecraft.world.phys.Vec3; +import org.joml.Vector3f; import org.quiltmc.loader.api.QuiltLoader; import org.quiltmc.loader.api.minecraft.ClientOnly; diff --git a/src/main/java/com/fusionflux/portalcubed/compat/rayon/absent/RayonIntegrationAbsent.java b/src/main/java/com/fusionflux/portalcubed/compat/rayon/absent/RayonIntegrationAbsent.java index 07b42cfe..90784a50 100644 --- a/src/main/java/com/fusionflux/portalcubed/compat/rayon/absent/RayonIntegrationAbsent.java +++ b/src/main/java/com/fusionflux/portalcubed/compat/rayon/absent/RayonIntegrationAbsent.java @@ -2,10 +2,11 @@ import com.fusionflux.portalcubed.compat.rayon.RayonIntegration; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Vector3f; +import com.mojang.math.Axis; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.MoverType; import net.minecraft.world.phys.Vec3; +import org.joml.Vector3f; import org.quiltmc.loader.api.minecraft.ClientOnly; public enum RayonIntegrationAbsent implements RayonIntegration { @@ -52,8 +53,8 @@ public void setAngularVelocityYaw(Entity entity, Vector3f angle) { @Override @ClientOnly public void multiplyMatrices(PoseStack matrices, Entity entity, float tickDelta) { - matrices.mulPose(Vector3f.YP.rotationDegrees(180f - entity.getViewYRot(tickDelta))); - matrices.mulPose(Vector3f.XP.rotationDegrees(entity.getViewXRot(tickDelta))); + matrices.mulPose(Axis.YP.rotationDegrees(180f - entity.getViewYRot(tickDelta))); + matrices.mulPose(Axis.XP.rotationDegrees(entity.getViewXRot(tickDelta))); } } diff --git a/src/main/java/com/fusionflux/portalcubed/compat/rayon/present/RayonIntegrationPresent.java b/src/main/java/com/fusionflux/portalcubed/compat/rayon/present/RayonIntegrationPresent.java index 017837b4..d3fe4b1d 100644 --- a/src/main/java/com/fusionflux/portalcubed/compat/rayon/present/RayonIntegrationPresent.java +++ b/src/main/java/com/fusionflux/portalcubed/compat/rayon/present/RayonIntegrationPresent.java @@ -57,7 +57,7 @@ public void setNoGravity(Entity entity, boolean noGravity) { public float getYaw(Entity entity) { if (entity instanceof EntityPhysicsElement physicsElement) { final com.jme3.math.Quaternion q = physicsElement.getRigidBody().getPhysicsRotation(null); - https://stackoverflow.com/a/5783030/8840278 + // https://stackoverflow.com/a/5783030/8840278 return (float)Math.toDegrees(2 * Math.acos(q.getW())); } return entity.getYRot(); @@ -77,7 +77,7 @@ public void rotateYaw(Entity entity, float amount) { } @Override - public void setAngularVelocityYaw(Entity entity, com.mojang.math.Vector3f angle) { + public void setAngularVelocityYaw(Entity entity, org.joml.Vector3f angle) { if (entity instanceof EntityPhysicsElement physicsElement) { physicsElement.getRigidBody().setAngularVelocity(Convert.toBullet(angle)); } diff --git a/src/main/java/com/fusionflux/portalcubed/entity/AdventureCoreEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/AdventureCoreEntity.java index d0ac3a13..6f83f203 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/AdventureCoreEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/AdventureCoreEntity.java @@ -21,7 +21,7 @@ public AdventureCoreEntity(EntityType type, Level world public boolean hurt(DamageSource source, float amount) { if (!this.level.isClientSide && !this.isRemoved()) { boolean bl = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; - if (source.getEntity() instanceof Player || source == DamageSource.OUT_OF_WORLD) { + if (source.getEntity() instanceof Player || source == damageSources().outOfWorld()) { if (source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().mayBuild) { if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !bl) { this.spawnAtLocation(PortalCubedItems.ADVENTURE_CORE); diff --git a/src/main/java/com/fusionflux/portalcubed/entity/AngerCoreEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/AngerCoreEntity.java index 02f23c6e..9f7d5bc5 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/AngerCoreEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/AngerCoreEntity.java @@ -21,7 +21,7 @@ public AngerCoreEntity(EntityType type, Level world) { public boolean hurt(DamageSource source, float amount) { if (!this.level.isClientSide && !this.isRemoved()) { boolean bl = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; - if (source.getEntity() instanceof Player || source == DamageSource.OUT_OF_WORLD) { + if (source.getEntity() instanceof Player || source == damageSources().outOfWorld()) { if (source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().mayBuild) { if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !bl) { this.spawnAtLocation(PortalCubedItems.ANGER_CORE); diff --git a/src/main/java/com/fusionflux/portalcubed/entity/BeansEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/BeansEntity.java index dd2d5322..3bfab2c7 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/BeansEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/BeansEntity.java @@ -18,7 +18,7 @@ public BeansEntity(EntityType type, Level world) { public boolean hurt(DamageSource source, float amount) { if (!this.level.isClientSide && !this.isRemoved()) { boolean bl = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; - if (source.getEntity() instanceof Player || source == DamageSource.OUT_OF_WORLD) { + if (source.getEntity() instanceof Player || source == damageSources().outOfWorld()) { if (source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().mayBuild) { if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !bl) { this.spawnAtLocation(PortalCubedItems.BEANS); diff --git a/src/main/java/com/fusionflux/portalcubed/entity/CakeCoreEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/CakeCoreEntity.java index 591de03d..72c605f3 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/CakeCoreEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/CakeCoreEntity.java @@ -21,7 +21,7 @@ public CakeCoreEntity(EntityType type, Level world) { public boolean hurt(DamageSource source, float amount) { if (!this.level.isClientSide && !this.isRemoved()) { boolean bl = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; - if (source.getEntity() instanceof Player || source == DamageSource.OUT_OF_WORLD) { + if (source.getEntity() instanceof Player || source == damageSources().outOfWorld()) { if (source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().mayBuild) { if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !bl) { this.spawnAtLocation(PortalCubedItems.CAKE_CORE); diff --git a/src/main/java/com/fusionflux/portalcubed/entity/ChairEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/ChairEntity.java index 4ced96ac..cd354bb2 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/ChairEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/ChairEntity.java @@ -18,7 +18,7 @@ public ChairEntity(EntityType type, Level world) { public boolean hurt(DamageSource source, float amount) { if (!this.level.isClientSide && !this.isRemoved()) { boolean bl = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; - if (source.getEntity() instanceof Player || source == DamageSource.OUT_OF_WORLD) { + if (source.getEntity() instanceof Player || source == damageSources().outOfWorld()) { if (source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().mayBuild) { if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !bl) { this.spawnAtLocation(PortalCubedItems.CHAIR); diff --git a/src/main/java/com/fusionflux/portalcubed/entity/CompanionCubeEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/CompanionCubeEntity.java index 8efb1808..f8ac4b13 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/CompanionCubeEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/CompanionCubeEntity.java @@ -22,7 +22,7 @@ public CompanionCubeEntity(EntityType type, Level world public boolean hurt(DamageSource source, float amount) { if (!this.level.isClientSide && !this.isRemoved()) { boolean bl = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; - if (source.getEntity() instanceof Player || source == DamageSource.OUT_OF_WORLD) { + if (source.getEntity() instanceof Player || source == damageSources().outOfWorld()) { if (source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().mayBuild) { if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !bl) { this.spawnAtLocation(PortalCubedItems.COMPANION_CUBE); diff --git a/src/main/java/com/fusionflux/portalcubed/entity/ComputerEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/ComputerEntity.java index 88d3129e..d2827ff8 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/ComputerEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/ComputerEntity.java @@ -18,7 +18,7 @@ public ComputerEntity(EntityType type, Level world) { public boolean hurt(DamageSource source, float amount) { if (!this.level.isClientSide && !this.isRemoved()) { boolean bl = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; - if (source.getEntity() instanceof Player || source == DamageSource.OUT_OF_WORLD) { + if (source.getEntity() instanceof Player || source == damageSources().outOfWorld()) { if (source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().mayBuild) { if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !bl) { this.spawnAtLocation(PortalCubedItems.COMPUTER); diff --git a/src/main/java/com/fusionflux/portalcubed/entity/CoreFrameEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/CoreFrameEntity.java index 60887450..9745470c 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/CoreFrameEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/CoreFrameEntity.java @@ -19,7 +19,7 @@ public CoreFrameEntity(EntityType type, Level world) { public boolean hurt(DamageSource source, float amount) { if (!this.level.isClientSide && !this.isRemoved()) { boolean bl = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; - if (source.getEntity() instanceof Player || source == DamageSource.OUT_OF_WORLD) { + if (source.getEntity() instanceof Player || source == damageSources().outOfWorld()) { if (source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().mayBuild) { if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !bl) { this.spawnAtLocation(PortalCubedItems.CORE_FRAME); diff --git a/src/main/java/com/fusionflux/portalcubed/entity/CorePhysicsEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/CorePhysicsEntity.java index 95a6f1ef..034beb72 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/CorePhysicsEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/CorePhysicsEntity.java @@ -12,7 +12,6 @@ import com.fusionflux.portalcubed.util.AdvancedEntityRaycast; import com.fusionflux.portalcubed.util.PortalCubedComponents; import com.fusionflux.portalcubed.util.PortalDirectionUtils; -import com.mojang.math.Vector3f; import net.minecraft.client.Minecraft; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.protocol.Packet; @@ -35,6 +34,8 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.NotNull; +import org.joml.Vector3f; import org.quiltmc.qsl.networking.api.PacketByteBufs; import org.quiltmc.qsl.networking.api.PlayerLookup; import org.quiltmc.qsl.networking.api.ServerPlayNetworking; @@ -81,14 +82,14 @@ public boolean isPushable() { @Override public boolean isInvulnerableTo(DamageSource damageSource) { - return damageSource != DamageSource.OUT_OF_WORLD && !damageSource.isCreativePlayer(); + return damageSource != damageSources().outOfWorld() && !damageSource.isCreativePlayer(); } @Override public boolean hurt(DamageSource source, float amount) { if (!this.level.isClientSide && !this.isRemoved()) { boolean bl = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; - if (source.getEntity() instanceof Player || source == DamageSource.OUT_OF_WORLD) { + if (source.getEntity() instanceof Player || source == damageSources().outOfWorld()) { if (source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().mayBuild) { if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !bl) { this.spawnAtLocation(PortalCubedItems.STORAGE_CUBE); @@ -256,11 +257,13 @@ public boolean isControlledByLocalInstance() { return !level.isClientSide || getHolderUUID().isPresent(); } + @NotNull @Override public Iterable getArmorSlots() { return Collections.emptyList(); } + @NotNull @Override public ItemStack getItemBySlot(EquipmentSlot slot) { return ItemStack.EMPTY; @@ -270,6 +273,7 @@ public ItemStack getItemBySlot(EquipmentSlot slot) { public void setItemSlot(EquipmentSlot slot, ItemStack stack) { } + @NotNull @Override public HumanoidArm getMainArm() { return HumanoidArm.RIGHT; diff --git a/src/main/java/com/fusionflux/portalcubed/entity/CuriosityCoreEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/CuriosityCoreEntity.java index a4bb863e..bcb11d94 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/CuriosityCoreEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/CuriosityCoreEntity.java @@ -21,7 +21,7 @@ public CuriosityCoreEntity(EntityType type, Level world public boolean hurt(DamageSource source, float amount) { if (!this.level.isClientSide && !this.isRemoved()) { boolean bl = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; - if (source.getEntity() instanceof Player || source == DamageSource.OUT_OF_WORLD) { + if (source.getEntity() instanceof Player || source == damageSources().outOfWorld()) { if (source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().mayBuild) { if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !bl) { this.spawnAtLocation(PortalCubedItems.CURIOSITY_CORE); diff --git a/src/main/java/com/fusionflux/portalcubed/entity/EnergyPelletEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/EnergyPelletEntity.java index 5bb4155d..a1b444c9 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/EnergyPelletEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/EnergyPelletEntity.java @@ -3,13 +3,10 @@ import com.fusionflux.portalcubed.PortalCubedConfig; import com.fusionflux.portalcubed.items.PortalCubedItems; import com.fusionflux.portalcubed.listeners.WentThroughPortalListener; -import com.fusionflux.portalcubed.mechanics.PortalCubedDamageSources; import com.fusionflux.portalcubed.particle.DecalParticleEffect; import com.fusionflux.portalcubed.sound.PortalCubedSounds; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.protocol.Packet; -import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; @@ -32,6 +29,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import static com.fusionflux.portalcubed.mechanics.PortalCubedDamageSources.pcSources; + public class EnergyPelletEntity extends Entity implements ItemSupplier, WentThroughPortalListener { private static final EntityDataAccessor STARTING_LIFE = SynchedEntityData.defineId(EnergyPelletEntity.class, EntityDataSerializers.INT); private static final EntityDataAccessor LIFE = SynchedEntityData.defineId(EnergyPelletEntity.class, EntityDataSerializers.INT); @@ -56,12 +55,6 @@ protected void addAdditionalSaveData(CompoundTag nbt) { nbt.putInt("Life", getLife()); } - @NotNull - @Override - public Packet getAddEntityPacket() { - return new ClientboundAddEntityPacket(this); - } - public int getStartingLife() { return entityData.get(STARTING_LIFE); } @@ -185,7 +178,7 @@ private void bounceOrKill(LivingEntity entity) { private void kill(@Nullable LivingEntity entity) { level.playSound(null, position().x, position().y, position().z, PortalCubedSounds.PELLET_EXPLODE_EVENT, SoundSource.HOSTILE, 0.8f, 1f); if (entity != null) { - entity.hurt(PortalCubedDamageSources.VAPORIZATION, PortalCubedConfig.pelletDamage); + entity.hurt(pcSources(level).vaporization(), PortalCubedConfig.pelletDamage); } kill(); } diff --git a/src/main/java/com/fusionflux/portalcubed/entity/ExperimentalPortal.java b/src/main/java/com/fusionflux/portalcubed/entity/ExperimentalPortal.java index 3721fb63..f8d0c620 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/ExperimentalPortal.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/ExperimentalPortal.java @@ -11,8 +11,6 @@ import net.minecraft.core.Cursor3D; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.protocol.Packet; -import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; @@ -141,12 +139,6 @@ public void setColor(int color) { this.getEntityData().set(COLOR, color); } - @NotNull - @Override - public Packet getAddEntityPacket() { - return new ClientboundAddEntityPacket(this); - } - public Optional getLinkedPortalUUID() { return getEntityData().get(LINKED_PORTAL_UUID); } @@ -295,7 +287,7 @@ private boolean validateBehind() { Mth.floor(portalBox.maxY + EPSILON) + 1, Mth.floor(portalBox.maxZ + EPSILON) + 1 ); - final Direction forward = Direction.fromNormal(new BlockPos(getNormal())); + final Direction forward = Direction.fromNormal(BlockPos.containing(getNormal())); assert forward != null; while (iter.advance()) { final BlockPos pos = new BlockPos(iter.nextX(), iter.nextY(), iter.nextZ()); diff --git a/src/main/java/com/fusionflux/portalcubed/entity/FactCoreEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/FactCoreEntity.java index 6b90f467..1da678f8 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/FactCoreEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/FactCoreEntity.java @@ -21,7 +21,7 @@ public FactCoreEntity(EntityType type, Level world) { public boolean hurt(DamageSource source, float amount) { if (!this.level.isClientSide && !this.isRemoved()) { boolean bl = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; - if (source.getEntity() instanceof Player || source == DamageSource.OUT_OF_WORLD) { + if (source.getEntity() instanceof Player || source == damageSources().outOfWorld()) { if (source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().mayBuild) { if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !bl) { this.spawnAtLocation(PortalCubedItems.FACT_CORE); diff --git a/src/main/java/com/fusionflux/portalcubed/entity/GelBlobEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/GelBlobEntity.java index 50dd0688..f7aa01c0 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/GelBlobEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/GelBlobEntity.java @@ -5,7 +5,7 @@ import com.fusionflux.portalcubed.sound.PortalCubedSounds; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.Tag; import net.minecraft.network.FriendlyByteBuf; @@ -16,7 +16,6 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundSource; import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.damagesource.EntityDamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.player.Player; @@ -162,7 +161,7 @@ protected void onHit(HitResult hitResult) { if (!level.isClientSide) { if (hitResult instanceof EntityHitResult ehr && ehr.getEntity() instanceof ServerPlayer serverPlayer) { final FriendlyByteBuf buf = PacketByteBufs.create(); - buf.writeResourceLocation(Registry.BLOCK.getKey(getGel())); + buf.writeResourceLocation(BuiltInRegistries.BLOCK.getKey(getGel())); ServerPlayNetworking.send( serverPlayer, PortalCubedClientPackets.GEL_OVERLAY_PACKET, @@ -185,7 +184,7 @@ protected void checkFallDamage(double heightDifference, boolean onGround, BlockS public void explode() { level.playSound(null, getX(), getY(), getZ(), PortalCubedSounds.GEL_SPLAT_EVENT, SoundSource.NEUTRAL, 0.5f, 1f); final FriendlyByteBuf buf = PacketByteBufs.create(); - buf.writeResourceLocation(Registry.BLOCK.getKey(getGel())); + buf.writeResourceLocation(BuiltInRegistries.BLOCK.getKey(getGel())); final int overlayDiameter = getSize() + 1; level.getEntities( EntityType.PLAYER, @@ -199,7 +198,7 @@ public void explode() { final int radius = getExplosionRadius(); final Vec3 origin = getBoundingBox().getCenter(); if (radius == 0) { - final BlockPos originPos = new BlockPos(origin); + final BlockPos originPos = BlockPos.containing(origin); for (final Direction dir : Direction.values()) { maybeExplodeAt(new BlockHitResult( origin.add(Vec3.atLowerCornerOf(dir.getNormal())), @@ -237,10 +236,16 @@ private void maybeExplodeAt(BlockHitResult hit) { @Override public boolean hurt(DamageSource source, float amount) { - if (amount != 0 && - (!(source instanceof EntityDamageSource eds) || - (eds.getEntity() instanceof Player player && - player.isCreative())) +// if (amount != 0 && +// (!(source instanceof EntityDamageSource eds) || +// (eds.getEntity() instanceof Player player && +// player.isCreative())) +// ) { + if ( + amount != 0 && + (source.getDirectEntity() == null || + (source.getDirectEntity() instanceof Player player && + player.isCreative())) ) { remove(RemovalReason.KILLED); } diff --git a/src/main/java/com/fusionflux/portalcubed/entity/HoopyEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/HoopyEntity.java index ea5506ca..768891a7 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/HoopyEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/HoopyEntity.java @@ -18,7 +18,7 @@ public HoopyEntity(EntityType type, Level world) { public boolean hurt(DamageSource source, float amount) { if (!this.level.isClientSide && !this.isRemoved()) { boolean bl = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; - if (source.getEntity() instanceof Player || source == DamageSource.OUT_OF_WORLD) { + if (source.getEntity() instanceof Player || source == damageSources().outOfWorld()) { if (source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().mayBuild) { if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !bl) { this.spawnAtLocation(PortalCubedItems.HOOPY); diff --git a/src/main/java/com/fusionflux/portalcubed/entity/JugEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/JugEntity.java index 68d2dddf..67fc690d 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/JugEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/JugEntity.java @@ -18,7 +18,7 @@ public JugEntity(EntityType type, Level world) { public boolean hurt(DamageSource source, float amount) { if (!this.level.isClientSide && !this.isRemoved()) { boolean bl = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; - if (source.getEntity() instanceof Player || source == DamageSource.OUT_OF_WORLD) { + if (source.getEntity() instanceof Player || source == damageSources().outOfWorld()) { if (source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().mayBuild) { if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !bl) { this.spawnAtLocation(PortalCubedItems.JUG); diff --git a/src/main/java/com/fusionflux/portalcubed/entity/LilPineappleEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/LilPineappleEntity.java index 5ce32f72..9416fbd7 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/LilPineappleEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/LilPineappleEntity.java @@ -18,7 +18,7 @@ public LilPineappleEntity(EntityType type, Level world) public boolean hurt(DamageSource source, float amount) { if (!this.level.isClientSide && !this.isRemoved()) { boolean bl = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; - if (source.getEntity() instanceof Player || source == DamageSource.OUT_OF_WORLD) { + if (source.getEntity() instanceof Player || source == damageSources().outOfWorld()) { if (source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().mayBuild) { if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !bl) { this.spawnAtLocation(PortalCubedItems.LIL_PINEAPPLE); diff --git a/src/main/java/com/fusionflux/portalcubed/entity/MoralityCoreEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/MoralityCoreEntity.java index 69169405..0ba46327 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/MoralityCoreEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/MoralityCoreEntity.java @@ -18,7 +18,7 @@ public MoralityCoreEntity(EntityType type, Level world) public boolean hurt(DamageSource source, float amount) { if (!this.level.isClientSide && !this.isRemoved()) { boolean bl = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; - if (source.getEntity() instanceof Player || source == DamageSource.OUT_OF_WORLD) { + if (source.getEntity() instanceof Player || source == damageSources().outOfWorld()) { if (source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().mayBuild) { if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !bl) { this.spawnAtLocation(PortalCubedItems.MORALITY_CORE); diff --git a/src/main/java/com/fusionflux/portalcubed/entity/MugEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/MugEntity.java index c578aec1..d06ce559 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/MugEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/MugEntity.java @@ -53,7 +53,7 @@ protected void defineSynchedData() { public boolean hurt(DamageSource source, float amount) { if (!this.level.isClientSide && !this.isRemoved()) { boolean bl = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; - if (source.getEntity() instanceof Player || source == DamageSource.OUT_OF_WORLD) { + if (source.getEntity() instanceof Player || source == damageSources().outOfWorld()) { if (source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().mayBuild) { if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !bl) { this.spawnAtLocation(PortalCubedItems.MUG); diff --git a/src/main/java/com/fusionflux/portalcubed/entity/OldApCubeEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/OldApCubeEntity.java index 1f6b5e0a..3b784115 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/OldApCubeEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/OldApCubeEntity.java @@ -18,7 +18,7 @@ public OldApCubeEntity(EntityType type, Level world) { public boolean hurt(DamageSource source, float amount) { if (!this.level.isClientSide && !this.isRemoved()) { boolean bl = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; - if (source.getEntity() instanceof Player || source == DamageSource.OUT_OF_WORLD) { + if (source.getEntity() instanceof Player || source == damageSources().outOfWorld()) { if (source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().mayBuild) { if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !bl) { this.spawnAtLocation(PortalCubedItems.OLD_AP_CUBE); diff --git a/src/main/java/com/fusionflux/portalcubed/entity/Portal1CompanionCubeEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/Portal1CompanionCubeEntity.java index 5490310e..31150e61 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/Portal1CompanionCubeEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/Portal1CompanionCubeEntity.java @@ -1,7 +1,6 @@ package com.fusionflux.portalcubed.entity; import com.fusionflux.portalcubed.items.PortalCubedItems; -import com.fusionflux.portalcubed.mechanics.PortalCubedDamageSources; import net.minecraft.core.BlockPos; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; @@ -14,6 +13,8 @@ import java.util.List; +import static com.fusionflux.portalcubed.mechanics.PortalCubedDamageSources.pcSources; + public class Portal1CompanionCubeEntity extends CorePhysicsEntity { public Portal1CompanionCubeEntity(EntityType type, Level world) { super(type, world); @@ -24,7 +25,7 @@ public Portal1CompanionCubeEntity(EntityType type, Leve public boolean hurt(DamageSource source, float amount) { if (!this.level.isClientSide && !this.isRemoved()) { boolean bl = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; - if (source.getEntity() instanceof Player || source == DamageSource.OUT_OF_WORLD) { + if (source.getEntity() instanceof Player || source == damageSources().outOfWorld()) { if (source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().mayBuild) { if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !bl) { this.spawnAtLocation(PortalCubedItems.PORTAL_1_COMPANION_CUBE); @@ -48,7 +49,7 @@ protected void checkFallDamage(double heightDifference, boolean onGround, BlockS if (onGround && landedState.isAir()) { final List collisions = level.getEntitiesOfClass(Entity.class, getBoundingBox().expandTowards(0, -0.1, 0), this::canCollideWith); for (final Entity collision : collisions) { - collision.causeFallDamage(fallDistance + 3, 1.5f, PortalCubedDamageSources.CUBE); + collision.causeFallDamage(fallDistance + 3, 1.5f, pcSources(level).cube()); } } super.checkFallDamage(heightDifference, onGround, landedState, landedPosition); diff --git a/src/main/java/com/fusionflux/portalcubed/entity/Portal1StorageCubeEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/Portal1StorageCubeEntity.java index df4ca51e..e3a900ba 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/Portal1StorageCubeEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/Portal1StorageCubeEntity.java @@ -1,7 +1,6 @@ package com.fusionflux.portalcubed.entity; import com.fusionflux.portalcubed.items.PortalCubedItems; -import com.fusionflux.portalcubed.mechanics.PortalCubedDamageSources; import net.minecraft.core.BlockPos; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; @@ -14,6 +13,8 @@ import java.util.List; +import static com.fusionflux.portalcubed.mechanics.PortalCubedDamageSources.pcSources; + public class Portal1StorageCubeEntity extends CorePhysicsEntity { public Portal1StorageCubeEntity(EntityType type, Level world) { super(type, world); @@ -24,7 +25,7 @@ public Portal1StorageCubeEntity(EntityType type, Level public boolean hurt(DamageSource source, float amount) { if (!this.level.isClientSide && !this.isRemoved()) { boolean bl = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; - if (source.getEntity() instanceof Player || source == DamageSource.OUT_OF_WORLD) { + if (source.getEntity() instanceof Player || source == damageSources().outOfWorld()) { if (source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().mayBuild) { if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !bl) { this.spawnAtLocation(PortalCubedItems.PORTAL_1_STORAGE_CUBE); @@ -48,7 +49,7 @@ protected void checkFallDamage(double heightDifference, boolean onGround, BlockS if (onGround && landedState.isAir()) { final List collisions = level.getEntitiesOfClass(Entity.class, getBoundingBox().expandTowards(0, -0.1, 0), this::canCollideWith); for (final Entity collision : collisions) { - collision.causeFallDamage(fallDistance + 3, 1.5f, PortalCubedDamageSources.CUBE); + collision.causeFallDamage(fallDistance + 3, 1.5f, pcSources(level).cube()); } } super.checkFallDamage(heightDifference, onGround, landedState, landedPosition); diff --git a/src/main/java/com/fusionflux/portalcubed/entity/PortalCubedEntities.java b/src/main/java/com/fusionflux/portalcubed/entity/PortalCubedEntities.java index f209233f..bd2214b0 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/PortalCubedEntities.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/PortalCubedEntities.java @@ -3,6 +3,7 @@ import com.fusionflux.portalcubed.blocks.BaseGel; import com.fusionflux.portalcubed.blocks.PortalCubedBlocks; import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.EntityDimensions; import net.minecraft.world.entity.EntityType; @@ -128,41 +129,41 @@ PortalCubedBlocks.REFLECTION_GEL, id("textures/block/reflection_gel.png") .build(); public static void registerEntities() { - Registry.register(Registry.ENTITY_TYPE, id("experimental_portal"), EXPERIMENTAL_PORTAL); - Registry.register(Registry.ENTITY_TYPE, id("storage_cube"), STORAGE_CUBE); - Registry.register(Registry.ENTITY_TYPE, id("companion_cube"), COMPANION_CUBE); - Registry.register(Registry.ENTITY_TYPE, id("radio"), RADIO); - Registry.register(Registry.ENTITY_TYPE, id("redirection_cube"), REDIRECTION_CUBE); - Registry.register(Registry.ENTITY_TYPE, id("old_ap_cube"), OLD_AP_CUBE); - Registry.register(Registry.ENTITY_TYPE, id("portal_1_companion_cube"), PORTAL_1_COMPANION_CUBE); - Registry.register(Registry.ENTITY_TYPE, id("portal_1_storage_cube"), PORTAL_1_STORAGE_CUBE); - Registry.register(Registry.ENTITY_TYPE, id("beans"), BEANS); - Registry.register(Registry.ENTITY_TYPE, id("mug"), MUG); - Registry.register(Registry.ENTITY_TYPE, id("jug"), JUG); - Registry.register(Registry.ENTITY_TYPE, id("computer"), COMPUTER); - Registry.register(Registry.ENTITY_TYPE, id("chair"), CHAIR); - Registry.register(Registry.ENTITY_TYPE, id("lil_pineapple"), LIL_PINEAPPLE); - Registry.register(Registry.ENTITY_TYPE, id("hoopy"), HOOPY); - Registry.register(Registry.ENTITY_TYPE, id("core_frame"), CORE_FRAME); - Registry.register(Registry.ENTITY_TYPE, id("anger_core"), ANGER_CORE); - Registry.register(Registry.ENTITY_TYPE, id("intelligence_core"), CAKE_CORE); - Registry.register(Registry.ENTITY_TYPE, id("curiosity_core"), CURIOSITY_CORE); - Registry.register(Registry.ENTITY_TYPE, id("morality_core"), MORALITY_CORE); - Registry.register(Registry.ENTITY_TYPE, id("space_core"), SPACE_CORE); - Registry.register(Registry.ENTITY_TYPE, id("adventure_core"), ADVENTURE_CORE); - Registry.register(Registry.ENTITY_TYPE, id("fact_core"), FACT_CORE); - - Registry.register(Registry.ENTITY_TYPE, id("propulsion_gel_blob"), PROPULSION_GEL_BLOB); - Registry.register(Registry.ENTITY_TYPE, id("repulsion_gel_blob"), REPULSION_GEL_BLOB); - Registry.register(Registry.ENTITY_TYPE, id("adhesion_gel_blob"), ADHESION_GEL_BLOB); - Registry.register(Registry.ENTITY_TYPE, id("conversion_gel_blob"), CONVERSION_GEL_BLOB); - Registry.register(Registry.ENTITY_TYPE, id("reflection_gel_blob"), REFLECTION_GEL_BLOB); - - Registry.register(Registry.ENTITY_TYPE, id("rocket"), ROCKET); - - Registry.register(Registry.ENTITY_TYPE, id("energy_pellet"), ENERGY_PELLET); - - Registry.register(Registry.ENTITY_TYPE, id("turret"), TURRET); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("experimental_portal"), EXPERIMENTAL_PORTAL); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("storage_cube"), STORAGE_CUBE); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("companion_cube"), COMPANION_CUBE); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("radio"), RADIO); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("redirection_cube"), REDIRECTION_CUBE); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("old_ap_cube"), OLD_AP_CUBE); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("portal_1_companion_cube"), PORTAL_1_COMPANION_CUBE); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("portal_1_storage_cube"), PORTAL_1_STORAGE_CUBE); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("beans"), BEANS); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("mug"), MUG); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("jug"), JUG); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("computer"), COMPUTER); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("chair"), CHAIR); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("lil_pineapple"), LIL_PINEAPPLE); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("hoopy"), HOOPY); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("core_frame"), CORE_FRAME); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("anger_core"), ANGER_CORE); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("intelligence_core"), CAKE_CORE); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("curiosity_core"), CURIOSITY_CORE); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("morality_core"), MORALITY_CORE); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("space_core"), SPACE_CORE); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("adventure_core"), ADVENTURE_CORE); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("fact_core"), FACT_CORE); + + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("propulsion_gel_blob"), PROPULSION_GEL_BLOB); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("repulsion_gel_blob"), REPULSION_GEL_BLOB); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("adhesion_gel_blob"), ADHESION_GEL_BLOB); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("conversion_gel_blob"), CONVERSION_GEL_BLOB); + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("reflection_gel_blob"), REFLECTION_GEL_BLOB); + + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("rocket"), ROCKET); + + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("energy_pellet"), ENERGY_PELLET); + + Registry.register(BuiltInRegistries.ENTITY_TYPE, id("turret"), TURRET); DefaultAttributes.SUPPLIERS.put(STORAGE_CUBE, StorageCubeEntity.createMobAttributes().build()); DefaultAttributes.SUPPLIERS.put(COMPANION_CUBE, CompanionCubeEntity.createMobAttributes().build()); diff --git a/src/main/java/com/fusionflux/portalcubed/entity/PortalCubedTrackedDataHandlers.java b/src/main/java/com/fusionflux/portalcubed/entity/PortalCubedTrackedDataHandlers.java index 6b6db0e3..f55fdb50 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/PortalCubedTrackedDataHandlers.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/PortalCubedTrackedDataHandlers.java @@ -1,10 +1,10 @@ package com.fusionflux.portalcubed.entity; -import com.mojang.math.Quaternion; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.syncher.EntityDataSerializer; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.phys.Vec3; +import org.joml.Quaternionf; import org.quiltmc.qsl.entity.networking.api.tracked_data.QuiltTrackedDataHandlerRegistry; import java.util.Optional; @@ -13,14 +13,14 @@ public class PortalCubedTrackedDataHandlers { - public static final EntityDataSerializer QUATERNION = EntityDataSerializer.simple( + public static final EntityDataSerializer QUATERNION = EntityDataSerializer.simple( (buf, value) -> { - buf.writeFloat(value.i()); - buf.writeFloat(value.j()); - buf.writeFloat(value.k()); - buf.writeFloat(value.r()); + buf.writeFloat(value.x()); + buf.writeFloat(value.y()); + buf.writeFloat(value.z()); + buf.writeFloat(value.w()); }, - buf -> new Quaternion(buf.readFloat(), buf.readFloat(), buf.readFloat(), buf.readFloat()) + buf -> new Quaternionf(buf.readFloat(), buf.readFloat(), buf.readFloat(), buf.readFloat()) ); public static final EntityDataSerializer VEC3D = EntityDataSerializer.simple( diff --git a/src/main/java/com/fusionflux/portalcubed/entity/RadioEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/RadioEntity.java index b61369f2..39ad3141 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/RadioEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/RadioEntity.java @@ -56,7 +56,7 @@ protected void defineSynchedData() { public boolean hurt(DamageSource source, float amount) { if (!this.level.isClientSide && !this.isRemoved()) { boolean bl = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; - if (source.getEntity() instanceof Player || source == DamageSource.OUT_OF_WORLD) { + if (source.getEntity() instanceof Player || source == damageSources().outOfWorld()) { if (source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().mayBuild) { if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !bl) { this.spawnAtLocation(PortalCubedItems.RADIO); diff --git a/src/main/java/com/fusionflux/portalcubed/entity/RedirectionCubeEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/RedirectionCubeEntity.java index d66bfda9..72bee638 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/RedirectionCubeEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/RedirectionCubeEntity.java @@ -18,7 +18,7 @@ public RedirectionCubeEntity(EntityType type, Level wor public boolean hurt(DamageSource source, float amount) { if (!this.level.isClientSide && !this.isRemoved()) { boolean bl = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; - if (source.getEntity() instanceof Player || source == DamageSource.OUT_OF_WORLD) { + if (source.getEntity() instanceof Player || source == damageSources().outOfWorld()) { if (source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().mayBuild) { if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !bl) { this.spawnAtLocation(PortalCubedItems.REDIRECTION_CUBE); diff --git a/src/main/java/com/fusionflux/portalcubed/entity/RocketEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/RocketEntity.java index 0f54bb39..75219c88 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/RocketEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/RocketEntity.java @@ -1,7 +1,7 @@ package com.fusionflux.portalcubed.entity; -import com.fusionflux.portalcubed.client.packet.PortalCubedClientPackets; import com.fusionflux.portalcubed.PortalCubedConfig; +import com.fusionflux.portalcubed.client.packet.PortalCubedClientPackets; import com.fusionflux.portalcubed.fluids.PortalCubedFluids; import com.fusionflux.portalcubed.sound.PortalCubedSounds; import net.minecraft.client.Minecraft; @@ -9,10 +9,9 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.protocol.Packet; -import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundSource; -import net.minecraft.world.damagesource.IndirectEntityDamageSource; +import net.minecraft.world.damagesource.DamageTypes; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; @@ -52,12 +51,6 @@ protected void readAdditionalSaveData(@NotNull CompoundTag nbt) { protected void addAdditionalSaveData(@NotNull CompoundTag nbt) { } - @NotNull - @Override - public Packet getAddEntityPacket() { - return new ClientboundAddEntityPacket(this); - } - @Override public void tick() { super.tick(); @@ -134,7 +127,7 @@ protected boolean canHit(Entity entity) { public void explode(@Nullable LivingEntity entity) { if (entity != null) { entity.hurt( - new IndirectEntityDamageSource("fireworks", this, null).setExplosion(), + damageSources().source(DamageTypes.FIREWORKS, this), PortalCubedConfig.rocketDamage ); } diff --git a/src/main/java/com/fusionflux/portalcubed/entity/SpaceCoreEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/SpaceCoreEntity.java index 0dff80e7..eb904ad1 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/SpaceCoreEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/SpaceCoreEntity.java @@ -21,7 +21,7 @@ public SpaceCoreEntity(EntityType type, Level world) { public boolean hurt(DamageSource source, float amount) { if (!this.level.isClientSide && !this.isRemoved()) { boolean bl = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; - if (source.getEntity() instanceof Player || source == DamageSource.OUT_OF_WORLD) { + if (source.getEntity() instanceof Player || source == damageSources().outOfWorld()) { if (source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().mayBuild) { if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !bl) { this.spawnAtLocation(PortalCubedItems.SPACE_CORE); diff --git a/src/main/java/com/fusionflux/portalcubed/entity/StorageCubeEntity.java b/src/main/java/com/fusionflux/portalcubed/entity/StorageCubeEntity.java index afb72c35..d113b76b 100644 --- a/src/main/java/com/fusionflux/portalcubed/entity/StorageCubeEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/entity/StorageCubeEntity.java @@ -20,7 +20,7 @@ public StorageCubeEntity(EntityType type, Level world) public boolean hurt(DamageSource source, float amount) { if (!this.level.isClientSide && !this.isRemoved()) { boolean bl = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; - if (source.getEntity() instanceof Player || source == DamageSource.OUT_OF_WORLD) { + if (source.getEntity() instanceof Player || source == damageSources().outOfWorld()) { if (source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().mayBuild) { if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !bl) { this.spawnAtLocation(PortalCubedItems.STORAGE_CUBE); diff --git a/src/main/java/com/fusionflux/portalcubed/fluids/PortalCubedFluids.java b/src/main/java/com/fusionflux/portalcubed/fluids/PortalCubedFluids.java index 867f452c..63d01daf 100644 --- a/src/main/java/com/fusionflux/portalcubed/fluids/PortalCubedFluids.java +++ b/src/main/java/com/fusionflux/portalcubed/fluids/PortalCubedFluids.java @@ -1,8 +1,8 @@ package com.fusionflux.portalcubed.fluids; -import com.fusionflux.portalcubed.PortalCubed; import com.google.common.base.Suppliers; import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.item.BucketItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; @@ -25,7 +25,7 @@ public class PortalCubedFluids { ); private static FluidRegistryContainer createFluid(String name, FlowingFluid flowing, FlowingFluid still, Function blockSupplier) { - return new FluidRegistryContainer(name, flowing, still, blockSupplier, new BucketItem(still, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP).craftRemainder(Items.BUCKET).stacksTo(1))); + return new FluidRegistryContainer(name, flowing, still, blockSupplier, new BucketItem(still, new QuiltItemSettings().craftRemainder(Items.BUCKET).stacksTo(1))); } public static void registerFluids() { @@ -49,10 +49,10 @@ private FluidRegistryContainer(String name, FlowingFluid flowing, FlowingFluid s } private void register() { - Registry.register(Registry.FLUID, id("flowing_" + name), flowing); - Registry.register(Registry.FLUID, id(name), still); - Registry.register(Registry.BLOCK, id(name), block.get()); - if (bucket != null) Registry.register(Registry.ITEM, id(name + "_bucket"), bucket); + Registry.register(BuiltInRegistries.FLUID, id("flowing_" + name), flowing); + Registry.register(BuiltInRegistries.FLUID, id(name), still); + Registry.register(BuiltInRegistries.BLOCK, id(name), block.get()); + if (bucket != null) Registry.register(BuiltInRegistries.ITEM, id(name + "_bucket"), bucket); } public LiquidBlock getBlock() { diff --git a/src/main/java/com/fusionflux/portalcubed/fluids/ToxicGooFluid.java b/src/main/java/com/fusionflux/portalcubed/fluids/ToxicGooFluid.java index b14bdda8..a3ad3641 100644 --- a/src/main/java/com/fusionflux/portalcubed/fluids/ToxicGooFluid.java +++ b/src/main/java/com/fusionflux/portalcubed/fluids/ToxicGooFluid.java @@ -1,7 +1,6 @@ package com.fusionflux.portalcubed.fluids; import com.fusionflux.portalcubed.entity.Fizzleable; -import com.fusionflux.portalcubed.mechanics.PortalCubedDamageSources; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.entity.Entity; @@ -17,23 +16,30 @@ import net.minecraft.world.level.material.FlowingFluid; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.FluidState; +import org.jetbrains.annotations.NotNull; + +import static com.fusionflux.portalcubed.mechanics.PortalCubedDamageSources.pcSources; public abstract class ToxicGooFluid extends FlowingFluid { + @NotNull @Override public Fluid getSource() { return PortalCubedFluids.TOXIC_GOO.still; } + @NotNull @Override public Fluid getFlowing() { return PortalCubedFluids.TOXIC_GOO.flowing; } + @NotNull @Override public Item getBucket() { return PortalCubedFluids.TOXIC_GOO.bucket; } + @NotNull @Override protected BlockState createLegacyBlock(FluidState state) { return PortalCubedFluids.TOXIC_GOO.getBlock().defaultBlockState().setValue(BlockStateProperties.LEVEL, getLegacyLevel(state)); @@ -45,7 +51,7 @@ public boolean isSame(Fluid fluid) { } @Override - protected boolean canConvertToSource() { + protected boolean canConvertToSource(Level level) { return true; } @@ -116,14 +122,14 @@ public Block(FlowingFluid flowableFluid, Properties settings) { @Override @SuppressWarnings("deprecation") - public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { + public void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { if (!entity.isAlive()) return; if (entity instanceof Fizzleable fizzleable) { - if (!world.isClientSide && fizzleable.fizzlesInGoo()) { + if (!level.isClientSide && fizzleable.fizzlesInGoo()) { fizzleable.fizzle(); } } else { - entity.hurt(PortalCubedDamageSources.ACID, world.getRandom().nextIntBetweenInclusive(7, 10)); + entity.hurt(pcSources(level).acid(), level.getRandom().nextIntBetweenInclusive(7, 10)); } } } diff --git a/src/main/java/com/fusionflux/portalcubed/items/PortalArmor.java b/src/main/java/com/fusionflux/portalcubed/items/PortalArmor.java index 96afe38f..2af17615 100644 --- a/src/main/java/com/fusionflux/portalcubed/items/PortalArmor.java +++ b/src/main/java/com/fusionflux/portalcubed/items/PortalArmor.java @@ -3,7 +3,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; -import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.ArmorMaterial; import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.Ingredient; @@ -18,13 +18,13 @@ public class PortalArmor implements ArmorMaterial { private static final int[] PROTECTION_VALUES = new int[]{3, 6, 8, 3}; @Override - public int getDurabilityForSlot(EquipmentSlot slot) { - return BASE_DURABILITY[slot.getIndex()] * 37; + public int getDurabilityForType(ArmorItem.Type type) { + return BASE_DURABILITY[type.getSlot().getIndex()] * 37; } @Override - public int getDefenseForSlot(EquipmentSlot slot) { - return PROTECTION_VALUES[slot.getIndex()]; + public int getDefenseForType(ArmorItem.Type type) { + return PROTECTION_VALUES[type.getSlot().getIndex()]; } @Override @@ -32,16 +32,19 @@ public int getEnchantmentValue() { return 15; } + @NotNull @Override public SoundEvent getEquipSound() { return SoundEvents.ARMOR_EQUIP_NETHERITE; } + @NotNull @Override public Ingredient getRepairIngredient() { return Ingredient.of(Items.NETHERITE_INGOT); } + @NotNull @Override public String getName() { return "portal_armor"; diff --git a/src/main/java/com/fusionflux/portalcubed/items/PortalCubedItems.java b/src/main/java/com/fusionflux/portalcubed/items/PortalCubedItems.java index dae86233..fbdd320a 100644 --- a/src/main/java/com/fusionflux/portalcubed/items/PortalCubedItems.java +++ b/src/main/java/com/fusionflux/portalcubed/items/PortalCubedItems.java @@ -1,125 +1,124 @@ package com.fusionflux.portalcubed.items; -import com.fusionflux.portalcubed.PortalCubed; import com.fusionflux.portalcubed.entity.PortalCubedEntities; import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; -import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.item.*; import net.minecraft.world.level.block.DispenserBlock; import org.quiltmc.qsl.item.setting.api.QuiltItemSettings; import org.quiltmc.qsl.tag.api.QuiltTagKey; import org.quiltmc.qsl.tag.api.TagType; -import static com.fusionflux.portalcubed.PortalCubed.TESTING_ELEMENTS_GROUP; import static com.fusionflux.portalcubed.PortalCubed.id; public class PortalCubedItems { public static final ArmorMaterial PORTAL_ARMOR = new PortalArmor(); - public static final Item LONG_FALL_BOOTS = new ArmorItem(PORTAL_ARMOR, EquipmentSlot.FEET, new Item.Properties().tab(PortalCubed.TESTING_ELEMENTS_GROUP).fireResistant()); - public static final PortalGun PORTAL_GUN = new PortalGun(new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP).stacksTo(1).fireResistant()); + public static final Item LONG_FALL_BOOTS = new ArmorItem(PORTAL_ARMOR, ArmorItem.Type.BOOTS, new Item.Properties().fireResistant()); + public static final PortalGun PORTAL_GUN = new PortalGun(new QuiltItemSettings().stacksTo(1).fireResistant()); - public static final PortalGunPrimary PORTAL_GUN_PRIMARY = new PortalGunPrimary(new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP).stacksTo(1).fireResistant()); + public static final PortalGunPrimary PORTAL_GUN_PRIMARY = new PortalGunPrimary(new QuiltItemSettings().stacksTo(1).fireResistant()); - public static final PortalGunSecondary PORTAL_GUN_SECONDARY = new PortalGunSecondary(new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP).stacksTo(1).fireResistant()); + public static final PortalGunSecondary PORTAL_GUN_SECONDARY = new PortalGunSecondary(new QuiltItemSettings().stacksTo(1).fireResistant()); - public static final PaintGun PAINT_GUN = new PaintGun(new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP).stacksTo(1).fireResistant()); + public static final PaintGun PAINT_GUN = new PaintGun(new QuiltItemSettings().stacksTo(1).fireResistant()); - public static final Item PORTAL_GUN_FRAME = new Item(new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP).stacksTo(1).fireResistant()); - public static final Item PORTAL_GUN_CASING = new Item(new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP).stacksTo(1).fireResistant()); - public static final Item MINI_BLACKHOLE = new Item(new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP).stacksTo(1).fireResistant()); + public static final Item PORTAL_GUN_FRAME = new Item(new QuiltItemSettings().stacksTo(1).fireResistant()); + public static final Item PORTAL_GUN_CASING = new Item(new QuiltItemSettings().stacksTo(1).fireResistant()); + public static final Item MINI_BLACKHOLE = new Item(new QuiltItemSettings().stacksTo(1).fireResistant()); public static final Item BLOCK_ITEM_ICON = new Item(new QuiltItemSettings().stacksTo(1).fireResistant()); - public static final SpawnEggItem STORAGE_CUBE = new SpawnEggItem(PortalCubedEntities.STORAGE_CUBE, 1, 1, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP)); - public static final SpawnEggItem COMPANION_CUBE = new SpawnEggItem(PortalCubedEntities.COMPANION_CUBE, 1, 1, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP)); - public static final SpawnEggItem RADIO = new SpawnEggItem(PortalCubedEntities.RADIO, 1, 1, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP)); - public static final SpawnEggItem REDIRECTION_CUBE = new SpawnEggItem(PortalCubedEntities.REDIRECTION_CUBE, 1, 1, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP)); - public static final SpawnEggItem OLD_AP_CUBE = new SpawnEggItem(PortalCubedEntities.OLD_AP_CUBE, 1, 1, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP)); - public static final SpawnEggItem PORTAL_1_COMPANION_CUBE = new SpawnEggItem(PortalCubedEntities.PORTAL_1_COMPANION_CUBE, 1, 1, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP)); - public static final SpawnEggItem PORTAL_1_STORAGE_CUBE = new SpawnEggItem(PortalCubedEntities.PORTAL_1_STORAGE_CUBE, 1, 1, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP)); - public static final SpawnEggItem LIL_PINEAPPLE = new SpawnEggItem(PortalCubedEntities.LIL_PINEAPPLE, 1, 1, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP)); + public static final SpawnEggItem STORAGE_CUBE = new SpawnEggItem(PortalCubedEntities.STORAGE_CUBE, 1, 1, new QuiltItemSettings()); + public static final SpawnEggItem COMPANION_CUBE = new SpawnEggItem(PortalCubedEntities.COMPANION_CUBE, 1, 1, new QuiltItemSettings()); + public static final SpawnEggItem RADIO = new SpawnEggItem(PortalCubedEntities.RADIO, 1, 1, new QuiltItemSettings()); + public static final SpawnEggItem REDIRECTION_CUBE = new SpawnEggItem(PortalCubedEntities.REDIRECTION_CUBE, 1, 1, new QuiltItemSettings()); + public static final SpawnEggItem OLD_AP_CUBE = new SpawnEggItem(PortalCubedEntities.OLD_AP_CUBE, 1, 1, new QuiltItemSettings()); + public static final SpawnEggItem PORTAL_1_COMPANION_CUBE = new SpawnEggItem(PortalCubedEntities.PORTAL_1_COMPANION_CUBE, 1, 1, new QuiltItemSettings()); + public static final SpawnEggItem PORTAL_1_STORAGE_CUBE = new SpawnEggItem(PortalCubedEntities.PORTAL_1_STORAGE_CUBE, 1, 1, new QuiltItemSettings()); + public static final SpawnEggItem LIL_PINEAPPLE = new SpawnEggItem(PortalCubedEntities.LIL_PINEAPPLE, 1, 1, new QuiltItemSettings()); - public static final SpawnEggItem BEANS = new SpawnEggItem(PortalCubedEntities.BEANS, 1, 1, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP)); - public static final SpawnEggItem MUG = new SpawnEggItem(PortalCubedEntities.MUG, 1, 1, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP)); - public static final SpawnEggItem JUG = new SpawnEggItem(PortalCubedEntities.JUG, 1, 1, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP)); - public static final SpawnEggItem COMPUTER = new SpawnEggItem(PortalCubedEntities.COMPUTER, 1, 1, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP)); - public static final SpawnEggItem CHAIR = new SpawnEggItem(PortalCubedEntities.CHAIR, 1, 1, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP)); - public static final SpawnEggItem HOOPY = new SpawnEggItem(PortalCubedEntities.HOOPY, 1, 1, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP)); + public static final SpawnEggItem BEANS = new SpawnEggItem(PortalCubedEntities.BEANS, 1, 1, new QuiltItemSettings()); + public static final SpawnEggItem MUG = new SpawnEggItem(PortalCubedEntities.MUG, 1, 1, new QuiltItemSettings()); + public static final SpawnEggItem JUG = new SpawnEggItem(PortalCubedEntities.JUG, 1, 1, new QuiltItemSettings()); + public static final SpawnEggItem COMPUTER = new SpawnEggItem(PortalCubedEntities.COMPUTER, 1, 1, new QuiltItemSettings()); + public static final SpawnEggItem CHAIR = new SpawnEggItem(PortalCubedEntities.CHAIR, 1, 1, new QuiltItemSettings()); + public static final SpawnEggItem HOOPY = new SpawnEggItem(PortalCubedEntities.HOOPY, 1, 1, new QuiltItemSettings()); - public static final SpawnEggItem CORE_FRAME = new SpawnEggItem(PortalCubedEntities.CORE_FRAME, 1, 1, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP)); - public static final SpawnEggItem ANGER_CORE = new SpawnEggItem(PortalCubedEntities.ANGER_CORE, 1, 1, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP)); - public static final SpawnEggItem MORALITY_CORE = new SpawnEggItem(PortalCubedEntities.MORALITY_CORE, 1, 1, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP)); - public static final SpawnEggItem CAKE_CORE = new SpawnEggItem(PortalCubedEntities.CAKE_CORE, 1, 1, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP)); - public static final SpawnEggItem CURIOSITY_CORE = new SpawnEggItem(PortalCubedEntities.CURIOSITY_CORE, 1, 1, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP)); + public static final SpawnEggItem CORE_FRAME = new SpawnEggItem(PortalCubedEntities.CORE_FRAME, 1, 1, new QuiltItemSettings()); + public static final SpawnEggItem ANGER_CORE = new SpawnEggItem(PortalCubedEntities.ANGER_CORE, 1, 1, new QuiltItemSettings()); + public static final SpawnEggItem MORALITY_CORE = new SpawnEggItem(PortalCubedEntities.MORALITY_CORE, 1, 1, new QuiltItemSettings()); + public static final SpawnEggItem CAKE_CORE = new SpawnEggItem(PortalCubedEntities.CAKE_CORE, 1, 1, new QuiltItemSettings()); + public static final SpawnEggItem CURIOSITY_CORE = new SpawnEggItem(PortalCubedEntities.CURIOSITY_CORE, 1, 1, new QuiltItemSettings()); - public static final SpawnEggItem SPACE_CORE = new SpawnEggItem(PortalCubedEntities.SPACE_CORE, 1, 1, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP)); - public static final SpawnEggItem FACT_CORE = new SpawnEggItem(PortalCubedEntities.FACT_CORE, 1, 1, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP)); - public static final SpawnEggItem ADVENTURE_CORE = new SpawnEggItem(PortalCubedEntities.ADVENTURE_CORE, 1, 1, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP)); - public static final SpawnEggItem TURRET = new SpawnEggItem(PortalCubedEntities.TURRET, 1, 1, new QuiltItemSettings().tab(PortalCubed.TESTING_ELEMENTS_GROUP)); + public static final SpawnEggItem SPACE_CORE = new SpawnEggItem(PortalCubedEntities.SPACE_CORE, 1, 1, new QuiltItemSettings()); + public static final SpawnEggItem FACT_CORE = new SpawnEggItem(PortalCubedEntities.FACT_CORE, 1, 1, new QuiltItemSettings()); + public static final SpawnEggItem ADVENTURE_CORE = new SpawnEggItem(PortalCubedEntities.ADVENTURE_CORE, 1, 1, new QuiltItemSettings()); + public static final SpawnEggItem TURRET = new SpawnEggItem(PortalCubedEntities.TURRET, 1, 1, new QuiltItemSettings()); - public static final Item HAMMER = new Item(new QuiltItemSettings().tab(TESTING_ELEMENTS_GROUP).stacksTo(1)); + public static final Item HAMMER = new Item(new QuiltItemSettings().stacksTo(1)); - public static final EnergyPelletItem ENERGY_PELLET = new EnergyPelletItem(new QuiltItemSettings().tab(TESTING_ELEMENTS_GROUP), false); - public static final EnergyPelletItem SUPER_PELLET = new EnergyPelletItem(new QuiltItemSettings().tab(TESTING_ELEMENTS_GROUP), true); + public static final EnergyPelletItem ENERGY_PELLET = new EnergyPelletItem(new QuiltItemSettings(), false); + public static final EnergyPelletItem SUPER_PELLET = new EnergyPelletItem(new QuiltItemSettings(), true); - public static final CrowbarItem CROWBAR = new CrowbarItem(new QuiltItemSettings().tab(TESTING_ELEMENTS_GROUP)); + public static final CrowbarItem CROWBAR = new CrowbarItem(new QuiltItemSettings()); - public static final Item STILL_ALIVE = new RecordItem(15, new SoundEvent(id("disc/still_alive")), new Item.Properties().stacksTo(1).tab(CreativeModeTab.TAB_MISC).rarity(Rarity.RARE), 177); - public static final Item CARA_MIA_ADDIO = new RecordItem(15, new SoundEvent(id("disc/cara_mia_addio")), new Item.Properties().stacksTo(1).tab(CreativeModeTab.TAB_MISC).rarity(Rarity.RARE), 154); - public static final Item WANT_YOU_GONE = new RecordItem(15, new SoundEvent(id("disc/want_you_gone")), new Item.Properties().stacksTo(1).tab(CreativeModeTab.TAB_MISC).rarity(Rarity.RARE), 142); - public static final Item RECONSTRUCTING_MORE_SCIENCE = new RecordItem(15, new SoundEvent(id("disc/reconstructing_more_science")), new Item.Properties().stacksTo(1).tab(CreativeModeTab.TAB_MISC).rarity(Rarity.RARE), 157); + public static final Item STILL_ALIVE = new RecordItem(15, SoundEvent.createVariableRangeEvent(id("disc/still_alive")), new Item.Properties().stacksTo(1).rarity(Rarity.RARE), 177); + public static final Item CARA_MIA_ADDIO = new RecordItem(15, SoundEvent.createVariableRangeEvent(id("disc/cara_mia_addio")), new Item.Properties().stacksTo(1).rarity(Rarity.RARE), 154); + public static final Item WANT_YOU_GONE = new RecordItem(15, SoundEvent.createVariableRangeEvent(id("disc/want_you_gone")), new Item.Properties().stacksTo(1).rarity(Rarity.RARE), 142); + public static final Item RECONSTRUCTING_MORE_SCIENCE = new RecordItem(15, SoundEvent.createVariableRangeEvent(id("disc/reconstructing_more_science")), new Item.Properties().stacksTo(1).rarity(Rarity.RARE), 157); - public static final TagKey HOLDS_OBJECT = QuiltTagKey.of(Registry.ITEM_REGISTRY, id("holds_object"), TagType.CLIENT_ONLY); - public static final TagKey LAYS_ON_FLOOR = QuiltTagKey.of(Registry.ITEM_REGISTRY, id("lays_on_floor"), TagType.CLIENT_ONLY); + public static final TagKey HOLDS_OBJECT = QuiltTagKey.of(Registries.ITEM, id("holds_object"), TagType.CLIENT_ONLY); + public static final TagKey LAYS_ON_FLOOR = QuiltTagKey.of(Registries.ITEM, id("lays_on_floor"), TagType.CLIENT_ONLY); public static void registerItems() { - Registry.register(Registry.ITEM, id("long_fall_boots"), LONG_FALL_BOOTS); - Registry.register(Registry.ITEM, id("portal_gun"), PORTAL_GUN); - Registry.register(Registry.ITEM, id("portal_gun_primary"), PORTAL_GUN_PRIMARY); - Registry.register(Registry.ITEM, id("portal_gun_secondary"), PORTAL_GUN_SECONDARY); - - Registry.register(Registry.ITEM, id("paint_gun"), PAINT_GUN); - Registry.register(Registry.ITEM, id("portal_gun_frame"), PORTAL_GUN_FRAME); - Registry.register(Registry.ITEM, id("portal_gun_casing"), PORTAL_GUN_CASING); - Registry.register(Registry.ITEM, id("mini_blackhole"), MINI_BLACKHOLE); - Registry.register(Registry.ITEM, id("storage_cube"), STORAGE_CUBE); - Registry.register(Registry.ITEM, id("companion_cube"), COMPANION_CUBE); - Registry.register(Registry.ITEM, id("redirection_cube"), REDIRECTION_CUBE); - Registry.register(Registry.ITEM, id("old_ap_cube"), OLD_AP_CUBE); - Registry.register(Registry.ITEM, id("portal_1_companion_cube"), PORTAL_1_COMPANION_CUBE); - Registry.register(Registry.ITEM, id("portal_1_storage_cube"), PORTAL_1_STORAGE_CUBE); - Registry.register(Registry.ITEM, id("lil_pineapple"), LIL_PINEAPPLE); - - Registry.register(Registry.ITEM, id("radio"), RADIO); - Registry.register(Registry.ITEM, id("beans"), BEANS); - Registry.register(Registry.ITEM, id("mug"), MUG); - Registry.register(Registry.ITEM, id("jug"), JUG); - Registry.register(Registry.ITEM, id("computer"), COMPUTER); - Registry.register(Registry.ITEM, id("chair"), CHAIR); - Registry.register(Registry.ITEM, id("hoopy"), HOOPY); - Registry.register(Registry.ITEM, id("core_frame"), CORE_FRAME); - Registry.register(Registry.ITEM, id("anger_core"), ANGER_CORE); - Registry.register(Registry.ITEM, id("intelligence_core"), CAKE_CORE); - Registry.register(Registry.ITEM, id("curiosity_core"), CURIOSITY_CORE); - Registry.register(Registry.ITEM, id("morality_core"), MORALITY_CORE); - - Registry.register(Registry.ITEM, id("space_core"), SPACE_CORE); - Registry.register(Registry.ITEM, id("fact_core"), FACT_CORE); - Registry.register(Registry.ITEM, id("adventure_core"), ADVENTURE_CORE); - Registry.register(Registry.ITEM, id("turret"), TURRET); - - Registry.register(Registry.ITEM, id("block_item_icon"), BLOCK_ITEM_ICON); - - Registry.register(Registry.ITEM, id("hammer"), HAMMER); - Registry.register(Registry.ITEM, id("energy_pellet"), ENERGY_PELLET); - Registry.register(Registry.ITEM, id("super_pellet"), SUPER_PELLET); - Registry.register(Registry.ITEM, id("crowbar"), CROWBAR); - - Registry.register(Registry.ITEM, id("music_disc_still_alive"), STILL_ALIVE); - Registry.register(Registry.ITEM, id("music_disc_cara_mia_addio"), CARA_MIA_ADDIO); - Registry.register(Registry.ITEM, id("music_disc_want_you_gone"), WANT_YOU_GONE); - Registry.register(Registry.ITEM, id("music_disc_reconstructing_more_science"), RECONSTRUCTING_MORE_SCIENCE); + Registry.register(BuiltInRegistries.ITEM, id("long_fall_boots"), LONG_FALL_BOOTS); + Registry.register(BuiltInRegistries.ITEM, id("portal_gun"), PORTAL_GUN); + Registry.register(BuiltInRegistries.ITEM, id("portal_gun_primary"), PORTAL_GUN_PRIMARY); + Registry.register(BuiltInRegistries.ITEM, id("portal_gun_secondary"), PORTAL_GUN_SECONDARY); + + Registry.register(BuiltInRegistries.ITEM, id("paint_gun"), PAINT_GUN); + Registry.register(BuiltInRegistries.ITEM, id("portal_gun_frame"), PORTAL_GUN_FRAME); + Registry.register(BuiltInRegistries.ITEM, id("portal_gun_casing"), PORTAL_GUN_CASING); + Registry.register(BuiltInRegistries.ITEM, id("mini_blackhole"), MINI_BLACKHOLE); + Registry.register(BuiltInRegistries.ITEM, id("storage_cube"), STORAGE_CUBE); + Registry.register(BuiltInRegistries.ITEM, id("companion_cube"), COMPANION_CUBE); + Registry.register(BuiltInRegistries.ITEM, id("redirection_cube"), REDIRECTION_CUBE); + Registry.register(BuiltInRegistries.ITEM, id("old_ap_cube"), OLD_AP_CUBE); + Registry.register(BuiltInRegistries.ITEM, id("portal_1_companion_cube"), PORTAL_1_COMPANION_CUBE); + Registry.register(BuiltInRegistries.ITEM, id("portal_1_storage_cube"), PORTAL_1_STORAGE_CUBE); + Registry.register(BuiltInRegistries.ITEM, id("lil_pineapple"), LIL_PINEAPPLE); + + Registry.register(BuiltInRegistries.ITEM, id("radio"), RADIO); + Registry.register(BuiltInRegistries.ITEM, id("beans"), BEANS); + Registry.register(BuiltInRegistries.ITEM, id("mug"), MUG); + Registry.register(BuiltInRegistries.ITEM, id("jug"), JUG); + Registry.register(BuiltInRegistries.ITEM, id("computer"), COMPUTER); + Registry.register(BuiltInRegistries.ITEM, id("chair"), CHAIR); + Registry.register(BuiltInRegistries.ITEM, id("hoopy"), HOOPY); + Registry.register(BuiltInRegistries.ITEM, id("core_frame"), CORE_FRAME); + Registry.register(BuiltInRegistries.ITEM, id("anger_core"), ANGER_CORE); + Registry.register(BuiltInRegistries.ITEM, id("intelligence_core"), CAKE_CORE); + Registry.register(BuiltInRegistries.ITEM, id("curiosity_core"), CURIOSITY_CORE); + Registry.register(BuiltInRegistries.ITEM, id("morality_core"), MORALITY_CORE); + + Registry.register(BuiltInRegistries.ITEM, id("space_core"), SPACE_CORE); + Registry.register(BuiltInRegistries.ITEM, id("fact_core"), FACT_CORE); + Registry.register(BuiltInRegistries.ITEM, id("adventure_core"), ADVENTURE_CORE); + Registry.register(BuiltInRegistries.ITEM, id("turret"), TURRET); + + Registry.register(BuiltInRegistries.ITEM, id("block_item_icon"), BLOCK_ITEM_ICON); + + Registry.register(BuiltInRegistries.ITEM, id("hammer"), HAMMER); + Registry.register(BuiltInRegistries.ITEM, id("energy_pellet"), ENERGY_PELLET); + Registry.register(BuiltInRegistries.ITEM, id("super_pellet"), SUPER_PELLET); + Registry.register(BuiltInRegistries.ITEM, id("crowbar"), CROWBAR); + + Registry.register(BuiltInRegistries.ITEM, id("music_disc_still_alive"), STILL_ALIVE); + Registry.register(BuiltInRegistries.ITEM, id("music_disc_cara_mia_addio"), CARA_MIA_ADDIO); + Registry.register(BuiltInRegistries.ITEM, id("music_disc_want_you_gone"), WANT_YOU_GONE); + Registry.register(BuiltInRegistries.ITEM, id("music_disc_reconstructing_more_science"), RECONSTRUCTING_MORE_SCIENCE); DispenserBlock.registerBehavior(ENERGY_PELLET, ENERGY_PELLET.createDispenserBehavior()); DispenserBlock.registerBehavior(SUPER_PELLET, SUPER_PELLET.createDispenserBehavior()); diff --git a/src/main/java/com/fusionflux/portalcubed/items/PortalGun.java b/src/main/java/com/fusionflux/portalcubed/items/PortalGun.java index ec7d5022..33722581 100644 --- a/src/main/java/com/fusionflux/portalcubed/items/PortalGun.java +++ b/src/main/java/com/fusionflux/portalcubed/items/PortalGun.java @@ -38,6 +38,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.quiltmc.loader.api.minecraft.ClientOnly; @@ -129,6 +130,7 @@ public InteractionResult onDirectUse(Player user, InteractionHand hand) { return InteractionResult.CONSUME; } + @NotNull @Override public UseAnim getUseAnimation(ItemStack stack) { return UseAnim.NONE; @@ -382,7 +384,7 @@ public HitResult customRaycast(Entity user, double maxDistance, float tickDelta) }, context -> { final Vec3 offset = start.subtract(end); - return BlockHitResult.miss(end, Direction.getNearest(offset.x, offset.y, offset.z), new BlockPos(end)); + return BlockHitResult.miss(end, Direction.getNearest(offset.x, offset.y, offset.z), BlockPos.containing(end)); } ); } diff --git a/src/main/java/com/fusionflux/portalcubed/items/PortalTabsLoader.java b/src/main/java/com/fusionflux/portalcubed/items/PortalTabsLoader.java index 0cbe1d88..76dac6d9 100644 --- a/src/main/java/com/fusionflux/portalcubed/items/PortalTabsLoader.java +++ b/src/main/java/com/fusionflux/portalcubed/items/PortalTabsLoader.java @@ -35,6 +35,7 @@ @ClientOnly public class PortalTabsLoader { private static final Map>> CONDITION_TYPES = Map.of( + "always", o -> p -> true, "and", o -> GsonHelper.getAsJsonArray(o, "conditions") .asList() .stream() @@ -90,16 +91,22 @@ private static void load(JsonObject jsonObject) { if (entryData.has("backgroundImage")) { builder.backgroundSuffix(GsonHelper.getAsString(entryData, "backgroundImage")); } - if (entryData.has("items") || entryData.has("itemConditions")) { - final List items = parseItemArray(entryData); - final var itemConditions = GsonHelper.getAsJsonArray(entryData, "itemConditions", new JsonArray()) + if (entryData.has("items")) { + final var items = GsonHelper.getAsJsonArray(entryData, "items") .asList() .stream() - .map(e -> Pair.of(parseCondition(e), parseItemArray((JsonObject)e))) + .map(e -> { + if (e.isJsonPrimitive() || (e.isJsonObject() && !e.getAsJsonObject().has("type"))) { + return Pair.of( + (Predicate)p -> true, + List.of(parseItemStack(e, "item").get()) + ); + } + return Pair.of(parseCondition(e), parseItemArray((JsonObject)e)); + }) .toList(); builder.displayItems((itemDisplayParameters, output) -> { - output.acceptAll(items); - for (final var condition : itemConditions) { + for (final var condition : items) { if (condition.key().test(itemDisplayParameters)) { output.acceptAll(condition.value()); } diff --git a/src/main/java/com/fusionflux/portalcubed/mechanics/PortalCubedDamageSources.java b/src/main/java/com/fusionflux/portalcubed/mechanics/PortalCubedDamageSources.java index 9661261c..59c53b6c 100644 --- a/src/main/java/com/fusionflux/portalcubed/mechanics/PortalCubedDamageSources.java +++ b/src/main/java/com/fusionflux/portalcubed/mechanics/PortalCubedDamageSources.java @@ -1,18 +1,59 @@ package com.fusionflux.portalcubed.mechanics; -import com.fusionflux.portalcubed.PortalCubed; +import com.fusionflux.portalcubed.accessor.LevelExt; +import net.minecraft.core.Registry; +import net.minecraft.core.RegistryAccess; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.damagesource.DamageType; +import net.minecraft.world.level.Level; public class PortalCubedDamageSources { - public static final DamageSource ACID = source("acid").bypassArmor(); - public static final DamageSource FIZZLE = source("fizzle").bypassArmor(); - public static final DamageSource VAPORIZATION = source("vaporization").bypassArmor(); - public static final DamageSource LASER = source("laser").bypassArmor().setIsFire(); - public static final DamageSource CUBE = source("cube").damageHelmet(); + private final Registry damageTypes; - private static DamageSource source(String id) { - return new DamageSource(PortalCubed.MOD_ID + '.' + id); + private final DamageSource acid; + private final DamageSource fizzle; + private final DamageSource vaporization; + private final DamageSource laser; + private final DamageSource cube; + + public PortalCubedDamageSources(RegistryAccess registryAccess) { + this.damageTypes = registryAccess.registryOrThrow(Registries.DAMAGE_TYPE); + acid = source(PortalCubedDamageTypes.ACID); + fizzle = source(PortalCubedDamageTypes.FIZZLE); + vaporization = source(PortalCubedDamageTypes.VAPORIZATION); + laser = source(PortalCubedDamageTypes.LASER); + cube = source(PortalCubedDamageTypes.CUBE); + } + + public static PortalCubedDamageSources pcSources(Level level) { + return ((LevelExt)level).pcDamageSources(); + } + + private DamageSource source(ResourceKey key) { + return new DamageSource(damageTypes.getHolderOrThrow(key)); + } + + public DamageSource acid() { + return acid; + } + + public DamageSource fizzle() { + return fizzle; + } + + public DamageSource vaporization() { + return vaporization; + } + + public DamageSource laser() { + return laser; + } + + public DamageSource cube() { + return cube; } } diff --git a/src/main/java/com/fusionflux/portalcubed/mechanics/PortalCubedDamageTypes.java b/src/main/java/com/fusionflux/portalcubed/mechanics/PortalCubedDamageTypes.java new file mode 100644 index 00000000..ab129f28 --- /dev/null +++ b/src/main/java/com/fusionflux/portalcubed/mechanics/PortalCubedDamageTypes.java @@ -0,0 +1,15 @@ +package com.fusionflux.portalcubed.mechanics; + +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.damagesource.DamageType; + +import static com.fusionflux.portalcubed.PortalCubed.id; + +public interface PortalCubedDamageTypes { + ResourceKey ACID = ResourceKey.create(Registries.DAMAGE_TYPE, id("acid")); + ResourceKey FIZZLE = ResourceKey.create(Registries.DAMAGE_TYPE, id("fizzle")); + ResourceKey VAPORIZATION = ResourceKey.create(Registries.DAMAGE_TYPE, id("vaporization")); + ResourceKey LASER = ResourceKey.create(Registries.DAMAGE_TYPE, id("laser")); + ResourceKey CUBE = ResourceKey.create(Registries.DAMAGE_TYPE, id("cube")); +} diff --git a/src/main/java/com/fusionflux/portalcubed/mixin/EntityMixin.java b/src/main/java/com/fusionflux/portalcubed/mixin/EntityMixin.java index c41e3a32..7e89af11 100644 --- a/src/main/java/com/fusionflux/portalcubed/mixin/EntityMixin.java +++ b/src/main/java/com/fusionflux/portalcubed/mixin/EntityMixin.java @@ -25,6 +25,7 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.util.Mth; import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.damagesource.DamageSources; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; @@ -138,6 +139,8 @@ public void setMaxFallSpeed(double maxFallSpeed) { @Shadow public abstract float getXRot(); + @Shadow public abstract DamageSources damageSources(); + private static final AABB NULL_BOX = new AABB(0, 0, 0, 0, 0, 0); @Unique @@ -547,7 +550,7 @@ public void setCFG() { //noinspection ConstantValue if (!((Object)this instanceof LivingEntity living)) return; ItemStack stack = living.getItemBySlot(EquipmentSlot.FEET); - if (damageSource == DamageSource.FALL && (stack.is(PortalCubedItems.LONG_FALL_BOOTS))) { + if (damageSource == damageSources().fall() && (stack.is(PortalCubedItems.LONG_FALL_BOOTS))) { cir.setReturnValue(true); } } diff --git a/src/main/java/com/fusionflux/portalcubed/mixin/LevelMixin.java b/src/main/java/com/fusionflux/portalcubed/mixin/LevelMixin.java index d7330897..a6cdde33 100644 --- a/src/main/java/com/fusionflux/portalcubed/mixin/LevelMixin.java +++ b/src/main/java/com/fusionflux/portalcubed/mixin/LevelMixin.java @@ -1,24 +1,60 @@ package com.fusionflux.portalcubed.mixin; import com.fusionflux.portalcubed.accessor.Accessors; +import com.fusionflux.portalcubed.accessor.LevelExt; +import com.fusionflux.portalcubed.mechanics.PortalCubedDamageSources; +import net.minecraft.core.Holder; +import net.minecraft.core.RegistryAccess; +import net.minecraft.resources.ResourceKey; +import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; +import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.world.level.entity.LevelEntityGetter; +import net.minecraft.world.level.storage.WritableLevelData; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +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 java.util.UUID; +import java.util.function.Supplier; @Mixin(Level.class) -public abstract class LevelMixin implements Accessors { +public abstract class LevelMixin implements Accessors, LevelExt { + @Unique + PortalCubedDamageSources pc$damageSources; @Shadow protected abstract LevelEntityGetter getEntities(); + @Inject(method = "", at = @At("TAIL")) + private void createDamageSources( + WritableLevelData writableLevelData, + ResourceKey resourceKey, + RegistryAccess registryAccess, + Holder holder, + Supplier supplier, + boolean bl, + boolean bl2, + long l, + int i, + CallbackInfo ci + ) { + pc$damageSources = new PortalCubedDamageSources(registryAccess); + } + @Override @Nullable public Entity getEntity(UUID uuid) { return this.getEntities().get(uuid); } + + @Override + public PortalCubedDamageSources pcDamageSources() { + return pc$damageSources; + } } diff --git a/src/main/java/com/fusionflux/portalcubed/mixin/PlayerMixin.java b/src/main/java/com/fusionflux/portalcubed/mixin/PlayerMixin.java index 4b89560c..b64ded54 100644 --- a/src/main/java/com/fusionflux/portalcubed/mixin/PlayerMixin.java +++ b/src/main/java/com/fusionflux/portalcubed/mixin/PlayerMixin.java @@ -78,17 +78,13 @@ protected PlayerMixin(EntityType entityType, Level world @ModifyVariable(method = "travel", at = @At("HEAD"), argsOnly = true) private Vec3 portalCubed$what(Vec3 travelVectorOriginal) { - if (!this.isNoGravity()) { - ItemStack itemFeet = this.getItemBySlot(EquipmentSlot.FEET); - if (!this.isOnGround() && PortalCubedConfig.enableAccurateMovement && !this.isSwimming() && !this.abilities.flying && !this.isFallFlying() && itemFeet.getItem().equals(PortalCubedItems.LONG_FALL_BOOTS) && !this.level.getBlockState(this.blockPosition()).getBlock().equals(PortalCubedBlocks.EXCURSION_FUNNEL) && !this.level.getBlockState(new BlockPos(this.blockPosition().getX(), this.blockPosition().getY() + 1, this.blockPosition().getZ())).getBlock().equals(PortalCubedBlocks.EXCURSION_FUNNEL)) { - double mathVal = 1; - double horizontalVelocity = Math.abs(this.getDeltaMovement().x) + Math.abs(this.getDeltaMovement().z); - if (horizontalVelocity / 0.01783440120041885 > 1) { - mathVal = horizontalVelocity / 0.01783440120041885; - } - travelVectorOriginal = new Vec3(travelVectorOriginal.x / mathVal, travelVectorOriginal.y, travelVectorOriginal.z / mathVal); - this.flyingSpeed = .04f; + if (!this.isNoGravity() && !this.isOnGround() && PortalCubedConfig.enableAccurateMovement && !this.isSwimming() && !this.abilities.flying && !this.isFallFlying() && this.getItemBySlot(EquipmentSlot.FEET).getItem().equals(PortalCubedItems.LONG_FALL_BOOTS) && !this.level.getBlockState(this.blockPosition()).getBlock().equals(PortalCubedBlocks.EXCURSION_FUNNEL) && !this.level.getBlockState(new BlockPos(this.blockPosition().getX(), this.blockPosition().getY() + 1, this.blockPosition().getZ())).getBlock().equals(PortalCubedBlocks.EXCURSION_FUNNEL)) { + double mathVal = 1; + double horizontalVelocity = Math.abs(this.getDeltaMovement().x) + Math.abs(this.getDeltaMovement().z); + if (horizontalVelocity / 0.01783440120041885 > 1) { + mathVal = horizontalVelocity / 0.01783440120041885; } + travelVectorOriginal = new Vec3(travelVectorOriginal.x / mathVal, travelVectorOriginal.y, travelVectorOriginal.z / mathVal); } if (CalledValues.getIsTeleporting(this)) { travelVectorOriginal = Vec3.ZERO; @@ -97,6 +93,13 @@ protected PlayerMixin(EntityType entityType, Level world return travelVectorOriginal; } + @Inject(method = "getFlyingSpeed", at = @At("HEAD"), cancellable = true) + private void replaceFlyingSpeed(CallbackInfoReturnable cir) { + if (!this.isNoGravity() && !this.isOnGround() && PortalCubedConfig.enableAccurateMovement && !this.isSwimming() && !this.abilities.flying && !this.isFallFlying() && this.getItemBySlot(EquipmentSlot.FEET).getItem().equals(PortalCubedItems.LONG_FALL_BOOTS) && !this.level.getBlockState(this.blockPosition()).getBlock().equals(PortalCubedBlocks.EXCURSION_FUNNEL) && !this.level.getBlockState(new BlockPos(this.blockPosition().getX(), this.blockPosition().getY() + 1, this.blockPosition().getZ())).getBlock().equals(PortalCubedBlocks.EXCURSION_FUNNEL)) { + cir.setReturnValue(0.04f); + } + } + private boolean enableNoDrag2; private static final AABB NULL_BOX = new AABB(0, 0, 0, 0, 0, 0); diff --git a/src/main/java/com/fusionflux/portalcubed/mixin/client/ItemInHandRendererMixin.java b/src/main/java/com/fusionflux/portalcubed/mixin/client/ItemInHandRendererMixin.java index bc7dba7f..8194ec22 100644 --- a/src/main/java/com/fusionflux/portalcubed/mixin/client/ItemInHandRendererMixin.java +++ b/src/main/java/com/fusionflux/portalcubed/mixin/client/ItemInHandRendererMixin.java @@ -7,7 +7,7 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Vector3f; +import com.mojang.math.Axis; import net.minecraft.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.player.AbstractClientPlayer; @@ -20,6 +20,7 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +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; @@ -27,21 +28,24 @@ @Mixin(ItemInHandRenderer.class) public class ItemInHandRendererMixin implements ItemInHandRendererExt { @Shadow @Final private Minecraft minecraft; + + @Unique private boolean isHoldingInvisible; + @Unique private boolean handFaker; @Inject( method = "renderArmWithItem", at = @At( value = "INVOKE", - target = "Lnet/minecraft/client/renderer/ItemInHandRenderer;renderItem(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/client/renderer/block/model/ItemTransforms$TransformType;ZLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", + target = "Lnet/minecraft/client/renderer/ItemInHandRenderer;renderItem(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/ItemDisplayContext;ZLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", ordinal = 1 ) ) private void shakeGun(AbstractClientPlayer player, float tickDelta, float pitch, InteractionHand hand, float swingProgress, ItemStack item, float equipProgress, PoseStack matrices, MultiBufferSource vertexConsumers, int light, CallbackInfo ci) { final long time = Util.getMillis() - PortalCubedClient.shakeStart; if (time > 440) return; - matrices.mulPose(Vector3f.ZP.rotationDegrees((float)Math.sin(time / 35.0) * 6)); + matrices.mulPose(Axis.ZP.rotationDegrees((float)Math.sin(time / 35.0) * 6)); } @Inject( diff --git a/src/main/java/com/fusionflux/portalcubed/mixin/client/LocalPlayerMixin.java b/src/main/java/com/fusionflux/portalcubed/mixin/client/LocalPlayerMixin.java index 7f22ef1e..ea6bff1d 100644 --- a/src/main/java/com/fusionflux/portalcubed/mixin/client/LocalPlayerMixin.java +++ b/src/main/java/com/fusionflux/portalcubed/mixin/client/LocalPlayerMixin.java @@ -2,22 +2,19 @@ import com.fusionflux.portalcubed.accessor.HasMovementInputAccessor; import com.fusionflux.portalcubed.client.PortalCubedClient; -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.mojang.authlib.GameProfile; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.player.AbstractClientPlayer; import net.minecraft.client.player.Input; import net.minecraft.client.player.LocalPlayer; -import net.minecraft.world.effect.MobEffect; -import net.minecraft.world.entity.player.ProfilePublicKey; import net.minecraft.world.phys.Vec2; -import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(LocalPlayer.class) public class LocalPlayerMixin extends AbstractClientPlayer implements HasMovementInputAccessor { @@ -26,8 +23,8 @@ public class LocalPlayerMixin extends AbstractClientPlayer implements HasMovemen @Shadow public Input input; - public LocalPlayerMixin(ClientLevel clientWorld, GameProfile gameProfile, @Nullable ProfilePublicKey playerPublicKey) { - super(clientWorld, gameProfile, playerPublicKey); + public LocalPlayerMixin(ClientLevel clientLevel, GameProfile gameProfile) { + super(clientLevel, gameProfile); } @@ -37,18 +34,15 @@ public boolean hasMovementInputPublic() { return vec2f.x != 0.0F || vec2f.y != 0.0F; } - @WrapOperation( - method = "aiStep", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/player/LocalPlayer;hasEffect(Lnet/minecraft/world/effect/MobEffect;)Z" - ) + @Inject( + method = "canStartSprinting", + at = @At("HEAD"), + cancellable = true ) - private boolean noSprinting(LocalPlayer instance, MobEffect effect, Operation original) { + private void noSprintingInPortalHud(CallbackInfoReturnable cir) { if (PortalCubedClient.isPortalHudMode()) { - return true; + cir.setReturnValue(false); } - return original.call(instance, effect); } } diff --git a/src/main/java/com/fusionflux/portalcubed/mixin/client/SoundEngineMixin.java b/src/main/java/com/fusionflux/portalcubed/mixin/client/SoundEngineMixin.java index 1a092679..18e2ba4f 100644 --- a/src/main/java/com/fusionflux/portalcubed/mixin/client/SoundEngineMixin.java +++ b/src/main/java/com/fusionflux/portalcubed/mixin/client/SoundEngineMixin.java @@ -5,7 +5,8 @@ import net.minecraft.client.resources.sounds.SimpleSoundInstance; import net.minecraft.client.resources.sounds.SoundInstance; import net.minecraft.client.sounds.SoundEngine; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -28,8 +29,10 @@ public abstract class SoundEngineMixin { private void ohFiddlesticks(SoundInstance sound, CallbackInfo ci) { if ( !sound.getLocation().getNamespace().equals(PortalCubed.MOD_ID) || - Registry.SOUND_EVENT.getOrCreateTag(PortalCubedSounds.NO_ERROR_SOUND) - .contains(Registry.SOUND_EVENT.getHolderOrThrow(ResourceKey.create(Registry.SOUND_EVENT_REGISTRY, sound.getLocation()))) + BuiltInRegistries.SOUND_EVENT.getOrCreateTag(PortalCubedSounds.NO_ERROR_SOUND) + .contains(BuiltInRegistries.SOUND_EVENT.getHolderOrThrow( + ResourceKey.create(Registries.SOUND_EVENT, sound.getLocation()) + )) ) return; play(SimpleSoundInstance.forUI(PortalCubedSounds.ERROR_EVENT, 1f)); } diff --git a/src/main/java/com/fusionflux/portalcubed/optionslist/ButtonEntry.java b/src/main/java/com/fusionflux/portalcubed/optionslist/ButtonEntry.java index c863dad5..4fdd5a79 100644 --- a/src/main/java/com/fusionflux/portalcubed/optionslist/ButtonEntry.java +++ b/src/main/java/com/fusionflux/portalcubed/optionslist/ButtonEntry.java @@ -9,6 +9,7 @@ import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.narration.NarratableEntry; import net.minecraft.network.chat.Component; +import org.jetbrains.annotations.NotNull; import org.quiltmc.loader.api.minecraft.ClientOnly; import java.util.ArrayList; @@ -36,7 +37,7 @@ public class ButtonEntry extends ContainerObjectSelectionList.Entry @Override public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) { buttons.forEach(b -> { - b.y = y; + b.setY(y); b.render(matrices, mouseX, mouseY, tickDelta); }); if (text != null && (!text.getString().contains("spacer") || !buttons.isEmpty())) { @@ -46,11 +47,13 @@ public void render(PoseStack matrices, int index, int y, int x, int entryWidth, } } + @NotNull @Override public List children() { return children; } + @NotNull @Override public List narratables() { return children; diff --git a/src/main/java/com/fusionflux/portalcubed/optionslist/OptionsListScreen.java b/src/main/java/com/fusionflux/portalcubed/optionslist/OptionsListScreen.java index d229b301..657aaf2f 100644 --- a/src/main/java/com/fusionflux/portalcubed/optionslist/OptionsListScreen.java +++ b/src/main/java/com/fusionflux/portalcubed/optionslist/OptionsListScreen.java @@ -10,7 +10,7 @@ import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.resources.language.I18n; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; @@ -48,7 +48,7 @@ public OptionsListScreen(OptionsListScreenHandler handler, Inventory inventory, } target = ola; //noinspection DataFlowIssue - this.translationPrefix = "optionslist." + Registry.BLOCK_ENTITY_TYPE.getKey(ola.getType()).toString().replace(':', '.') + "."; + this.translationPrefix = "optionslist." + BuiltInRegistries.BLOCK_ENTITY_TYPE.getKey(ola.getType()).toString().replace(':', '.') + "."; for (final EntryInfo entry : OptionsListData.getEntries(target)) { try { entry.value = entry.field.get(target); @@ -65,7 +65,7 @@ public void init() { imageHeight = height; super.init(); - Button done = this.addRenderableWidget(new Button(this.width / 2 - 75, this.height - 28, 150, 20, CommonComponents.GUI_DONE, (button) -> { + Button done = this.addRenderableWidget(Button.builder(CommonComponents.GUI_DONE, (button) -> { for (EntryInfo info : OptionsListData.getEntries(target)) { try { info.field.set(target, info.value); @@ -73,7 +73,7 @@ public void init() { } } onClose(); - })); + }).width(150).pos(this.width / 2 - 75, this.height - 28).build()); this.list = new OptionsListListWidget(this.minecraft, this.width, this.height, 32, this.height - 32, 25); if (this.minecraft != null && this.minecraft.level != null) this.list.setRenderBackground(false); @@ -85,7 +85,7 @@ public void init() { Map.Entry> widget = (Map.Entry>)info.widget; if (info.field.getType().isEnum()) widget.setValue(value -> Component.translatable(translationPrefix + "enum." + info.field.getType().getSimpleName() + "." + info.value.toString())); - this.list.addButton(List.of(new Button(width - 160, 0, 150, 20, widget.getValue().apply(info.value), widget.getKey())), name, info); + this.list.addButton(List.of(Button.builder(widget.getValue().apply(info.value), widget.getKey()).width(150).pos(width - 160, 0).build()), name, info); } else if (info.field.getType() == List.class) { if (!reload) info.index = 0; EditBox widget = new EditBox(font, width - 160, 0, 150, 20, Component.empty()); @@ -94,7 +94,7 @@ public void init() { widget.setValue((String.valueOf(((List)info.value).get(info.index)))); Predicate processor = ((BiFunction>)info.widget).apply(widget, done); widget.setFilter(processor); - Button cycleButton = new Button(width - 185, 0, 20, 20, Component.literal(String.valueOf(info.index)).withStyle(ChatFormatting.GOLD), (button -> { + Button cycleButton = Button.builder(Component.literal(String.valueOf(info.index)).withStyle(ChatFormatting.GOLD), (button -> { ((List)info.value).remove(""); double scrollAmount = list.getScrollAmount(); this.reload = true; @@ -102,7 +102,7 @@ public void init() { if (info.index > ((List)info.value).size()) info.index = 0; Objects.requireNonNull(minecraft).setScreen(this); list.setScrollAmount(scrollAmount); - })); + })).width(20).size(width - 185, 0).build(); this.list.addButton(List.of(widget, cycleButton), name, info); } else if (info.widget != null) { AbstractWidget widget; @@ -117,8 +117,8 @@ public void init() { textField.setFilter(processor); } if (e.isColor()) { - Button colorButton = new Button(width - 185, 0, 20, 20, Component.literal("⬛"), (button -> { - })); + Button colorButton = Button.builder(Component.literal("⬛"), (button -> { + })).width(20).pos(width - 185, 0).build(); try { colorButton.setMessage(Component.literal("⬛").setStyle(Style.EMPTY.withColor(Color.decode(info.tempValue).getRGB()))); } catch (Exception ignored) { diff --git a/src/main/java/com/fusionflux/portalcubed/particle/DecalParticleEffect.java b/src/main/java/com/fusionflux/portalcubed/particle/DecalParticleEffect.java index a032c29d..709d3aa0 100644 --- a/src/main/java/com/fusionflux/portalcubed/particle/DecalParticleEffect.java +++ b/src/main/java/com/fusionflux/portalcubed/particle/DecalParticleEffect.java @@ -7,11 +7,12 @@ import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.commands.arguments.ResourceLocationArgument; import net.minecraft.core.Direction; -import net.minecraft.core.Registry; import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleType; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; import static com.fusionflux.portalcubed.PortalCubed.id; @@ -23,6 +24,7 @@ public class DecalParticleEffect implements ParticleOptions { @SuppressWarnings("deprecation") public static final ParticleOptions.Deserializer PARAMETERS_FACTORY = new Deserializer<>() { + @NotNull @Override public DecalParticleEffect fromCommand(ParticleType type, StringReader reader) throws CommandSyntaxException { reader.expect(' '); @@ -39,6 +41,7 @@ public DecalParticleEffect fromCommand(ParticleType type, S return new DecalParticleEffect(type, texture, direction, multiply); } + @NotNull @Override public DecalParticleEffect fromNetwork(ParticleType type, FriendlyByteBuf buf) { return new DecalParticleEffect( @@ -70,6 +73,7 @@ public DecalParticleEffect(ResourceLocation texture, Direction direction) { this(texture, direction, false); } + @NotNull @Override public ParticleType getType() { return particleType; @@ -80,9 +84,10 @@ public void writeToNetwork(FriendlyByteBuf buf) { buf.writeResourceLocation(texture); } + @NotNull @Override public String writeToString() { - return Registry.PARTICLE_TYPE.getKey(particleType) + " " + texture; + return BuiltInRegistries.PARTICLE_TYPE.getKey(particleType) + " " + texture; } public ResourceLocation getTexture() { diff --git a/src/main/java/com/fusionflux/portalcubed/particle/PortalCubedParticleTypes.java b/src/main/java/com/fusionflux/portalcubed/particle/PortalCubedParticleTypes.java index e8bf4f5d..7bdc3f05 100644 --- a/src/main/java/com/fusionflux/portalcubed/particle/PortalCubedParticleTypes.java +++ b/src/main/java/com/fusionflux/portalcubed/particle/PortalCubedParticleTypes.java @@ -4,6 +4,8 @@ import net.minecraft.core.Registry; import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleType; +import net.minecraft.core.registries.BuiltInRegistries; +import org.jetbrains.annotations.NotNull; import java.util.function.Function; @@ -18,7 +20,8 @@ public class PortalCubedParticleTypes { private static ParticleType register( String name, boolean alwaysShow, ParticleOptions.Deserializer parameterFactory, Function, Codec> codecProvider ) { - return Registry.register(Registry.PARTICLE_TYPE, id(name), new ParticleType(alwaysShow, parameterFactory) { + return Registry.register(BuiltInRegistries.PARTICLE_TYPE, id(name), new ParticleType(alwaysShow, parameterFactory) { + @NotNull @Override public Codec codec() { return codecProvider.apply(this); diff --git a/src/main/java/com/fusionflux/portalcubed/sound/PortalCubedSounds.java b/src/main/java/com/fusionflux/portalcubed/sound/PortalCubedSounds.java index 5ad77e8d..286263b5 100644 --- a/src/main/java/com/fusionflux/portalcubed/sound/PortalCubedSounds.java +++ b/src/main/java/com/fusionflux/portalcubed/sound/PortalCubedSounds.java @@ -1,6 +1,8 @@ package com.fusionflux.portalcubed.sound; import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -83,153 +85,153 @@ public class PortalCubedSounds { public static final ResourceLocation CROWBAR_SWOOSH = id("crowbar_swoosh"); - public static final SoundEvent ERROR_EVENT = new SoundEvent(ERROR); - - public static final SoundEvent GEL_BOUNCE_EVENT = new SoundEvent(GEL_BOUNCE); - public static final SoundEvent GEL_RUN_EVENT = new SoundEvent(GEL_RUN); - public static final SoundEvent GEL_SPLAT_EVENT = new SoundEvent(GEL_SPLAT); - public static final SoundEvent PORTAL_AMBIENT_EVENT = new SoundEvent(PORTAL_AMBIANCE); - public static final SoundEvent FIRE_EVENT_PRIMARY = new SoundEvent(PORTAL_GUN_PRIMARY); - public static final SoundEvent FIRE_EVENT_SECONDARY = new SoundEvent(PORTAL_GUN_SECONDARY); - public static final SoundEvent INVALID_PORTAL_EVENT = new SoundEvent(PORTAL_INVALID_SURFACE); - public static final SoundEvent NOTHING_TO_GRAB_EVENT = new SoundEvent(NOTHING_TO_GRAB); - public static final SoundEvent ENTITY_ENTER_PORTAL = new SoundEvent(PORTAL_ENTER); - public static final SoundEvent ENTITY_EXIT_PORTAL = new SoundEvent(PORTAL_EXIT); - public static final SoundEvent ENTITY_PORTAL_OPEN = new SoundEvent(PORTAL_OPEN); - public static final SoundEvent ENTITY_PORTAL_CLOSE = new SoundEvent(PORTAL_CLOSE); - public static final SoundEvent ENTITY_PORTAL_FIZZLE = new SoundEvent(PORTAL_FIZZLE); - public static final SoundEvent CUBE_HIGH_HIT_EVENT = new SoundEvent(CUBE_HIT_HIGH); - public static final SoundEvent CUBE_LOW_HIT_EVENT = new SoundEvent(CUBE_HIT_LOW); - public static final SoundEvent CUBE_SCRAPE_EVENT = new SoundEvent(CUBE_SCRAPE); - public static final SoundEvent COMPANION_CUBE_AMBIANCE_EVENT = new SoundEvent(COMPANION_CUBE_AMBIANCE); - public static final SoundEvent MATERIAL_EMANCIPATION_EVENT = new SoundEvent(MATERIAL_EMANCIPATION); - public static final SoundEvent CATAPULT_LAUNCH_EVENT = new SoundEvent(CATAPULT_LAUNCH); - - public static final SoundEvent PEDESTAL_BUTTON_PRESS_EVENT = new SoundEvent(PEDESTAL_BUTTON_PRESS); - public static final SoundEvent PEDESTAL_BUTTON_RELEASE_EVENT = new SoundEvent(PEDESTAL_BUTTON_RELEASE); - public static final SoundEvent OLD_AP_PEDESTAL_BUTTON_PRESS_EVENT = new SoundEvent(OLD_AP_PEDESTAL_BUTTON_PRESS); - public static final SoundEvent OLD_AP_PEDESTAL_BUTTON_RELEASE_EVENT = new SoundEvent(OLD_AP_PEDESTAL_BUTTON_RELEASE); - public static final SoundEvent FLOOR_BUTTON_PRESS_EVENT = new SoundEvent(FLOOR_BUTTON_PRESS); - public static final SoundEvent FLOOR_BUTTON_RELEASE_EVENT = new SoundEvent(FLOOR_BUTTON_RELEASE); - public static final SoundEvent OLD_AP_FLOOR_BUTTON_PRESS_EVENT = new SoundEvent(OLD_AP_FLOOR_BUTTON_PRESS); - public static final SoundEvent OLD_AP_FLOOR_BUTTON_RELEASE_EVENT = new SoundEvent(OLD_AP_FLOOR_BUTTON_RELEASE); - - public static final SoundEvent ROCKET_FIRE_EVENT = new SoundEvent(ROCKET_FIRE); - public static final SoundEvent ROCKET_FLY_EVENT = new SoundEvent(ROCKET_FLY); - public static final SoundEvent ROCKET_LOCKED_EVENT = new SoundEvent(ROCKET_LOCKED); - public static final SoundEvent ROCKET_LOCKING_EVENT = new SoundEvent(ROCKET_LOCKING); - public static final SoundEvent ROCKET_EXPLODE_EVENT = new SoundEvent(ROCKET_EXPLODE); - public static final SoundEvent ROCKET_GOO_EVENT = new SoundEvent(ROCKET_GOO); - - public static final SoundEvent LASER_EMITTER_ACTIVATE_EVENT = new SoundEvent(LASER_EMITTER_ACTIVATE); - public static final SoundEvent LASER_BEAM_MUSIC_EVENT = new SoundEvent(LASER_BEAM_MUSIC); - public static final SoundEvent LASER_NODE_MUSIC_EVENT = new SoundEvent(LASER_NODE_MUSIC); - public static final SoundEvent LASER_NODE_ACTIVATE_EVENT = new SoundEvent(LASER_NODE_ACTIVATE); - public static final SoundEvent LASER_NODE_DEACTIVATE_EVENT = new SoundEvent(LASER_NODE_DEACTIVATE); - public static final SoundEvent LASER_TRIPLE_LASER_SOUND_DEMO_1_EVENT = new SoundEvent(LASER_TRIPLE_LASER_SOUND_DEMO_1); - public static final SoundEvent LASER_TRIPLE_LASER_SOUND_DEMO_2_EVENT = new SoundEvent(LASER_TRIPLE_LASER_SOUND_DEMO_2); - public static final SoundEvent LASER_TRIPLE_LASER_SOUND_DEMO_3_EVENT = new SoundEvent(LASER_TRIPLE_LASER_SOUND_DEMO_3); - - public static final SoundEvent PELLET_BOUNCE_EVENT = new SoundEvent(PELLET_BOUNCE); - public static final SoundEvent PELLET_EXPLODE_EVENT = new SoundEvent(PELLET_EXPLODE); - public static final SoundEvent PELLET_SPAWN_EVENT = new SoundEvent(PELLET_SPAWN); - public static final SoundEvent PELLET_TRAVEL_EVENT = new SoundEvent(PELLET_TRAVEL); - - public static final SoundEvent TBEAM_ENTER_EVENT = new SoundEvent(TBEAM_ENTER); - public static final SoundEvent TBEAM_TRAVEL_EVENT = new SoundEvent(TBEAM_TRAVEL); - - public static final SoundEvent BULLET_CONCRETE_EVENT = new SoundEvent(BULLET_CONCRETE); - public static final SoundEvent BULLET_GLASS_EVENT = new SoundEvent(BULLET_GLASS); - public static final SoundEvent BULLET_METAL_EVENT = new SoundEvent(BULLET_METAL); - - public static final SoundEvent RADIO_MUSIC_EVENT = new SoundEvent(RADIO_MUSIC); - public static final SoundEvent EXILE_MUSIC_EVENT = new SoundEvent(EXILE_SONG); - public static final SoundEvent CURIOSITY_CORE_EVENT = new SoundEvent(CURIOSITY_CORE_SOUND); - public static final SoundEvent ANGER_CORE_EVENT = new SoundEvent(ANGER_CORE_SOUND); - public static final SoundEvent CAKE_CORE_EVENT = new SoundEvent(CAKE_CORE_SOUND); - public static final SoundEvent SPACE_CORE_EVENT = new SoundEvent(SPACE_CORE_SOUND); - public static final SoundEvent FACT_CORE_EVENT = new SoundEvent(FACT_CORE_SOUND); - public static final SoundEvent ADVENTURE_CORE_EVENT = new SoundEvent(ADVENTURE_CORE_SOUND); - - public static final SoundEvent SEWAGE_STEP_EVENT = new SoundEvent(SEWAGE_STEP); - - public static final SoundEvent CROWBAR_SWOOSH_EVENT = new SoundEvent(CROWBAR_SWOOSH); - - public static final TagKey NO_ERROR_SOUND = QuiltTagKey.of(Registry.SOUND_EVENT_REGISTRY, id("no_error_sound"), TagType.CLIENT_ONLY); + public static final SoundEvent ERROR_EVENT = SoundEvent.createVariableRangeEvent(ERROR); + + public static final SoundEvent GEL_BOUNCE_EVENT = SoundEvent.createVariableRangeEvent(GEL_BOUNCE); + public static final SoundEvent GEL_RUN_EVENT = SoundEvent.createVariableRangeEvent(GEL_RUN); + public static final SoundEvent GEL_SPLAT_EVENT = SoundEvent.createVariableRangeEvent(GEL_SPLAT); + public static final SoundEvent PORTAL_AMBIENT_EVENT = SoundEvent.createVariableRangeEvent(PORTAL_AMBIANCE); + public static final SoundEvent FIRE_EVENT_PRIMARY = SoundEvent.createVariableRangeEvent(PORTAL_GUN_PRIMARY); + public static final SoundEvent FIRE_EVENT_SECONDARY = SoundEvent.createVariableRangeEvent(PORTAL_GUN_SECONDARY); + public static final SoundEvent INVALID_PORTAL_EVENT = SoundEvent.createVariableRangeEvent(PORTAL_INVALID_SURFACE); + public static final SoundEvent NOTHING_TO_GRAB_EVENT = SoundEvent.createVariableRangeEvent(NOTHING_TO_GRAB); + public static final SoundEvent ENTITY_ENTER_PORTAL = SoundEvent.createVariableRangeEvent(PORTAL_ENTER); + public static final SoundEvent ENTITY_EXIT_PORTAL = SoundEvent.createVariableRangeEvent(PORTAL_EXIT); + public static final SoundEvent ENTITY_PORTAL_OPEN = SoundEvent.createVariableRangeEvent(PORTAL_OPEN); + public static final SoundEvent ENTITY_PORTAL_CLOSE = SoundEvent.createVariableRangeEvent(PORTAL_CLOSE); + public static final SoundEvent ENTITY_PORTAL_FIZZLE = SoundEvent.createVariableRangeEvent(PORTAL_FIZZLE); + public static final SoundEvent CUBE_HIGH_HIT_EVENT = SoundEvent.createVariableRangeEvent(CUBE_HIT_HIGH); + public static final SoundEvent CUBE_LOW_HIT_EVENT = SoundEvent.createVariableRangeEvent(CUBE_HIT_LOW); + public static final SoundEvent CUBE_SCRAPE_EVENT = SoundEvent.createVariableRangeEvent(CUBE_SCRAPE); + public static final SoundEvent COMPANION_CUBE_AMBIANCE_EVENT = SoundEvent.createVariableRangeEvent(COMPANION_CUBE_AMBIANCE); + public static final SoundEvent MATERIAL_EMANCIPATION_EVENT = SoundEvent.createVariableRangeEvent(MATERIAL_EMANCIPATION); + public static final SoundEvent CATAPULT_LAUNCH_EVENT = SoundEvent.createVariableRangeEvent(CATAPULT_LAUNCH); + + public static final SoundEvent PEDESTAL_BUTTON_PRESS_EVENT = SoundEvent.createVariableRangeEvent(PEDESTAL_BUTTON_PRESS); + public static final SoundEvent PEDESTAL_BUTTON_RELEASE_EVENT = SoundEvent.createVariableRangeEvent(PEDESTAL_BUTTON_RELEASE); + public static final SoundEvent OLD_AP_PEDESTAL_BUTTON_PRESS_EVENT = SoundEvent.createVariableRangeEvent(OLD_AP_PEDESTAL_BUTTON_PRESS); + public static final SoundEvent OLD_AP_PEDESTAL_BUTTON_RELEASE_EVENT = SoundEvent.createVariableRangeEvent(OLD_AP_PEDESTAL_BUTTON_RELEASE); + public static final SoundEvent FLOOR_BUTTON_PRESS_EVENT = SoundEvent.createVariableRangeEvent(FLOOR_BUTTON_PRESS); + public static final SoundEvent FLOOR_BUTTON_RELEASE_EVENT = SoundEvent.createVariableRangeEvent(FLOOR_BUTTON_RELEASE); + public static final SoundEvent OLD_AP_FLOOR_BUTTON_PRESS_EVENT = SoundEvent.createVariableRangeEvent(OLD_AP_FLOOR_BUTTON_PRESS); + public static final SoundEvent OLD_AP_FLOOR_BUTTON_RELEASE_EVENT = SoundEvent.createVariableRangeEvent(OLD_AP_FLOOR_BUTTON_RELEASE); + + public static final SoundEvent ROCKET_FIRE_EVENT = SoundEvent.createVariableRangeEvent(ROCKET_FIRE); + public static final SoundEvent ROCKET_FLY_EVENT = SoundEvent.createVariableRangeEvent(ROCKET_FLY); + public static final SoundEvent ROCKET_LOCKED_EVENT = SoundEvent.createVariableRangeEvent(ROCKET_LOCKED); + public static final SoundEvent ROCKET_LOCKING_EVENT = SoundEvent.createVariableRangeEvent(ROCKET_LOCKING); + public static final SoundEvent ROCKET_EXPLODE_EVENT = SoundEvent.createVariableRangeEvent(ROCKET_EXPLODE); + public static final SoundEvent ROCKET_GOO_EVENT = SoundEvent.createVariableRangeEvent(ROCKET_GOO); + + public static final SoundEvent LASER_EMITTER_ACTIVATE_EVENT = SoundEvent.createVariableRangeEvent(LASER_EMITTER_ACTIVATE); + public static final SoundEvent LASER_BEAM_MUSIC_EVENT = SoundEvent.createVariableRangeEvent(LASER_BEAM_MUSIC); + public static final SoundEvent LASER_NODE_MUSIC_EVENT = SoundEvent.createVariableRangeEvent(LASER_NODE_MUSIC); + public static final SoundEvent LASER_NODE_ACTIVATE_EVENT = SoundEvent.createVariableRangeEvent(LASER_NODE_ACTIVATE); + public static final SoundEvent LASER_NODE_DEACTIVATE_EVENT = SoundEvent.createVariableRangeEvent(LASER_NODE_DEACTIVATE); + public static final SoundEvent LASER_TRIPLE_LASER_SOUND_DEMO_1_EVENT = SoundEvent.createVariableRangeEvent(LASER_TRIPLE_LASER_SOUND_DEMO_1); + public static final SoundEvent LASER_TRIPLE_LASER_SOUND_DEMO_2_EVENT = SoundEvent.createVariableRangeEvent(LASER_TRIPLE_LASER_SOUND_DEMO_2); + public static final SoundEvent LASER_TRIPLE_LASER_SOUND_DEMO_3_EVENT = SoundEvent.createVariableRangeEvent(LASER_TRIPLE_LASER_SOUND_DEMO_3); + + public static final SoundEvent PELLET_BOUNCE_EVENT = SoundEvent.createVariableRangeEvent(PELLET_BOUNCE); + public static final SoundEvent PELLET_EXPLODE_EVENT = SoundEvent.createVariableRangeEvent(PELLET_EXPLODE); + public static final SoundEvent PELLET_SPAWN_EVENT = SoundEvent.createVariableRangeEvent(PELLET_SPAWN); + public static final SoundEvent PELLET_TRAVEL_EVENT = SoundEvent.createVariableRangeEvent(PELLET_TRAVEL); + + public static final SoundEvent TBEAM_ENTER_EVENT = SoundEvent.createVariableRangeEvent(TBEAM_ENTER); + public static final SoundEvent TBEAM_TRAVEL_EVENT = SoundEvent.createVariableRangeEvent(TBEAM_TRAVEL); + + public static final SoundEvent BULLET_CONCRETE_EVENT = SoundEvent.createVariableRangeEvent(BULLET_CONCRETE); + public static final SoundEvent BULLET_GLASS_EVENT = SoundEvent.createVariableRangeEvent(BULLET_GLASS); + public static final SoundEvent BULLET_METAL_EVENT = SoundEvent.createVariableRangeEvent(BULLET_METAL); + + public static final SoundEvent RADIO_MUSIC_EVENT = SoundEvent.createVariableRangeEvent(RADIO_MUSIC); + public static final SoundEvent EXILE_MUSIC_EVENT = SoundEvent.createVariableRangeEvent(EXILE_SONG); + public static final SoundEvent CURIOSITY_CORE_EVENT = SoundEvent.createVariableRangeEvent(CURIOSITY_CORE_SOUND); + public static final SoundEvent ANGER_CORE_EVENT = SoundEvent.createVariableRangeEvent(ANGER_CORE_SOUND); + public static final SoundEvent CAKE_CORE_EVENT = SoundEvent.createVariableRangeEvent(CAKE_CORE_SOUND); + public static final SoundEvent SPACE_CORE_EVENT = SoundEvent.createVariableRangeEvent(SPACE_CORE_SOUND); + public static final SoundEvent FACT_CORE_EVENT = SoundEvent.createVariableRangeEvent(FACT_CORE_SOUND); + public static final SoundEvent ADVENTURE_CORE_EVENT = SoundEvent.createVariableRangeEvent(ADVENTURE_CORE_SOUND); + + public static final SoundEvent SEWAGE_STEP_EVENT = SoundEvent.createVariableRangeEvent(SEWAGE_STEP); + + public static final SoundEvent CROWBAR_SWOOSH_EVENT = SoundEvent.createVariableRangeEvent(CROWBAR_SWOOSH); + + public static final TagKey NO_ERROR_SOUND = QuiltTagKey.of(Registries.SOUND_EVENT, id("no_error_sound"), TagType.CLIENT_ONLY); public static void registerSounds() { - Registry.register(Registry.SOUND_EVENT, ERROR, ERROR_EVENT); - - Registry.register(Registry.SOUND_EVENT, GEL_BOUNCE, GEL_BOUNCE_EVENT); - Registry.register(Registry.SOUND_EVENT, GEL_RUN, GEL_RUN_EVENT); - Registry.register(Registry.SOUND_EVENT, GEL_SPLAT, GEL_SPLAT_EVENT); - Registry.register(Registry.SOUND_EVENT, PORTAL_AMBIANCE, PORTAL_AMBIENT_EVENT); - Registry.register(Registry.SOUND_EVENT, PORTAL_GUN_PRIMARY, FIRE_EVENT_PRIMARY); - Registry.register(Registry.SOUND_EVENT, PORTAL_GUN_SECONDARY, FIRE_EVENT_SECONDARY); - Registry.register(Registry.SOUND_EVENT, PORTAL_INVALID_SURFACE, INVALID_PORTAL_EVENT); - Registry.register(Registry.SOUND_EVENT, NOTHING_TO_GRAB, NOTHING_TO_GRAB_EVENT); - Registry.register(Registry.SOUND_EVENT, PORTAL_ENTER, ENTITY_ENTER_PORTAL); - Registry.register(Registry.SOUND_EVENT, PORTAL_EXIT, ENTITY_EXIT_PORTAL); - Registry.register(Registry.SOUND_EVENT, PORTAL_OPEN, ENTITY_PORTAL_OPEN); - Registry.register(Registry.SOUND_EVENT, PORTAL_CLOSE, ENTITY_PORTAL_CLOSE); - Registry.register(Registry.SOUND_EVENT, PORTAL_FIZZLE, ENTITY_PORTAL_FIZZLE); - Registry.register(Registry.SOUND_EVENT, CUBE_HIT_HIGH, CUBE_HIGH_HIT_EVENT); - Registry.register(Registry.SOUND_EVENT, CUBE_HIT_LOW, CUBE_LOW_HIT_EVENT); - Registry.register(Registry.SOUND_EVENT, CUBE_SCRAPE, CUBE_SCRAPE_EVENT); - - Registry.register(Registry.SOUND_EVENT, COMPANION_CUBE_AMBIANCE, COMPANION_CUBE_AMBIANCE_EVENT); - Registry.register(Registry.SOUND_EVENT, MATERIAL_EMANCIPATION, MATERIAL_EMANCIPATION_EVENT); - Registry.register(Registry.SOUND_EVENT, CATAPULT_LAUNCH, CATAPULT_LAUNCH_EVENT); - - Registry.register(Registry.SOUND_EVENT, PEDESTAL_BUTTON_PRESS, PEDESTAL_BUTTON_PRESS_EVENT); - Registry.register(Registry.SOUND_EVENT, PEDESTAL_BUTTON_RELEASE, PEDESTAL_BUTTON_RELEASE_EVENT); - Registry.register(Registry.SOUND_EVENT, OLD_AP_PEDESTAL_BUTTON_PRESS, OLD_AP_PEDESTAL_BUTTON_PRESS_EVENT); - Registry.register(Registry.SOUND_EVENT, OLD_AP_PEDESTAL_BUTTON_RELEASE, OLD_AP_PEDESTAL_BUTTON_RELEASE_EVENT); - Registry.register(Registry.SOUND_EVENT, FLOOR_BUTTON_PRESS, FLOOR_BUTTON_PRESS_EVENT); - Registry.register(Registry.SOUND_EVENT, FLOOR_BUTTON_RELEASE, FLOOR_BUTTON_RELEASE_EVENT); - Registry.register(Registry.SOUND_EVENT, OLD_AP_FLOOR_BUTTON_PRESS, OLD_AP_FLOOR_BUTTON_PRESS_EVENT); - Registry.register(Registry.SOUND_EVENT, OLD_AP_FLOOR_BUTTON_RELEASE, OLD_AP_FLOOR_BUTTON_RELEASE_EVENT); - - Registry.register(Registry.SOUND_EVENT, ROCKET_FIRE, ROCKET_FIRE_EVENT); - Registry.register(Registry.SOUND_EVENT, ROCKET_FLY, ROCKET_FLY_EVENT); - Registry.register(Registry.SOUND_EVENT, ROCKET_LOCKED, ROCKET_LOCKED_EVENT); - Registry.register(Registry.SOUND_EVENT, ROCKET_LOCKING, ROCKET_LOCKING_EVENT); - Registry.register(Registry.SOUND_EVENT, ROCKET_EXPLODE, ROCKET_EXPLODE_EVENT); - Registry.register(Registry.SOUND_EVENT, ROCKET_GOO, ROCKET_GOO_EVENT); - - Registry.register(Registry.SOUND_EVENT, LASER_EMITTER_ACTIVATE, LASER_EMITTER_ACTIVATE_EVENT); - Registry.register(Registry.SOUND_EVENT, LASER_BEAM_MUSIC, LASER_BEAM_MUSIC_EVENT); - Registry.register(Registry.SOUND_EVENT, LASER_NODE_MUSIC, LASER_NODE_MUSIC_EVENT); - Registry.register(Registry.SOUND_EVENT, LASER_NODE_ACTIVATE, LASER_NODE_ACTIVATE_EVENT); - Registry.register(Registry.SOUND_EVENT, LASER_NODE_DEACTIVATE, LASER_NODE_DEACTIVATE_EVENT); - Registry.register(Registry.SOUND_EVENT, LASER_TRIPLE_LASER_SOUND_DEMO_1, LASER_TRIPLE_LASER_SOUND_DEMO_1_EVENT); - Registry.register(Registry.SOUND_EVENT, LASER_TRIPLE_LASER_SOUND_DEMO_2, LASER_TRIPLE_LASER_SOUND_DEMO_2_EVENT); - Registry.register(Registry.SOUND_EVENT, LASER_TRIPLE_LASER_SOUND_DEMO_3, LASER_TRIPLE_LASER_SOUND_DEMO_3_EVENT); - - Registry.register(Registry.SOUND_EVENT, PELLET_BOUNCE, PELLET_BOUNCE_EVENT); - Registry.register(Registry.SOUND_EVENT, PELLET_EXPLODE, PELLET_EXPLODE_EVENT); - Registry.register(Registry.SOUND_EVENT, PELLET_SPAWN, PELLET_SPAWN_EVENT); - Registry.register(Registry.SOUND_EVENT, PELLET_TRAVEL, PELLET_TRAVEL_EVENT); - - Registry.register(Registry.SOUND_EVENT, TBEAM_ENTER, TBEAM_ENTER_EVENT); - Registry.register(Registry.SOUND_EVENT, TBEAM_TRAVEL, TBEAM_TRAVEL_EVENT); - - Registry.register(Registry.SOUND_EVENT, BULLET_CONCRETE, BULLET_CONCRETE_EVENT); - Registry.register(Registry.SOUND_EVENT, BULLET_GLASS, BULLET_GLASS_EVENT); - Registry.register(Registry.SOUND_EVENT, BULLET_METAL, BULLET_METAL_EVENT); - - Registry.register(Registry.SOUND_EVENT, RADIO_MUSIC, RADIO_MUSIC_EVENT); - Registry.register(Registry.SOUND_EVENT, EXILE_SONG, EXILE_MUSIC_EVENT); - Registry.register(Registry.SOUND_EVENT, CURIOSITY_CORE_SOUND, CURIOSITY_CORE_EVENT); - Registry.register(Registry.SOUND_EVENT, ANGER_CORE_SOUND, ANGER_CORE_EVENT); - Registry.register(Registry.SOUND_EVENT, CAKE_CORE_SOUND, CAKE_CORE_EVENT); - - Registry.register(Registry.SOUND_EVENT, SPACE_CORE_SOUND, SPACE_CORE_EVENT); - Registry.register(Registry.SOUND_EVENT, FACT_CORE_SOUND, FACT_CORE_EVENT); - Registry.register(Registry.SOUND_EVENT, ADVENTURE_CORE_SOUND, ADVENTURE_CORE_EVENT); - - Registry.register(Registry.SOUND_EVENT, SEWAGE_STEP, SEWAGE_STEP_EVENT); - - Registry.register(Registry.SOUND_EVENT, CROWBAR_SWOOSH, CROWBAR_SWOOSH_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, ERROR, ERROR_EVENT); + + Registry.register(BuiltInRegistries.SOUND_EVENT, GEL_BOUNCE, GEL_BOUNCE_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, GEL_RUN, GEL_RUN_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, GEL_SPLAT, GEL_SPLAT_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, PORTAL_AMBIANCE, PORTAL_AMBIENT_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, PORTAL_GUN_PRIMARY, FIRE_EVENT_PRIMARY); + Registry.register(BuiltInRegistries.SOUND_EVENT, PORTAL_GUN_SECONDARY, FIRE_EVENT_SECONDARY); + Registry.register(BuiltInRegistries.SOUND_EVENT, PORTAL_INVALID_SURFACE, INVALID_PORTAL_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, NOTHING_TO_GRAB, NOTHING_TO_GRAB_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, PORTAL_ENTER, ENTITY_ENTER_PORTAL); + Registry.register(BuiltInRegistries.SOUND_EVENT, PORTAL_EXIT, ENTITY_EXIT_PORTAL); + Registry.register(BuiltInRegistries.SOUND_EVENT, PORTAL_OPEN, ENTITY_PORTAL_OPEN); + Registry.register(BuiltInRegistries.SOUND_EVENT, PORTAL_CLOSE, ENTITY_PORTAL_CLOSE); + Registry.register(BuiltInRegistries.SOUND_EVENT, PORTAL_FIZZLE, ENTITY_PORTAL_FIZZLE); + Registry.register(BuiltInRegistries.SOUND_EVENT, CUBE_HIT_HIGH, CUBE_HIGH_HIT_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, CUBE_HIT_LOW, CUBE_LOW_HIT_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, CUBE_SCRAPE, CUBE_SCRAPE_EVENT); + + Registry.register(BuiltInRegistries.SOUND_EVENT, COMPANION_CUBE_AMBIANCE, COMPANION_CUBE_AMBIANCE_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, MATERIAL_EMANCIPATION, MATERIAL_EMANCIPATION_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, CATAPULT_LAUNCH, CATAPULT_LAUNCH_EVENT); + + Registry.register(BuiltInRegistries.SOUND_EVENT, PEDESTAL_BUTTON_PRESS, PEDESTAL_BUTTON_PRESS_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, PEDESTAL_BUTTON_RELEASE, PEDESTAL_BUTTON_RELEASE_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, OLD_AP_PEDESTAL_BUTTON_PRESS, OLD_AP_PEDESTAL_BUTTON_PRESS_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, OLD_AP_PEDESTAL_BUTTON_RELEASE, OLD_AP_PEDESTAL_BUTTON_RELEASE_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, FLOOR_BUTTON_PRESS, FLOOR_BUTTON_PRESS_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, FLOOR_BUTTON_RELEASE, FLOOR_BUTTON_RELEASE_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, OLD_AP_FLOOR_BUTTON_PRESS, OLD_AP_FLOOR_BUTTON_PRESS_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, OLD_AP_FLOOR_BUTTON_RELEASE, OLD_AP_FLOOR_BUTTON_RELEASE_EVENT); + + Registry.register(BuiltInRegistries.SOUND_EVENT, ROCKET_FIRE, ROCKET_FIRE_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, ROCKET_FLY, ROCKET_FLY_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, ROCKET_LOCKED, ROCKET_LOCKED_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, ROCKET_LOCKING, ROCKET_LOCKING_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, ROCKET_EXPLODE, ROCKET_EXPLODE_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, ROCKET_GOO, ROCKET_GOO_EVENT); + + Registry.register(BuiltInRegistries.SOUND_EVENT, LASER_EMITTER_ACTIVATE, LASER_EMITTER_ACTIVATE_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, LASER_BEAM_MUSIC, LASER_BEAM_MUSIC_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, LASER_NODE_MUSIC, LASER_NODE_MUSIC_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, LASER_NODE_ACTIVATE, LASER_NODE_ACTIVATE_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, LASER_NODE_DEACTIVATE, LASER_NODE_DEACTIVATE_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, LASER_TRIPLE_LASER_SOUND_DEMO_1, LASER_TRIPLE_LASER_SOUND_DEMO_1_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, LASER_TRIPLE_LASER_SOUND_DEMO_2, LASER_TRIPLE_LASER_SOUND_DEMO_2_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, LASER_TRIPLE_LASER_SOUND_DEMO_3, LASER_TRIPLE_LASER_SOUND_DEMO_3_EVENT); + + Registry.register(BuiltInRegistries.SOUND_EVENT, PELLET_BOUNCE, PELLET_BOUNCE_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, PELLET_EXPLODE, PELLET_EXPLODE_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, PELLET_SPAWN, PELLET_SPAWN_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, PELLET_TRAVEL, PELLET_TRAVEL_EVENT); + + Registry.register(BuiltInRegistries.SOUND_EVENT, TBEAM_ENTER, TBEAM_ENTER_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, TBEAM_TRAVEL, TBEAM_TRAVEL_EVENT); + + Registry.register(BuiltInRegistries.SOUND_EVENT, BULLET_CONCRETE, BULLET_CONCRETE_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, BULLET_GLASS, BULLET_GLASS_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, BULLET_METAL, BULLET_METAL_EVENT); + + Registry.register(BuiltInRegistries.SOUND_EVENT, RADIO_MUSIC, RADIO_MUSIC_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, EXILE_SONG, EXILE_MUSIC_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, CURIOSITY_CORE_SOUND, CURIOSITY_CORE_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, ANGER_CORE_SOUND, ANGER_CORE_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, CAKE_CORE_SOUND, CAKE_CORE_EVENT); + + Registry.register(BuiltInRegistries.SOUND_EVENT, SPACE_CORE_SOUND, SPACE_CORE_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, FACT_CORE_SOUND, FACT_CORE_EVENT); + Registry.register(BuiltInRegistries.SOUND_EVENT, ADVENTURE_CORE_SOUND, ADVENTURE_CORE_EVENT); + + Registry.register(BuiltInRegistries.SOUND_EVENT, SEWAGE_STEP, SEWAGE_STEP_EVENT); + + Registry.register(BuiltInRegistries.SOUND_EVENT, CROWBAR_SWOOSH, CROWBAR_SWOOSH_EVENT); } } diff --git a/src/main/java/com/fusionflux/portalcubed/util/BlockEntityWrapperEntity.java b/src/main/java/com/fusionflux/portalcubed/util/BlockEntityWrapperEntity.java index 04a7b036..be3d8482 100644 --- a/src/main/java/com/fusionflux/portalcubed/util/BlockEntityWrapperEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/util/BlockEntityWrapperEntity.java @@ -2,9 +2,11 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.Packet; +import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.block.entity.BlockEntity; +import org.jetbrains.annotations.NotNull; public final class BlockEntityWrapperEntity extends Entity { private final E blockEntity; @@ -26,9 +28,10 @@ protected void readAdditionalSaveData(CompoundTag nbt) { protected void addAdditionalSaveData(CompoundTag nbt) { } + @NotNull @Override - public Packet getAddEntityPacket() { - return null; + public Packet getAddEntityPacket() { + throw new UnsupportedOperationException("Shouldn't call getAddEntityPacket() on BlockEntityWrapperEntity."); } public E getBlockEntity() { diff --git a/src/main/java/com/fusionflux/portalcubed/util/PortalDirectionUtils.java b/src/main/java/com/fusionflux/portalcubed/util/PortalDirectionUtils.java index 6026871e..4c621e57 100644 --- a/src/main/java/com/fusionflux/portalcubed/util/PortalDirectionUtils.java +++ b/src/main/java/com/fusionflux/portalcubed/util/PortalDirectionUtils.java @@ -20,7 +20,7 @@ public class PortalDirectionUtils { public static Vec3 rotateVector(ExperimentalPortal portal, Vec3 vector) { Direction portalFacing = portal.getFacingDirection(); Direction otherDirec = Direction.fromNormal((int) portal.getOtherFacing().x(), (int) portal.getOtherFacing().y(), (int) portal.getOtherFacing().z()); - Direction portalVertFacing = Direction.fromNormal(new BlockPos(portal.getAxisH().get().x, portal.getAxisH().get().y, portal.getAxisH().get().z)); + Direction portalVertFacing = Direction.fromNormal(BlockPos.containing(portal.getAxisH().get().x, portal.getAxisH().get().y, portal.getAxisH().get().z)); IPQuaternion rotationW = IPQuaternion.getRotationBetween(portal.getAxisW().orElseThrow().scale(-1), portal.getOtherAxisW(), (portal.getAxisH().orElseThrow())); IPQuaternion rotationH = IPQuaternion.getRotationBetween((portal.getAxisH().orElseThrow()), (portal.getOtherAxisH()), portal.getAxisW().orElseThrow().scale(-1)); diff --git a/src/main/resources/data/minecraft/tags/damage_type/bypasses_armor.json b/src/main/resources/data/minecraft/tags/damage_type/bypasses_armor.json new file mode 100644 index 00000000..3af60939 --- /dev/null +++ b/src/main/resources/data/minecraft/tags/damage_type/bypasses_armor.json @@ -0,0 +1,9 @@ +{ + "replace": false, + "values": [ + "portalcubed:acid", + "portalcubed:fizzle", + "portalcubed:vaporization", + "portalcubed:laser" + ] +} \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/damage_type/damages_helmet.json b/src/main/resources/data/minecraft/tags/damage_type/damages_helmet.json new file mode 100644 index 00000000..66b5d460 --- /dev/null +++ b/src/main/resources/data/minecraft/tags/damage_type/damages_helmet.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "portalcubed:cube" + ] +} \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/damage_type/is_fire.json b/src/main/resources/data/minecraft/tags/damage_type/is_fire.json new file mode 100644 index 00000000..e3c7f7c6 --- /dev/null +++ b/src/main/resources/data/minecraft/tags/damage_type/is_fire.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "portalcubed:laser" + ] +} \ No newline at end of file diff --git a/src/main/resources/data/portalcubed/damage_type/acid.json b/src/main/resources/data/portalcubed/damage_type/acid.json new file mode 100644 index 00000000..c0522cc6 --- /dev/null +++ b/src/main/resources/data/portalcubed/damage_type/acid.json @@ -0,0 +1,6 @@ +{ + "effects": "drowning", + "exhaustion": 0, + "message_id": "acid", + "scaling": "when_caused_by_living_non_player" +} \ No newline at end of file diff --git a/src/main/resources/data/portalcubed/damage_type/cube.json b/src/main/resources/data/portalcubed/damage_type/cube.json new file mode 100644 index 00000000..73d0d878 --- /dev/null +++ b/src/main/resources/data/portalcubed/damage_type/cube.json @@ -0,0 +1,5 @@ +{ + "exhaustion": 0.1, + "message_id": "acid", + "scaling": "when_caused_by_living_non_player" +} \ No newline at end of file diff --git a/src/main/resources/data/portalcubed/damage_type/fizzle.json b/src/main/resources/data/portalcubed/damage_type/fizzle.json new file mode 100644 index 00000000..89243dfa --- /dev/null +++ b/src/main/resources/data/portalcubed/damage_type/fizzle.json @@ -0,0 +1,5 @@ +{ + "exhaustion": 0, + "message_id": "fizzle", + "scaling": "when_caused_by_living_non_player" +} \ No newline at end of file diff --git a/src/main/resources/data/portalcubed/damage_type/laser.json b/src/main/resources/data/portalcubed/damage_type/laser.json new file mode 100644 index 00000000..6b727506 --- /dev/null +++ b/src/main/resources/data/portalcubed/damage_type/laser.json @@ -0,0 +1,6 @@ +{ + "effects": "burning", + "exhaustion": 0, + "message_id": "laser", + "scaling": "when_caused_by_living_non_player" +} \ No newline at end of file diff --git a/src/main/resources/data/portalcubed/damage_type/vaporization.json b/src/main/resources/data/portalcubed/damage_type/vaporization.json new file mode 100644 index 00000000..e06d50ed --- /dev/null +++ b/src/main/resources/data/portalcubed/damage_type/vaporization.json @@ -0,0 +1,5 @@ +{ + "exhaustion": 0, + "message_id": "vaporization", + "scaling": "when_caused_by_living_non_player" +} \ No newline at end of file