Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/main/java/ru/mcmodding/tutorial/client/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ public void init(FMLInitializationEvent event) {
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);

switch (id) {
case GUI_CHEST:
return new ChestGui(new ChestContainer((ChestTile)tile, player.inventory));
default:
return null;
if (id == GUI_CHEST) {
return new ChestGui(new ChestContainer((ChestTile) tile, player.inventory));
}
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package ru.mcmodding.tutorial.client.render.entity;

import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import ru.mcmodding.tutorial.McModding;
import ru.mcmodding.tutorial.client.render.model.GooseModel;

public class GooseEntityRender extends RenderLiving {
private static final ResourceLocation GOOSE_TEXTURE = new ResourceLocation(McModding.MOD_ID, "textures/entity/goose.png");

public GooseEntityRender() {
super(new GooseModel(), 0.7F);
}

@Override
protected ResourceLocation getEntityTexture(Entity entity) {
return GOOSE_TEXTURE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package ru.mcmodding.tutorial.client.render.model;

import net.minecraft.client.model.ModelBase;

public class GooseModel extends ModelBase {
public GooseModel() {

}
}
9 changes: 4 additions & 5 deletions src/main/java/ru/mcmodding/tutorial/common/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void preInit(FMLPreInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(new ForgeEventListener());

ModBlocks.register();
ModEntities.register();
ModItems.register();

GameRegistry.registerFuelHandler(new FuelHandler());
Expand Down Expand Up @@ -79,12 +80,10 @@ public static PacketHandler getPacketHandler() {
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);

switch (id) {
case GUI_CHEST:
return new ChestContainer((ChestTile)tile, player.inventory);
default:
return null;
if (id == GUI_CHEST) {
return new ChestContainer((ChestTile) tile, player.inventory);
}
return null;
}

@Override
Expand Down
78 changes: 78 additions & 0 deletions src/main/java/ru/mcmodding/tutorial/common/entity/GooseEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package ru.mcmodding.tutorial.common.entity;

import net.minecraft.block.Block;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityChicken;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import ru.mcmodding.tutorial.McModding;

public class GooseEntity extends EntityAnimal {
public GooseEntity(World world) {
super(world);
setSize(0.9F, 0.9F);
getNavigator().setAvoidsWater(true);

tasks.addTask(0, new EntityAISwimming(this));
tasks.addTask(1, new EntityAIMate(this, 1.0D));
tasks.addTask(2, new EntityAIAttackOnCollide(this, 1.0, true));
tasks.addTask(2, new EntityAIFollowParent(this, 1.1D));
tasks.addTask(3, new EntityAIWander(this, 1.0D));
tasks.addTask(4, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
tasks.addTask(5, new EntityAILookIdle(this));
}

@Override
public boolean isAIEnabled() {
return true;
}

@Override
protected void applyEntityAttributes() {
super.applyEntityAttributes();
getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D);
getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25D);
}

@Override
public String getLivingSound() {
return McModding.MOD_ID + ":goose_say";
}

@Override
public String getHurtSound() {
return McModding.MOD_ID + ":goose_say";
}

@Override
public String getDeathSound() {
return McModding.MOD_ID + ":goose_death";
}

@Override
public void func_145780_a(int x, int y, int z, Block block) {
playSound("mob.chicken.step", 0.15F, 1.0F);
}

@Override
public Item getDropItem() {
return Items.feather;
}

@Override
public boolean isBreedingItem(ItemStack stack) {
return stack != null && stack.getItem() instanceof ItemSeeds;
}

@Override
public EntityAgeable createChild(EntityAgeable ageable) {
return new GooseEntity(worldObj);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package ru.mcmodding.tutorial.common.handler;

import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
import ru.mcmodding.tutorial.McModding;
import ru.mcmodding.tutorial.client.render.entity.GooseEntityRender;
import ru.mcmodding.tutorial.common.entity.GooseEntity;

public class ModEntities {
private ModEntities() {
throw new UnsupportedOperationException();
}

public static void register() {
EntityRegistry.registerModEntity(GooseEntity.class, "goose", 0, McModding.instance, 80, 3, true);
RenderingRegistry.registerEntityRenderingHandler(GooseEntity.class, new GooseEntityRender());
}
}