Skip to content

Commit a0b2c68

Browse files
Add back camel to rideable mob listener
1 parent 3b3f76d commit a0b2c68

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

src/main/java/me/eccentric_nz/TARDIS/listeners/TARDISRideableMobListener.java

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ public void onInteract(EntityInteractEvent event) {
114114
TARDISHorse tmhor = null;
115115
TARDISLlama tmlla = null;
116116
TARDISPig tmpig = null;
117+
TARDISHorse tmcamel = null;
117118
TARDISMob mob = null;
118119
switch (type) {
119120
case DONKEY, HORSE, MULE, SKELETON_HORSE, ZOMBIE_HORSE -> {
@@ -196,7 +197,22 @@ public void onInteract(EntityInteractEvent event) {
196197
mob.setName(ComponentUtils.stripColour(e.customName()));
197198
}
198199
case CAMEL -> {
199-
200+
Camel camel = (Camel) e;
201+
// save camel
202+
tmcamel = new TARDISHorse();
203+
tmcamel.setType(type);
204+
tmcamel.setAge(camel.getTicksLived());
205+
tmcamel.setBaby(!camel.isAdult());
206+
tmcamel.setHorseVariant(e.getType());
207+
tmcamel.setName(ComponentUtils.stripColour(camel.customName()));
208+
tmcamel.setTamed(true);
209+
tmcamel.setHorseInventory(camel.getInventory().getContents());
210+
tmcamel.setDomesticity(camel.getDomestication());
211+
tmcamel.setJumpStrength(camel.getJumpStrength());
212+
double mh = camel.getAttribute(Attribute.MAX_HEALTH).getValue();
213+
tmcamel.setHorseHealth(mh);
214+
tmcamel.setHealth(camel.getHealth());
215+
tmcamel.setSpeed(camel.getAttribute(Attribute.MOVEMENT_SPEED).getBaseValue());
200216
}
201217
default -> { }
202218
}
@@ -281,6 +297,24 @@ public void onInteract(EntityInteractEvent event) {
281297
}
282298
pig.setSaddle(true);
283299
pig.setRemoveWhenFarAway(false);
300+
} else if (tmcamel != null) {
301+
ent = world.spawnEntity(l, EntityType.CAMEL);
302+
Camel humped = (Camel) ent;
303+
humped.setAge(tmcamel.getAge());
304+
humped.setDomestication(tmcamel.getDomesticity());
305+
humped.setJumpStrength(tmcamel.getJumpStrength());
306+
String name = tmcamel.getName();
307+
if (!name.isEmpty()) {
308+
humped.customName(Component.text(name));
309+
}
310+
AttributeInstance attribute = humped.getAttribute(Attribute.MAX_HEALTH);
311+
attribute.setBaseValue(tmcamel.getHorseHealth());
312+
humped.setHealth(tmcamel.getHealth());
313+
Inventory inv = humped.getInventory();
314+
inv.setContents(tmcamel.getHorseinventory());
315+
humped.getAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(tmcamel.getSpeed());
316+
humped.setTamed(true);
317+
humped.setOwner(p);
284318
} else if (mob != null) {
285319
ent = world.spawnEntity(l, EntityType.STRIDER);
286320
Strider strider = (Strider) ent;

0 commit comments

Comments
 (0)