Skip to content

Commit

Permalink
feat: add substitution log ability
Browse files Browse the repository at this point in the history
  • Loading branch information
sekwah41 committed May 5, 2022
1 parent 69f580d commit 7369d88
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.sekwah.narutomod.abilities.Ability;
import com.sekwah.narutomod.capabilities.INinjaData;
import com.sekwah.narutomod.entity.SubstitutionLogEntity;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.server.level.ServerLevel;
Expand Down Expand Up @@ -37,6 +38,9 @@ public void performServer(Player player, INinjaData ninjaData, int ticksActive)
if(loc != null) {
double distance = player.position().distanceTo(loc);
if(distance < 40 && player.level.dimension().location().equals(ninjaData.getSubstitutionDimension())) {
SubstitutionLogEntity log = new SubstitutionLogEntity(player.level);
log.setPos(player.position());
player.level.addFreshEntity(log);
if(player.level instanceof ServerLevel serverLevel) {
serverLevel.sendParticles(ParticleTypes.CLOUD,
player.getX(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static LayerDefinition createLayer() {
.mirror(true)
.texOffs(0, 0)
.addBox(-2F, 0F, -2F, 4, 8, 4)
, PartPose.offsetAndRotation(0F, 0F, 0F, (float) Math.PI, 0F, 0F));
, PartPose.offsetAndRotation(0F, 5F, 0F, (float) Math.PI, 0F, 0F));

main.addOrReplaceChild("Shape2",
CubeListBuilder.create()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public SubstitutionLogRenderer(EntityRendererProvider.Context manager) {
public void render(SubstitutionLogEntity substitutionLogEntity, float p_114486_, float partial, PoseStack poseStack, MultiBufferSource multiBufferSource, int p_114490_) {
VertexConsumer vertexconsumer = multiBufferSource.getBuffer(RENDER_TYPE);
poseStack.pushPose();
poseStack.translate(0,substitutionLogEntity.getBbHeight() / 2f,0);

poseStack.translate(0,substitutionLogEntity.getBbHeight() * 2,0);
poseStack.scale(2,2,2);
this.model.renderToBuffer(poseStack, vertexconsumer, p_114490_, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
poseStack.popPose();
super.render(substitutionLogEntity, p_114486_, partial, poseStack, multiBufferSource, p_114490_);
Expand Down
19 changes: 0 additions & 19 deletions src/main/java/com/sekwah/narutomod/coremod/CoreModTestCalls.java

This file was deleted.

12 changes: 11 additions & 1 deletion src/main/java/com/sekwah/narutomod/entity/NarutoEntities.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.sekwah.narutomod.entity;

import com.sekwah.narutomod.NarutoMod;
import com.sekwah.narutomod.entity.item.PaperBombEntity;
import com.sekwah.narutomod.entity.jutsuprojectile.FireballJutsuEntity;
import com.sekwah.narutomod.entity.jutsuprojectile.WaterBulletJutsuEntity;
Expand All @@ -10,13 +11,17 @@
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

import static com.sekwah.narutomod.NarutoMod.MOD_ID;

@Mod.EventBusSubscriber(modid = NarutoMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class NarutoEntities {

private static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, MOD_ID);
Expand Down Expand Up @@ -46,7 +51,7 @@ public class NarutoEntities {


public static final RegistryObject<EntityType<SubstitutionLogEntity>> SUBSTITUTION_LOG = register("substitution_log",
EntityType.Builder.of(SubstitutionLogEntity::new, MobCategory.MISC).fireImmune().sized(0.3F, 0.3F).clientTrackingRange(4).updateInterval(10));
EntityType.Builder.<SubstitutionLogEntity>of(SubstitutionLogEntity::new, MobCategory.MISC).fireImmune().sized(0.3F, 0.3F).clientTrackingRange(4));

private static <T extends Entity> RegistryObject<EntityType<T>> register(String key, EntityType.Builder<T> builder) {
return ENTITIES.register(key, () -> builder.build(key));
Expand All @@ -56,4 +61,9 @@ public static void register(IEventBus eventBus) {
ENTITIES.register(eventBus);
}

@SubscribeEvent
public static void entityAttributeCreation(EntityAttributeCreationEvent event) {
event.put(SUBSTITUTION_LOG.get(), SubstitutionLogEntity.createAttributes().build());
}

}
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
package com.sekwah.narutomod.entity;

import net.minecraft.network.protocol.Packet;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.monster.Monster;
import net.minecraft.world.level.Level;
import net.minecraftforge.network.NetworkHooks;

public class SubstitutionLogEntity extends Mob {

protected SubstitutionLogEntity(EntityType<? extends Mob> p_21368_, Level p_21369_) {
public SubstitutionLogEntity(EntityType<SubstitutionLogEntity> p_21368_, Level p_21369_) {
super(p_21368_, p_21369_);
}


@Override
protected void defineSynchedData() {
public boolean hurt(DamageSource pSource, float pAmount) {
this.setInvulnerable(true);
return super.hurt(pSource, pAmount);
}

public SubstitutionLogEntity(Level worldIn) {
this(NarutoEntities.SUBSTITUTION_LOG.get(), worldIn);
}

public static AttributeSupplier.Builder createAttributes() {
return Monster.createMonsterAttributes().add(Attributes.MAX_HEALTH, 8.0D).add(Attributes.MOVEMENT_SPEED, 0.6D).add(Attributes.ATTACK_DAMAGE, 0.0D);
}

@Override
Expand Down

0 comments on commit 7369d88

Please sign in to comment.