Skip to content

Commit

Permalink
1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Weever1337 committed May 31, 2024
1 parent d560b9c commit 88f232d
Show file tree
Hide file tree
Showing 19 changed files with 464 additions and 61 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

addon_version=1.2
addon_version=1.2.1
# https://github.com/StandoByte/RotP-maven/commits/main
main_mod_version=1.16.5-0.2.2-snapshot-240331-b

Expand Down
130 changes: 130 additions & 0 deletions src/main/java/com/weever/rotp_cm/action/stand/CMoonEffectivePunch.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package com.weever.rotp_cm.action.stand;

import java.util.Random;
import com.github.standobyte.jojo.action.stand.StandEntityAction;

import com.github.standobyte.jojo.action.Action;
import com.github.standobyte.jojo.action.ActionConditionResult;
import com.github.standobyte.jojo.action.ActionTarget;
import com.github.standobyte.jojo.action.stand.StandAction;
import com.github.standobyte.jojo.action.stand.StandEntityHeavyAttack;
import com.github.standobyte.jojo.action.stand.punch.StandEntityPunch;
import com.github.standobyte.jojo.entity.stand.StandEntity;
import com.github.standobyte.jojo.entity.stand.StandEntityTask;
import com.github.standobyte.jojo.power.impl.stand.IStandPower;
import com.github.standobyte.jojo.util.mc.damage.StandEntityDamageSource;
import com.github.standobyte.jojo.action.ActionConditionResult;
import com.github.standobyte.jojo.util.mod.JojoModUtil;
import com.weever.rotp_cm.entity.CMoonEntity;
import com.weever.rotp_cm.init.InitEffects;
import com.weever.rotp_cm.init.InitSounds;
import com.weever.rotp_cm.init.InitStands;
import com.weever.rotp_cm.network.AddonPackets;
import com.weever.rotp_cm.network.server.AddTagPacket;

import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.potion.EffectInstance;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;

public class CMoonEffectivePunch extends StandEntityHeavyAttack {
public CMoonEffectivePunch (StandEntityHeavyAttack.Builder builder){
super(builder);
}

@Override
protected Action<IStandPower> replaceAction(IStandPower power, ActionTarget target) {
String s_id = String.valueOf(power.getUser().getUUID());
Entity exist = EntityRange(power,16,s_id);
if (exist != null){
return InitStands.CMOON_EFFECTIVE_PUNCH_RUN.get();
}
return super.replaceAction(power, target);
}

@Override
protected ActionConditionResult checkStandConditions(StandEntity stand, IStandPower power, ActionTarget target) {
CMoonEntity CMoon = (CMoonEntity) stand;
if (CMoon.isAtt()) return conditionMessage("cant_control_stand");
if (power.getStamina() < 50) return ActionConditionResult.NEGATIVE;
return ActionConditionResult.POSITIVE;
}

@Override
public StandEntityPunch punchEntity(StandEntity stand, Entity target, StandEntityDamageSource dmgSource) {
IStandPower power = stand.getUserPower();
LivingEntity user = power.getUser();
String s_id = String.valueOf(user.getUUID());
//Entity exist = EntityRange(power,2*10,s_id);
target.addTag(s_id);
if (user instanceof ServerPlayerEntity) {
AddonPackets.sendToClient(new AddTagPacket(target.getId(), s_id), (ServerPlayerEntity) user);
}
return super.punchEntity(stand, target, dmgSource)
.addKnockback(0.0F)
.disableBlocking(0.0F);
}


// @Override
// public void standTickPerform(World world, StandEntity standEntity, IStandPower userPower, StandEntityTask task){
// LivingEntity user = userPower.getUser();
// String s_id = String.valueOf(user.getUUID());
// double range = 10;
//
// Entity exist = EntityRange(userPower,2*range,s_id);
//
// if (exist != null){
// LivingEntity entity = standEntity.isManuallyControlled() ? standEntity:user;
//
// RayTraceResult ray = JojoModUtil.rayTrace(entity.getEyePosition(1.0F),entity.getLookAngle(),
// range,world,entity,e->!(e.is(standEntity) || e.is(user)),0,0);
// if(ray.getType() == RayTraceResult.Type.ENTITY) {
// Entity target = ((EntityRayTraceResult) ray).getEntity();
// standEntity.moveTo(target.position());
// }
// }
// }
//
// @Override
// public void standPerform(World world, StandEntity standEntity, IStandPower userPower, StandEntityTask task){
// if(!world.isClientSide){
// LivingEntity user = userPower.getUser();
// String s_id = String.valueOf(user.getUUID());
// double range = 10;
//
// Entity exist = EntityRange(userPower,2*range,s_id);
//
// if(exist == null){
// LivingEntity entity = standEntity.isManuallyControlled() ? standEntity:user;
//
// RayTraceResult ray = JojoModUtil.rayTrace(entity.getEyePosition(1.0F),entity.getLookAngle(),
// range,world,entity,e->!(e.is(standEntity) || e.is(user)),0,0);
// if(ray.getType() == RayTraceResult.Type.ENTITY){
// Entity target = ((EntityRayTraceResult) ray).getEntity();
// standEntity.moveTo(target.position());
// target.addTag(s_id);
// if (user instanceof ServerPlayerEntity) {
// AddonPackets.sendToClient(new AddTagPacket(target.getId(), s_id), (ServerPlayerEntity) user);
// }
// }
// }
// }
//}

public static Entity EntityRange(IStandPower userPower, double range, String id){
LivingEntity user = userPower.getUser();
World world = user.level;
Entity entidad = world.getEntities(null, user.getBoundingBox().inflate(range)).stream().filter(entity -> entity.getTags().contains(id)).findFirst().orElse(null);
return entidad;
}


@Override
public StandAction[] getExtraUnlockable() {
return new StandAction[] { InitStands.CMOON_EFFECTIVE_PUNCH_RUN.get(), InitStands.CMOON_EFFECTIVE_PUNCH_QUIT.get()};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.weever.rotp_cm.action.stand;

import com.github.standobyte.jojo.action.ActionConditionResult;
import com.github.standobyte.jojo.action.ActionTarget;
import com.github.standobyte.jojo.action.stand.StandEntityAction;
import com.github.standobyte.jojo.entity.stand.StandEntity;
import com.github.standobyte.jojo.entity.stand.StandEntityTask;
import com.github.standobyte.jojo.power.impl.stand.IStandPower;
import com.weever.rotp_cm.entity.CMoonEntity;
import com.weever.rotp_cm.network.AddonPackets;
import com.weever.rotp_cm.network.server.RemoveTagPacket;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.world.World;

public class CMoonEffectivePunchQuit extends StandEntityAction {
public CMoonEffectivePunchQuit(StandEntityAction.Builder builder) {
super(builder);
}

@Override
protected ActionConditionResult checkStandConditions(StandEntity stand, IStandPower power, ActionTarget target) {
CMoonEntity CMoon = (CMoonEntity) stand;
if (CMoon.isAtt()) return conditionMessage("cant_control_stand");
if (power.getStamina() < 50) return ActionConditionResult.NEGATIVE;
return ActionConditionResult.POSITIVE;
}

@Override
public void standPerform(World world, StandEntity standEntity, IStandPower userPower, StandEntityTask task){
if(!world.isClientSide){
Double range = 3*standEntity.getMaxRange();
LivingEntity sigma = userPower.getUser();
String s_id = String.valueOf(sigma.getUUID());
Entity entity = CMoonEffectivePunch.EntityRange(userPower,range*3,s_id);
if(entity!= null){
entity.removeTag(s_id);

if (sigma instanceof ServerPlayerEntity) {
AddonPackets.sendToClient(new RemoveTagPacket(entity.getId(), s_id), (ServerPlayerEntity) sigma);
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package com.weever.rotp_cm.action.stand;

import java.util.Random;

import com.github.standobyte.jojo.action.ActionConditionResult;
import com.github.standobyte.jojo.action.ActionTarget;
import com.github.standobyte.jojo.action.stand.StandEntityAction;
import com.github.standobyte.jojo.entity.stand.StandEntity;
import com.github.standobyte.jojo.entity.stand.StandEntityTask;
import com.github.standobyte.jojo.power.impl.stand.IStandPower;
import com.weever.rotp_cm.entity.CMoonEntity;
import com.weever.rotp_cm.init.InitEffects;
import com.weever.rotp_cm.network.AddonPackets;
import com.weever.rotp_cm.network.server.RemoveTagPacket;

import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityPredicates;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;


public class CMoonEffectivePunchRun extends StandEntityAction {
public CMoonEffectivePunchRun(StandEntityAction.Builder builder) {
super(builder);
}

@Override
protected ActionConditionResult checkStandConditions(StandEntity stand, IStandPower power, ActionTarget target) {
CMoonEntity CMoon = (CMoonEntity) stand;
if (CMoon.isAtt()) return conditionMessage("cant_control_stand");
if (power.getStamina() < 50) return ActionConditionResult.NEGATIVE;
return ActionConditionResult.POSITIVE;
}

@Override
public void standPerform(World world, StandEntity standEntity, IStandPower userPower, StandEntityTask task){
if(!world.isClientSide){
Double range = (double) (3*10);
LivingEntity user = userPower.getUser();
LivingEntity entity = LivingEntityRange(userPower,range);

if(entity != null){
Random random = new Random();
int number = random.nextInt(3);
switch (number) {
case (1): // Gravitation (levitation) effect
if (!entity.hasEffect(Effects.LEVITATION)) entity.addEffect(new EffectInstance(Effects.LEVITATION, 10, 20, false, false, true));
break;
case (2): // Paralysis effect
if (!entity.hasEffect(InitEffects.CM_PARALYSIS.get())) entity.addEffect(new EffectInstance(InitEffects.CM_PARALYSIS.get(), 50, 2, false, false, true));
break;
case (3):
if (!entity.hasEffect(InitEffects.CM_INVERSION.get())) entity.addEffect(new EffectInstance(InitEffects.CM_INVERSION.get(), 50, 1, false, false, true));
break;
default:
entity.hurt(DamageSource.MAGIC, 2.5F);
}
String s_id = String.valueOf(user.getUUID());
entity.removeTag(s_id);
if (user instanceof ServerPlayerEntity) {
AddonPackets.sendToClient(new RemoveTagPacket(entity.getId(), s_id), (ServerPlayerEntity) user);
}
}
}
}


public static LivingEntity LivingEntityRange(IStandPower standuser, Double range){
LivingEntity user = standuser.getUser();
World world = user.level;
String s_id = String.valueOf(user.getUUID());
LivingEntity entidad = world.getEntitiesOfClass(LivingEntity.class,user.getBoundingBox().inflate(range),
EntityPredicates.ENTITY_STILL_ALIVE).stream().filter(entity -> entity.getTags().contains(s_id)).findFirst().orElse(null);
return entidad;

}




}

This file was deleted.

58 changes: 58 additions & 0 deletions src/main/java/com/weever/rotp_cm/client/ui/marker/EntityMark.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.weever.rotp_cm.client.ui.marker;

import com.github.standobyte.jojo.client.ui.marker.MarkerRenderer;
import com.github.standobyte.jojo.entity.stand.StandEntity;
import com.github.standobyte.jojo.power.impl.stand.IStandPower;
import com.weever.rotp_cm.RotpCMoonAddon;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.EntityPredicates;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World;


import java.util.List;
import java.util.stream.Stream;


public class EntityMark extends MarkerRenderer {

public EntityMark (Minecraft mc){
super(new ResourceLocation(RotpCMoonAddon.MOD_ID,"textures/action/cm_effective_punch.png"), mc);
}

@Override
protected boolean shouldRender() {
return true;
}

protected static class Marker extends MarkerRenderer.MarkerInstance {
public Marker(Vector3d pos, boolean outlined) {
super(pos, outlined);
}
}

@Override
protected void updatePositions(List<MarkerRenderer.MarkerInstance> list, float partialTick) {
IStandPower.getStandPowerOptional(this.mc.player).ifPresent((stand) ->{

Targets(this.mc.player).forEach((livingEntity -> {
list.add(new Marker(livingEntity.getPosition(partialTick).add(0,livingEntity.getBbHeight()*1.1,0),true));

}));
});
}


public static Stream<LivingEntity> Targets(LivingEntity user){
World world = user.level;
String s_id = String.valueOf(user.getUUID());
Stream<LivingEntity> entidades = world.getEntitiesOfClass(LivingEntity.class,user.getBoundingBox().inflate(100),
EntityPredicates.ENTITY_STILL_ALIVE).stream().filter(entity -> entity.getTags().contains(s_id));
return entidades;
}



}
Loading

0 comments on commit 88f232d

Please sign in to comment.