Skip to content

Commit

Permalink
WIP 1.21 refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaMode committed Jul 14, 2024
1 parent 3e5aab5 commit 6a94fa1
Show file tree
Hide file tree
Showing 297 changed files with 10,302 additions and 7,027 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ Just choose a version and use its version number.
| `tags` | Forge tags |
| `tool_actions` | Utilities for tool interactions |
| `transfer` | Storage implementations, client-side lookup, FluidStack, assorted transfer utilities |
| `utility` | Miscellaneous utilities that are too niche for other modules |

### Contributing
See [the contribution information](CONTRIBUTING.md).
Expand Down
14 changes: 9 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,12 @@ allprojects {
dependencies {
// dev environment
minecraft("com.mojang:minecraft:$minecraft_version")
mappings(loom.layered {
if (parchment_version != "none")
it.parchment("org.parchmentmc.data:parchment-$minecraft_version:$parchment_version@zip")
it.officialMojangMappings { nameSyntheticMembers = false }
})
// mappings(loom.layered {
// if (parchment_version != "none")
// it.parchment("org.parchmentmc.data:parchment-$minecraft_version:$parchment_version@zip")
// it.officialMojangMappings { nameSyntheticMembers = false }
// })
mappings(loom.officialMojangMappings())
modImplementation("net.fabricmc:fabric-loader:$loader_version")

modLocalRuntime("com.terraformersmc:modmenu:$modmenu_version") { exclude group: "net.fabricmc"; exclude group: "net.fabricmc.fabric-api" }
Expand All @@ -112,6 +113,9 @@ allprojects {

implementation("javax.annotation:javax.annotation-api:1.3.2")
implementation("com.google.code.findbugs:jsr305:3.0.2")

if (mixin_extras_version != "none")
include(implementation(annotationProcessor("io.github.llamalad7:mixinextras-fabric:${mixin_extras_version}")))
}

loom {
Expand Down
6 changes: 6 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ minecraft_dependency = 1.21
loader_version = 0.15.11
fabric_version = 0.100.2+1.21

# Mixin Extra's
# https://github.com/LlamaLad7/MixinExtras
# If set to 'none' Mixin Extra's will not be JiJ'd and Porting Lib will use whatever version fabric loader bundles
# ! Currently we use 0.4.0-beta.2 for @WrapMethod
mixin_extras_version = 0.4.0-beta.2

# Mappings
# https://lambdaurora.dev/tools/import_quilt.html
# unused
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"common.accessor.BlockEntityAccessor",
"common.accessor.BlockLootSubProviderAccessor",
"common.accessor.BucketItemAccessor",
"common.accessor.BundleItemAccessor",
"common.accessor.ClientboundPlayerAbilitiesPacketAccessor",
"common.accessor.CubeVoxelShapeAccessor",
"common.accessor.EntityAccessor",
Expand All @@ -26,14 +25,10 @@
"common.accessor.LiquidBlockAccessor",
"common.accessor.LivingEntityAccessor",
"common.accessor.MinecraftServerAccessor",
"common.accessor.MobAccessor",
"common.accessor.PackRepositoryAccessor",
"common.accessor.PaintingAccessor",
"common.accessor.PlayerAccessor",
"common.accessor.PotionBrewing$MixAccessor",
"common.accessor.PotionBrewingAccessor",
"common.accessor.RailStateAccessor",
"common.accessor.RecipeManagerAccessor",
"common.accessor.ServerGamePacketListenerImplAccessor",
"common.accessor.ServerPlayerAccessor",
"common.accessor.SlotAccessor",
Expand All @@ -52,12 +47,10 @@
"client.accessor.CommandSuggestions$SuggestionsListAccessor",
"client.accessor.FontAccessor",
"client.accessor.GameRendererAccessor",
"client.accessor.GuiAccessor",
"client.accessor.HumanoidModelAccessor",
"client.accessor.ItemInHandRendererAccessor",
"client.accessor.ItemRendererAccessor",
"client.accessor.KeyMappingAccessor",
"client.accessor.ModelBakeryAccessor",
"client.accessor.ModelPartAccessor",
"client.accessor.ParticleAccessor",
"client.accessor.ParticleEngineAccessor",
Expand All @@ -68,8 +61,7 @@
"client.accessor.SimpleBakedModel$BuilderAccessor",
"client.accessor.TextureAtlasSprite$AnimatedTextureAccessor",
"client.accessor.TextureSheetParticleAccessor",
"client.accessor.TextureStateShardAccessor",
"client.accessor.TitleScreenAccessor"
"client.accessor.TextureStateShardAccessor"
],
"injectors": {
"defaultRequire": 1,
Expand Down
1 change: 0 additions & 1 deletion modules/base/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ portingLib.addModuleDependencies([
"extensions",
"gui_utils",
"transfer",
"utility",
"entity",
"common",
"config",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import io.github.fabricators_of_create.porting_lib.command.ConfigCommand;
import io.github.fabricators_of_create.porting_lib.command.EnumArgument;
import io.github.fabricators_of_create.porting_lib.event.common.ModsLoadedCallback;
import io.github.fabricators_of_create.porting_lib.util.DeferredSpawnEggItem;
import io.github.fabricators_of_create.porting_lib.util.UsernameCache;

import net.fabricmc.fabric.api.command.v2.ArgumentTypeRegistry;
Expand All @@ -15,20 +17,15 @@
import io.github.fabricators_of_create.porting_lib.core.PortingLib;
import io.github.fabricators_of_create.porting_lib.transfer.item.ItemItemStorages;
import io.github.fabricators_of_create.porting_lib.util.PortingHooks;
import io.github.fabricators_of_create.porting_lib.util.TierSortingRegistry;
import net.fabricmc.api.ModInitializer;
import net.minecraft.commands.synchronization.ArgumentTypeInfos;
import net.minecraft.commands.synchronization.SingletonArgumentInfo;
import net.minecraft.core.registries.BuiltInRegistries;

public class PortingLibBase implements ModInitializer {
public static final Logger LOGGER = LoggerFactory.getLogger("Porting Lib Base");
@Override
public void onInitialize() {
TierSortingRegistry.init();
ItemItemStorages.init();
UsernameCache.load();
PortingHooks.init();
// can be used to force all mixins to apply
// MixinEnvironment.getCurrentEnvironment().audit();

Expand All @@ -38,5 +35,7 @@ public void onInitialize() {
new EnumArgument.Info());

CommandRegistrationCallback.EVENT.register(ConfigCommand::register);

ModsLoadedCallback.EVENT.register(envType -> DeferredSpawnEggItem.init());
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package io.github.fabricators_of_create.porting_lib;

import io.github.fabricators_of_create.porting_lib.event.common.ModsLoadedCallback;

import io.github.fabricators_of_create.porting_lib.util.DeferredSpawnEggItem;
import net.fabricmc.api.EnvType;

import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.minecraft.util.FastColor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.github.fabricators_of_create.porting_lib.util.FluidTextUtil;
import io.github.fabricators_of_create.porting_lib.util.LogicalSidedProvider;
import io.github.fabricators_of_create.porting_lib.util.NetworkHooks;
import io.netty.buffer.Unpooled;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerType;
Expand All @@ -23,7 +29,7 @@
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.MenuType;

public class PortingLibClient implements ClientModInitializer {
public class PortingLibBaseClient implements ClientModInitializer {
private final Logger LOGGER = LoggerFactory.getLogger("porting_lib_client");

@Override
Expand All @@ -40,9 +46,12 @@ public void onInitializeClient() {

client.execute(() -> openScreen(typeId, syncId, title, extraData));
});
ClientLifecycleEvents.CLIENT_STARTED.register(client -> LogicalSidedProvider.setClient(() -> client));


ModsLoadedCallback.EVENT.register(envType -> {
if (envType == EnvType.CLIENT) {
DeferredSpawnEggItem.MOD_EGGS.forEach(egg -> ColorProviderRegistry.ITEM.register((stack, layer) -> FastColor.ARGB32.opaque(egg.getColor(layer)), egg));
}
});
}

private void openScreen(int typeId, int syncId, Component title, FriendlyByteBuf buf) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
package io.github.fabricators_of_create.porting_lib.block;

import net.minecraft.core.HolderLookup;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.Connection;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.world.level.block.entity.BlockEntity;

public interface CustomDataPacketHandlingBlockEntity {
void onDataPacket(Connection connection, ClientboundBlockEntityDataPacket packet);
/**
* Called when you receive a {@link ClientboundBlockEntityDataPacket} packet for the location this
* BlockEntity is currently in. On the client, the Connection will always
* be the remote server. On the server, it will be whomever is responsible for
* sending the packet.
*
* @param net The Connection the packet originated from
* @param pkt The data packet
*/
default void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt, HolderLookup.Provider lookupProvider) {
CompoundTag compoundtag = pkt.getTag();
if (!compoundtag.isEmpty()) {
((BlockEntity) this).loadWithComponents(compoundtag, lookupProvider);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
package io.github.fabricators_of_create.porting_lib.block;

import net.minecraft.core.BlockPos;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentEffectComponents;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;

import org.jetbrains.annotations.Nullable;

public interface CustomExpBlock {
/**
* Gathers how much experience this block drops when broken.
* Returns how many experience points this block drops when broken, before application of {@linkplain EnchantmentEffectComponents#BLOCK_EXPERIENCE enchantments}.
*
* @param state The current state
* @param level The level
* @param randomSource Random source to use for experience randomness
* @param pos Block position
* @param fortuneLevel fortune enchantment level of tool being used
* @param silkTouchLevel silk touch enchantment level of tool being used
* @return Amount of XP from breaking this block.
* @param state The state of the block being broken
* @param level The level
* @param pos The position of the block being broken
* @param blockEntity The block entity, if any
* @param breaker The entity who broke the block, if known
* @param tool The item stack used to break the block. May be empty
* @return The amount of experience points dropped by this block
*/
default int getExpDrop(BlockState state, LevelReader level, RandomSource randomSource, BlockPos pos, int fortuneLevel, int silkTouchLevel) {
default int getExpDrop(BlockState state, LevelAccessor level, BlockPos pos, @Nullable BlockEntity blockEntity, @Nullable Entity breaker, ItemStack tool) {
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,18 @@

public interface CustomRunningEffectsBlock {
/**
* @return true to prevent vanilla particles spawning
* Allows a block to override the standard vanilla running particles.
* This is called from Entity.spawnSprintParticle and is called both,
* Client and server side, it's up to the implementor to client check / server check.
* By default vanilla spawns particles only on the client and the server methods no-op.
*
* @param state The BlockState the entity is running on.
* @param level The level.
* @param pos The position at the entities feet.
* @param entity The entity running on the block.
* @return True to prevent vanilla running particles from spawning.
*/
boolean addRunningEffects(BlockState state, Level world, BlockPos pos, Entity entity);
default boolean addRunningEffects(BlockState state, Level level, BlockPos pos, Entity entity) {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
package io.github.fabricators_of_create.porting_lib.block;

import net.minecraft.core.HolderLookup;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.block.entity.BlockEntity;

public interface CustomUpdateTagHandlingBlockEntity {
default void handleUpdateTag(CompoundTag tag) {
((BlockEntity) this).load(tag);
/**
* Called when the chunk's BE update tag, gotten from {@link BlockEntity#getUpdateTag(HolderLookup.Provider)}, is received on the client.
* <p>
* Used to handle this tag in a special way. By default this simply calls {@link BlockEntity#loadWithComponents(CompoundTag, HolderLookup.Provider)}.
*
* @param tag The {@link CompoundTag} sent from {@link BlockEntity#getUpdateTag(HolderLookup.Provider)}
*/
default void handleUpdateTag(CompoundTag tag, HolderLookup.Provider lookupProvider) {
((BlockEntity) this).loadWithComponents(tag, lookupProvider);
}
}

This file was deleted.

Loading

0 comments on commit 6a94fa1

Please sign in to comment.