- Баллы
- 66
- Имя в Minecraft
- kvq_play
РЕШЕНО: Может кому пригодится
тут спрашивать о чем-то сложнее управления конфигом смысла нет
Добрый день
Пытался сделать кастомный класс для моба по этому тутору (как смог переделал под 1.10)
В итоге спамит ошибкой в консоль
тут спрашивать о чем-то сложнее управления конфигом смысла нет
Добрый день
Пытался сделать кастомный класс для моба по этому тутору (как смог переделал под 1.10)
В итоге спамит ошибкой в консоль
Код:
[15:13:24 WARN]: java.lang.NoSuchMethodException: me.kvq.game.slaugher.AI.Custom
EntityChicken.<init>(net.minecraft.server.v1_10_R1.World)
[15:13:24 WARN]: at java.lang.Class.getConstructor0(Unknown Source)
[15:13:24 WARN]: at java.lang.Class.getConstructor(Unknown Source)
[15:13:24 WARN]: at net.minecraft.server.v1_10_R1.SpawnerCreature.a(Spawn
erCreature.java:177)
[15:13:24 WARN]: at net.minecraft.server.v1_10_R1.WorldServer.doTick(Worl
dServer.java:227)
[15:13:24 WARN]: at net.minecraft.server.v1_10_R1.MinecraftServer.D(Minec
raftServer.java:783)
[15:13:24 WARN]: at net.minecraft.server.v1_10_R1.DedicatedServer.D(Dedic
atedServer.java:400)
[15:13:24 WARN]: at net.minecraft.server.v1_10_R1.MinecraftServer.C(Minec
raftServer.java:668)
[15:13:24 WARN]: at net.minecraft.server.v1_10_R1.MinecraftServer.run(Min
ecraftServer.java:567)
[15:13:24 WARN]: at java.lang.Thread.run(Unknown Source)
Код:
public class CustomEntityChicken extends EntityChicken {
// private static final Set<Item> bF = Sets.newHashSet((Object[])(new Item[]{Items.WHEAT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS, Items.BEETROOT_SEEDS}));
public float bx;
public float by;
public float bz;
public float bB;
public float bC = 1.0F;
public int bD;
public boolean bE;
public CustomEntityChicken(net.minecraft.server.v1_10_R1.World world) {
super(world);
this.setSize(0.4F, 0.7F);
this.bD = this.random.nextInt(6000) + 6000;
this.a(PathType.WATER, 0.0F);
}
protected void r() {
this.goalSelector.a(0, new PathfinderGoalFloat(this));
this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, 1.0D, false));
this.goalSelector.a(5, new PathfinderGoalRandomStroll(this, 1.0D));
this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, HumanEntity.class, true));
this.goalSelector.a(7, new PathfinderGoalRandomLookaround(this));
this.goalSelector.a(7, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F));
this.o();
}
protected void o() {
this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false));
this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true, new Class[]{EntityPigZombie.class}));
this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true));
if(this.world.spigotConfig.zombieAggressiveTowardsVillager) {
this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, false));
}
this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityIronGolem.class, true));
}
public float getHeadHeight() {
return this.length;
}
protected void initAttributes() {
super.initAttributes();
this.getAttributeInstance(GenericAttributes.maxHealth).setValue(4.0D);
this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(5.8D);
}
public void n() {
if(this.isChickenJockey()) {
this.persistent = !this.isTypeNotPersistent();
}
super.n();
this.bB = this.bx;
this.bz = this.by;
this.by = (float)((double)this.by + (double)(this.onGround?-1:4) * 0.3D);
this.by = MathHelper.a(this.by, 0.0F, 1.0F);
if(!this.onGround && this.bC < 1.0F) {
this.bC = 1.0F;
}
this.bC = (float)((double)this.bC * 0.9D);
if(!this.onGround && this.motY < 0.0D) {
this.motY *= 0.6D;
}
this.bx += this.bC * 2.0F;
}
public void e(float f, float f1) {}
protected SoundEffect G() {
return SoundEffects.Y;
}
protected SoundEffect bV() {
return SoundEffects.ab;
}
protected SoundEffect bW() {
return SoundEffects.Z;
}
protected void a(BlockPosition blockposition, Block block) {
this.a(SoundEffects.ac, 0.15F, 1.0F);
}
@Nullable
protected MinecraftKey J() {
return LootTables.C;
}
public EntityChicken b(EntityAgeable entityageable) {
return new EntityChicken(this.world);
}
public boolean e(@Nullable ItemStack itemstack) {
return false;
}
protected int getExpValue(EntityHuman entityhuman) {
return 0;
}
public static void b(DataConverterManager dataconvertermanager) {
EntityInsentient.a(dataconvertermanager, "Chicken");
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
this.bE = nbttagcompound.getBoolean("IsChickenJockey");
if(nbttagcompound.hasKey("EggLayTime")) {
this.bD = nbttagcompound.getInt("EggLayTime");
}
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
nbttagcompound.setBoolean("IsChickenJockey", this.bE);
nbttagcompound.setInt("EggLayTime", this.bD);
}
protected boolean isTypeNotPersistent() {
return this.isChickenJockey() && !this.isVehicle();
}
public void k(Entity entity) {
super.k(entity);
float f = MathHelper.sin(this.aO * 0.017453292F);
float f1 = MathHelper.cos(this.aO * 0.017453292F);
entity.setPosition(this.locX + (double)(0.1F * f), this.locY + (double)(this.length * 0.5F) + entity.ax() + 0.0D, this.locZ - (double)(0.1F * f1));
if(entity instanceof EntityLiving) {
((EntityLiving)entity).aO = this.aO;
}
}
public boolean isChickenJockey() {
return this.bE;
}
public void p(boolean flag) {
this.bE = flag;
}
public EntityAgeable createChild(EntityAgeable entityageable) {
return this.b(entityageable);
}
}
Код:
public enum CustomEntityType {
Custom_Chicken("CustomChicken", 2000, EntityType.CHICKEN, EntityChicken.class, CustomEntityChicken.class);
private String name;
private int id;
private EntityType entityType;
private Class<? extends EntityInsentient> nmsClass;
private Class<? extends EntityInsentient> customClass;
private CustomEntityType(String name, int id, EntityType entityType, Class<? extends EntityInsentient> nmsClass, Class<? extends EntityInsentient> customClass){
this.name = name;
this.id = id;
this.entityType = entityType;
this.nmsClass = nmsClass;
this.customClass = customClass;
}
public String getName(){
return this.name;
}
public int getID(){
return this.id;
}
public EntityType getEntityType(){
return this.entityType;
}
public Class<? extends EntityInsentient> getNMSClass(){
return this.nmsClass;
}
public Class<? extends EntityInsentient> getCustomClass(){
return this.customClass;
}
}
Код:
public void onEnable(){
registerEntities();
}
public static void registerEntities(){
for (CustomEntityType entity : CustomEntityType.values()){
try{
Method a = EntityTypes.class.getDeclaredMethod("a", new Class<?>[]{Class.class, String.class, int.class});
a.setAccessible(true);
a.invoke(null, entity.getCustomClass(), entity.getName(), entity.getID());
}catch (Exception e){
e.printStackTrace();
}
}
for (BiomeBase biomeBase : BiomeBase.i){
if (biomeBase == null){
break;
}
for (String field : new String[]{"u", "v", "w", "x"}){
try{
Field list = BiomeBase.class.getDeclaredField(field);
list.setAccessible(true);
@SuppressWarnings("unchecked")
List<BiomeMeta> mobList = (List<BiomeMeta>) list.get(biomeBase);
for (BiomeMeta meta : mobList){
for (CustomEntityType entity : CustomEntityType.values()){
if (entity.getNMSClass().equals(meta.b)){
meta.b = entity.getCustomClass();
}
}
}
}catch (Exception e){
e.printStackTrace();
}
}
}
}
Последнее редактирование: