Skip to content

Commit

Permalink
Update to use Rabbit.Type instead of RabbitType
Browse files Browse the repository at this point in the history
Follow-up to:
#599 Add Part 1 of Passive Entities [Entities]
instead of taking the Glowkit change to add RabbitType:
https://github.com/GlowstoneMC/Glowkit/pull/31 Add 1.8 LivingEntities
using Spigot's Rabbit.Type:
GlowstonePlusPlus/Glowkit-Legacy@c6b3d17 Add RabbitType API.
  • Loading branch information
deathcap committed Apr 6, 2015
1 parent c37ac2a commit f62c253
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
22 changes: 11 additions & 11 deletions src/main/java/net/glowstone/entity/passive/GlowRabbit.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,30 @@

public class GlowRabbit extends GlowAnimal implements Rabbit {

private static final ImmutableBiMap<RabbitType, Integer> rabbitTypeIntegerMap = ImmutableBiMap.<RabbitType, Integer>builder()
.put(Rabbit.RabbitType.BROWN, 0)
.put(Rabbit.RabbitType.WHITE, 1)
.put(Rabbit.RabbitType.BLACK, 2)
.put(Rabbit.RabbitType.BLACK_AND_WHITE, 3)
.put(Rabbit.RabbitType.GOLD, 4)
.put(Rabbit.RabbitType.SALT_PEPPER, 5)
.put(Rabbit.RabbitType.KILLER, 99)
private static final ImmutableBiMap<Rabbit.Type, Integer> rabbitTypeIntegerMap = ImmutableBiMap.<Rabbit.Type, Integer>builder()
.put(Rabbit.Type.BROWN, 0)
.put(Rabbit.Type.WHITE, 1)
.put(Rabbit.Type.BLACK, 2)
.put(Rabbit.Type.BLACK_AND_WHITE, 3)
.put(Rabbit.Type.GOLD, 4)
.put(Rabbit.Type.SALT_AND_PEPPER, 5)
.put(Type.THE_KILLER_BUNNY, 99)
.build();

private RabbitType rabbitType = RabbitType.BROWN;
private Rabbit.Type rabbitType = Rabbit.Type.BROWN;

public GlowRabbit(Location location) {
super(location, EntityType.RABBIT);
setSize(0.3F, 0.7F);
}

@Override
public RabbitType getRabbitType() {
public Rabbit.Type getRabbitType() {
return rabbitType;
}

@Override
public void setRabbitType(RabbitType type) {
public void setRabbitType(Rabbit.Type type) {
Validate.notNull(type, "Cannot set a null rabbit type!");
this.rabbitType = type;
}
Expand Down
40 changes: 20 additions & 20 deletions src/main/java/net/glowstone/io/entity/RabbitStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@

class RabbitStore extends AgeableStore<GlowRabbit> {

private final Map<Integer, Rabbit.RabbitType> rabbitTypeMap = ImmutableMap.<Integer, Rabbit.RabbitType>builder()
.put(0, Rabbit.RabbitType.BROWN)
.put(1, Rabbit.RabbitType.WHITE)
.put(2, Rabbit.RabbitType.BLACK)
.put(3, Rabbit.RabbitType.BLACK_AND_WHITE)
.put(4, Rabbit.RabbitType.GOLD)
.put(5, Rabbit.RabbitType.SALT_PEPPER)
.put(99, Rabbit.RabbitType.KILLER)
private final Map<Integer, Rabbit.Type> rabbitTypeMap = ImmutableMap.<Integer, Rabbit.Type>builder()
.put(0, Rabbit.Type.BROWN)
.put(1, Rabbit.Type.WHITE)
.put(2, Rabbit.Type.BLACK)
.put(3, Rabbit.Type.BLACK_AND_WHITE)
.put(4, Rabbit.Type.GOLD)
.put(5, Rabbit.Type.SALT_AND_PEPPER)
.put(99, Rabbit.Type.THE_KILLER_BUNNY)
.build();
private final Map<Rabbit.RabbitType, Integer> rabbitTypeIntegerMap = ImmutableMap.<Rabbit.RabbitType, Integer>builder()
.put(Rabbit.RabbitType.BROWN, 0)
.put(Rabbit.RabbitType.WHITE, 1)
.put(Rabbit.RabbitType.BLACK, 2)
.put(Rabbit.RabbitType.BLACK_AND_WHITE, 3)
.put(Rabbit.RabbitType.GOLD, 4)
.put(Rabbit.RabbitType.SALT_PEPPER, 5)
.put(Rabbit.RabbitType.KILLER, 99)
private final Map<Rabbit.Type, Integer> rabbitTypeIntegerMap = ImmutableMap.<Rabbit.Type, Integer>builder()
.put(Rabbit.Type.BROWN, 0)
.put(Rabbit.Type.WHITE, 1)
.put(Rabbit.Type.BLACK, 2)
.put(Rabbit.Type.BLACK_AND_WHITE, 3)
.put(Rabbit.Type.GOLD, 4)
.put(Rabbit.Type.SALT_AND_PEPPER, 5)
.put(Rabbit.Type.THE_KILLER_BUNNY, 99)
.build();

public RabbitStore() {
Expand All @@ -41,12 +41,12 @@ public GlowRabbit createEntity(Location location, CompoundTag compound) {
@Override
public void load(GlowRabbit entity, CompoundTag compound) {
super.load(entity, compound);
Rabbit.RabbitType rabbitType;
Rabbit.Type rabbitType;
int rabbitId = compound.getInt("RabbitType");
if (rabbitTypeMap.containsKey(rabbitId)) {
rabbitType = rabbitTypeMap.get(rabbitId);
} else {
rabbitType = Rabbit.RabbitType.BROWN;
rabbitType = Rabbit.Type.BROWN;
}
entity.setRabbitType(rabbitType);
// TODO "MoreCarrotTicks" -> int
Expand All @@ -55,9 +55,9 @@ public void load(GlowRabbit entity, CompoundTag compound) {
@Override
public void save(GlowRabbit entity, CompoundTag tag) {
super.save(entity, tag);
Rabbit.RabbitType rabbitType = entity.getRabbitType();
Rabbit.Type rabbitType = entity.getRabbitType();
if (rabbitType == null) {
rabbitType = Rabbit.RabbitType.BROWN;
rabbitType = Rabbit.Type.BROWN;
}
tag.putInt("RabbitType", rabbitTypeIntegerMap.get(rabbitType));
}
Expand Down

0 comments on commit f62c253

Please sign in to comment.