This commit is contained in:
parent
9e0fc49f6b
commit
c41c42c5cc
@ -80,7 +80,7 @@ public class MixinBoatEntity implements BoatUtil {
|
||||
|
||||
setChestItem(newStack);
|
||||
|
||||
newMode.interact((ServerPlayerEntity) player);
|
||||
newMode.triggerAdvancement((ServerPlayerEntity) player);
|
||||
}
|
||||
info.setReturnValue(ActionResult.SUCCESS);
|
||||
} else if (player.isSneaking()) {
|
||||
|
@ -60,18 +60,18 @@ public class BoatChestMode {
|
||||
private final BoatScreenHandlerFactory screenHandlerFactory;
|
||||
private final Function<ItemStack, Text> screenHandlerNameFactory;
|
||||
|
||||
private final Consumer<ServerPlayerEntity> onInteract;
|
||||
private final Consumer<ServerPlayerEntity> advancementTrigger;
|
||||
|
||||
private final int id;
|
||||
|
||||
private final SoundEvent openSound;
|
||||
private final SoundEvent closeSound;
|
||||
|
||||
private BoatChestMode(Block block, boolean hasItems, boolean containsItems, int size, BoatScreenHandlerFactory screenHandlerFactory, Function<ItemStack, Text> screenHandlerNameFactory, Consumer<ServerPlayerEntity> onInteract, SoundEvent openSound, SoundEvent closeSound) {
|
||||
private BoatChestMode(Block block, boolean hasItems, boolean containsItems, int size, BoatScreenHandlerFactory screenHandlerFactory, Function<ItemStack, Text> screenHandlerNameFactory, Consumer<ServerPlayerEntity> advancementTrigger, SoundEvent openSound, SoundEvent closeSound) {
|
||||
this.screenHandlerFactory = screenHandlerFactory;
|
||||
this.size = size;
|
||||
this.screenHandlerNameFactory = screenHandlerNameFactory;
|
||||
this.onInteract = onInteract;
|
||||
this.advancementTrigger = advancementTrigger;
|
||||
this.openSound = openSound;
|
||||
this.closeSound = closeSound;
|
||||
this.id = values.size();
|
||||
@ -81,8 +81,8 @@ public class BoatChestMode {
|
||||
values.add(this);
|
||||
}
|
||||
|
||||
private BoatChestMode(Block block, BoatScreenHandlerFactory screenHandlerFactory, Function<ItemStack, Text> screenHandlerNameFactory, Consumer<ServerPlayerEntity> onInteract) {
|
||||
this(block,false, false, 0, screenHandlerFactory, screenHandlerNameFactory, onInteract, null, null);
|
||||
private BoatChestMode(Block block, BoatScreenHandlerFactory screenHandlerFactory, Function<ItemStack, Text> screenHandlerNameFactory, Consumer<ServerPlayerEntity> advancementTrigger) {
|
||||
this(block,false, false, 0, screenHandlerFactory, screenHandlerNameFactory, advancementTrigger, null, null);
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
@ -97,9 +97,9 @@ public class BoatChestMode {
|
||||
return screenHandlerNameFactory.apply(stack);
|
||||
}
|
||||
|
||||
public void interact(ServerPlayerEntity player) {
|
||||
if (onInteract != null) {
|
||||
onInteract.accept(player);
|
||||
public void triggerAdvancement(ServerPlayerEntity player) {
|
||||
if (advancementTrigger != null) {
|
||||
advancementTrigger.accept(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,11 +25,15 @@ public class BoatInventory extends ItemInventory {
|
||||
|
||||
@Override
|
||||
public void onOpen(PlayerEntity player) {
|
||||
BoatUtil.playSound(entity, openSound);
|
||||
if (openSound != null) {
|
||||
BoatUtil.playSound(entity, openSound);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(PlayerEntity player) {
|
||||
BoatUtil.playSound(entity, closeSound);
|
||||
if (closeSound != null) {
|
||||
BoatUtil.playSound(entity, closeSound);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user