feat: 适配1.19.4
This commit is contained in:
1 parent
f30e7425e6
commit
82611a23d4
6 files changed
+24
-12
No files matched your search
+4
-4
@@ -3,12 +3,12 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
|
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/develop
|
# check these on https://fabricmc.net/develop
|
||||||
minecraft_version=1.19.2
|
minecraft_version=1.19.4
|
||||||
yarn_mappings=1.19.2+build.8
|
yarn_mappings=1.19.4+build.1
|
||||||
loader_version=0.14.9
|
loader_version=0.14.17
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 0.4
|
mod_version = 0.5
|
||||||
maven_group = com.github.zly2006
|
maven_group = com.github.zly2006
|
||||||
archives_base_name = carpet-sls-addition
|
archives_base_name = carpet-sls-addition
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.recipe.Ingredient;
|
import net.minecraft.recipe.Ingredient;
|
||||||
import net.minecraft.recipe.ShapedRecipe;
|
import net.minecraft.recipe.ShapedRecipe;
|
||||||
|
import net.minecraft.recipe.book.CraftingRecipeCategory;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.command.CommandManager;
|
import net.minecraft.server.command.CommandManager;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
@@ -69,7 +70,7 @@ public class ServerMain implements ModInitializer, CarpetExtension {
|
|||||||
ingredients.set(2, Ingredient.ofItems(Items.OBSIDIAN));
|
ingredients.set(2, Ingredient.ofItems(Items.OBSIDIAN));
|
||||||
ingredients.set(4, Ingredient.ofItems(Items.STICK));
|
ingredients.set(4, Ingredient.ofItems(Items.STICK));
|
||||||
ingredients.set(7, Ingredient.ofItems(Items.STICK));
|
ingredients.set(7, Ingredient.ofItems(Items.STICK));
|
||||||
server.getRecipeManager().setRecipes(List.of(new ShapedRecipe(new Identifier(MOD_ID, "recipe.obsidian_pickaxe"), MOD_ID, 3, 3, ingredients, stack)));
|
server.getRecipeManager().setRecipes(List.of(new ShapedRecipe(new Identifier(MOD_ID, "recipe.obsidian_pickaxe"), MOD_ID, CraftingRecipeCategory.EQUIPMENT, 3, 3, ingredients, stack)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -4,7 +4,7 @@ import carpet.patches.EntityPlayerMPFake;
|
|||||||
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
|
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import net.minecraft.util.UserCache;
|
import net.minecraft.util.UserCache;
|
||||||
import net.minecraft.util.dynamic.DynamicSerializableUuid;
|
import net.minecraft.util.Uuids;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
@@ -17,7 +17,7 @@ public class MixinFakePlayer {
|
|||||||
@Redirect(method = "createFake", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/UserCache;findByName(Ljava/lang/String;)Ljava/util/Optional;"))
|
@Redirect(method = "createFake", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/UserCache;findByName(Ljava/lang/String;)Ljava/util/Optional;"))
|
||||||
private static Optional<GameProfile> onCreate(UserCache instance, String name) {
|
private static Optional<GameProfile> onCreate(UserCache instance, String name) {
|
||||||
if (SLSCarpetSettings.offlineFakePlayers) {
|
if (SLSCarpetSettings.offlineFakePlayers) {
|
||||||
UUID uuid = DynamicSerializableUuid.getOfflinePlayerUuid(name);
|
UUID uuid = Uuids.getOfflinePlayerUuid(name);
|
||||||
return Optional.of(new GameProfile(uuid, name));
|
return Optional.of(new GameProfile(uuid, name));
|
||||||
}
|
}
|
||||||
return instance.findByName(name);
|
return instance.findByName(name);
|
||||||
|
|||||||
+11
-2
@@ -1,10 +1,14 @@
|
|||||||
package com.github.zly2006.carpetslsaddition.mixin.entity;
|
package com.github.zly2006.carpetslsaddition.mixin.entity;
|
||||||
|
|
||||||
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
|
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
|
||||||
|
import com.github.zly2006.carpetslsaddition.ServerMain;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.ItemEntity;
|
import net.minecraft.entity.ItemEntity;
|
||||||
import net.minecraft.entity.damage.DamageSource;
|
import net.minecraft.entity.damage.DamageSource;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
@@ -12,7 +16,11 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
@Mixin(ItemEntity.class)
|
@Mixin(ItemEntity.class)
|
||||||
public abstract class MixinItemEntity {
|
public abstract class MixinItemEntity extends Entity {
|
||||||
|
public MixinItemEntity(EntityType<?> type, World world) {
|
||||||
|
super(type, world);
|
||||||
|
}
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
public abstract ItemStack getStack();
|
public abstract ItemStack getStack();
|
||||||
|
|
||||||
@@ -21,7 +29,8 @@ public abstract class MixinItemEntity {
|
|||||||
|
|
||||||
@Inject(method = "damage", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/ItemEntity;discard()V"), cancellable = true)
|
@Inject(method = "damage", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/ItemEntity;discard()V"), cancellable = true)
|
||||||
private void damage(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
|
private void damage(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
|
||||||
if (source == DamageSource.ANVIL && SLSCarpetSettings.obtainableReinforcedDeepSlate) {
|
// TODO: 迁移至1.19.4时,需要修改DamageSource相关逻辑
|
||||||
|
if (source == this.getDamageSources().fallingAnvil() && SLSCarpetSettings.obtainableReinforcedDeepSlate) {
|
||||||
if ((getStack().isOf(Items.DEEPSLATE) || getStack().isOf(Items.COBBLED_DEEPSLATE))
|
if ((getStack().isOf(Items.DEEPSLATE) || getStack().isOf(Items.COBBLED_DEEPSLATE))
|
||||||
&& getStack().getCount() == 64) {
|
&& getStack().getCount() == 64) {
|
||||||
setStack(new ItemStack(Items.REINFORCED_DEEPSLATE));
|
setStack(new ItemStack(Items.REINFORCED_DEEPSLATE));
|
||||||
|
|||||||
+4
-2
@@ -23,10 +23,11 @@ public abstract class MixinServerPlayerEntity extends PlayerEntity {
|
|||||||
private int sneakTimes = 0;
|
private int sneakTimes = 0;
|
||||||
private long lastSneakTime = 0;
|
private long lastSneakTime = 0;
|
||||||
|
|
||||||
public MixinServerPlayerEntity(World world, BlockPos pos, float yaw, GameProfile gameProfile, @Nullable PlayerPublicKey publicKey) {
|
public MixinServerPlayerEntity(World world, BlockPos pos, float yaw, GameProfile gameProfile) {
|
||||||
super(world, pos, yaw, gameProfile, publicKey);
|
super(world, pos, yaw, gameProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSneaking(boolean sneaking){
|
public void setSneaking(boolean sneaking){
|
||||||
if (!SLSCarpetSettings.playerSit || (sneaking && this.isSneaking())) {
|
if (!SLSCarpetSettings.playerSit || (sneaking && this.isSneaking())) {
|
||||||
@@ -59,6 +60,7 @@ public abstract class MixinServerPlayerEntity extends PlayerEntity {
|
|||||||
// 同步潜行状态到客户端
|
// 同步潜行状态到客户端
|
||||||
// 如果不同步的话客户端会认为仍在潜行,从而碰撞箱的高度会计算错误
|
// 如果不同步的话客户端会认为仍在潜行,从而碰撞箱的高度会计算错误
|
||||||
if (sneakTimes == 0 && this.networkHandler != null) {
|
if (sneakTimes == 0 && this.networkHandler != null) {
|
||||||
|
// TODO: 构造函数改变,需要进行适配
|
||||||
this.networkHandler.sendPacket(new EntityTrackerUpdateS2CPacket(this.getId(), this.getDataTracker(), true));
|
this.networkHandler.sendPacket(new EntityTrackerUpdateS2CPacket(this.getId(), this.getDataTracker(), true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -29,7 +29,7 @@ public abstract class MixinBeehiveBlockEntity extends BlockEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "tickBees", at = @At(value = "INVOKE", target = "Ljava/util/Iterator;remove()V", shift = At.Shift.AFTER))
|
@Inject(method = "tickBees", at = @At(value = "INVOKE", target = "Ljava/util/Iterator;remove()V", shift = At.Shift.AFTER))
|
||||||
private static void postTickBees(World world, BlockPos pos, BlockState state, List<BeehiveBlockEntity.Bee> bees, BlockPos flowerPos, CallbackInfo ci) {
|
private static void postTickBees(World world, BlockPos pos, BlockState state, List<Object> bees, BlockPos flowerPos, CallbackInfo ci) {
|
||||||
if (SLSCarpetSettings.pcaSyncProtocol && PcaSyncProtocol.syncBlockEntityToClient(Objects.requireNonNull(world.getBlockEntity(pos)))) {
|
if (SLSCarpetSettings.pcaSyncProtocol && PcaSyncProtocol.syncBlockEntityToClient(Objects.requireNonNull(world.getBlockEntity(pos)))) {
|
||||||
ServerMain.LOGGER.debug("update BeehiveBlockEntity: {}", pos);
|
ServerMain.LOGGER.debug("update BeehiveBlockEntity: {}", pos);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user