Fix several container problem (#115)
This commit is contained in:
parent
678c8e886c
commit
cfc83f9aea
@ -705,9 +705,11 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
|
||||
ArclightCaptures.resetContainerOwner();
|
||||
}
|
||||
|
||||
@Inject(method = "closeScreen", at = @At("HEAD"))
|
||||
@Inject(method = "closeContainer", at = @At("HEAD"))
|
||||
private void arclight$invClose(CallbackInfo ci) {
|
||||
CraftEventFactory.handleInventoryCloseEvent((ServerPlayerEntity) (Object) this);
|
||||
if (this.openContainer != this.container) {
|
||||
CraftEventFactory.handleInventoryCloseEvent((ServerPlayerEntity) (Object) this);
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "addStat", at = @At(value = "INVOKE", target = "Lnet/minecraft/scoreboard/Scoreboard;forAllObjectives(Lnet/minecraft/scoreboard/ScoreCriteria;Ljava/lang/String;Ljava/util/function/Consumer;)V"))
|
||||
|
||||
@ -87,18 +87,20 @@ public abstract class ContainerMixin implements ContainerBridge {
|
||||
|
||||
public final ITextComponent getTitle() {
|
||||
if (this.title == null) {
|
||||
if (this.containerType != null && this.containerType.getRegistryName() != null) {
|
||||
this.title = new StringTextComponent(this.containerType.getRegistryName().toString());
|
||||
} else {
|
||||
this.title = new StringTextComponent(this.toString());
|
||||
}
|
||||
ArclightMod.LOGGER.warn("Container {}/{} has no title.", this, this.getClass().getName());
|
||||
if (this.containerType != null && this.containerType.getRegistryName() != null) {
|
||||
return new StringTextComponent(this.containerType.getRegistryName().toString());
|
||||
} else {
|
||||
return new StringTextComponent(this.toString());
|
||||
}
|
||||
}
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public final void setTitle(ITextComponent title) {
|
||||
this.title = title;
|
||||
if (this.title == null) {
|
||||
this.title = title;
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "onContainerClosed", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;dropItem(Lnet/minecraft/item/ItemStack;Z)Lnet/minecraft/entity/item/ItemEntity;"))
|
||||
|
||||
@ -1208,9 +1208,8 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB
|
||||
private void arclight$invClose(CCloseWindowPacket packetIn, CallbackInfo ci) {
|
||||
if (((ServerPlayerEntityBridge) this.player).bridge$isMovementBlocked()) {
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
CraftEventFactory.handleInventoryCloseEvent(this.player);
|
||||
// CraftEventFactory.handleInventoryCloseEvent(this.player); handled in ServerPlayerEntity#closeContainer
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package io.izzel.arclight.common.mixin.forge;
|
||||
|
||||
import io.izzel.arclight.common.bridge.inventory.container.ContainerBridge;
|
||||
import io.izzel.arclight.common.mod.util.ArclightCaptures;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
@ -24,7 +25,9 @@ public class NetworkHooksMixin {
|
||||
private static void arclight$openContainer(ServerPlayerEntity player, INamedContainerProvider containerSupplier, Consumer<PacketBuffer> extraDataWriter, CallbackInfo ci,
|
||||
int currentId, PacketBuffer extraData, PacketBuffer output, Container container) {
|
||||
((ContainerBridge) container).bridge$setTitle(containerSupplier.getDisplayName());
|
||||
ArclightCaptures.captureContainerOwner(player);
|
||||
container = CraftEventFactory.callInventoryOpenEvent(player, container);
|
||||
ArclightCaptures.resetContainerOwner();
|
||||
if (container == null) {
|
||||
if (containerSupplier instanceof IInventory) {
|
||||
((IInventory) containerSupplier).closeInventory(player);
|
||||
|
||||
@ -106,7 +106,7 @@ public class ArclightContainer {
|
||||
if (candidate == null) {
|
||||
throw new RuntimeException("candidate cannot be null, " + container + "/" + container.getClass());
|
||||
}
|
||||
if (bottomBegin < bottomEnd) {
|
||||
if (bottomBegin < bottomEnd || bottomBegin == -1) {
|
||||
bottomBegin = container.inventorySlots.size();
|
||||
}
|
||||
Inventory viewing = new CraftInventory(new ContainerInvWrapper(container, bottomBegin, candidate));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user