mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-31 21:48:08 +01:00
Fishes
This commit is contained in:
parent
07be9d449b
commit
cfc5f860e9
@ -15,6 +15,7 @@ import net.minestom.server.entity.type.projectile.EntityArrow;
|
||||
import net.minestom.server.entity.type.projectile.EntityPotion;
|
||||
import net.minestom.server.entity.type.projectile.EntitySpectralArrow;
|
||||
import net.minestom.server.entity.type.vehicle.EntityBoat;
|
||||
import net.minestom.server.entity.type.water.*;
|
||||
import net.minestom.server.registry.Registries;
|
||||
import net.minestom.server.utils.LambdaMetafactoryUtils;
|
||||
import net.minestom.server.utils.NamespaceID;
|
||||
@ -50,7 +51,7 @@ public enum EntityType {
|
||||
|
||||
CHICKEN("minecraft:chicken", EntityChicken.class),
|
||||
|
||||
COD("minecraft:cod"),
|
||||
COD("minecraft:cod", EntityCod.class),
|
||||
|
||||
COW("minecraft:cow", EntityCow.class),
|
||||
|
||||
|
@ -12,16 +12,18 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Created by k.shandurenko on 23.02.2021
|
||||
* TODO: update bounding box depending on state
|
||||
*/
|
||||
public class EntityShulker extends EntityCreature implements Constructable {
|
||||
|
||||
public EntityShulker(@NotNull Position spawnPosition) {
|
||||
super(EntityType.SHULKER, spawnPosition);
|
||||
setBoundingBox(1D, 1D, 1D);
|
||||
}
|
||||
|
||||
public EntityShulker(@NotNull Position spawnPosition, @Nullable Instance instance) {
|
||||
super(EntityType.SHULKER, spawnPosition, instance);
|
||||
setBoundingBox(1D, 1D, 1D);
|
||||
}
|
||||
|
||||
public Direction getAttachFace() {
|
||||
@ -49,7 +51,7 @@ public class EntityShulker extends EntityCreature implements Constructable {
|
||||
}
|
||||
|
||||
public byte getColor() {
|
||||
return this.metadata.getIndex((byte) 18, (byte) 0);
|
||||
return this.metadata.getIndex((byte) 18, (byte) 10);
|
||||
}
|
||||
|
||||
public void setColor(byte value) {
|
||||
|
@ -0,0 +1,32 @@
|
||||
package net.minestom.server.entity.type.water;
|
||||
|
||||
import net.minestom.server.entity.EntityCreature;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import net.minestom.server.utils.Position;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Created by k.shandurenko on 23.02.2021
|
||||
*/
|
||||
public class EntityAbstractFish extends EntityCreature {
|
||||
|
||||
protected EntityAbstractFish(@NotNull EntityType entityType, @NotNull Position spawnPosition) {
|
||||
super(entityType, spawnPosition);
|
||||
}
|
||||
|
||||
protected EntityAbstractFish(@NotNull EntityType entityType, @NotNull Position spawnPosition, @Nullable Instance instance) {
|
||||
super(entityType, spawnPosition, instance);
|
||||
}
|
||||
|
||||
public boolean isFromBucket() {
|
||||
return this.metadata.getIndex((byte) 15, false);
|
||||
}
|
||||
|
||||
public void setFromBucket(boolean value) {
|
||||
this.metadata.setIndex((byte) 15, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package net.minestom.server.entity.type.water;
|
||||
|
||||
import net.minestom.server.entity.EntityType;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import net.minestom.server.utils.Position;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Created by k.shandurenko on 23.02.2021
|
||||
*/
|
||||
public class EntityCod extends EntityAbstractFish {
|
||||
|
||||
public EntityCod(@NotNull Position spawnPosition) {
|
||||
super(EntityType.COD, spawnPosition);
|
||||
setBoundingBox(.5D, .3D, .5D);
|
||||
}
|
||||
|
||||
public EntityCod(@NotNull Position spawnPosition, @Nullable Instance instance) {
|
||||
super(EntityType.COD, spawnPosition, instance);
|
||||
setBoundingBox(.5D, .3D, .5D);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package net.minestom.server.entity.type.water;
|
||||
|
||||
import net.minestom.server.entity.EntityType;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import net.minestom.server.utils.Position;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Created by k.shandurenko on 23.02.2021
|
||||
*/
|
||||
public class EntityPufferFish extends EntityAbstractFish {
|
||||
|
||||
public EntityPufferFish(@NotNull Position spawnPosition) {
|
||||
super(EntityType.PUFFERFISH, spawnPosition);
|
||||
updateBoundingBox(State.UNPUFFED);
|
||||
}
|
||||
|
||||
public EntityPufferFish(@NotNull Position spawnPosition, @Nullable Instance instance) {
|
||||
super(EntityType.PUFFERFISH, spawnPosition, instance);
|
||||
updateBoundingBox(State.UNPUFFED);
|
||||
}
|
||||
|
||||
public State getState() {
|
||||
return State.VALUES[this.metadata.getIndex((byte) 16, 0)];
|
||||
}
|
||||
|
||||
public void setState(State state) {
|
||||
this.metadata.setIndex((byte) 16, Metadata.VarInt(state.ordinal()));
|
||||
updateBoundingBox(state);
|
||||
}
|
||||
|
||||
private void updateBoundingBox(State state) {
|
||||
switch (state) {
|
||||
case UNPUFFED:
|
||||
setBoundingBox(.35D, .35D, .35D);
|
||||
break;
|
||||
case SEMI_PUFFED:
|
||||
setBoundingBox(.5D, .5D, .5D);
|
||||
break;
|
||||
default:
|
||||
setBoundingBox(.7D, .7D, .7D);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public enum State {
|
||||
UNPUFFED,
|
||||
SEMI_PUFFED,
|
||||
FULLY_PUFFED;
|
||||
|
||||
private final static State[] VALUES = values();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package net.minestom.server.entity.type.water;
|
||||
|
||||
import net.minestom.server.entity.EntityType;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import net.minestom.server.utils.Position;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Created by k.shandurenko on 23.02.2021
|
||||
*/
|
||||
public class EntitySalmon extends EntityAbstractFish {
|
||||
|
||||
public EntitySalmon(@NotNull Position spawnPosition) {
|
||||
super(EntityType.SALMON, spawnPosition);
|
||||
setBoundingBox(.7D, .4D, .7D);
|
||||
}
|
||||
|
||||
public EntitySalmon(@NotNull Position spawnPosition, @Nullable Instance instance) {
|
||||
super(EntityType.SALMON, spawnPosition, instance);
|
||||
setBoundingBox(.7D, .4D, .7D);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package net.minestom.server.entity.type.water;
|
||||
|
||||
import net.minestom.server.entity.EntityCreature;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import net.minestom.server.utils.Position;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Created by k.shandurenko on 23.02.2021
|
||||
*/
|
||||
public class EntitySquid extends EntityCreature {
|
||||
|
||||
public EntitySquid(@NotNull Position spawnPosition) {
|
||||
super(EntityType.SQUID, spawnPosition);
|
||||
setBoundingBox(.8D, .8D, .8D);
|
||||
}
|
||||
|
||||
public EntitySquid(@NotNull Position spawnPosition, @Nullable Instance instance) {
|
||||
super(EntityType.SQUID, spawnPosition, instance);
|
||||
setBoundingBox(.8D, .8D, .8D);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
package net.minestom.server.entity.type.water;
|
||||
|
||||
import net.minestom.server.entity.EntityType;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import net.minestom.server.utils.Position;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Created by k.shandurenko on 23.02.2021
|
||||
*/
|
||||
public class EntityTropicalFish extends EntityAbstractFish {
|
||||
|
||||
public EntityTropicalFish(@NotNull Position spawnPosition) {
|
||||
super(EntityType.TROPICAL_FISH, spawnPosition);
|
||||
setBoundingBox(.5D, .4D, .5D);
|
||||
}
|
||||
|
||||
public EntityTropicalFish(@NotNull Position spawnPosition, @Nullable Instance instance) {
|
||||
super(EntityType.TROPICAL_FISH, spawnPosition, instance);
|
||||
setBoundingBox(.5D, .4D, .5D);
|
||||
}
|
||||
|
||||
public Variant getVariant() {
|
||||
return getVariantFromID(this.metadata.getIndex((byte) 16, 0));
|
||||
}
|
||||
|
||||
public void setVariant(Variant variant) {
|
||||
this.metadata.setIndex((byte) 16, Metadata.VarInt(getVariantID(variant)));
|
||||
}
|
||||
|
||||
public static int getVariantID(Variant variant) {
|
||||
int id = 0;
|
||||
id |= variant.patternColor;
|
||||
id <<= 8;
|
||||
id |= variant.bodyColor;
|
||||
id <<= 8;
|
||||
id |= variant.pattern.ordinal();
|
||||
id <<= 8;
|
||||
id |= variant.type.ordinal();
|
||||
return id;
|
||||
}
|
||||
|
||||
public static Variant getVariantFromID(int variantID) {
|
||||
Type type = Type.VALUES[variantID & 0xFF];
|
||||
variantID >>= 8;
|
||||
Pattern pattern = Pattern.VALUES[variantID & 0xFF];
|
||||
variantID >>= 8;
|
||||
byte bodyColor = (byte) (variantID & 0xFF);
|
||||
variantID >>= 8;
|
||||
byte patternColor = (byte) (variantID & 0xFF);
|
||||
return new Variant(type, pattern, bodyColor, patternColor);
|
||||
}
|
||||
|
||||
public static class Variant {
|
||||
|
||||
private Type type;
|
||||
private Pattern pattern;
|
||||
private byte bodyColor;
|
||||
private byte patternColor;
|
||||
|
||||
public Variant(@NotNull Type type, @NotNull Pattern pattern, byte bodyColor, byte patternColor) {
|
||||
this.type = type;
|
||||
this.pattern = pattern;
|
||||
this.bodyColor = bodyColor;
|
||||
this.patternColor = patternColor;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Type getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void setType(@NotNull Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Pattern getPattern() {
|
||||
return this.pattern;
|
||||
}
|
||||
|
||||
public void setPattern(@NotNull Pattern pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
public byte getBodyColor() {
|
||||
return this.bodyColor;
|
||||
}
|
||||
|
||||
public void setBodyColor(byte bodyColor) {
|
||||
this.bodyColor = bodyColor;
|
||||
}
|
||||
|
||||
public byte getPatternColor() {
|
||||
return this.patternColor;
|
||||
}
|
||||
|
||||
public void setPatternColor(byte patternColor) {
|
||||
this.patternColor = patternColor;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
SMALL,
|
||||
LARGE,
|
||||
INVISIBLE;
|
||||
|
||||
private final static Type[] VALUES = values();
|
||||
}
|
||||
|
||||
public enum Pattern {
|
||||
KOB, // FLOPPER for LARGE fish
|
||||
SUNSTREAK, // STRIPEY for LARGE fish
|
||||
SNOOPER, // GLITTER for LARGE fish
|
||||
DASHER, // BLOCKFISH for LARGE fish
|
||||
BRINELY, // BETTY for LARGE fish
|
||||
SPOTTY, // CLAYFISH for LARGE fish
|
||||
NONE;
|
||||
|
||||
private final static Pattern[] VALUES = values();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user