Plex-FAWE/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricEntityProperties.java
Matthew Miller aa8d34c913
feature(fabric): added fabric support (#491)
* Initial work towards Fabric compat. This does not compile yet

* Further updates - should compile but Gradle is being weird.

* Remove useless buildscript extras

* Added mixins to buildscript classpath to fix Loom crash

* Make it compile

* Got it building and added interaction

* Fixed review comments

* Use ServerPlayerEntity for FakePlayer

* Use method references for nicer names

* Fixed remaining comments and added networking for CUI

* Output as dist.jar

* Added mixins for left click air

* Use regex for cleanliness
2019-06-27 22:25:02 +10:00

152 lines
4.3 KiB
Java

/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.fabric;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.entity.metadata.EntityProperties;
import net.minecraft.entity.EnderEyeEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.ExperienceOrbEntity;
import net.minecraft.entity.FallingBlockEntity;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.Npc;
import net.minecraft.entity.TntEntity;
import net.minecraft.entity.boss.dragon.EnderDragonEntity;
import net.minecraft.entity.decoration.ArmorStandEntity;
import net.minecraft.entity.decoration.ItemFrameEntity;
import net.minecraft.entity.decoration.painting.PaintingEntity;
import net.minecraft.entity.mob.AmbientEntity;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.passive.TameableEntity;
import net.minecraft.entity.passive.GolemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.Projectile;
import net.minecraft.entity.vehicle.AbstractMinecartEntity;
import net.minecraft.entity.vehicle.BoatEntity;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.village.Trader;
public class FabricEntityProperties implements EntityProperties {
private final Entity entity;
public FabricEntityProperties(Entity entity) {
checkNotNull(entity);
this.entity = entity;
}
@Override
public boolean isPlayerDerived() {
return entity instanceof PlayerEntity;
}
@Override
public boolean isProjectile() {
return entity instanceof EnderEyeEntity || entity instanceof Projectile;
}
@Override
public boolean isItem() {
return entity instanceof ItemEntity;
}
@Override
public boolean isFallingBlock() {
return entity instanceof FallingBlockEntity;
}
@Override
public boolean isPainting() {
return entity instanceof PaintingEntity;
}
@Override
public boolean isItemFrame() {
return entity instanceof ItemFrameEntity;
}
@Override
public boolean isBoat() {
return entity instanceof BoatEntity;
}
@Override
public boolean isMinecart() {
return entity instanceof AbstractMinecartEntity;
}
@Override
public boolean isTNT() {
return entity instanceof TntEntity;
}
@Override
public boolean isExperienceOrb() {
return entity instanceof ExperienceOrbEntity;
}
@Override
public boolean isLiving() {
return entity instanceof MobEntity;
}
@Override
public boolean isAnimal() {
return entity instanceof AnimalEntity;
}
@Override
public boolean isAmbient() {
return entity instanceof AmbientEntity;
}
@Override
public boolean isNPC() {
return entity instanceof Npc || entity instanceof Trader;
}
@Override
public boolean isGolem() {
return entity instanceof GolemEntity;
}
@Override
public boolean isTamed() {
return entity instanceof TameableEntity && ((TameableEntity) entity).isTamed();
}
@Override
public boolean isTagged() {
return entity.hasCustomName();
}
@Override
public boolean isArmorStand() {
return entity instanceof ArmorStandEntity;
}
@Override
public boolean isPasteable() {
return !(entity instanceof ServerPlayerEntity || entity instanceof EnderDragonEntity);
}
}