Skip to content

Commit

Permalink
add defender texture and mother core texture
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheaterpaul committed Oct 25, 2023
1 parent 9254e8d commit d137dba
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 11 deletions.
1 change: 1 addition & 0 deletions dev_resources/models/defender.bbmodel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"meta":{"format_version":"4.5","model_format":"modded_entity","box_uv":true},"name":"defender","model_identifier":"","modded_entity_version":"1.17","modded_entity_flip_y":true,"visible_box":[1,1,0],"variable_placeholders":"","variable_placeholder_buttons":[],"unhandled_root_fields":{},"resolution":{"width":24,"height":24},"elements":[{"name":"cube","box_uv":true,"rescale":false,"locked":false,"render_order":"default","allow_mirror_modeling":true,"from":[-6,0,0],"to":[6,12,0.01],"autouv":0,"color":8,"origin":[0,0,0],"uv_offset":[-0.01,-0.01],"faces":{"north":{"uv":[0,0,12,12]},"east":{"uv":[-0.01,0,0,12]},"south":{"uv":[12.01,0,24.009999999999998,12]},"west":{"uv":[12,0,12.01,12]},"up":{"uv":[12,0,-2.1337098754514727e-16,-0.01]},"down":{"uv":[24,-0.01,12.000000000000002,0]}},"type":"cube","uuid":"885a951a-9019-d169-e38c-73726f062998"},{"name":"cube","box_uv":true,"rescale":false,"locked":false,"render_order":"default","allow_mirror_modeling":true,"from":[-6,0,0],"to":[6,12,0.01],"autouv":0,"color":8,"origin":[0,0,0],"uv_offset":[-0.01,-0.01],"faces":{"north":{"uv":[0,0,12,12]},"east":{"uv":[-0.01,0,0,12]},"south":{"uv":[12.01,0,24.009999999999998,12]},"west":{"uv":[12,0,12.01,12]},"up":{"uv":[12,0,-2.1337098754514727e-16,-0.01]},"down":{"uv":[24,-0.01,12.000000000000002,0]}},"type":"cube","uuid":"582ecae4-b50c-0c1c-8816-198d159fe599"}],"outliner":[{"name":"cube","origin":[0,0,0],"rotation":[0,45,0],"color":0,"nbt":"{}","uuid":"677d5f39-9d0b-763c-37f0-5e7a804c1cd8","export":true,"mirror_uv":false,"isOpen":true,"locked":false,"visibility":true,"autouv":0,"children":["885a951a-9019-d169-e38c-73726f062998"]},{"name":"cube2","origin":[0,0,0],"rotation":[0,-45,0],"color":0,"nbt":"{}","uuid":"33e45818-f49a-7047-f0e1-5660d2f7b10e","export":true,"mirror_uv":false,"isOpen":true,"locked":false,"visibility":true,"autouv":0,"children":["582ecae4-b50c-0c1c-8816-198d159fe599"]}],"textures":[]}
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,34 @@

public class RemainsDefenderModel extends EntityModel<RemainsDefenderEntity> {

private static final String MAIN = "main";
private static final String PART1 = "part1";
private static final String PART2 = "part2";

protected final @NotNull ModelPart main;
protected final @NotNull ModelPart part1;
protected final @NotNull ModelPart part2;

public static LayerDefinition createBodyLayer() {
MeshDefinition meshdefinition = new MeshDefinition();
PartDefinition partdefinition = meshdefinition.getRoot();

PartDefinition main = partdefinition.addOrReplaceChild(MAIN, CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, -4.0F, -4.0F, 8.0F, 4.0F, 8.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F));
PartDefinition cube = partdefinition.addOrReplaceChild(PART1, CubeListBuilder.create().texOffs(0, 0).addBox(-6.0F, -12.0F, 0.0F, 12.0F, 12.0F, 0.01F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 24.0F, 0.0F, 0.0F, -0.7854F, 0.0F));
PartDefinition cube2 = partdefinition.addOrReplaceChild(PART2, CubeListBuilder.create().texOffs(0, 0).addBox(-6.0F, -12.0F, 0.0F, 12.0F, 12.0F, 0.01F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 24.0F, 0.0F, 0.0F, 0.7854F, 0.0F));

return LayerDefinition.create(meshdefinition, 32, 32);
return LayerDefinition.create(meshdefinition, 24, 24);
}

public RemainsDefenderModel(ModelPart part) {
this.main = part.getChild(MAIN);
this.part1 = part.getChild(PART1);
this.part2 = part.getChild(PART2);
}

@Override
public void setupAnim(RemainsDefenderEntity pEntity, float pLimbSwing, float pLimbSwingAmount, float pAgeInTicks, float pNetHeadYaw, float pHeadPitch) {
main.yRot = 0;
main.zRot = 0;
main.xRot = 0;
}

