Fix jerboa movement and facing with native armadillo behavior and meerkat assets
This commit is contained in:
parent
a723e3b329
commit
ef8be0a39a
17 changed files with 215 additions and 29 deletions
File diff suppressed because one or more lines are too long
1
DuneRealmsGUI/ecology/models/jerboa_curled.json
Normal file
1
DuneRealmsGUI/ecology/models/jerboa_curled.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"ambientocclusion":false,"textures":{"fur":"dunerealms:entity/jerboa"},"elements":[{"from":[3,1,4],"to":[13,10,15],"faces":{"north":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"south":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"east":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"west":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"up":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"down":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]}}},{"from":[2,3,5],"to":[14,8,14],"faces":{"north":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"south":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"east":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"west":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"up":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"down":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]}}},{"from":[5,0,6],"to":[11,2,13],"faces":{"north":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"south":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"east":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"west":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"up":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"down":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]}}},{"from":[4,3,2],"to":[12,8,6],"faces":{"north":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"south":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"east":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"west":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"up":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"down":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]}}},{"from":[4,2,14],"to":[12,4,17],"faces":{"north":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"south":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"east":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"west":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"up":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]},"down":{"texture":"#fur","uv":[1.7777777777777777,0.4444444444444444,3.111111111111111,1.7777777777777777]}}}]}
|
||||
1
DuneRealmsGUI/ecology/models/jerboa_walk_left.json
Normal file
1
DuneRealmsGUI/ecology/models/jerboa_walk_left.json
Normal file
File diff suppressed because one or more lines are too long
1
DuneRealmsGUI/ecology/models/jerboa_walk_right.json
Normal file
1
DuneRealmsGUI/ecology/models/jerboa_walk_right.json
Normal file
File diff suppressed because one or more lines are too long
BIN
DuneRealmsGUI/ecology/sounds/jerboa_hurt.ogg
Normal file
BIN
DuneRealmsGUI/ecology/sounds/jerboa_hurt.ogg
Normal file
Binary file not shown.
BIN
DuneRealmsGUI/ecology/sounds/jerboa_idle.ogg
Normal file
BIN
DuneRealmsGUI/ecology/sounds/jerboa_idle.ogg
Normal file
Binary file not shown.
BIN
DuneRealmsGUI/ecology/textures/jerboa.png
Normal file
BIN
DuneRealmsGUI/ecology/textures/jerboa.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1 MiB |
84
DuneRealmsGUI/ecology/vendor/runes-and-dunes/MeerkatModel.java.txt
vendored
Normal file
84
DuneRealmsGUI/ecology/vendor/runes-and-dunes/MeerkatModel.java.txt
vendored
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
package net.thefluffycart.dunes_mod.entity.client;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.client.model.HierarchicalModel;
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.client.model.geom.PartPose;
|
||||
import net.minecraft.client.model.geom.builders.*;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.thefluffycart.dunes_mod.entity.animations.ModAnimationDefinitions;
|
||||
import net.thefluffycart.dunes_mod.entity.custom.MeerkatEntity;
|
||||
|
||||
public class MeerkatModel<T extends MeerkatEntity> extends HierarchicalModel<T> {
|
||||
|
||||
private final ModelPart Meerkat;
|
||||
private final ModelPart head;
|
||||
|
||||
public MeerkatModel(ModelPart root) {
|
||||
this.Meerkat = root.getChild("meerkat");
|
||||
this.head = Meerkat.getChild("head");
|
||||
}
|
||||
|
||||
public static LayerDefinition createBodyLayer() {
|
||||
MeshDefinition meshdefinition = new MeshDefinition();
|
||||
PartDefinition partdefinition = meshdefinition.getRoot();
|
||||
|
||||
PartDefinition meerkat = partdefinition.addOrReplaceChild("meerkat", CubeListBuilder.create(), PartPose.offset(1.0F, 24.0F, -1.0F));
|
||||
|
||||
PartDefinition head = meerkat.addOrReplaceChild("head", CubeListBuilder.create().texOffs(11, 9).addBox(-2.5F, -4.0F, -2.5F, 5.0F, 4.0F, 5.0F, new CubeDeformation(0.0F))
|
||||
.texOffs(25, 0).addBox(-1.5F, -2.0F, -4.5F, 3.0F, 2.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(-1.0F, -12.0F, 1.0F));
|
||||
|
||||
PartDefinition ear_left = head.addOrReplaceChild("ear_left", CubeListBuilder.create().texOffs(12, 0).addBox(0.0F, -1.0F, -0.5F, 1.0F, 2.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offset(2.5F, -2.0F, 1.0F));
|
||||
|
||||
PartDefinition ear_right = head.addOrReplaceChild("ear_right", CubeListBuilder.create().texOffs(0, 0).addBox(-1.0F, -1.0F, -0.5F, 1.0F, 2.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offset(-2.5F, -2.0F, 1.0F));
|
||||
|
||||
PartDefinition body = meerkat.addOrReplaceChild("body", CubeListBuilder.create().texOffs(0, 0).addBox(-1.5F, -5.0F, -1.5F, 4.0F, 10.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offset(-1.5F, -7.0F, 0.5F));
|
||||
|
||||
PartDefinition arm_left = meerkat.addOrReplaceChild("arm_left", CubeListBuilder.create(), PartPose.offset(0.0F, -10.0F, 1.0F));
|
||||
|
||||
PartDefinition cube_r1 = arm_left.addOrReplaceChild("cube_r1", CubeListBuilder.create().texOffs(0, 20).addBox(0.5F, -2.5F, -1.5F, 2.0F, 5.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-0.5F, 1.5F, -0.5F, -0.5236F, 0.0F, 0.0F));
|
||||
|
||||
PartDefinition arm_right = meerkat.addOrReplaceChild("arm_right", CubeListBuilder.create(), PartPose.offset(-2.0F, -10.0F, 1.0F));
|
||||
|
||||
PartDefinition cube_r2 = arm_right.addOrReplaceChild("cube_r2", CubeListBuilder.create().texOffs(12, 18).addBox(-0.5F, -2.5F, -1.5F, 2.0F, 5.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-1.5F, 1.5F, -0.5F, -0.5236F, 0.0F, 0.0F));
|
||||
|
||||
PartDefinition foot_left = meerkat.addOrReplaceChild("foot_left", CubeListBuilder.create().texOffs(5, 24).addBox(0.0F, 0.0F, -1.5F, 1.0F, 4.0F, 2.5F, new CubeDeformation(0.0F))
|
||||
.texOffs(16, 0).addBox(-1.0F, 4.0F, -3.5F, 2.0F, 1.0F, 5.0F, new CubeDeformation(0.0F)), PartPose.offset(0.5F, -5.0F, 1.5F));
|
||||
|
||||
PartDefinition foot_right = meerkat.addOrReplaceChild("foot_right", CubeListBuilder.create().texOffs(0, 14).addBox(-1.0F, 4.0F, -3.5F, 2.0F, 1.0F, 5.0F, new CubeDeformation(0.0F))
|
||||
.texOffs(20, 18).addBox(-1.0F, 0.0F, -1.5F, 1.0F, 4.0F, 2.5F, new CubeDeformation(0.0F)), PartPose.offset(-2.5F, -5.0F, 1.5F));
|
||||
|
||||
PartDefinition tail = meerkat.addOrReplaceChild("tail", CubeListBuilder.create(), PartPose.offset(-1.0F, -5.5F, 3.0F));
|
||||
|
||||
PartDefinition cube_r3 = tail.addOrReplaceChild("cube_r3", CubeListBuilder.create().texOffs(13, 25).addBox(0.0F, -2.5F, -1.0F, 1.0F, 5.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-0.5F, -1.0F, 1.5F, -0.7854F, 0.0F, 0.0F));
|
||||
|
||||
return LayerDefinition.create(meshdefinition, 36, 36);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
|
||||
this.root().getAllParts().forEach(ModelPart::resetPose);
|
||||
this.animateWalk(ModAnimationDefinitions.MEERKAT_WALK, limbSwing, limbSwingAmount, 2f, 2.5f);
|
||||
this.animate(entity.idleAnimationState, ModAnimationDefinitions.MEERKAT_IDLE, ageInTicks, 1f);
|
||||
this.animate(entity.sitAnimationState, ModAnimationDefinitions.MEERKAT_SIT, ageInTicks, 1f);
|
||||
}
|
||||
|
||||
|
||||
private void applyHeadRotation(MeerkatEntity pEntity, float pNetHeadYaw, float pHeadPitch, float pAgeInTicks) {
|
||||
pNetHeadYaw = Mth.clamp(pNetHeadYaw, -30.0F, 30.0F);
|
||||
pHeadPitch = Mth.clamp(pHeadPitch, -25.0F, 45.0F);
|
||||
|
||||
this.head.yRot = pNetHeadYaw * ((float) Math.PI / 180F);
|
||||
this.head.xRot = pHeadPitch * ((float) Math.PI / 180F);
|
||||
}
|
||||
@Override
|
||||
public void renderToBuffer(PoseStack poseStack, VertexConsumer vertexConsumer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) {
|
||||
Meerkat.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelPart root() {
|
||||
return Meerkat;
|
||||
}
|
||||
}
|
||||
34
DuneRealmsGUI/ecology/vendor/runes-and-dunes/NOTICE.txt
vendored
Normal file
34
DuneRealmsGUI/ecology/vendor/runes-and-dunes/NOTICE.txt
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
Runes and Dunes meerkat assets
|
||||
Author: TheFluffycart55 and Runes and Dunes contributors
|
||||
Source: https://github.com/TheFluffycart55/Runes-And-Dunes-1.20.X
|
||||
Pinned revision: c33d58cbae17e0869c4a512a0e4ea2ab7a0251af
|
||||
Project licence declaration: https://modrinth.com/mod/runes-and-dunes/
|
||||
The project author declares MIT on Modrinth. The repository LICENSE.txt is
|
||||
the Forge development kit's separate LGPL notice, not an asset-specific notice.
|
||||
|
||||
Adapted by DuneRealms on 2026-11-23: converted meerkat box geometry to native
|
||||
item-display models; two walking poses and defensive curl; newly repainted
|
||||
jerboa texture. Original idle and hurt OGG recordings are unchanged.
|
||||
The original model source is included alongside this notice.
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright TheFluffycart55 and Runes and Dunes contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
|
@ -27,11 +27,14 @@ final class FaunaModels implements AutoCloseable {
|
|||
displays.put(id,display);carriers.put(id,carrier);
|
||||
}
|
||||
carrier.setInvisible(true);
|
||||
NamespacedKey selected=new NamespacedKey("dunerealms","entity/"+model);
|
||||
var shown=display.getItemStack();var shownMeta=shown.getItemMeta();
|
||||
if(!selected.equals(shownMeta.getItemModel())){shownMeta.setItemModel(selected);shown.setItemMeta(shownMeta);display.setItemStack(shown);}
|
||||
// Living-entity ticks recalculate visibility from effects; a raw entity flag
|
||||
// alone is cleared between model updates on current Paper.
|
||||
var invisible=carrier.getPotionEffect(PotionEffectType.INVISIBILITY);if(invisible==null||invisible.getDuration()<40)carrier.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY,200,0,false,false,false));
|
||||
if(!Objects.equals(sizes.get(id),size)){float s=(float)size;display.setTransformation(new Transformation(new Vector3f(0,.5f*s,0),new Quaternionf(),new Vector3f(s),new Quaternionf()));sizes.put(id,size);}
|
||||
Location at=carrier.getLocation();at.setPitch(0);at.setYaw(at.getYaw()+180);Location last=display.getLocation();
|
||||
Location at=carrier.getLocation();at.setPitch(0);Location last=display.getLocation();
|
||||
if(last.distanceSquared(at)>.0001||Math.abs(last.getYaw()-at.getYaw())>.5)display.teleport(at);
|
||||
}
|
||||
void retain(Set<UUID> alive){for(UUID id:new ArrayList<>(displays.keySet()))if(!alive.contains(id))remove(id);}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import org.bukkit.plugin.Plugin;
|
|||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
/** Cat locomotion and native breeding, with a separate, real jerboa model. */
|
||||
/** Armadillo locomotion, defensive curling and native breeding, with a separate, real jerboa model. */
|
||||
final class JerboaMobs implements Listener {
|
||||
static final NamespacedKey KIND=new NamespacedKey("dunerealms","jerboa"),ROLLED=new NamespacedKey("dunerealms","jerboa_mother_rolled");
|
||||
private static final NamespacedKey EI=new NamespacedKey("executableitems","ei-id");
|
||||
|
|
@ -32,22 +32,29 @@ final class JerboaMobs implements Listener {
|
|||
static boolean mother(Entity e){return e.getPersistentDataContainer().getOrDefault(KIND,PersistentDataType.BYTE,(byte)0)==2;}
|
||||
private static boolean arrakis(Entity e){return e.getWorld().getName().equalsIgnoreCase("arrakis");}
|
||||
private static String itemId(ItemStack item){return item==null||!item.hasItemMeta()?null:item.getItemMeta().getPersistentDataContainer().get(EI,PersistentDataType.STRING);}
|
||||
private static void prepare(Cat cat,int age){cat.getPersistentDataContainer().set(KIND,PersistentDataType.BYTE,(byte)1);cat.setTamed(true);cat.setSitting(false);cat.setAge(age);cat.setRemoveWhenFarAway(true);cat.customName(Component.text("Jerboa",NamedTextColor.YELLOW));var speed=cat.getAttribute(Attribute.MOVEMENT_SPEED);if(speed!=null)speed.setBaseValue(SPEED);var health=cat.getAttribute(Attribute.MAX_HEALTH);if(health!=null){health.setBaseValue(3);cat.setHealth(3);}}
|
||||
private Cat spawn(Location at,int age){return at.getWorld().spawn(at,Cat.class,c->prepare(c,age));}
|
||||
private static void prepare(Armadillo cat,int age){cat.getPersistentDataContainer().set(KIND,PersistentDataType.BYTE,(byte)1);cat.setAge(age);cat.setSilent(true);cat.setRemoveWhenFarAway(true);cat.customName(Component.text("Jerboa",NamedTextColor.YELLOW));var speed=cat.getAttribute(Attribute.MOVEMENT_SPEED);if(speed!=null)speed.setBaseValue(SPEED);var health=cat.getAttribute(Attribute.MAX_HEALTH);if(health!=null){health.setBaseValue(3);cat.setHealth(3);}}
|
||||
private Armadillo spawn(Location at,int age){return at.getWorld().spawn(at,Armadillo.class,c->prepare(c,age));}
|
||||
void replace(Rabbit rabbit){
|
||||
if(!rabbit.isValid()||rabbit.hasMetadata("NPC")||!replacing.add(rabbit.getUniqueId()))return;
|
||||
try{Cat cat=spawn(rabbit.getLocation(),rabbit.getAge());if(!cat.isValid())return;
|
||||
try{Armadillo cat=spawn(rabbit.getLocation(),rabbit.getAge());if(!cat.isValid())return;
|
||||
cat.setFireTicks(rabbit.getFireTicks());cat.setHealth(Math.min(rabbit.getHealth(),cat.getAttribute(Attribute.MAX_HEALTH).getValue()));rabbit.remove();
|
||||
}finally{replacing.remove(rabbit.getUniqueId());}
|
||||
}
|
||||
void migrate(Cat old){
|
||||
Armadillo replacement=spawn(old.getLocation(),old.getAge());if(!replacement.isValid())return;replacement.setFireTicks(old.getFireTicks());replacement.setHealth(Math.min(3,old.getHealth()));replacement.customName(old.customName());if(old.getPersistentDataContainer().has(ROLLED,PersistentDataType.BYTE))replacement.getPersistentDataContainer().set(ROLLED,PersistentDataType.BYTE,(byte)1);old.remove();
|
||||
}
|
||||
private void maintain(){
|
||||
World world=Bukkit.getWorld("arrakis");if(world==null)return;
|
||||
var valid=new HashSet<UUID>();
|
||||
for(var entity:world.getLivingEntities()){
|
||||
if(entity instanceof Rabbit rabbit){replace(rabbit);continue;}
|
||||
if(entity instanceof Cat cat&&isJerboa(cat)){migrate(cat);continue;}
|
||||
if(isJerboa(entity)){
|
||||
valid.add(entity.getUniqueId());models.track(entity,"jerboa",entity instanceof Cat c&&!c.isAdult()?.48:mother(entity)?2:1);
|
||||
if(entity instanceof Cat cat){cat.setSitting(false);if(cat.isAdult()&&!cat.getPersistentDataContainer().has(ROLLED,PersistentDataType.BYTE))rollMother(cat);}
|
||||
valid.add(entity.getUniqueId());entity.setSilent(true);boolean curled=entity instanceof Armadillo a&&a.getState()!=Armadillo.State.IDLE;
|
||||
String model=curled?"jerboa_curled":entity.getVelocity().lengthSquared()>.001?(entity.getTicksLived()/4%2==0?"jerboa_walk_left":"jerboa_walk_right"):"jerboa";
|
||||
models.track(entity,model,entity instanceof Armadillo c&&!c.isAdult()?.48:mother(entity)?2:1);
|
||||
if(!curled&&random.getAsDouble()<.01)entity.getWorld().playSound(entity.getLocation(),"dunerealms:jerboa.idle",SoundCategory.NEUTRAL,.35f,mother(entity)?.8f:1.1f);
|
||||
if(entity instanceof Armadillo cat){if(cat.isAdult()&&!cat.getPersistentDataContainer().has(ROLLED,PersistentDataType.BYTE))rollMother(cat);}
|
||||
else if(entity instanceof Spider spider){UUID target=retaliation.get(spider.getUniqueId());LivingEntity attacker=target==null?null:Bukkit.getEntity(target) instanceof LivingEntity l?l:null;if(attacker==null||!attacker.isValid()||attacker.isDead()||!attacker.getWorld().equals(world)||attacker.getLocation().distanceSquared(spider.getLocation())>1024){retaliation.remove(spider.getUniqueId());spider.setTarget(null);}else spider.setTarget(attacker);}
|
||||
}else if(entity instanceof Wolf&&entity.getPersistentDataContainer().has(new NamespacedKey("dunerealms","tiny_worm_pet"),PersistentDataType.BYTE)){
|
||||
valid.add(entity.getUniqueId());models.track(entity,"tiny_worm",((Wolf)entity).isAdult()?.8:.45);
|
||||
|
|
@ -55,28 +62,29 @@ final class JerboaMobs implements Listener {
|
|||
}
|
||||
models.retain(valid);retaliation.keySet().retainAll(valid);instantFeeds.entrySet().removeIf(e->e.getValue()+1000<System.currentTimeMillis());
|
||||
}
|
||||
private void rollMother(Cat adult){
|
||||
private void rollMother(Armadillo adult){
|
||||
adult.getPersistentDataContainer().set(ROLLED,PersistentDataType.BYTE,(byte)1);
|
||||
if(random.getAsDouble()>=MOTHER_CHANCE||adult.getNearbyEntities(32,16,32).stream().anyMatch(JerboaMobs::mother))return;
|
||||
Location at=adult.getLocation().clone().add(2,0,2);if(!at.getChunk().isLoaded()||!at.getBlock().isPassable()||!at.clone().add(0,1,0).getBlock().isPassable()||!at.clone().add(0,-1,0).getBlock().getType().isSolid())return;
|
||||
at.getWorld().spawn(at,Spider.class,s->{s.getPersistentDataContainer().set(KIND,PersistentDataType.BYTE,(byte)2);s.customName(Component.text("Big Mama Jerboa",NamedTextColor.GOLD));s.getAttribute(Attribute.MAX_HEALTH).setBaseValue(6);s.setHealth(6);s.getAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(SPEED);s.getAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(3);var scale=s.getAttribute(Attribute.SCALE);if(scale!=null)scale.setBaseValue(1.4);s.setTarget(null);});
|
||||
}
|
||||
private static void consume(Player player,EquipmentSlot hand){if(player.getGameMode()==GameMode.CREATIVE)return;ItemStack item=player.getInventory().getItem(hand);item.setAmount(item.getAmount()-1);player.getInventory().setItem(hand,item);}
|
||||
private void litter(Cat parent){for(int i=0;i<4;i++){var at=parent.getLocation().clone().add((i%2-.5)*.4,0,(i/2-.5)*.4);spawn(at,-24000);}parent.getWorld().spawnParticle(Particle.HEART,parent.getLocation().add(0,.5,0),7,.3,.3,.3);}
|
||||
private void litter(Armadillo parent){for(int i=0;i<4;i++){var at=parent.getLocation().clone().add((i%2-.5)*.4,0,(i/2-.5)*.4);spawn(at,-24000);}parent.getWorld().spawnParticle(Particle.HEART,parent.getLocation().add(0,.5,0),7,.3,.3,.3);}
|
||||
@EventHandler(priority=EventPriority.HIGHEST,ignoreCancelled=true) public void feed(PlayerInteractEntityEvent event){
|
||||
if(!arrakis(event.getRightClicked())||!isJerboa(event.getRightClicked()))return;event.setCancelled(true);
|
||||
if(!(event.getRightClicked() instanceof Cat cat)||!cat.isAdult())return;Player player=event.getPlayer();String id=itemId(player.getInventory().getItem(event.getHand()));
|
||||
if(!(event.getRightClicked() instanceof Armadillo cat)||!cat.isAdult())return;Player player=event.getPlayer();String id=itemId(player.getInventory().getItem(event.getHand()));
|
||||
if("spice_block".equals(id)||"smuggled_spice_block".equals(id)){
|
||||
long now=System.currentTimeMillis();if(now-instantFeeds.getOrDefault(cat.getUniqueId(),0L)<250)return;
|
||||
litter(cat);instantFeeds.put(cat.getUniqueId(),now);consume(player,event.getHand());
|
||||
}else if("refined_spice".equals(id)&&cat.canBreed()&&cat.getLoveModeTicks()==0){cat.setLoveModeTicks(600);consume(player,event.getHand());}
|
||||
}
|
||||
@EventHandler(priority=EventPriority.MONITOR,ignoreCancelled=true) public void breed(EntityBreedEvent event){
|
||||
if(!arrakis(event.getEntity())||!isJerboa(event.getMother())||!isJerboa(event.getFather())||!(event.getEntity() instanceof Cat child))return;
|
||||
if(!arrakis(event.getEntity())||!isJerboa(event.getMother())||!isJerboa(event.getFather())||!(event.getEntity() instanceof Armadillo child))return;
|
||||
prepare(child,-24000);for(int i=0;i<3;i++)spawn(child.getLocation(),-24000);
|
||||
}
|
||||
@EventHandler(priority=EventPriority.HIGHEST,ignoreCancelled=true) public void target(EntityTargetLivingEntityEvent event){if(mother(event.getEntity())&&event.getTarget()!=null&&!event.getTarget().getUniqueId().equals(retaliation.get(event.getEntity().getUniqueId())))event.setCancelled(true);}
|
||||
@EventHandler(priority=EventPriority.MONITOR,ignoreCancelled=true) public void attacked(EntityDamageByEntityEvent event){
|
||||
if(isJerboa(event.getEntity()))event.getEntity().getWorld().playSound(event.getEntity().getLocation(),"dunerealms:jerboa.hurt",SoundCategory.NEUTRAL,.5f,mother(event.getEntity())?.8f:1.1f);
|
||||
if(!mother(event.getEntity()))return;Entity attacker=event.getDamager();if(attacker instanceof Projectile p&&p.getShooter() instanceof Entity shooter)attacker=shooter;
|
||||
if(attacker instanceof LivingEntity&&attacker!=event.getEntity())retaliation.put(event.getEntity().getUniqueId(),attacker.getUniqueId());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||
/** Disposable native boot check. Never runs on a production world. */
|
||||
public final class ArrakisFaunaSmoke extends JavaPlugin {
|
||||
private JerboaMobs fauna;private ItemStack held;
|
||||
@Override public void onEnable(){fauna=new JerboaMobs(this,this::item,()->0);fauna.start();Bukkit.getScheduler().runTaskLater(this,()->{try{run();}catch(Throwable failure){getLogger().severe("FAUNA_SMOKE_FAIL "+failure);failure.printStackTrace();Bukkit.shutdown();}},50);}
|
||||
@Override public void onEnable(){fauna=new JerboaMobs(this,this::item,()->1);fauna.start();Bukkit.getScheduler().runTaskLater(this,()->{try{run();}catch(Throwable failure){getLogger().severe("FAUNA_SMOKE_FAIL "+failure);failure.printStackTrace();Bukkit.shutdown();}},50);}
|
||||
private ItemStack item(String id){var stack=new ItemStack(id.contains("hide")?Material.RABBIT_HIDE:id.contains("vial")?Material.POTION:id.contains("cooked")?Material.COOKED_RABBIT:Material.RABBIT);var meta=stack.getItemMeta();meta.getPersistentDataContainer().set(new NamespacedKey("executableitems","ei-id"),PersistentDataType.STRING,id);stack.setItemMeta(meta);return stack;}
|
||||
private static void check(boolean condition,String message){if(!condition)throw new IllegalStateException(message);}
|
||||
private Object defaults(Method m){Class<?> r=m.getReturnType();if(r==boolean.class)return false;if(r==int.class)return 0;if(r==float.class)return 0f;if(r==double.class)return 0d;if(r==long.class)return 0L;return null;}
|
||||
|
|
@ -39,8 +39,10 @@ public final class ArrakisFaunaSmoke extends JavaPlugin {
|
|||
held=new ItemStack(Material.BRUSH);bridge.brush(new PlayerInteractEvent(player,Action.RIGHT_CLICK_BLOCK,held,block,BlockFace.UP,EquipmentSlot.HAND));check(block.getType()==Material.SAND,"Brush did not restore original sand");
|
||||
var plain=world.getBlockAt(9,65,8);plain.setType(Material.SANDSTONE,false);bridge.brush(new PlayerInteractEvent(player,Action.RIGHT_CLICK_BLOCK,held,plain,BlockFace.UP,EquipmentSlot.HAND));check(plain.getType()==Material.SANDSTONE,"Brush altered ordinary construction");
|
||||
Rabbit rabbit=world.spawn(new Location(world,2.5,65,2.5),Rabbit.class);fauna.replace(rabbit);check(!rabbit.isValid(),"Rabbit was not replaced");
|
||||
Cat adult=world.getEntitiesByClass(Cat.class).stream().filter(JerboaMobs::isJerboa).findFirst().orElseThrow();check(adult.getAttribute(Attribute.MAX_HEALTH).getValue()==3,"Jerboa health changed");check(Math.abs(adult.getAttribute(Attribute.MOVEMENT_SPEED).getValue()-.225)<1e-6,"Jerboa speed changed");
|
||||
int before=world.getEntitiesByClass(Cat.class).size();held=item("spice_block");fauna.feed(new PlayerInteractEntityEvent(player,adult,EquipmentSlot.HAND));check(world.getEntitiesByClass(Cat.class).size()==before+4,"One-parent block did not produce four babies");
|
||||
Bukkit.getScheduler().runTaskLater(this,()->{try{check(adult.isInvisible(),"Carrier remains visible");check(world.getEntitiesByClass(ItemDisplay.class).stream().anyMatch(d->d.getItemStack().getItemMeta().hasItemModel()),"Custom model display absent");getLogger().info("FAUNA_SMOKE_SUCCESS sandWear=true brushRestore=true ordinarySandstonePreserved=true catCarrier=true fourBabies=true realModelDisplay=true");}catch(Throwable failure){getLogger().severe("FAUNA_SMOKE_FAIL "+failure);failure.printStackTrace();}finally{Bukkit.shutdown();}},20);
|
||||
Armadillo adult=world.getEntitiesByClass(Armadillo.class).stream().filter(e->JerboaMobs.isJerboa(e)&&e.isAdult()&&e.getLocation().distanceSquared(new Location(world,2.5,65,2.5))<.1).findFirst().orElseThrow();check(adult.getAttribute(Attribute.MAX_HEALTH).getValue()==3,"Jerboa health changed");check(Math.abs(adult.getAttribute(Attribute.MOVEMENT_SPEED).getValue()-.225)<1e-6,"Jerboa speed changed");
|
||||
Cat legacy=world.spawn(new Location(world,4.5,65,4.5),Cat.class);legacy.getPersistentDataContainer().set(JerboaMobs.KIND,PersistentDataType.BYTE,(byte)1);legacy.setAge(-1234);fauna.migrate(legacy);check(!legacy.isValid(),"Legacy cat not migrated");check(world.getEntitiesByClass(Armadillo.class).stream().anyMatch(a->a.getAge()==-1234),"Migration lost baby age");
|
||||
int before=world.getEntitiesByClass(Armadillo.class).size();held=item("spice_block");fauna.feed(new PlayerInteractEntityEvent(player,adult,EquipmentSlot.HAND));check(world.getEntitiesByClass(Armadillo.class).size()==before+4,"One-parent block did not produce four babies");
|
||||
Location start=adult.getLocation().clone();check(adult.getPathfinder().moveTo(new Location(world,12.5,65,2.5),1),"Native walking path unavailable");
|
||||
Bukkit.getScheduler().runTaskLater(this,()->{try{check(adult.getLocation().distanceSquared(start)>.04,"Native jerboa failed to walk");check(adult.isInvisible(),"Carrier remains visible");check(world.getEntitiesByClass(ItemDisplay.class).stream().anyMatch(d->d.getItemStack().getItemMeta().hasItemModel()),"Custom model display absent");adult.rollUp();check(adult.getState()!=Armadillo.State.IDLE,"Armadillo did not curl defensively");getLogger().info("FAUNA_SMOKE_SUCCESS sandWear=true brushRestore=true ordinarySandstonePreserved=true armadilloCarrier=true fourBabies=true realModelDisplay=true nativeWalking=true defensiveCurl=true");}catch(Throwable failure){getLogger().severe("FAUNA_SMOKE_FAIL "+failure);failure.printStackTrace();}finally{Bukkit.shutdown();}},40);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,9 +10,13 @@ export function build(output){
|
|||
entries.set(`assets/dunerealms/models/entity/${name}.json`,Buffer.from(JSON.stringify({ambientocclusion:false,...model})));
|
||||
entries.set(`assets/dunerealms/items/entity/${name}.json`,Buffer.from(JSON.stringify({model:{type:'minecraft:model',model:`dunerealms:entity/${name}`}})));
|
||||
}
|
||||
entries.set('assets/dunerealms/textures/entity/jerboa.png',fs.readFileSync(path.join(path.dirname(fileURLToPath(import.meta.url)),'../DuneRealmsGUI/ecology/textures/jerboa.png')));
|
||||
for(const name of ['idle','hurt'])entries.set(`assets/dunerealms/sounds/jerboa_${name}.ogg`,fs.readFileSync(path.join(path.dirname(fileURLToPath(import.meta.url)),`../DuneRealmsGUI/ecology/sounds/jerboa_${name}.ogg`)));
|
||||
entries.set('assets/dunerealms/sounds.json',Buffer.from(JSON.stringify(Object.fromEntries(['idle','hurt'].map(name=>[`jerboa.${name}`,{sounds:[`dunerealms:jerboa_${name}`]}])))));
|
||||
entries.set('licenses/Runes-and-Dunes-MIT.txt',fs.readFileSync(path.join(path.dirname(fileURLToPath(import.meta.url)),'../DuneRealmsGUI/ecology/vendor/runes-and-dunes/NOTICE.txt')));
|
||||
// Local Windows checkouts and Linux release workers must produce equal bytes.
|
||||
for(const [name,bytes]of entries)if(/\.(?:txt|md)$/.test(name))entries.set(name,Buffer.from(bytes.toString('utf8').replaceAll('\r\n','\n')));
|
||||
const filename='DuneRealms-Materials-arrakis-v3.zip',bytes=zip(entries);
|
||||
const filename='DuneRealms-Materials-arrakis-v4.zip',bytes=zip(entries);
|
||||
fs.mkdirSync(output,{recursive:true});fs.writeFileSync(path.join(output,filename),bytes);
|
||||
const digest=algorithm=>createHash(algorithm).update(bytes).digest('hex');
|
||||
const record={filename,url:'https://www.dunerealms.com/downloads/'+filename,sha1:digest('sha1'),sha256:digest('sha256'),bytes:bytes.length,entries:entries.size};
|
||||
|
|
|
|||
|
|
@ -24,11 +24,16 @@ def build(output, expanded=False):
|
|||
items[f'assets/dunerealms/textures/item/ecology/{item}.png'] = png(item, (32, 32))
|
||||
items[f'assets/dunerealms/models/item/ecology/{item}.json'] = json.dumps({'parent': 'minecraft:item/generated', 'textures': {'layer0': f'dunerealms:item/ecology/{item}'}}).encode()
|
||||
items[f'assets/dunerealms/items/ecology/{item}.json'] = json.dumps({'model': {'type': 'minecraft:model', 'model': f'dunerealms:item/ecology/{item}'}}).encode()
|
||||
for name in ('jerboa', 'tiny_worm'):
|
||||
for name in ('jerboa', 'jerboa_walk_left', 'jerboa_walk_right', 'jerboa_curled', 'tiny_worm'):
|
||||
model = (ART / 'models' / (name + '.json')).read_bytes()
|
||||
assert json.loads(model)['elements'], 'Real custom geometry required'
|
||||
items[f'assets/dunerealms/models/entity/{name}.json'] = model
|
||||
items[f'assets/dunerealms/items/entity/{name}.json'] = json.dumps({'model': {'type': 'minecraft:model', 'model': f'dunerealms:entity/{name}'}}).encode()
|
||||
items['assets/dunerealms/textures/entity/jerboa.png'] = (ART / 'textures/jerboa.png').read_bytes()
|
||||
items['assets/dunerealms/sounds.json'] = json.dumps({f'jerboa.{name}': {'sounds': [f'dunerealms:jerboa_{name}']} for name in ('idle', 'hurt')}).encode()
|
||||
for name in ('idle', 'hurt'):
|
||||
items[f'assets/dunerealms/sounds/jerboa_{name}.ogg'] = (ART / 'sounds' / f'jerboa_{name}.ogg').read_bytes()
|
||||
items['licenses/Runes-and-Dunes-MIT.txt'] = (ART / 'vendor/runes-and-dunes/NOTICE.txt').read_bytes()
|
||||
entities = dict(common)
|
||||
if expanded:
|
||||
texture=png('spice_block',(32,32))
|
||||
|
|
|
|||
|
|
@ -2,26 +2,18 @@
|
|||
import {mkdir,writeFile} from 'node:fs/promises';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import path from 'node:path';
|
||||
import {meerkatModels} from './build-jerboa-meerkat.mjs';
|
||||
const root=fileURLToPath(new URL('../DuneRealmsGUI/ecology/models/',import.meta.url));
|
||||
const faces=texture=>Object.fromEntries(['north','south','east','west','up','down'].map(face=>[face,{texture:'#'+texture,uv:[0,0,16,16]}]));
|
||||
const box=(from,to,texture)=>({from,to,faces:faces(texture)});
|
||||
export function faunaModels(){
|
||||
const jerboa=[
|
||||
box([4,3,8],[12,10,18],'fur'),box([3,4,9],[13,9,16],'fur'),box([5,2.5,8],[11,5,18],'belly'),
|
||||
box([3.5,6,2],[12.5,12,9],'fur'),box([5,6,0],[11,9,4],'belly'),box([7,7,-.5],[9,8.5,1],'nose'),
|
||||
box([3,11,4],[6,16,6],'fur'),box([10,11,4],[13,16,6],'fur'),box([3.5,12,3.8],[5.5,15,4],'ear'),box([10.5,12,3.8],[12.5,15,4],'ear'),
|
||||
box([3.3,9,2.5],[4.1,11,4.5],'eye'),box([11.9,9,2.5],[12.7,11,4.5],'eye'),
|
||||
box([3.2,10,2.2],[4.2,10.8,2.6],'glint'),box([11.8,10,2.2],[12.8,10.8,2.6],'glint'),
|
||||
box([3,1,12],[6,5,18],'fur'),box([10,1,12],[13,5,18],'fur'),box([2,0,8],[6,1.5,17],'belly'),box([10,0,8],[14,1.5,17],'belly'),
|
||||
box([4.5,0,4],[6,6,7],'belly'),box([10,0,4],[11.5,6,7],'belly'),
|
||||
box([7,3,17],[9,4.5,24],'tail'),box([8,3,23],[10,4.5,28],'tail'),box([9,3,27],[12,5,31],'eye')
|
||||
];
|
||||
const worm=[];
|
||||
for(let i=0;i<7;i++){const width=7-i*.55,z=4+i*3.2;worm.push(box([8-width/2,2+i*.08,z],[8+width/2,2+width,z+3.2],i%2?'ridge':'body'));}
|
||||
worm.push(box([3,2,0],[13,11,4],'body'),box([4,3,-.1],[12,10,.1],'mouth'),box([6,5,-.2],[10,8,0],'throat'));
|
||||
for(let i=0;i<4;i++){worm.push(box([4.5+i*1.8,3,-.4],[5.3+i*1.8,4.5,.1],'tooth'),box([4.5+i*1.8,8.5,-.4],[5.3+i*1.8,10,.1],'tooth'));}
|
||||
return {
|
||||
jerboa:{textures:{fur:'minecraft:block/brown_terracotta',belly:'minecraft:block/terracotta',nose:'minecraft:block/pink_terracotta',ear:'minecraft:block/pink_terracotta',eye:'minecraft:block/black_concrete',glint:'minecraft:block/white_concrete',tail:'minecraft:block/terracotta'},elements:jerboa},
|
||||
...meerkatModels(),
|
||||
jerboa_curled:{textures:{fur:'dunerealms:entity/jerboa'},elements:[box([3,1,4],[13,10,15],'fur'),box([2,3,5],[14,8,14],'fur'),box([5,0,6],[11,2,13],'fur'),box([4,3,2],[12,8,6],'fur'),box([4,2,14],[12,4,17],'fur')].map(e=>({...e,faces:Object.fromEntries(Object.entries(e.faces).map(([face,data])=>[face,{...data,uv:[4,1,7,4].map(v=>v*16/36)}]))}))},
|
||||
tiny_worm:{textures:{body:'minecraft:block/terracotta',ridge:'minecraft:block/brown_terracotta',mouth:'minecraft:block/black_concrete',throat:'minecraft:block/orange_terracotta',tooth:'minecraft:block/bone_block_side'},elements:worm}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
30
tools/build-jerboa-meerkat.mjs
Normal file
30
tools/build-jerboa-meerkat.mjs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
// Runes and Dunes meerkat geometry, adapted for native item-display rendering.
|
||||
// TheFluffycart55, MIT as declared by the author's Modrinth project.
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..');
|
||||
export function meerkatModels(){
|
||||
const source=fs.readFileSync(path.join(root,'DuneRealmsGUI/ecology/vendor/runes-and-dunes/MeerkatModel.java.txt'),'utf8');
|
||||
const parts=new Map([['partdefinition',{at:[0,0,0],rotation:[0,0,0]}]]),elements=[];
|
||||
const numbers=s=>s.split(',').map(x=>Number(x.trim().replace(/F$/,'')));
|
||||
for(const statement of source.split(';')){
|
||||
const declaration=statement.match(/PartDefinition (\w+) = (\w+)\.addOrReplaceChild\("([^"]+)"/);if(!declaration)continue;
|
||||
const [,name,parent]=declaration,pose=statement.match(/PartPose\.(offset(?:AndRotation)?)\(([^)]+)\)/);if(!pose)throw Error('Pose missing: '+name);
|
||||
const values=numbers(pose[2]),ancestor=parts.get(parent);if(!ancestor)throw Error('Parent missing: '+parent);
|
||||
const at=values.slice(0,3).map((v,i)=>v+ancestor.at[i]),angles=values.slice(3);parts.set(name,{at,rotation:angles});
|
||||
for(const box of statement.matchAll(/texOffs\((\d+), (\d+)\)\.addBox\(([-\d.F]+), ([-\d.F]+), ([-\d.F]+), ([-\d.F]+), ([-\d.F]+), ([-\d.F]+),/g)){
|
||||
const u=+box[1],v=+box[2],[x,y,z,w,h,d]=box.slice(3).map(n=>Number(n.replace('F',''))),uv=(a,b,c,e)=>[a,b,c,e].map(n=>n*16/36);
|
||||
const faces={west:{uv:uv(u,v+d,u+d,v+d+h)},north:{uv:uv(u+d,v+d,u+d+w,v+d+h)},east:{uv:uv(u+d+w,v+d,u+2*d+w,v+d+h)},south:{uv:uv(u+2*d+w,v+d,u+2*d+2*w,v+d+h)},up:{uv:uv(u+d,v,u+d+w,v+d)},down:{uv:uv(u+d+w,v,u+d+2*w,v+d)}};
|
||||
for(const face of Object.values(faces))face.texture='#fur';
|
||||
const element={from:[8+at[0]+x,24-at[1]-y-h,8+at[2]+z],to:[8+at[0]+x+w,24-at[1]-y,8+at[2]+z+d],faces};
|
||||
if(angles.some(a=>a!==0))element.rotation={origin:[8+at[0],24-at[1],8+at[2]],axis:'x',angle:Math.round(-angles[0]*180/Math.PI/22.5)*22.5};
|
||||
elements.push({part:name,element,at});
|
||||
}
|
||||
}
|
||||
if(elements.length!==12)throw Error('Upstream model geometry changed: '+elements.length);
|
||||
const make=frame=>({textures:{fur:'dunerealms:entity/jerboa'},elements:elements.map(({part,element,at})=>{
|
||||
const copy=structuredClone(element);if(frame&&/^(?:foot_left|foot_right|cube_r1|cube_r2)$/.test(part))copy.rotation={origin:[8+at[0],24-at[1],8+at[2]],axis:'x',angle:(part==='foot_left'||part==='cube_r2'?1:-1)*frame*22.5};return copy;
|
||||
})});
|
||||
return {jerboa:make(0),jerboa_walk_left:make(1),jerboa_walk_right:make(-1)};
|
||||
}
|
||||
21
tools/patch-jerboa-motion.py
Normal file
21
tools/patch-jerboa-motion.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
"""Replace only fauna runtime classes in the hash-pinned current terrain JAR."""
|
||||
import pathlib,sys,hashlib,zipfile,json
|
||||
source,classes,output=map(pathlib.Path,sys.argv[1:4]);expected=sys.argv[4]
|
||||
assert not output.exists() and hashlib.sha256(source.read_bytes()).hexdigest()==expected
|
||||
allowed=['com/example/duneterrain/'+name+'.class' for name in ('JerboaMobs','FaunaModels')]
|
||||
with zipfile.ZipFile(source) as original:
|
||||
entries={name:original.read(name) for name in original.namelist()}
|
||||
assert len(entries)==len(original.namelist())
|
||||
before=dict(entries)
|
||||
for name in allowed:
|
||||
assert name in entries
|
||||
data=(classes/name).read_bytes();assert data[:4]==b'\xca\xfe\xba\xbe' and int.from_bytes(data[6:8],'big')==65
|
||||
entries[name]=data
|
||||
entries['plugin.yml']=entries['plugin.yml'].decode().replace('version: 1.0.12-arrakeen1-fauna2-trails1','version: 1.0.12-arrakeen1-fauna3-trails1').encode()
|
||||
assert entries['plugin.yml']!=before['plugin.yml']
|
||||
with zipfile.ZipFile(output,'x',zipfile.ZIP_DEFLATED) as target:
|
||||
for name,data in entries.items():target.writestr(name,data)
|
||||
with zipfile.ZipFile(output) as target:
|
||||
changed=[name for name in before if target.read(name)!=before[name]]
|
||||
assert set(changed)==set(allowed+['plugin.yml'])
|
||||
print(json.dumps({'sha256':hashlib.sha256(output.read_bytes()).hexdigest(),'changed':changed,'worldGenerationChanged':False}))
|
||||
Loading…
Reference in a new issue

Staff