This commit is contained in:
parent
4d14fe7487
commit
4ebd156bdc
@ -30,7 +30,7 @@ Glowing Obsidian heals monsters and hurts everything else. It naturally generate
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
## Chest Boats
|
## Chest Boats
|
||||||
Right-Click a Boat with a Chest to place it in the Boat, you can also use an Ender Chest. Shift-Right-Click the Boat to open the Chest. You can also open the Chest inside the Boat by opening your inventory.
|
Right-Click a Boat with a Chest to place it in the Boat, you can also use an Ender Chest or Trapped Chest. Shift-Right-Click the Boat to open the Chest. You can also open the Chest inside the Boat by opening your inventory.
|
||||||
|
|
||||||
## Difficulty Stages
|
## Difficulty Stages
|
||||||
Each player has a "personal" stage of an area, the highest online player's difficulty stage in an area will be the "effective" difficulty stage of that area.
|
Each player has a "personal" stage of an area, the highest online player's difficulty stage in an area will be the "effective" difficulty stage of that area.
|
||||||
|
@ -4,7 +4,7 @@ org.gradle.jvmargs = -Xmx1G
|
|||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/use
|
# check these on https://fabricmc.net/use
|
||||||
minecraft_version = 1.16-pre6
|
minecraft_version = 1.16-pre6
|
||||||
curseforge_id = 390000
|
curseforge_id = 390028
|
||||||
simple_minecraft_version = 1.16-Snapshot
|
simple_minecraft_version = 1.16-Snapshot
|
||||||
yarn_build = 3
|
yarn_build = 3
|
||||||
fabric_loader_version = 0.8.7+build.201
|
fabric_loader_version = 0.8.7+build.201
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.thebrokenrail.twine.mixin;
|
package com.thebrokenrail.twine.mixin;
|
||||||
|
|
||||||
import com.thebrokenrail.twine.Twine;
|
import com.thebrokenrail.twine.Twine;
|
||||||
import com.thebrokenrail.twine.advancement.ChestBoatCriterion;
|
|
||||||
import com.thebrokenrail.twine.util.BoatInventory;
|
import com.thebrokenrail.twine.util.BoatInventory;
|
||||||
import com.thebrokenrail.twine.util.BoatUtil;
|
import com.thebrokenrail.twine.util.BoatUtil;
|
||||||
import com.thebrokenrail.twine.util.EnderChestInventoryWrapper;
|
import com.thebrokenrail.twine.util.EnderChestInventoryWrapper;
|
||||||
@ -13,9 +12,7 @@ import net.minecraft.entity.damage.DamageSource;
|
|||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.vehicle.BoatEntity;
|
import net.minecraft.entity.vehicle.BoatEntity;
|
||||||
import net.minecraft.inventory.Inventory;
|
import net.minecraft.inventory.Inventory;
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.nbt.ListTag;
|
||||||
import net.minecraft.screen.GenericContainerScreenHandler;
|
import net.minecraft.screen.GenericContainerScreenHandler;
|
||||||
@ -44,14 +41,14 @@ public class MixinBoatEntity implements BoatUtil {
|
|||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "canAddPassenger", cancellable = true)
|
@Inject(at = @At("HEAD"), method = "canAddPassenger", cancellable = true)
|
||||||
public void canAddPassenger(Entity passenger, CallbackInfoReturnable<Boolean> info) {
|
public void canAddPassenger(Entity passenger, CallbackInfoReturnable<Boolean> info) {
|
||||||
if (((BoatEntity) (Object) this).getPassengerList().size() > 0 && hasChest() != BoatChestMode.NONE) {
|
if (((BoatEntity) (Object) this).getPassengerList().size() > 0 && getChestMode() != BoatChestMode.NONE) {
|
||||||
info.setReturnValue(false);
|
info.setReturnValue(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(at = @At(value = "INVOKE", target = "Ljava/util/List;size()I"), method = "updatePassengerPosition", allow = 2, require = 2)
|
@Redirect(at = @At(value = "INVOKE", target = "Ljava/util/List;size()I"), method = "updatePassengerPosition", allow = 2, require = 2)
|
||||||
public int updatePassengerPosition(List<Entity> list) {
|
public int updatePassengerPosition(List<Entity> list) {
|
||||||
if (hasChest() != BoatChestMode.NONE) {
|
if (getChestMode() != BoatChestMode.NONE) {
|
||||||
return list.size() + 1;
|
return list.size() + 1;
|
||||||
} else {
|
} else {
|
||||||
return list.size();
|
return list.size();
|
||||||
@ -60,21 +57,21 @@ public class MixinBoatEntity implements BoatUtil {
|
|||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "interact", cancellable = true)
|
@Inject(at = @At("HEAD"), method = "interact", cancellable = true)
|
||||||
public void interact(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResult> info) {
|
public void interact(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResult> info) {
|
||||||
BoatChestMode hasChest = hasChest();
|
BoatChestMode hasChest = getChestMode();
|
||||||
ItemStack stack = player.getStackInHand(hand);
|
ItemStack stack = player.getStackInHand(hand);
|
||||||
if ((stack.getItem() == Items.CHEST || stack.getItem() == Items.ENDER_CHEST) && hasChest == BoatChestMode.NONE) {
|
BoatChestMode newMode = BoatChestMode.valueOF(stack.getItem());
|
||||||
|
if (newMode != BoatChestMode.NONE && hasChest == BoatChestMode.NONE) {
|
||||||
List<Entity> passengers = ((BoatEntity) (Object) this).getPassengerList();
|
List<Entity> passengers = ((BoatEntity) (Object) this).getPassengerList();
|
||||||
for (int i = 1; i < passengers.size(); i++) {
|
for (int i = 1; i < passengers.size(); i++) {
|
||||||
passengers.get(i).stopRiding();
|
passengers.get(i).stopRiding();
|
||||||
}
|
}
|
||||||
if (!player.getEntityWorld().isClient()) {
|
if (!player.getEntityWorld().isClient()) {
|
||||||
if (stack.getItem() == Items.CHEST) {
|
if (newMode.hasItems()) {
|
||||||
Twine.CHEST_BOAT_CRITERION.trigger((ServerPlayerEntity) player);
|
Twine.CHEST_BOAT_CRITERION.trigger((ServerPlayerEntity) player);
|
||||||
setHasChest(BoatChestMode.CHEST);
|
} else if (newMode == BoatChestMode.ENDER_CHEST) {
|
||||||
} else {
|
|
||||||
Twine.ENDER_CHEST_BOAT_CRITERION.trigger((ServerPlayerEntity) player);
|
Twine.ENDER_CHEST_BOAT_CRITERION.trigger((ServerPlayerEntity) player);
|
||||||
setHasChest(BoatChestMode.ENDER_CHEST);
|
|
||||||
}
|
}
|
||||||
|
setChestMode(newMode);
|
||||||
updateInventory();
|
updateInventory();
|
||||||
}
|
}
|
||||||
if (!player.isCreative()) {
|
if (!player.isCreative()) {
|
||||||
@ -90,30 +87,15 @@ public class MixinBoatEntity implements BoatUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private void setHasChest(BoatChestMode mode) {
|
private void setChestMode(BoatChestMode mode) {
|
||||||
((BoatEntity) (Object) this).getDataTracker().set(BoatUtil.HAS_CHEST, mode.name());
|
((BoatEntity) (Object) this).getDataTracker().set(BoatUtil.HAS_CHEST, mode.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Item getChestItem() {
|
|
||||||
switch (hasChest()) {
|
|
||||||
case CHEST: {
|
|
||||||
return Items.CHEST;
|
|
||||||
}
|
|
||||||
case ENDER_CHEST: {
|
|
||||||
return Items.ENDER_CHEST;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return Items.AIR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private void dropItemsOnDestroy(boolean isCreative) {
|
private void dropItemsOnDestroy(boolean isCreative) {
|
||||||
if (((BoatEntity) (Object) this).getEntityWorld().getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) {
|
if (((BoatEntity) (Object) this).getEntityWorld().getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) {
|
||||||
if (!isCreative) {
|
if (!isCreative) {
|
||||||
((BoatEntity) (Object) this).dropStack(new ItemStack(getChestItem()));
|
((BoatEntity) (Object) this).dropStack(new ItemStack(getChestMode().getItem()));
|
||||||
}
|
}
|
||||||
dropItems();
|
dropItems();
|
||||||
}
|
}
|
||||||
@ -134,7 +116,7 @@ public class MixinBoatEntity implements BoatUtil {
|
|||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private void updateInventory() {
|
private void updateInventory() {
|
||||||
items = hasChest() == BoatChestMode.CHEST ? new BoatInventory((BoatEntity) (Object) this, 27) : null;
|
items = getChestMode().hasItems() ? new BoatInventory((BoatEntity) (Object) this, 27) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
@ -151,9 +133,9 @@ public class MixinBoatEntity implements BoatUtil {
|
|||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "writeCustomDataToTag")
|
@Inject(at = @At("RETURN"), method = "writeCustomDataToTag")
|
||||||
public void writeCustomDataToTag(CompoundTag tag, CallbackInfo info) {
|
public void writeCustomDataToTag(CompoundTag tag, CallbackInfo info) {
|
||||||
BoatChestMode hasChest = hasChest();
|
BoatChestMode hasChest = getChestMode();
|
||||||
tag.putString("HasChest", hasChest.name());
|
tag.putString("HasChest", hasChest.name());
|
||||||
if (hasChest == BoatChestMode.CHEST) {
|
if (hasChest.hasItems()) {
|
||||||
ListTag listTag = new ListTag();
|
ListTag listTag = new ListTag();
|
||||||
|
|
||||||
for (int i = 2; i < this.items.size(); ++i) {
|
for (int i = 2; i < this.items.size(); ++i) {
|
||||||
@ -178,9 +160,9 @@ public class MixinBoatEntity implements BoatUtil {
|
|||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
hasChest = BoatChestMode.NONE;
|
hasChest = BoatChestMode.NONE;
|
||||||
}
|
}
|
||||||
setHasChest(hasChest);
|
setChestMode(hasChest);
|
||||||
updateInventory();
|
updateInventory();
|
||||||
if (hasChest == BoatChestMode.CHEST) {
|
if (hasChest.hasItems()) {
|
||||||
ListTag listTag = tag.getList("Items", 10);
|
ListTag listTag = tag.getList("Items", 10);
|
||||||
|
|
||||||
for (int i = 0; i < listTag.size(); ++i) {
|
for (int i = 0; i < listTag.size(); ++i) {
|
||||||
@ -194,7 +176,7 @@ public class MixinBoatEntity implements BoatUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BoatChestMode hasChest() {
|
public BoatChestMode getChestMode() {
|
||||||
try {
|
try {
|
||||||
return BoatChestMode.valueOf(((BoatEntity) (Object) this).getDataTracker().get(BoatUtil.HAS_CHEST));
|
return BoatChestMode.valueOf(((BoatEntity) (Object) this).getDataTracker().get(BoatUtil.HAS_CHEST));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
@ -203,14 +185,14 @@ public class MixinBoatEntity implements BoatUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Inventory getInventory() {
|
public Inventory getChestInventory() {
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void openInventory(PlayerEntity player) {
|
public void openInventory(PlayerEntity player) {
|
||||||
if (hasChest() == BoatUtil.BoatChestMode.CHEST) {
|
if (getChestMode().hasItems()) {
|
||||||
player.openHandledScreen(new SimpleNamedScreenHandlerFactory((i, playerInventory, playerEntity) -> GenericContainerScreenHandler.createGeneric9x3(i, playerInventory, getInventory()), ((BoatEntity) (Object) this).getDisplayName()));
|
player.openHandledScreen(new SimpleNamedScreenHandlerFactory((i, playerInventory, playerEntity) -> GenericContainerScreenHandler.createGeneric9x3(i, playerInventory, getChestInventory()), ((BoatEntity) (Object) this).getDisplayName()));
|
||||||
} else {
|
} else {
|
||||||
player.openHandledScreen(new SimpleNamedScreenHandlerFactory((i, playerInventory, playerEntity) -> GenericContainerScreenHandler.createGeneric9x3(i, playerInventory, new EnderChestInventoryWrapper((BoatEntity) (Object) this, player.getEnderChestInventory())), EnderChestBlock.CONTAINER_NAME));
|
player.openHandledScreen(new SimpleNamedScreenHandlerFactory((i, playerInventory, playerEntity) -> GenericContainerScreenHandler.createGeneric9x3(i, playerInventory, new EnderChestInventoryWrapper((BoatEntity) (Object) this, player.getEnderChestInventory())), EnderChestBlock.CONTAINER_NAME));
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
public class MixinBoatEntityRenderer {
|
public class MixinBoatEntityRenderer {
|
||||||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;pop()V"), method = "render", allow = 1)
|
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;pop()V"), method = "render", allow = 1)
|
||||||
public void render(BoatEntity boatEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo info) {
|
public void render(BoatEntity boatEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo info) {
|
||||||
BlockState blockState = Block.getBlockFromItem(((BoatUtil) boatEntity).getChestItem()).getDefaultState();
|
BlockState blockState = Block.getBlockFromItem(((BoatUtil) boatEntity).getChestMode().getItem()).getDefaultState();
|
||||||
if (blockState.getRenderType() != BlockRenderType.INVISIBLE) {
|
if (blockState.getRenderType() != BlockRenderType.INVISIBLE) {
|
||||||
matrixStack.push();
|
matrixStack.push();
|
||||||
matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(180.0f));
|
matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(180.0f));
|
||||||
|
@ -23,7 +23,7 @@ public class MixinClientPlayerInteractionManager {
|
|||||||
@Inject(at = @At("HEAD"), method = "hasRidingInventory", cancellable = true)
|
@Inject(at = @At("HEAD"), method = "hasRidingInventory", cancellable = true)
|
||||||
public void hasRidingInventory(CallbackInfoReturnable<Boolean> info) {
|
public void hasRidingInventory(CallbackInfoReturnable<Boolean> info) {
|
||||||
assert client.player != null;
|
assert client.player != null;
|
||||||
if (client.player.hasVehicle() && client.player.getVehicle() instanceof BoatEntity && ((BoatUtil) client.player.getVehicle()).hasChest() != BoatUtil.BoatChestMode.NONE) {
|
if (client.player.hasVehicle() && client.player.getVehicle() instanceof BoatEntity && ((BoatUtil) client.player.getVehicle()).getChestMode() != BoatUtil.BoatChestMode.NONE) {
|
||||||
info.setReturnValue(true);
|
info.setReturnValue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ public class MixinServerPlayNetworkHandler {
|
|||||||
|
|
||||||
@Inject(at = @At("TAIL"), method = "onClientCommand")
|
@Inject(at = @At("TAIL"), method = "onClientCommand")
|
||||||
public void onClientCommand(ClientCommandC2SPacket packet, CallbackInfo info) {
|
public void onClientCommand(ClientCommandC2SPacket packet, CallbackInfo info) {
|
||||||
if (packet.getMode() == ClientCommandC2SPacket.Mode.OPEN_INVENTORY && player.hasVehicle() && player.getVehicle() instanceof BoatEntity && ((BoatUtil) player.getVehicle()).hasChest() != BoatUtil.BoatChestMode.NONE) {
|
if (packet.getMode() == ClientCommandC2SPacket.Mode.OPEN_INVENTORY && player.hasVehicle() && player.getVehicle() instanceof BoatEntity && ((BoatUtil) player.getVehicle()).getChestMode() != BoatUtil.BoatChestMode.NONE) {
|
||||||
((BoatUtil) player.getVehicle()).openInventory(player);
|
((BoatUtil) player.getVehicle()).openInventory(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ public class BoatInventory extends SimpleInventory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayerUse(PlayerEntity player) {
|
public boolean canPlayerUse(PlayerEntity player) {
|
||||||
return BoatUtil.canReachEntity(player, entity) && entity.isAlive() && ((BoatUtil) entity).hasChest() == BoatUtil.BoatChestMode.CHEST && super.canPlayerUse(player);
|
return BoatUtil.canReachEntity(player, entity) && entity.isAlive() && ((BoatUtil) entity).getChestMode() == BoatUtil.BoatChestMode.CHEST && super.canPlayerUse(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -8,20 +8,17 @@ import net.minecraft.entity.player.PlayerEntity;
|
|||||||
import net.minecraft.entity.vehicle.BoatEntity;
|
import net.minecraft.entity.vehicle.BoatEntity;
|
||||||
import net.minecraft.inventory.Inventory;
|
import net.minecraft.inventory.Inventory;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sound.SoundCategory;
|
||||||
import net.minecraft.sound.SoundEvent;
|
import net.minecraft.sound.SoundEvent;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public interface BoatUtil {
|
public interface BoatUtil {
|
||||||
TrackedData<String> HAS_CHEST = DataTracker.registerData(BoatEntity.class, TrackedDataHandlerRegistry.STRING);
|
TrackedData<String> HAS_CHEST = DataTracker.registerData(BoatEntity.class, TrackedDataHandlerRegistry.STRING);
|
||||||
|
|
||||||
Item getChestItem();
|
BoatChestMode getChestMode();
|
||||||
|
|
||||||
BoatChestMode hasChest();
|
Inventory getChestInventory();
|
||||||
|
|
||||||
Inventory getInventory();
|
|
||||||
|
|
||||||
void openInventory(PlayerEntity player);
|
void openInventory(PlayerEntity player);
|
||||||
|
|
||||||
@ -30,9 +27,35 @@ public interface BoatUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum BoatChestMode {
|
enum BoatChestMode {
|
||||||
ENDER_CHEST,
|
ENDER_CHEST(Items.ENDER_CHEST, false),
|
||||||
CHEST,
|
CHEST(Items.CHEST, true),
|
||||||
NONE
|
TRAPPED_CHEST(Items.TRAPPED_CHEST, true),
|
||||||
|
NONE(Items.AIR, false);
|
||||||
|
|
||||||
|
private final Item item;
|
||||||
|
private final boolean hasItems;
|
||||||
|
|
||||||
|
BoatChestMode(Item item, boolean hasItems) {
|
||||||
|
this.item = item;
|
||||||
|
this.hasItems = hasItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getItem() {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasItems() {
|
||||||
|
return hasItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BoatChestMode valueOF(Item item) {
|
||||||
|
for (BoatChestMode mode : values()) {
|
||||||
|
if (mode.getItem() == item) {
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NONE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void playSound(Entity vehicle, SoundEvent sound) {
|
static void playSound(Entity vehicle, SoundEvent sound) {
|
||||||
|
@ -53,7 +53,7 @@ public class EnderChestInventoryWrapper implements Inventory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayerUse(PlayerEntity player) {
|
public boolean canPlayerUse(PlayerEntity player) {
|
||||||
return BoatUtil.canReachEntity(player, entity) && entity.isAlive() && ((BoatUtil) entity).hasChest() == BoatUtil.BoatChestMode.ENDER_CHEST;
|
return BoatUtil.canReachEntity(player, entity) && entity.isAlive() && ((BoatUtil) entity).getChestMode() == BoatUtil.BoatChestMode.ENDER_CHEST;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user