- 89
- 2
Создал моба, в клиенте всё работает, моб спавнится, гуи работает.
На сервере моб не спавнится.
На сервере моб не спавнится.
Java:
package ru.theklimot.npc.mobs;
import net.minecraft.client.renderer.entity.RenderEntity;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.EntityEntry;
import net.minecraftforge.fml.common.registry.EntityEntryBuilder;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import ru.theklimot.npc.*;
import ru.theklimot.npc.gui.OpenGuiMobs;
@Mod.EventBusSubscriber(modid = Main.MODID)//�����������! <-------------
public class EntityRegistry {
@SideOnly(Side.CLIENT)//������ ������
public static void initModels() {
/*������������ ������, 1 �������� = ����� ����, 2 �������� = ��� ������ ������� */
RenderingRegistry.registerEntityRenderingHandler(EntitySmallHerobrine.class, RenderEntityHerobrine.FACTORY);
}
private static int ID = 7822;//��� ����
public static EntityEntry SMALL_HEROBRINE = EntityEntryBuilder
.create()//������ ����� EntityEntry
.entity(EntitySmallHerobrine.class)//����� ��� � EntityEntry
.name("Small Herobrine")//���
.id("small_herobrine", ID++)//���� � ��� �����������
.egg(0xff4040, 0xd891ef)//���� ����, ������ ������� ���, ������ "�����"
.tracker(160, 2, false)//������ ����
.build();//������������� ���������
@SubscribeEvent
public static void registryEntity(RegistryEvent.Register<EntityEntry> event) {
/*����� ����������� �� ������*/
event.getRegistry().registerAll(
SMALL_HEROBRINE
);
}
}
Java:
package ru.theklimot.npc.mobs;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.EntityEntry;
import net.minecraftforge.fml.common.registry.EntityEntryBuilder;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import ru.theklimot.npc.Main;
import ru.theklimot.npc.gui.SkolGui;
public class EntitySmallHerobrine extends EntityMob {
//��� ���. ����(���� � ��)
public static int ADD_DAMAGE = 15;
/*�����������*/
public EntitySmallHerobrine(World world) {
super(world);
setCustomNameTag("Путешественник");
setAlwaysRenderNameTag(true);
setSize(0.6F, 1.98F);//������ ����
}
/*����������� � ���������� �������*/
public EntitySmallHerobrine(World world, double x, double y, double z) {
super(world);
setSize(0.6F, 1.98F);//������ ����
setPositionAndUpdate(x, y, z);
}
@Override
protected void applyEntityAttributes() {
/*������� ���� ����� ��� ����������� ���������(����. ��, ��������, ���� �����, �����, �������� ����� � ��.)*/
super.applyEntityAttributes();
//������������� ��������
this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(35.0D);//������ ������ = 35 ������
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.0D);//�������� ����(��� �������: ������� ����� = 0.23D)
this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(0.0D);//���� �������� = 1.5 ��������(� �������� = 2D)
this.getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(2.0D);//����� ����(�� �� ������� ���� �� ����)
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(12398122.0D);
this.getEntityAttribute(SharedMonsterAttributes.ARMOR_TOUGHNESS).setBaseValue(2.0D);//������������ ����(������ ����� ������ ������������)
}
@Override
protected void initEntityAI() {
/*������ �������� ����
* 1 �������� - ���������
* 2 �������� - �������� ����� �� EntityAIBase
*/
this.tasks.addTask(0, new EntityAISwimming(this));//������� �� ���
this.tasks.addTask(1, new EntityAIAttackMelee(this, 0.0D, false));//����� �������� ���
this.tasks.addTask(2, new EntityAIWander(this, 0.0D));//��� ������������
this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));//������� �� EntityPlayer(�����)
this.tasks.addTask(4, new EntityAILookIdle(this));//����� ������ - ������� ������������� ������
}
@SideOnly(Side.CLIENT)
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
if(this.getEntityWorld().isRemote)
{
Minecraft.getMinecraft().displayGuiScreen(new SkolGui());
//player.openGui(GuardsCraft.instance, 1, this.getEntityWorld(), 0, 0, 0);
//player.openGui(GuardsCraft.instance, GUI_ID, world, this.chunkCoordX, this.chunkCoordY, this.chunkCoordZ);
//player.openGui(GuardsCraft.instance, GUI_ID, world, 153, 81, 251);
//return super.processInteract(player, hand);
return true;
}
else { return false; }
}
@Override
public boolean attackEntityAsMob(Entity entityIn) {
/*��� ���������� ��� �����*/
if (super.attackEntityAsMob(entityIn)) {//�������� �� �����
if (entityIn instanceof EntityLivingBase) {//���� ��� ���
((EntityLivingBase) entityIn).attackEntityAsMob(this);//������ ��������� ��������� ������ ����
entityIn.attackEntityFrom(((EntityLivingBase) entityIn).getLastDamageSource(), rand.nextInt(ADD_DAMAGE));//������� ���. ����
}
return true;
} else {
return false;
}
}
@Override
public int getMaxSpawnedInChunk() {
/*������� ��������� � �����*/
return 25;
}
}