fix: 修复了强化深板岩可获取功能不可用的问题
This commit is contained in:
1 parent
a0ffb5eb6a
commit
e8dc993ed2
13 files changed
+77
-68
No files matched your search
@@ -37,6 +37,9 @@ public class SLSCarpetSettings {
|
||||
@Rule(categories = {CARPET_ID, RuleCategory.FEATURE})
|
||||
public static boolean canUseSitCommand = false;
|
||||
|
||||
@Rule(categories = {CARPET_ID, RuleCategory.CREATIVE})
|
||||
public static int maxUpdateQueueSize = -1;
|
||||
|
||||
@Rule(categories = {CARPET_ID, PCA, PROTOCOL})
|
||||
public static boolean pcaSyncProtocol = false;
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ public class ServerMain implements ModInitializer, CarpetExtension {
|
||||
ServerPlayerEntity player = context.getSource().getPlayer();
|
||||
assert player != null;
|
||||
|
||||
if (player.getVehicle() != null) { // 防止重复的坐下行为
|
||||
if (player.getVehicle() != null || !player.isOnGround()) { // 防止错误的坐下行为
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
-50
@@ -1,50 +0,0 @@
|
||||
package com.github.zly2006.carpetslsaddition.mixin.block;
|
||||
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.SignBlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(AbstractSignBlock.class)
|
||||
public class MixinAbstractSignBlock {
|
||||
@Inject(method = "onUse", at = @At("HEAD"), cancellable = true)
|
||||
private void use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> cir) {
|
||||
if (state.getBlock() instanceof WallSignBlock && false) {
|
||||
BlockPos pos1 = pos.offset(state.get(WallSignBlock.FACING).getOpposite());
|
||||
BlockState state1 = world.getBlockState(pos1);
|
||||
if (state1.getBlock() instanceof ChestBlock || state1.getBlock() instanceof BarrelBlock) {
|
||||
SignBlockEntity signBlockEntity = (SignBlockEntity) world.getBlockEntity(pos);
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos1);
|
||||
if (blockEntity instanceof Inventory inventory) {
|
||||
if (signBlockEntity.getTextOnRow(0, true).getString().equals("[[Once]]")) {
|
||||
int i = 0;
|
||||
for (; i < inventory.size(); i++) {
|
||||
if (!inventory.getStack(i).isEmpty()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == inventory.size()) {
|
||||
return;
|
||||
}
|
||||
ItemStack stack = inventory.removeStack(i);
|
||||
inventory.markDirty();
|
||||
if (player.getInventory().insertStack(stack)) {
|
||||
cir.setReturnValue(ActionResult.SUCCESS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
-3
@@ -1,8 +1,15 @@
|
||||
package com.github.zly2006.carpetslsaddition.mixin.entity;
|
||||
|
||||
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.FallingBlockEntity;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.predicate.entity.EntityPredicates;
|
||||
import net.minecraft.world.World;
|
||||
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;
|
||||
@@ -11,9 +18,17 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@Mixin(FallingBlockEntity.class)
|
||||
public class MixinFallingBlockEntity {
|
||||
@Inject(method = "handleFallDamage", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getOtherEntities(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/math/Box;Ljava/util/function/Predicate;)Ljava/util/List;"), locals = LocalCapture.CAPTURE_FAILSOFT)
|
||||
private void handleFallDamage(float fallDistance, float damageMultiplier, DamageSource damageSource, CallbackInfoReturnable<Boolean> cir, int i, Predicate<?> predicate, DamageSource damageSource2, float f) {
|
||||
public abstract class MixinFallingBlockEntity extends Entity {
|
||||
|
||||
public MixinFallingBlockEntity(EntityType<?> type, World world) {
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
@Inject(method = "handleFallDamage", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getOtherEntities(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/math/Box;Ljava/util/function/Predicate;)Ljava/util/List;", shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILSOFT)
|
||||
private void handleFallDamage(float fallDistance, float damageMultiplier, DamageSource damageSource, CallbackInfoReturnable<Boolean> cir, int i, Predicate<Entity> predicate, DamageSource damageSource2, float f) {
|
||||
if (SLSCarpetSettings.obtainableReinforcedDeepSlate) {
|
||||
predicate = entity -> entity instanceof ItemEntity;
|
||||
this.getWorld().getOtherEntities(this, this.getBoundingBox(), predicate).forEach((entity) -> entity.damage(damageSource2, f));
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -14,10 +14,11 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(ServerPlayerEntity.class)
|
||||
public abstract class MixinServerPlayerEntity extends PlayerEntity {
|
||||
public abstract class MixinServerPlayerEntity extends PlayerEntity {
|
||||
@Shadow
|
||||
public ServerPlayNetworkHandler networkHandler;
|
||||
|
||||
|
||||
private int sneakTimes = 0;
|
||||
private long lastSneakTime = 0;
|
||||
|
||||
@@ -42,9 +43,9 @@ public abstract class MixinServerPlayerEntity extends PlayerEntity {
|
||||
if (this.isOnGround() && nowTime - lastSneakTime < 400) {
|
||||
sneakTimes += 1;
|
||||
if (sneakTimes == 3) {
|
||||
ArmorStandEntity armorStandEntity = new ArmorStandEntity(world, this.getX(), this.getY() - 0.16, this.getZ());
|
||||
ArmorStandEntity armorStandEntity = new ArmorStandEntity(getWorld(), this.getX(), this.getY() - 0.16, this.getZ());
|
||||
((SitEntity) armorStandEntity).setSitEntity(true);
|
||||
world.spawnEntity(armorStandEntity);
|
||||
getWorld().spawnEntity(armorStandEntity);
|
||||
this.setSneaking(false);
|
||||
this.startRiding(armorStandEntity);
|
||||
sneakTimes = 0;
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ public abstract class MixinMerchantEntity extends PassiveEntity implements Npc,
|
||||
|
||||
@Inject(method = "<init>(Lnet/minecraft/entity/EntityType;Lnet/minecraft/world/World;)V", at = @At(value = "RETURN"))
|
||||
private void addInventoryListener(EntityType<? extends MerchantEntity> entityType, World world, CallbackInfo info) {
|
||||
if (this.world.isClient()) {
|
||||
if (this.getWorld().isClient()) {
|
||||
return;
|
||||
}
|
||||
this.inventory.addListener(this);
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.github.zly2006.carpetslsaddition.mixin.world;
|
||||
|
||||
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
|
||||
import net.minecraft.world.block.ChainRestrictedNeighborUpdater;
|
||||
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.CallbackInfo;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
|
||||
@Mixin(ChainRestrictedNeighborUpdater.class)
|
||||
public class MixinChainRestrictedNeighborUpdater {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private ArrayDeque<?> queue;
|
||||
|
||||
@Inject(method = "runQueuedUpdates", at = @At(value = "INVOKE", target = "Ljava/util/List;clear()V", ordinal = 0, shift = At.Shift.BEFORE), cancellable = true)
|
||||
public void injectRunQueuedUpdates(CallbackInfo ci) {
|
||||
int maxSize = SLSCarpetSettings.maxUpdateQueueSize;
|
||||
if (maxSize > 0) {
|
||||
if (this.queue.size() > maxSize) {
|
||||
ci.cancel();
|
||||
// throw new OutOfMemoryError("The update queue exceeded the maximum allowed allocation of heap space set by SLS Addition!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -164,7 +164,7 @@ public class PcaSyncProtocol {
|
||||
return;
|
||||
}
|
||||
BlockPos pos = buf.readBlockPos();
|
||||
ServerWorld world = player.getWorld();
|
||||
ServerWorld world = player.getServerWorld();
|
||||
BlockState blockState = world.getBlockState(pos);
|
||||
clearPlayerWatchData(player);
|
||||
ServerMain.LOGGER.debug("{} watch blockpos {}: {}", player.getName().getString(), pos, blockState);
|
||||
@@ -219,7 +219,7 @@ public class PcaSyncProtocol {
|
||||
return;
|
||||
}
|
||||
int entityId = buf.readInt();
|
||||
ServerWorld world = player.getWorld();
|
||||
ServerWorld world = player.getServerWorld();
|
||||
Entity entity = world.getEntityById(entityId);
|
||||
if (entity == null) {
|
||||
ServerMain.LOGGER.debug("Can't find entity {}.", entityId);
|
||||
|
||||
Reference in new issue
Block a user