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