@Override
public void renderToBuffer(PoseStack pPoseStack, VertexConsumer pBuffer, int pPackedLight, int pPackedOverlay, float pRed, float pGreen, float pBlue, float pAlpha) {
this.main.render(pPoseStack, pBuffer, pPackedLight, pPackedOverlay);
this.part1.render(pPoseStack, pBuffer, pPackedLight, pPackedOverlay);
this.part2.render(pPoseStack, pBuffer, pPackedLight, pPackedOverlay);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,33 @@
import de.teamlapen.vampirism.entity.RemainsDefenderEntity;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import org.jetbrains.annotations.NotNull;

public class RemainsDefenderRenderer extends MobRenderer<RemainsDefenderEntity, RemainsDefenderModel> {
private final ResourceLocation TEX = new ResourceLocation(REFERENCE.MODID, "textures/entity/remains_defender.png");
private final ResourceLocation TEX1 = new ResourceLocation(REFERENCE.MODID, "textures/entity/remains_defender/remains_defender1.png");
private final ResourceLocation TEX2 = new ResourceLocation(REFERENCE.MODID, "textures/entity/remains_defender/remains_defender2.png");
private final ResourceLocation TEX3 = new ResourceLocation(REFERENCE.MODID, "textures/entity/remains_defender/remains_defender3.png");
private final ResourceLocation TEX4 = new ResourceLocation(REFERENCE.MODID, "textures/entity/remains_defender/remains_defender4.png");

public RemainsDefenderRenderer(EntityRendererProvider.Context pContext) {
super(pContext, new RemainsDefenderModel(pContext.bakeLayer(ModEntitiesRender.REMAINS_DEFENDER)), 0f);
}

@Override
public @NotNull ResourceLocation getTextureLocation(@NotNull RemainsDefenderEntity pEntity) {
return TEX;
int t = pEntity.tickCount % 20;
if (t> 15) {
return TEX4;
} else if (t > 10) {
return TEX3;
} else if (t > 5) {
return TEX2;
} else {
return TEX1;
}
}

@Override
Expand All @@ -28,4 +42,10 @@ protected void setupRotations(RemainsDefenderEntity pEntityLiving, PoseStack pMa
pMatrixStack.mulPose(pEntityLiving.getAttachFace().getOpposite().getRotation());
pMatrixStack.translate(0,-0.5,0);
}

@Override
protected int getBlockLightLevel(RemainsDefenderEntity pEntity, BlockPos pPos) {
int i = (int) Mth.clampedLerp(0.0F, 15.0F, (float)pEntity.getLightTicksRemaining() / 10.0F);
return i == 15 ? 15 : Math.max(i, super.getBlockLightLevel(pEntity, pPos));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
public class RemainsDefenderEntity extends AbstractGolem implements IRemainsEntity {

protected static final EntityDataAccessor<Direction> DATA_ATTACH_FACE_ID = SynchedEntityData.defineId(RemainsDefenderEntity.class, EntityDataSerializers.DIRECTION);
private static final EntityDataAccessor<Integer> DATA_LIGHT_TICKS_REMAINING = SynchedEntityData.defineId(RemainsDefenderEntity.class, EntityDataSerializers.INT);


public static AttributeSupplier.Builder createAttributes() {
return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 20.0D).add(Attributes.ARMOR, 15).add(Attributes.ATTACK_DAMAGE, 5).add(Attributes.ARMOR_TOUGHNESS, 6);
Expand Down Expand Up @@ -75,6 +77,15 @@ public void tick() {
}
}

@Override
public void aiStep() {
super.aiStep();
int i = this.getLightTicksRemaining();
if (i > 0) {
this.setLightTicksRemaining(i - 1);
}
}

@Override
public boolean isInvulnerableTo(@NotNull DamageSource pSource) {
return pSource.is(ModTags.DamageTypes.MOTHER_RESISTANT_TO) || pSource.is(DamageTypes.IN_WALL) || pSource.is(DamageTypes.DROWN) || super.isInvulnerableTo(pSource);
Expand All @@ -94,18 +105,21 @@ protected SoundEvent getDeathSound() {
protected void defineSynchedData() {
super.defineSynchedData();
this.entityData.define(DATA_ATTACH_FACE_ID, Direction.DOWN);
this.entityData.define(DATA_LIGHT_TICKS_REMAINING, 0);
}

@Override
public void readAdditionalSaveData(@NotNull CompoundTag pCompound) {
super.readAdditionalSaveData(pCompound);
this.setAttachFace(Direction.from3DDataValue(pCompound.getByte("AttachFace")));
this.setLightTicksRemaining(pCompound.getInt("LightTicks"));
}

@Override
public void addAdditionalSaveData(@NotNull CompoundTag pCompound) {
super.addAdditionalSaveData(pCompound);
pCompound.putByte("AttachFace", (byte) this.getAttachFace().get3DDataValue());
pCompound.putInt("LightTicks", this.getLightTicksRemaining());
}

@Override
Expand Down Expand Up @@ -204,6 +218,14 @@ public Optional<VulnerableRemainsDummyEntity> getDummy() {
return Optional.ofNullable(this.getVehicle()).filter(VulnerableRemainsDummyEntity.class::isInstance).map(VulnerableRemainsDummyEntity.class::cast);
}

private void setLightTicksRemaining(int ticks) {
this.entityData.set(DATA_LIGHT_TICKS_REMAINING, ticks);
}

public int getLightTicksRemaining() {
return this.entityData.get(DATA_LIGHT_TICKS_REMAINING);
}

class RemainsDefenderAttackGoal extends Goal {
private int attackTime;

Expand Down Expand Up @@ -253,6 +275,7 @@ public void tick() {
projectile.setDamage((float) RemainsDefenderEntity.this.getAttributeValue(Attributes.ATTACK_DAMAGE), 0);
projectile.excludeShooter();
RemainsDefenderEntity.this.level().addFreshEntity(projectile);
RemainsDefenderEntity.this.setLightTicksRemaining(40);
}
} else {
RemainsDefenderEntity.this.setTarget(null);
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"animation": {
"frametime": 5
}
}

0 comments on commit d137dba

Please sign in to comment.