Update Fabric API and make use of its new features.
|
@ -27,15 +27,21 @@ package reborncore;
|
|||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerBlockEntityEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerEntityEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents;
|
||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidStorage;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import reborncore.api.ToolManager;
|
||||
import reborncore.api.blockentity.UnloadHandler;
|
||||
import reborncore.api.items.ArmorRemoveHandler;
|
||||
import reborncore.common.RebornCoreCommands;
|
||||
import reborncore.common.RebornCoreConfig;
|
||||
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||
|
@ -110,6 +116,13 @@ public class RebornCore implements ModInitializer {
|
|||
ServerWorldEvents.LOAD.register((server, world) -> ChunkLoaderManager.get(world).onServerWorldLoad(world));
|
||||
ServerTickEvents.START_WORLD_TICK.register(world -> ChunkLoaderManager.get(world).onServerWorldTick(world));
|
||||
|
||||
ServerEntityEvents.EQUIPMENT_CHANGE.register((livingEntity, equipmentSlot, previousStack, currentStack) -> {
|
||||
if (livingEntity instanceof PlayerEntity playerEntity
|
||||
&& previousStack.getItem() instanceof ArmorRemoveHandler armorRemoveHandler) {
|
||||
armorRemoveHandler.onRemoved(playerEntity);
|
||||
}
|
||||
});
|
||||
|
||||
FluidStorage.SIDED.registerFallback((world, pos, state, be, direction) -> {
|
||||
if (be instanceof MachineBaseBlockEntity machineBase) {
|
||||
return machineBase.getTank();
|
||||
|
|
|
@ -28,7 +28,6 @@ import net.minecraft.entity.EntityType;
|
|||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
@ -36,8 +35,6 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import reborncore.api.items.ArmorBlockEntityTicker;
|
||||
import reborncore.api.items.ArmorRemoveHandler;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
|
||||
@Mixin(PlayerEntity.class)
|
||||
public abstract class MixinPlayerEntity extends LivingEntity {
|
||||
|
@ -49,21 +46,9 @@ public abstract class MixinPlayerEntity extends LivingEntity {
|
|||
super(type, world);
|
||||
}
|
||||
|
||||
private final DefaultedList<ItemStack> reborncore_armorcache = DefaultedList.ofSize(4, ItemStack.EMPTY);
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"))
|
||||
public void tick(CallbackInfo info) {
|
||||
int i = 0;
|
||||
for (ItemStack stack : getArmorItems()) {
|
||||
ItemStack cachedStack = reborncore_armorcache.get(i);
|
||||
if (!ItemUtils.isItemEqual(cachedStack, stack, false, false)) {
|
||||
if (cachedStack.getItem() instanceof ArmorRemoveHandler) {
|
||||
((ArmorRemoveHandler) cachedStack.getItem()).onRemoved((PlayerEntity) (Object) this);
|
||||
}
|
||||
reborncore_armorcache.set(i, stack.copy());
|
||||
}
|
||||
i++;
|
||||
|
||||
if (!stack.isEmpty() && stack.getItem() instanceof ArmorBlockEntityTicker) {
|
||||
((ArmorBlockEntityTicker) stack.getItem()).tickArmor(stack, (PlayerEntity) (Object) this);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.8",
|
||||
"fabric-api": ">=0.60.0",
|
||||
"fabric-api": ">=0.62.0",
|
||||
"team_reborn_energy": ">=2.2.0",
|
||||
"fabric-biome-api-v1": ">=3.0.0",
|
||||
"minecraft": "~1.19.2"
|
||||
|
|
|
@ -9,7 +9,7 @@ mod_version=5.3.4
|
|||
minecraft_version=1.19.2
|
||||
yarn_version=1.19.2+build.10
|
||||
loader_version=0.14.9
|
||||
fapi_version=0.60.0+1.19.2
|
||||
fapi_version=0.62.0+1.19.2
|
||||
|
||||
# Dependencies
|
||||
energy_version=2.2.0
|
||||
|
|
|
@ -26,6 +26,7 @@ package techreborn.datagen
|
|||
|
||||
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator
|
||||
import techreborn.TechReborn
|
||||
import techreborn.datagen.models.ModelProvider
|
||||
import techreborn.datagen.recipes.crafting.CraftingRecipesProvider
|
||||
import techreborn.datagen.recipes.machine.assembling_machine.AssemblingMachineRecipesProvider
|
||||
|
@ -65,4 +66,9 @@ class TechRebornDataGen implements DataGeneratorEntrypoint {
|
|||
|
||||
fabricDataGenerator.addProvider(ModelProvider.&new)
|
||||
}
|
||||
|
||||
@Override
|
||||
String getEffectiveModId() {
|
||||
return TechReborn.MOD_ID
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,6 +69,8 @@ public enum TRArmorMaterials implements ArmorMaterial {
|
|||
private final float knockbackResistance;
|
||||
private final Lazy<Ingredient> repairMaterial;
|
||||
|
||||
private final String name;
|
||||
|
||||
TRArmorMaterials(int maxDamageFactor, int[] damageReductionAmountArray, int enchantability,
|
||||
SoundEvent soundEvent, float toughness, float knockbackResistance, Supplier<Ingredient> repairMaterialIn) {
|
||||
this.maxDamageFactor = maxDamageFactor;
|
||||
|
@ -78,6 +80,7 @@ public enum TRArmorMaterials implements ArmorMaterial {
|
|||
this.toughness = toughness;
|
||||
this.knockbackResistance = knockbackResistance;
|
||||
this.repairMaterial = new Lazy<>(repairMaterialIn);
|
||||
this.name = "techreborn:" + this.toString().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
TRArmorMaterials(int maxDamageFactor, int[] damageReductionAmountArray, int enchantability,
|
||||
|
@ -112,7 +115,7 @@ public enum TRArmorMaterials implements ArmorMaterial {
|
|||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.toString().toLowerCase(Locale.ROOT);
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 616 B After Width: | Height: | Size: 616 B |
Before Width: | Height: | Size: 266 B After Width: | Height: | Size: 266 B |
Before Width: | Height: | Size: 624 B After Width: | Height: | Size: 624 B |
Before Width: | Height: | Size: 457 B After Width: | Height: | Size: 457 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 622 B After Width: | Height: | Size: 622 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 672 B After Width: | Height: | Size: 672 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 614 B After Width: | Height: | Size: 614 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 614 B After Width: | Height: | Size: 614 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 352 B After Width: | Height: | Size: 352 B |
Before Width: | Height: | Size: 575 B After Width: | Height: | Size: 575 B |
Before Width: | Height: | Size: 352 B After Width: | Height: | Size: 352 B |
|
@ -31,7 +31,7 @@
|
|||
},
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.8",
|
||||
"fabric-api": ">=0.60.0",
|
||||
"fabric-api": ">=0.62.0",
|
||||
"reborncore": "*",
|
||||
"team_reborn_energy": ">=2.2.0",
|
||||
"fabric-biome-api-v1": ">=3.0.0",
|
||||
|
|