Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (โ‹ฎ) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Minecraft version:1.16.5

Forge version:32.6.34

MCP mapping version:20201028-1.16.3-snapshot

I tried to add an entity to my game,compile is succsseful,but when i enter "/summon touhoucraft:power_point ~ ~ ~" It returned "Unable to summon entity"

this is the entity code and model& render code

package com.lucaiyu.touhoucraft.entities;

import net.minecraft.entity.EntityType;
import net.minecraft.entity.MobEntity;
import net.minecraft.world.World;


public class PowerPoint extends MobEntity {
    public PowerPoint(World worldIn){
        this(null, worldIn);
    }
    public PowerPoint(EntityType<? extends MobEntity> type, World worldIn) {
        super(type, worldIn);
    }
}
package com.lucaiyu.touhoucraft.entities.model;

import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.renderer.entity.model.EntityModel;
import net.minecraft.client.renderer.model.ModelRenderer;
import com.lucaiyu.touhoucraft.entities.PowerPoint;

public class PowerPointModel extends EntityModel<PowerPoint> {
	private final ModelRenderer bb_main;

	public PowerPointModel() {
		textureWidth = 64;
		textureHeight = 64;

		bb_main = new ModelRenderer(this);
		bb_main.setRotationPoint(0.0F, 24.0F, 0.0F);
		bb_main.setTextureOffset(0, 0).addBox(-5.0F, -0.5F, -5.0F, 10.0F, 1.0F, 10.0F, 0.0F, false);
	}

	@Override
	public void setRotationAngles(PowerPoint entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch){
	}

	@Override
	public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){
		bb_main.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
	}

	public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
		modelRenderer.rotateAngleX = x;
		modelRenderer.rotateAngleY = y;
		modelRenderer.rotateAngleZ = z;
	}
}
package com.lucaiyu.touhoucraft.entities.render;

import com.lucaiyu.touhoucraft.TouHouCraft;
import com.lucaiyu.touhoucraft.entities.PowerPoint;
import com.lucaiyu.touhoucraft.entities.model.PowerPointModel;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.util.ResourceLocation;

public class PowerPointRender extends MobRenderer<PowerPoint, PowerPointModel> {
    private static final ResourceLocation POWER_POINT_TEXTURE = new ResourceLocation(TouHouCraft.MOD_ID, "texture/entity/power_point.png");
    public PowerPointRender(EntityRendererManager renderManagerIn) {
        super(renderManagerIn, new PowerPointModel(), 0.8F);
    }
    public PowerPointRender(EntityRendererManager renderManagerIn, PowerPointModel entityModelIn, float shadowSizeIn) {
        super(renderManagerIn, entityModelIn, shadowSizeIn);
    }

    @Override
    public ResourceLocation getEntityTexture(PowerPoint entity) {
        return POWER_POINT_TEXTURE;
    }
}

This is the registry and client event

package com.lucaiyu.touhoucraft.entities;

import com.lucaiyu.touhoucraft.TouHouCraft;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

public class EntityRegistry {
    public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, TouHouCraft.MOD_ID);

    public static RegistryObject<EntityType<PowerPoint>> power_point =
            ENTITIES.register("power_point",
                    ()->EntityType.Builder.<PowerPoint>create(PowerPoint::new, EntityClassification.MISC)
                            .size(1.0F, 1.0F).build("power_point"));
}
package com.lucaiyu.touhoucraft.events;

import com.lucaiyu.touhoucraft.entities.EntityRegistry;
import com.lucaiyu.touhoucraft.entities.render.PowerPointRender;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;

@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class ClientEvent {
    @SubscribeEvent
    public static void onClientSetupEvent(FMLClientSetupEvent event){
        event.enqueueWork(()->{
            Minecraft mc = Minecraft.getInstance();
            EntityRendererManager manager = mc.getRenderManager();
            manager.register(EntityRegistry.power_point.get(), new PowerPointRender(manager));
        });
    }
}

And this is the main class

package com.lucaiyu.touhoucraft;

import com.lucaiyu.touhoucraft.blocks.BlockRegistry;
import com.lucaiyu.touhoucraft.entities.EntityRegistry;
import com.lucaiyu.touhoucraft.items.ItemRegistry;

import com.lucaiyu.touhoucraft.world.gen.OreGeneration;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.fml.common.Mod;

import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;


@Mod("touhoucraft")
public class TouHouCraft{
    public static String MOD_ID = "touhoucraft";
    public TouHouCraft() {
        ItemRegistry.ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
        BlockRegistry.BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus());
        MinecraftForge.EVENT_BUS.addListener(EventPriority.HIGH, OreGeneration::generateOres);
        EntityRegistry.ENTITIES.register(FMLJavaModLoadingContext.get().getModEventBus());
    }


}

ย 

Guest
This topic is now closed to further replies.

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions โ†’ Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.