Reformat
All checks were successful
Twine/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-06-15 20:30:22 -04:00
parent 4ebd156bdc
commit 8164f8f8b9
13 changed files with 43 additions and 34 deletions

View File

@ -13,9 +13,11 @@ import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry;
import net.fabricmc.fabric.api.tag.TagRegistry;
import net.minecraft.block.Block;
import net.minecraft.item.*;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.screen.GenericContainerScreenHandler;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.tag.Tag;
import net.minecraft.util.Identifier;

View File

@ -18,7 +18,8 @@ public class ChestBoatCriterion extends AbstractCriterion<AbstractCriterionCondi
@Override
protected AbstractCriterionConditions conditionsFromJson(JsonObject obj, EntityPredicate.Extended playerPredicate, AdvancementEntityPredicateDeserializer predicateDeserializer) {
return new AbstractCriterionConditions(ID, playerPredicate) {};
return new AbstractCriterionConditions(ID, playerPredicate) {
};
}
@Override

View File

@ -18,7 +18,8 @@ public class EnderChestBoatCriterion extends AbstractCriterion<AbstractCriterion
@Override
protected AbstractCriterionConditions conditionsFromJson(JsonObject obj, EntityPredicate.Extended playerPredicate, AdvancementEntityPredicateDeserializer predicateDeserializer) {
return new AbstractCriterionConditions(ID, playerPredicate) {};
return new AbstractCriterionConditions(ID, playerPredicate) {
};
}
@Override

View File

@ -1,6 +1,9 @@
package com.thebrokenrail.twine.block;
import net.minecraft.block.*;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.DispenserBlock;
import net.minecraft.block.Material;
import net.minecraft.block.dispenser.DispenserBehavior;
import net.minecraft.block.dispenser.ItemDispenserBehavior;
import net.minecraft.block.entity.BlockEntity;

View File

@ -3,7 +3,6 @@ package com.thebrokenrail.twine.block;
import net.minecraft.block.Block;
import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor;
import net.minecraft.entity.AreaEffectCloudEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;

View File

