Skip to content

Commit

Permalink
add IEntityArrow and IEntityThrowable
Browse files Browse the repository at this point in the history
  • Loading branch information
ExpensiveLadder committed Sep 24, 2020
1 parent e010885 commit 4659794
Show file tree
Hide file tree
Showing 14 changed files with 258 additions and 15 deletions.
Expand Up @@ -504,13 +504,12 @@ default void update(IData data){
CraftTweakerAPI.logError("IEntity#update not overwritten by implementation " + this.getClass() + "!");
}

@ZenMethod
default boolean onGround(){
return false;
}
@ZenGetter
boolean onGround();

@ZenMethod
default boolean isLightningbolt(){
return false;
}
@ZenGetter
boolean isLightningbolt();

@ZenGetter
boolean isArmorstand();
}
@@ -0,0 +1,58 @@
package crafttweaker.api.entity;

import crafttweaker.annotations.ZenRegister;
import stanhebben.zenscript.annotations.*;

@ZenClass("crafttweaker.entity.IEntityArrow")
@ZenRegister
public interface IEntityArrow extends IEntity {

@ZenMethod
@ZenSetter("damage")
IEntityArrow setDamage(double damage);

@ZenMethod
@ZenGetter("damage")
double getDamage();

@ZenMethod
@ZenSetter("critical")
IEntityArrow setIsCritical(boolean critical);

@ZenMethod
@ZenGetter("critical")
boolean getIsCritical();

@ZenMethod
@ZenSetter("knockbackStrength")
IEntityArrow setKnockbackStrength(int knockbackStrength);

@ZenMethod
@ZenGetter("shake")
int arrowShake();

@ZenMethod
@ZenSetter("shooter")
IEntityArrow setShooter(IEntity shooter);

@ZenMethod
@ZenGetter("shooter")
IEntity getShooter();

@ZenMethod
@ZenGetter("pickupStatus")
String getPickupStatus();

@ZenMethod
@ZenSetter("pickupStatus")
IEntityArrow setPickupStatus(String pickupStatus);

@ZenMethod
IEntityArrow setPickupDisallowed();

@ZenMethod
IEntityArrow setPickupAllowed();

@ZenMethod
IEntityArrow setPickupCreativeOnly();
}
@@ -0,0 +1,16 @@
package crafttweaker.api.entity;

import crafttweaker.annotations.ZenRegister;
import stanhebben.zenscript.annotations.*;

@ZenClass("crafttweaker.entity.IEntityThrowable")
@ZenRegister
public interface IEntityThrowable extends IEntity {

@ZenGetter("thrower")
IEntityLivingBase getThrower();

@ZenMethod
@ZenGetter("shake")
int throwableShake();
}
@@ -0,0 +1,12 @@
package crafttweaker.api.entity;

import crafttweaker.annotations.ZenRegister;
import stanhebben.zenscript.annotations.*;

@ZenClass("crafttweaker.entity.IProjectile")
@ZenRegister
public interface IProjectile {

@ZenMethod
void shoot(double x, double y, double z, float velocity, float inaccuracy);
}
Expand Up @@ -2,6 +2,7 @@

