Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
54ce687
Merge pull request #16 from Minecraft-LightLand/squad
D12epic Nov 6, 2023
ff8e9ac
Merge pull request #17 from Minecraft-LightLand/squad
D12epic Nov 11, 2023
1550661
Merge pull request #18 from Minecraft-LightLand/cataclysm
D12epic Mar 12, 2024
b5f49c3
Animate Rebuilded
Apr 8, 2024
4e36146
Animate Rebuilded
Apr 16, 2024
3cd42e2
Animate Rebuilded
Apr 16, 2024
ab0a1bf
Animate Rebuilded
Apr 19, 2024
080c2cf
Animate Rebuilded
Apr 19, 2024
b1d8c5f
Animate Rebuilded
Apr 22, 2024
a80237c
Animate Rebuilded
May 9, 2024
0a8ef45
Animate Rebuilded
May 10, 2024
3186bbc
Animate Rebuilded
May 10, 2024
d9ff501
Animate Rebuilded
May 10, 2024
2ffd6d1
Animate Rebuilded
May 10, 2024
bdea4c3
Animate Rebuilded
May 10, 2024
54f55b3
Animate Rebuilded
May 10, 2024
5dd1945
Animate Rebuilded
May 10, 2024
601d87d
Animate Rebuilded
May 11, 2024
c2c0050
Animate Rebuilded
May 11, 2024
60445cf
Animate Rebuilded
May 12, 2024
971ce50
Animate Rebuilded
May 14, 2024
4c5eafd
Animate Rebuilded
May 15, 2024
6bb9a91
Animate Rebuilded
May 15, 2024
38de6d5
Animate Rebuilded
May 15, 2024
22e916b
Animate Rebuilded
May 15, 2024
7c86e61
Animate Rebuilded
May 16, 2024
3a848c8
Animate Rebuilded
May 16, 2024
92aedf8
Animate Rebuilded
May 16, 2024
72cc581
Animate Rebuilded
May 16, 2024
ac0a1af
Animate Rebuilded
May 16, 2024
2dd5e82
Animate Rebuilded
May 16, 2024
22e1f10
Animate Rebuilded
May 16, 2024
ec57aa5
Animate Rebuilded
May 16, 2024
34a7052
Merge branch 'Minecraft-LightLand:1.20' into D12's_1.20.1(AnimateRebu…
D12epic Jun 11, 2024
48ab4dc
Merge pull request #45 from D12epic/D12's_1.20.1(AnimateRebuild)
lcy0x1 Jun 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ buildscript {
plugins {
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
}
plugins {
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
}

apply plugin: 'maven-publish'
apply plugin: 'org.spongepowered.mixin'
Expand All @@ -27,8 +30,7 @@ if (lljij.toBoolean()) jarJar.enable()
java.toolchain.languageVersion = JavaLanguageVersion.of(17)

minecraft {
//mappings channel: 'parchment', version: '1.19.3-2023.03.12-1.19.4'
mappings channel: 'official', version: "${minecraft_version}"
mappings channel: 'parchment', version: '2023.06.26-1.20.1'
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
runs {
client {
Expand Down
3 changes: 2 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
pluginManagement {
repositories {
maven { url = 'https://maven.parchmentmc.org' }
gradlePluginPortal()
maven {
name="MinecraftForge"
url = 'https://maven.minecraftforge.net/' }
url = 'https://maven.minecraftforge.net/'}
}
}
plugins {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package dev.xkmc.modulargolems.content.client.pose;// Save this class in your mod and generate all required imports

import net.minecraft.client.animation.AnimationChannel;
import net.minecraft.client.animation.AnimationDefinition;
import net.minecraft.client.animation.Keyframe;
import net.minecraft.client.animation.KeyframeAnimations;

/**
* Made with Blockbench 4.9.4
* Exported for Minecraft version 1.19 or later with Mojang mappings
* @author Author
*/
public class CustomModelAnimation {
public static final AnimationDefinition warningInAxe = AnimationDefinition.Builder.withLength(1.0F)
.addAnimation("right_arm", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.0833F, KeyframeAnimations.degreeVec(-110.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR)
))
.addAnimation("right_forearm", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(-2160.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(-75.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR)
))
.build();


public static final AnimationDefinition attackInAxe = AnimationDefinition.Builder.withLength(1.25F)
.addAnimation("right_arm", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(-110.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.25F, KeyframeAnimations.degreeVec(-32.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR)
))
.addAnimation("right_forearm", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.25F, KeyframeAnimations.degreeVec(80.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR)
))
.build();

public static final AnimationDefinition attackInSpear = AnimationDefinition.Builder.withLength(1.75F)
.addAnimation("right_arm", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(85.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.25F, KeyframeAnimations.degreeVec(-57.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR)
))
.addAnimation("right_forearm", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.25F, KeyframeAnimations.degreeVec(87.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(-2.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR)
))
.build();

public static final AnimationDefinition warningInSpear = AnimationDefinition.Builder.withLength(0.7083F)
.addAnimation("right_arm", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.2083F, KeyframeAnimations.degreeVec(85.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR)
))
.build();
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ public void handleEntityEvent(byte event) {

private static final EntityDataAccessor<Integer> DATA_MODE = GOLEM_DATA.define(SyncedData.INT, 0, "follow_mode");
private static final EntityDataAccessor<BlockPos> GUARD_POS = GOLEM_DATA.define(SyncedData.BLOCK_POS, BlockPos.ZERO, "guard_pos");

private static final EntityDataAccessor<BlockPos> SQUAD_POS = GOLEM_DATA.define(SyncedData.BLOCK_POS, BlockPos.ZERO, "cap_pos");
public GolemMode getMode() {
return GolemModes.get(this.entityData.get(DATA_MODE));
}
Expand All @@ -512,7 +512,9 @@ public void setMode(int mode, BlockPos pos) {
this.entityData.set(DATA_MODE, mode);
this.entityData.set(GUARD_POS, pos);
}

public void setCapDistance(BlockPos pos){
this.entityData.set(SQUAD_POS,pos);
}
public boolean initMode(@Nullable Player player) {
var config = getConfigEntry(null);
int mode = config == null ? 0 : config.defaultMode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.AnimationState;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
Expand All @@ -35,6 +36,10 @@

@SerialClass
public class MetalGolemEntity extends SweepGolemEntity<MetalGolemEntity, MetalGolemPartType> {
public final AnimationState axeAttackAnimationState = new AnimationState();
public final AnimationState axeWarningAnimationState = new AnimationState();
public final AnimationState spearAttackAnimationState = new AnimationState();
public final AnimationState spearWarningAnimationState = new AnimationState();
public MetalGolemEntity(EntityType<MetalGolemEntity> type, Level level) {
super(type, level);
this.setMaxUpStep(1);
Expand Down Expand Up @@ -64,7 +69,6 @@ protected void registerGoals() {
this.goalSelector.addGoal(2, new GolemMeleeGoal(this));
super.registerGoals();
}

public void aiStep() {
super.aiStep();
if (this.attackAnimationTick > 0) {
Expand Down Expand Up @@ -105,23 +109,21 @@ public boolean hurt(DamageSource source, float amount) {
}
return flag;
}

public int getAttackAnimationTick() {
return this.attackAnimationTick;
}
public IronGolem.Crackiness getCrackiness() {
return IronGolem.Crackiness.byFraction(this.getHealth() / this.getMaxHealth());
}

public void handleEntityEvent(byte event) {
if (event == 4) {
this.attackAnimationTick = 10;
this.playSound(SoundEvents.IRON_GOLEM_ATTACK, 1.0F, 1.0F);
} else {
super.handleEntityEvent(event);
public void handleEntityEvent(byte pId) {
if (pId == 4) {
this.attackAnimationTick=4;
this.axeAttackAnimationState.start(this.tickCount);
this.playSound(SoundEvents.IRON_GOLEM_ATTACK, 1.0F, 1.0F);
}else{
super.handleEntityEvent(pId);
}

}

public int getAttackAnimationTick() {
return this.attackAnimationTick;
}

protected SoundEvent getHurtSound(DamageSource p_28872_) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
package dev.xkmc.modulargolems.content.entity.metalgolem;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Axis;
import dev.xkmc.modulargolems.content.client.armor.GolemEquipmentModels;
import dev.xkmc.modulargolems.content.client.pose.MetalGolemPose;
import dev.xkmc.modulargolems.content.client.pose.WeaponPose;
import dev.xkmc.modulargolems.content.entity.common.IGolemModel;
import dev.xkmc.modulargolems.content.entity.common.IHeadedModel;
import dev.xkmc.modulargolems.content.item.equipments.MetalGolemWeaponItem;
import net.minecraft.client.model.HierarchicalModel;
import net.minecraft.client.model.geom.EntityModelSet;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.Item;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

import dev.xkmc.modulargolems.content.client.pose.CustomModelAnimation;
@OnlyIn(Dist.CLIENT)
public class MetalGolemModel extends HierarchicalModel<MetalGolemEntity> implements IGolemModel<MetalGolemEntity, MetalGolemPartType, MetalGolemModel>, IHeadedModel {

Expand Down Expand Up @@ -61,31 +60,53 @@ public void copyFrom(MetalGolemModel other) {
leftForeArm.copyFrom(other.leftForeArm);
rightForeArm.copyFrom(other.rightForeArm);
}

public void setupAnim(MetalGolemEntity entity, float f1, float f2, float f3, float f4, float f5) {
this.head.yRot = f4 * ((float) Math.PI / 180F);
this.head.xRot = f5 * ((float) Math.PI / 180F);
this.rightLeg.xRot = -1.5F * Mth.triangleWave(f1, 13.0F) * f2;
this.leftLeg.xRot = 1.5F * Mth.triangleWave(f1, 13.0F) * f2;
public void setupAnim(MetalGolemEntity pEntity, float pLimbSwing, float pLimbSwingAmount, float pAgeInTicks, float pNetHeadYaw, float pHeadPitch) {
this.root().getAllParts().forEach(ModelPart::resetPose);
int atkTick = pEntity.getAttackAnimationTick();
Item its =pEntity.getMainHandItem().getItem();
this.animateWalk(pNetHeadYaw, pHeadPitch, pLimbSwing, pLimbSwingAmount);
if(its instanceof MetalGolemWeaponItem wi){
switch (wi.getGolemWeaponType(wi)) {
case SWORD, AXE -> {
if (atkTick > 0) {
this.animate(pEntity.axeAttackAnimationState, CustomModelAnimation.attackInAxe, pAgeInTicks);
}else if(pEntity.isAggressive()) {
this.animate(pEntity.axeWarningAnimationState, CustomModelAnimation.warningInAxe, pAgeInTicks);
}
}
case SPEAR -> {
if (atkTick > 0) {
this.animate(pEntity.spearAttackAnimationState, CustomModelAnimation.attackInSpear, pAgeInTicks);
} else if (pEntity.isAggressive()) {
this.animate(pEntity.spearWarningAnimationState, CustomModelAnimation.warningInSpear, pAgeInTicks);
}
}
}
}
}
private void animateWalk(float pNetHeadYaw, float pHeadPitch,float pLimbSwing,float pLimbSwingAmount) {
this.head.yRot = pNetHeadYaw * ((float) Math.PI / 180F);
this.head.xRot = pHeadPitch * ((float) Math.PI / 180F);
this.rightLeg.xRot = -1.5F * Mth.triangleWave(pLimbSwing, 13.0F) * pLimbSwingAmount;
this.leftLeg.xRot = 1.5F * Mth.triangleWave(pLimbSwing, 13.0F) * pLimbSwingAmount;
this.rightLeg.yRot = 0.0F;
this.leftLeg.yRot = 0.0F;
this.rightArm.xRot = (-0.2F + 1.5F * Mth.triangleWave(pLimbSwing, 13.0F)) * pLimbSwingAmount;
this.leftArm.xRot = (-0.2F - 1.5F * Mth.triangleWave(pLimbSwing, 13.0F)) * pLimbSwingAmount;
this.rightForeArm.xRot = 0;
this.leftForeArm.xRot = 0;
this.resetArmPoses();
}

public void prepareMobModel(MetalGolemEntity entity, float bob, float speed, float pTick) {
MetalGolemPose pose = MetalGolemPose.DEFAULT;
if (!entity.getMainHandItem().isEmpty()) {
pose = WeaponPose.WEAPON;
}
int atkTick = entity.getAttackAnimationTick();
if (atkTick > 0) {
pose.attackModel(entity, this, atkTick - pTick);
} else if (entity.isAggressive()) {
pose.aggressive(entity, this, bob, speed, pTick);
} else {
pose.walking(entity, this, bob, speed, pTick);
}
private void resetArmPoses() {
this.leftArm.yRot = 0.0F;
this.leftArm.z = 0.0F;
this.leftArm.x = 0.0F;
this.leftArm.y = -7.0F;
this.rightArm.yRot = 0.0F;
this.rightArm.z = 0.0F;
this.rightArm.x = -0.0F;
this.rightArm.y = -7.0F;
}

public void renderToBufferInternal(MetalGolemPartType type, PoseStack stack, VertexConsumer consumer, int i, int j, float f1, float f2, float f3, float f4) {
if (type == MetalGolemPartType.BODY) {
this.body.render(stack, consumer, i, j, f1, f2, f3, f4);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.xkmc.modulargolems.content.item.equipments;

import dev.xkmc.modulargolems.init.material.GolemWeaponType;
import dev.xkmc.modulargolems.init.registrate.GolemTypes;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
Expand All @@ -10,8 +11,8 @@
import net.minecraftforge.common.ForgeMod;

public class MetalGolemWeaponItem extends GolemEquipmentItem {

public MetalGolemWeaponItem(Properties properties, int attackDamage, double percentAttack, float range, float sweep) {
protected final GolemWeaponType gwt;
public MetalGolemWeaponItem(Properties properties, int attackDamage, double percentAttack, float range, float sweep, GolemWeaponType gwt) {
super(properties, EquipmentSlot.MAINHAND, GolemTypes.ENTITY_GOLEM::get, builder -> {
var uuid = UUID.get(EquipmentSlot.MAINHAND);
if (attackDamage > 0) {
Expand All @@ -27,13 +28,12 @@ public MetalGolemWeaponItem(Properties properties, int attackDamage, double perc
builder.put(GolemTypes.GOLEM_SWEEP.get(), new AttributeModifier(uuid, "spear_sweep", sweep, AttributeModifier.Operation.ADDITION));
}
});
this.gwt = gwt;
}

@Override
public boolean isEnchantable(ItemStack stack) {
return true;
}

@Override
public int getEnchantmentValue() {
return 15;
Expand All @@ -46,5 +46,7 @@ public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantmen
}
return super.canApplyAtEnchantingTable(stack, enchantment);
}

public GolemWeaponType getGolemWeaponType(MetalGolemWeaponItem i) {
return i.gwt;
}
}
Loading