@ -36,19 +36,19 @@ import java.util.List;
public class MixinBoatEntity implements BoatUtil {
@Inject(at = @At("RETURN"), method = "initDataTracker")
public void initDataTracker(CallbackInfo info) {
((BoatEntity) (Object) this).getDataTracker().startTracking(BoatUtil.HAS_CHEST, BoatChestMode.NONE.name());
((BoatEntity) (Object) this).getDataTracker().startTracking(BoatUtil.HAS_CHEST, ChestMode.NONE.name());
}
@Inject(at = @At("HEAD"), method = "canAddPassenger", cancellable = true)
public void canAddPassenger(Entity passenger, CallbackInfoReturnable<Boolean> info) {
if (((BoatEntity) (Object) this).getPassengerList().size() > 0 && getChestMode() != BoatChestMode.NONE) {
if (((BoatEntity) (Object) this).getPassengerList().size() > 0 && getChestMode() != ChestMode.NONE) {
info.setReturnValue(false);
}
}
@Redirect(at = @At(value = "INVOKE", target = "Ljava/util/List;size()I"), method = "updatePassengerPosition", allow = 2, require = 2)
public int updatePassengerPosition(List<Entity> list) {
if (getChestMode() != BoatChestMode.NONE) {
if (getChestMode() != ChestMode.NONE) {
return list.size() + 1;
} else {
return list.size();
@ -57,10 +57,10 @@ public class MixinBoatEntity implements BoatUtil {
@Inject(at = @At("HEAD"), method = "interact", cancellable = true)
public void interact(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResult> info) {
BoatChestMode hasChest = getChestMode();
ChestMode hasChest = getChestMode();
ItemStack stack = player.getStackInHand(hand);
BoatChestMode newMode = BoatChestMode.valueOF(stack.getItem());
if (newMode != BoatChestMode.NONE && hasChest == BoatChestMode.NONE) {
ChestMode newMode = ChestMode.valueOF(stack.getItem());
if (newMode != ChestMode.NONE && hasChest == ChestMode.NONE) {
List<Entity> passengers = ((BoatEntity) (Object) this).getPassengerList();
for (int i = 1; i < passengers.size(); i++) {
passengers.get(i).stopRiding();
@ -68,7 +68,7 @@ public class MixinBoatEntity implements BoatUtil {
if (!player.getEntityWorld().isClient()) {
if (newMode.hasItems()) {
Twine.CHEST_BOAT_CRITERION.trigger((ServerPlayerEntity) player);
} else if (newMode == BoatChestMode.ENDER_CHEST) {
} else if (newMode == ChestMode.ENDER_CHEST) {
Twine.ENDER_CHEST_BOAT_CRITERION.trigger((ServerPlayerEntity) player);
}
setChestMode(newMode);
@ -87,7 +87,7 @@ public class MixinBoatEntity implements BoatUtil {
}
@Unique
private void setChestMode(BoatChestMode mode) {
private void setChestMode(ChestMode mode) {
((BoatEntity) (Object) this).getDataTracker().set(BoatUtil.HAS_CHEST, mode.name());
}
@ -133,7 +133,7 @@ public class MixinBoatEntity implements BoatUtil {
@Inject(at = @At("RETURN"), method = "writeCustomDataToTag")
public void writeCustomDataToTag(CompoundTag tag, CallbackInfo info) {
BoatChestMode hasChest = getChestMode();
ChestMode hasChest = getChestMode();
tag.putString("HasChest", hasChest.name());
if (hasChest.hasItems()) {
ListTag listTag = new ListTag();
@ -154,11 +154,11 @@ public class MixinBoatEntity implements BoatUtil {
@Inject(at = @At("RETURN"), method = "readCustomDataFromTag")
public void readCustomDataFromTag(CompoundTag tag, CallbackInfo info) {
BoatChestMode hasChest;
ChestMode hasChest;
try {
hasChest = BoatChestMode.valueOf(tag.getString("HasChest"));
hasChest = ChestMode.valueOf(tag.getString("HasChest"));
} catch (IllegalArgumentException e) {
hasChest = BoatChestMode.NONE;
hasChest = ChestMode.NONE;
}
setChestMode(hasChest);
updateInventory();
@ -176,11 +176,11 @@ public class MixinBoatEntity implements BoatUtil {
}
@Override
public BoatChestMode getChestMode() {
public ChestMode getChestMode() {
try {
return BoatChestMode.valueOf(((BoatEntity) (Object) this).getDataTracker().get(BoatUtil.HAS_CHEST));
return ChestMode.valueOf(((BoatEntity) (Object) this).getDataTracker().get(BoatUtil.HAS_CHEST));
} catch (IllegalArgumentException e) {
return BoatChestMode.NONE;
return ChestMode.NONE;
}
}
@ -193,7 +193,7 @@ public class MixinBoatEntity implements BoatUtil {
public void openInventory(PlayerEntity player) {
if (getChestMode().hasItems()) {
player.openHandledScreen(new SimpleNamedScreenHandlerFactory((i, playerInventory, playerEntity) -> GenericContainerScreenHandler.createGeneric9x3(i, playerInventory, getChestInventory()), ((BoatEntity) (Object) this).getDisplayName()));
} else {
} else if (getChestMode() == ChestMode.ENDER_CHEST) {
player.openHandledScreen(new SimpleNamedScreenHandlerFactory((i, playerInventory, playerEntity) -> GenericContainerScreenHandler.createGeneric9x3(i, playerInventory, new EnderChestInventoryWrapper((BoatEntity) (Object) this, player.getEnderChestInventory())), EnderChestBlock.CONTAINER_NAME));
}
}

View File

@ -23,7 +23,7 @@ public class MixinClientPlayerInteractionManager {
@Inject(at = @At("HEAD"), method = "hasRidingInventory", cancellable = true)
public void hasRidingInventory(CallbackInfoReturnable<Boolean> info) {
assert client.player != null;
if (client.player.hasVehicle() && client.player.getVehicle() instanceof BoatEntity && ((BoatUtil) client.player.getVehicle()).getChestMode() != BoatUtil.BoatChestMode.NONE) {
if (client.player.hasVehicle() && client.player.getVehicle() instanceof BoatEntity && ((BoatUtil) client.player.getVehicle()).getChestMode() != BoatUtil.ChestMode.NONE) {
info.setReturnValue(true);
}
}

View File

@ -9,7 +9,10 @@ import com.thebrokenrail.twine.util.StageUtil;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ai.goal.FollowTargetGoal;
import net.minecraft.entity.ai.goal.GoalSelector;
import net.minecraft.entity.mob.*;
import net.minecraft.entity.mob.CreeperEntity;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.mob.MobEntityWithAi;
import net.minecraft.entity.mob.Monster;
import net.minecraft.entity.passive.IronGolemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.world.ServerWorld;

View File

@ -18,7 +18,7 @@ public class MixinServerPlayNetworkHandler {
@Inject(at = @At("TAIL"), method = "onClientCommand")
public void onClientCommand(ClientCommandC2SPacket packet, CallbackInfo info) {
if (packet.getMode() == ClientCommandC2SPacket.Mode.OPEN_INVENTORY && player.hasVehicle() && player.getVehicle() instanceof BoatEntity && ((BoatUtil) player.getVehicle()).getChestMode() != BoatUtil.BoatChestMode.NONE) {
if (packet.getMode() == ClientCommandC2SPacket.Mode.OPEN_INVENTORY && player.hasVehicle() && player.getVehicle() instanceof BoatEntity && ((BoatUtil) player.getVehicle()).getChestMode() != BoatUtil.ChestMode.NONE) {
((BoatUtil) player.getVehicle()).openInventory(player);
}
}

View File

@ -15,7 +15,7 @@ public class BoatInventory extends SimpleInventory {
@Override
public boolean canPlayerUse(PlayerEntity player) {
return BoatUtil.canReachEntity(player, entity) && entity.isAlive() && ((BoatUtil) entity).getChestMode() == BoatUtil.BoatChestMode.CHEST && super.canPlayerUse(player);
return BoatUtil.canReachEntity(player, entity) && entity.isAlive() && ((BoatUtil) entity).getChestMode() == BoatUtil.ChestMode.CHEST && super.canPlayerUse(player);
}
@Override

View File

@ -16,7 +16,7 @@ import net.minecraft.util.math.Vec3d;
public interface BoatUtil {
TrackedData<String> HAS_CHEST = DataTracker.registerData(BoatEntity.class, TrackedDataHandlerRegistry.STRING);
BoatChestMode getChestMode();
ChestMode getChestMode();
Inventory getChestInventory();
@ -26,7 +26,7 @@ public interface BoatUtil {
return player.squaredDistanceTo(entity.getPos().getX(), entity.getPos().getY(), entity.getPos().getZ()) <= 64d;
}
enum BoatChestMode {
enum ChestMode {
ENDER_CHEST(Items.ENDER_CHEST, false),
CHEST(Items.CHEST, true),
TRAPPED_CHEST(Items.TRAPPED_CHEST, true),
@ -35,7 +35,7 @@ public interface BoatUtil {
private final Item item;
private final boolean hasItems;
BoatChestMode(Item item, boolean hasItems) {
ChestMode(Item item, boolean hasItems) {
this.item = item;
this.hasItems = hasItems;
}
@ -48,8 +48,8 @@ public interface BoatUtil {
return hasItems;
}
public static BoatChestMode valueOF(Item item) {
for (BoatChestMode mode : values()) {
public static ChestMode valueOF(Item item) {
for (ChestMode mode : values()) {
if (mode.getItem() == item) {
return mode;
}

View File

@ -53,7 +53,7 @@ public class EnderChestInventoryWrapper implements Inventory {
@Override
public boolean canPlayerUse(PlayerEntity player) {
return BoatUtil.canReachEntity(player, entity) && entity.isAlive() && ((BoatUtil) entity).getChestMode() == BoatUtil.BoatChestMode.ENDER_CHEST;
return BoatUtil.canReachEntity(player, entity) && entity.isAlive() && ((BoatUtil) entity).getChestMode() == BoatUtil.ChestMode.ENDER_CHEST;
}
@Override