import crafttweaker.annotations.ZenRegister;
import crafttweaker.api.entity.IEntity;
import crafttweaker.api.entity.IEntityArrow;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenGetter;
import stanhebben.zenscript.annotations.ZenMethod;
Expand All @@ -11,7 +12,7 @@
@ZenRegister
public interface ProjectileImpactArrowEvent extends IProjectileImpactEvent, IEventCancelable {
@ZenGetter("arrow")
IEntity getArrow();
IEntityArrow getArrow();

@ZenGetter("shooter")
IEntity getShooter();
Expand Down
@@ -1,16 +1,16 @@
package crafttweaker.api.event;

import crafttweaker.annotations.ZenRegister;
import crafttweaker.api.entity.IEntity;
import crafttweaker.api.entity.IEntityLivingBase;
import crafttweaker.api.entity.IEntityThrowable;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenGetter;

@ZenClass("crafttweaker.event.ProjectileImpactThrowableEvent")
@ZenRegister
public interface ProjectileImpactThrowableEvent extends IProjectileImpactEvent, IEventCancelable {
@ZenGetter("throwable")
IEntity getThrowable();
IEntityThrowable getThrowable();

@ZenGetter("thrower")
IEntityLivingBase getThrower();
Expand Down
Expand Up @@ -5,6 +5,9 @@
import crafttweaker.api.block.*;
import crafttweaker.api.data.IData;
import crafttweaker.api.entity.IEntity;
import crafttweaker.api.entity.IEntityArrow;
import crafttweaker.api.entity.IEntityLivingBase;
import crafttweaker.api.entity.IEntityThrowable;
import crafttweaker.api.item.IItemStack;
import crafttweaker.api.player.IPlayer;
import crafttweaker.api.util.Position3f;
Expand Down
Expand Up @@ -42,7 +42,9 @@
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.entity.projectile.EntityFishHook;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.inventory.*;
import net.minecraft.item.*;
import net.minecraft.item.crafting.Ingredient;
Expand Down Expand Up @@ -966,4 +968,11 @@ public static IEntityAttributeModifier getIEntityAttributeModifier(AttributeModi
return modifier == null ? null : new MCEntityAttributeModifier(modifier);
}

public static IEntityArrow getIEntityArrow(EntityArrow entity) {
return entity == null ? null : new MCEntityArrow(entity);
}

public static IEntityThrowable getIEntityThrowable(EntityThrowable entity) {
return entity == null ? null : new MCEntityThrowable(entity);
}
}
Expand Up @@ -16,6 +16,7 @@
import crafttweaker.mc1120.util.MCPosition3f;
import net.minecraft.entity.Entity;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.*;
Expand Down Expand Up @@ -675,4 +676,9 @@ public boolean onGround() {
public boolean isLightningbolt() {
return entity instanceof EntityLightningBolt;
}

@Override
public boolean isArmorstand() {
return entity instanceof EntityArmorStand;
}
}
@@ -0,0 +1,98 @@
package crafttweaker.mc1120.entity;

import javax.annotation.Nullable;

import crafttweaker.api.entity.IEntity;
import crafttweaker.api.entity.IEntityArrow;
import crafttweaker.api.entity.IProjectile;
import crafttweaker.api.minecraft.CraftTweakerMC;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.entity.projectile.EntityArrow.PickupStatus;

public class MCEntityArrow extends MCEntity implements IEntityArrow, IProjectile {
private final EntityArrow entityArrow;

public MCEntityArrow(EntityArrow entityArrow) {
super(entityArrow);
this.entityArrow = entityArrow;
}

@Override
public void shoot(double x, double y, double z, float velocity, float inaccuracy) {
entityArrow.shoot(x, y, z, velocity, inaccuracy);
}

@Override
public IEntityArrow setDamage(double damage) {
entityArrow.setDamage(damage);
return (IEntityArrow) entityArrow;
}

@Override
public double getDamage() {
return entityArrow.getDamage();
}

@Override
public IEntityArrow setIsCritical(boolean critical) {
entityArrow.setIsCritical(critical);
return (IEntityArrow) entityArrow;
}

@Override
public boolean getIsCritical() {
return entityArrow.getIsCritical();
}

@Override
public IEntityArrow setKnockbackStrength(int knockbackStrength) {
entityArrow.setKnockbackStrength(knockbackStrength);
return (IEntityArrow) entityArrow;
}

@Override
public int arrowShake() {
return entityArrow.arrowShake;
}

@Override
@Nullable
public IEntity getShooter() {
return CraftTweakerMC.getIEntity(entityArrow.shootingEntity);
}

@Override
public IEntityArrow setShooter(IEntity shooter) {
entityArrow.shootingEntity = CraftTweakerMC.getEntity(shooter);
return (IEntityArrow) entityArrow;
}

@Override
public String getPickupStatus() {
return String.valueOf(entityArrow.pickupStatus);
}

@Override
public IEntityArrow setPickupStatus(String pickupStatus) {
PickupStatus.valueOf(pickupStatus);
return (IEntityArrow) entityArrow;
}

@Override
public IEntityArrow setPickupDisallowed() {
entityArrow.pickupStatus = EntityArrow.PickupStatus.DISALLOWED;
return (IEntityArrow) entityArrow;
}

@Override
public IEntityArrow setPickupAllowed() {
entityArrow.pickupStatus = EntityArrow.PickupStatus.ALLOWED;
return (IEntityArrow) entityArrow;
}

@Override
public IEntityArrow setPickupCreativeOnly() {
entityArrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY;
return (IEntityArrow) entityArrow;
}
}
@@ -0,0 +1,34 @@
package crafttweaker.mc1120.entity;

import javax.annotation.Nullable;

import crafttweaker.api.entity.IEntityLivingBase;
import crafttweaker.api.entity.IEntityThrowable;
import crafttweaker.api.entity.IProjectile;
import crafttweaker.api.minecraft.CraftTweakerMC;
import net.minecraft.entity.projectile.EntityThrowable;

public class MCEntityThrowable extends MCEntity implements IEntityThrowable, IProjectile {
private final EntityThrowable entityThrowable;

public MCEntityThrowable(EntityThrowable entityThrowable) {
super(entityThrowable);
this.entityThrowable = entityThrowable;
}

@Override
public void shoot(double x, double y, double z, float velocity, float inaccuracy) {
entityThrowable.shoot(x, y, z, velocity, inaccuracy);
}

@Override
@Nullable
public IEntityLivingBase getThrower() {
return CraftTweakerMC.getIEntityLivingBase(entityThrowable.getThrower());
}

@Override
public int throwableShake() {
return entityThrowable.throwableShake;
}
}
@@ -1,6 +1,7 @@
package crafttweaker.mc1120.events.handling;

import crafttweaker.api.entity.IEntity;
import crafttweaker.api.entity.IEntityArrow;
import crafttweaker.api.event.ProjectileImpactArrowEvent;
import crafttweaker.api.minecraft.CraftTweakerMC;
import net.minecraft.entity.projectile.EntityArrow;
Expand All @@ -17,7 +18,7 @@ public MCProjectileImpactArrowEvent(ProjectileImpactEvent.Arrow event) {
}

@Override
public IEntity getArrow() {
public IEntityArrow getArrow() {
return CraftTweakerMC.getIEntity(arrow);
}

Expand Down
Expand Up @@ -2,6 +2,7 @@

import crafttweaker.api.entity.IEntity;
import crafttweaker.api.entity.IEntityLivingBase;
import crafttweaker.api.entity.IEntityThrowable;
import crafttweaker.api.event.ProjectileImpactThrowableEvent;
import crafttweaker.api.minecraft.CraftTweakerMC;
import net.minecraft.entity.projectile.EntityThrowable;
Expand All @@ -18,8 +19,8 @@ public MCProjectileImpactThrowableEvent(ProjectileImpactEvent.Throwable event) {
}

@Override
public IEntity getThrowable() {
return CraftTweakerMC.getIEntity(throwable);
public IEntityThrowable getThrowable() {
return CraftTweakerMC.getIEntityThrowable(throwable);
}

@Override
Expand Down
Expand Up @@ -4,15 +4,20 @@
import crafttweaker.api.block.*;
import crafttweaker.api.data.IData;
import crafttweaker.api.entity.IEntity;
import crafttweaker.api.entity.IEntityArrow;
import crafttweaker.api.entity.IEntityLivingBase;
import crafttweaker.api.entity.IEntityThrowable;
import crafttweaker.api.item.IItemStack;
import crafttweaker.api.minecraft.CraftTweakerMC;
import crafttweaker.api.player.IPlayer;
import crafttweaker.api.util.Position3f;
import crafttweaker.api.world.*;
import crafttweaker.mc1120.data.NBTConverter;
import crafttweaker.mc1120.entity.MCEntity;
import crafttweaker.mc1120.entity.MCEntityThrowable;
import crafttweaker.mc1120.util.MCPosition3f;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
Expand Down Expand Up @@ -209,6 +214,6 @@ public IEntity createLightningBolt(double x, double y, double z, boolean effectO

@Override
public boolean addWeatherEffect(IEntity entity) {
return world.addWeatherEffect(CraftTweakerMC.getEntity(entity));
return world.addWeatherEffect(CraftTweakerMC.getEntity(entity))
}
}

0 comments on commit 4659794

Please sign in to comment.