EntityRegistry.registerModEntity(EntityArrowCustom.class, "carrow", 24, instance, 0, 64, false);
Так и надо было написать в первом посте. Покажи код модаВ одиночке его видно, а если зайду через физический сервер, то не видно, а стрела видна и там и там.
@Mod(version = "0.0.1 alpha", name = "Test Mod", modid = "testmod")
@NetworkMod(clientSideRequired = true, serverSideRequired = true, channels = "channel", packetHandler = PacketHandler.class)
public class Main {
@Instance()
public static Main instance;
@SidedProxy(clientSide = "mods.cool.testMod.client.ClientProxy", serverSide = "mods.cool.testMod.CommonProxy")
public static CommonProxy proxy = new CommonProxy();
public static Block invisible;
public static Item customBow;
public static void registerBlocks() {
int blockID = 1500;
}
public static void registerItems() {
int itemID = 2000;
customBow = new ItemCustomBow(itemID++, 800, "customBow", 50);
}
@PreInit
public static void preLoad(FMLPreInitializationEvent e) {
registerBlocks();
registerItems();
//Entity
EntityRegistry.registerModEntity(EntityArrowCustom.class, "carrow", 24, instance, 0, 64, false);
proxy.preLoad(e);
}
@Init
public static void load(FMLInitializationEvent e) {
proxy.load(e);
}
@PostInit
public static void postLoad(FMLPostInitializationEvent e) {
proxy.postLoad(e);
}
}
public class ClientProxy extends CommonProxy{
@Override
public void preLoad(FMLPreInitializationEvent e) {
RenderingRegistry.registerEntityRenderingHandler(EntityArrowCustom.class, new EntityArrowCustomRender());
}
@Override
public void load(FMLInitializationEvent e) {
MinecraftForge.EVENT_BUS.register(new Events());
TickRegistry.registerTickHandler(new ClientTicker(), Side.CLIENT);
}
@Override
public void postLoad(FMLPostInitializationEvent e) {
}
}
public class PacketHandler implements IPacketHandler{
@Override
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) {
try {
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(packet.data));
EntityPlayer p = (EntityPlayer)player;
World world = p.worldObj;
String pusher = p.username;
byte[] bytes = new byte[dis.available()];
byte b = 0;
for(int i = 0; i < bytes.length; i++) {
bytes[i] = dis.readByte();
b = bytes[i];
}
if(b == 1)
{
if(p.getCurrentEquippedItem().getItem() != null && p.getCurrentEquippedItem().getItem() instanceof ItemCustomBow) {
ItemCustomBowweapon = (ItemCustomBow) p.getCurrentEquippedItem().getItem();
world.spawnEntityInWorld(new EntityArrowCustom(world, p, 1.0f));
//world.spawnEntityInWorld(new EntityArrow(world, p, 2.0F));
}
}
} catch (IOException e) {
System.err.println("Ошибка при чтении пакета");
}
}
}
public class ClientTicker implements ITickHandler{
Minecraft mc = Minecraft.getMinecraft();
public static boolean isMouseDown = false;
@Override
public void tickStart(EnumSet<TickType> type, Object... tickData) {
isMouseDown = Mouse.isButtonDown(0);
EntityPlayer player = mc.thePlayer;
if(mc.theWorld != null) {
if(player.getCurrentEquippedItem().getItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemCustomBow) {
if(isMouseDown && mc.inGameHasFocus) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bos.write(1);
PacketDispatcher.sendPacketToServer(new Packet250CustomPayload("channel", bos.toByteArray()));
PacketDispatcher.sendPacketToAllAround(player.posX, player.posY, player.posZ, 300.0D, player.dimension, new Packet250CustomPayload("channel", bos.toByteArray()));
}
}
}
}
@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
}
@Override
public EnumSet ticks() {
return EnumSet.of(TickType.CLIENT);
}
@Override
public String getLabel() {
return "testTicker";
}
}
@SideOnly(Side.CLIENT)
public class RenderArrowCustomRender extends Render
{
public void renderBullet(EntityArrowCustom par1EntityArrow, double par2, double par4, double par6, float par8, float par9)
{
this.loadTexture("/mods/cool/testMod/textures/testArrow1.png");
GL11.glPushMatrix();
GL11.glTranslatef((float)par2, (float)par4, (float)par6);
GL11.glRotatef(par1EntityArrow.prevRotationYaw + (par1EntityArrow.rotationYaw - par1EntityArrow.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(par1EntityArrow.prevRotationPitch + (par1EntityArrow.rotationPitch - par1EntityArrow.prevRotationPitch) * par9, 0.0F, 0.0F, 1.0F);
Tessellator tessellator = Tessellator.instance;
byte b0 = 0;
float f2 = 0.0F;
float f3 = 0.5F;
float f4 = (float)(0 + b0 * 10) / 32.0F;
float f5 = (float)(5 + b0 * 10) / 32.0F;
float f6 = 0.0F;
float f7 = 0.15625F;
float f8 = (float)(5 + b0 * 10) / 32.0F;
float f9 = (float)(10 + b0 * 10) / 32.0F;
float f10 = 0.05625F;
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F);
GL11.glScalef(f10, f10, f10);
GL11.glTranslatef(-4.0F, 0.0F, 0.0F);
GL11.glNormal3f(f10, 0.0F, 0.0F);
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f8);
tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f8);
tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f9);
tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f9);
tessellator.draw();
GL11.glNormal3f(-f10, 0.0F, 0.0F);
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f8);
tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f8);
tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f9);
tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f9);
tessellator.draw();
for (int i = 0; i < 4; ++i)
{
GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
GL11.glNormal3f(0.0F, 0.0F, f10);
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double)f2, (double)f4);
tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, (double)f3, (double)f4);
tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, (double)f3, (double)f5);
tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double)f2, (double)f5);
tessellator.draw();
}
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
{
this.renderBullet((EntityArrowCustom)par1Entity, par2, par4, par6, par8, par9);
}
}
EntityRegistry.registerModEntity(EntityArrowCustom.class, "carrow", 24, instance, 0, 64, false);