Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Drullkus committed 2015-03-08 14:06:01 -07:00
commit 23c193a962
8 files changed
+215 -2

No files matched your search

@@ -2,6 +2,8 @@ package com.cricketcraft.chisel;
import java.io.File;
import com.cricketcraft.chisel.entity.EntityChiselSnowman;
import cpw.mods.fml.common.registry.EntityRegistry;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraftforge.common.MinecraftForge;
@@ -136,6 +138,8 @@ public class Chisel {
addWorldgen(Features.DIORITE, ChiselBlocks.diorite, Configurations.dioriteAmount, 40, 100, 0.5);
GameRegistry.registerWorldGenerator(GeneratorChisel.INSTANCE, 1000);
EntityRegistry.registerModEntity(EntityChiselSnowman.class, "snowman", 0, this, 80, 1, true);
proxy.init();
MinecraftForge.EVENT_BUS.register(this);
FMLCommonHandler.instance().bus().register(instance);
@@ -1162,7 +1162,7 @@ public enum Features {
jackolantern[metadata] = (BlockCarvablePumpkin) new BlockCarvablePumpkin(true).setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setHardness(1.0F).setBlockName("litpumpkin")
.setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setLightLevel(1.0f);
jackolantern[metadata].setInformation("pumpkin/pumpkin_face_" + (metadata + 1) + "_on");
GameRegistry.registerBlock(jackolantern[metadata], ("jackolantern" + (metadata + 1)));
GameRegistry.registerBlock(jackolantern[metadata], ItemCarvablePumpkin.class, ("jackolantern" + (metadata + 1)));
Carving.chisel.addVariation("jackolantern", jackolantern[metadata], 0, (metadata + 1));
}
Carving.chisel.addVariation("jackolantern", Blocks.lit_pumpkin, 0, 0);
@@ -1832,7 +1832,7 @@ public enum Features {
pumpkin[metadata] = (BlockCarvablePumpkin) new BlockCarvablePumpkin(false).setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setHardness(1.0F).setBlockName("pumpkin")
.setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
pumpkin[metadata].setInformation("pumpkin/pumpkin_face_" + (metadata + 1) + "_off");
GameRegistry.registerBlock(pumpkin[metadata], "pumpkin" + (metadata + 1));
GameRegistry.registerBlock(pumpkin[metadata], ItemCarvablePumpkin.class, "pumpkin" + (metadata + 1));
Carving.chisel.addVariation("pumpkin", pumpkin[metadata], 0, (metadata + 1));
}
Carving.chisel.addVariation("pumpkin", Blocks.pumpkin, 0, 0);
@@ -1,8 +1,12 @@
package com.cricketcraft.chisel.block;
import com.cricketcraft.chisel.entity.EntityChiselSnowman;
import com.cricketcraft.chisel.init.ChiselBlocks;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPumpkin;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.monster.EntityIronGolem;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
@@ -14,6 +18,7 @@ import com.cricketcraft.chisel.carving.CarvableVariation;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.world.World;
public class BlockCarvablePumpkin extends BlockPumpkin implements ICarvable {
@@ -32,6 +37,66 @@ public class BlockCarvablePumpkin extends BlockPumpkin implements ICarvable {
carverHelper = new CarvableHelper();
}
@Override
public void onBlockAdded(World world, int x, int y, int z){
if(world.getBlock(x, y - 1, z) == Blocks.snow && world.getBlock(x, y - 2, z) == Blocks.snow){
if(!world.isRemote){
//Let's grab the pumpkin before we start
ItemStack pumpkin = new ItemStack(world.getBlock(x, y, z), world.getBlockMetadata(x, y, z));
world.setBlock(x, y, z, Blocks.air, 0, 2);
world.setBlock(x, y - 1, z, Blocks.air, 0, 2);
world.setBlock(x, y - 2, z, Blocks.air, 0, 2);
EntityChiselSnowman snowman = new EntityChiselSnowman(world);
snowman.setCurrentItemOrArmor(2, pumpkin);
snowman.setLocationAndAngles((double) x + 0.5D, (double) y - 1.95D, (double) z + 0.5D, 0.0F, 0.0F);
world.spawnEntityInWorld(snowman);
world.notifyBlockChange(x, y, z, Blocks.air);
world.notifyBlockChange(x, y - 1, z, Blocks.air);
world.notifyBlockChange(x, y - 2, z, Blocks.air);
}
//Spawn some lovely particles
for(int c = 0; c < 120; ++c){
world.spawnParticle("snowshovel", (double)x + world.rand.nextDouble(), (double) (y - 2) + world.rand.nextDouble() * 2.5D, (double) z + world.rand.nextDouble(), 0.0D, 0.0D, 0.0D);
}
} else if(world.getBlock(x, y - 1, z) == Blocks.iron_block || world.getBlock(x, y - 2, z) == Blocks.iron_block){
boolean flag = world.getBlock(x - 1, y - 1, z) == Blocks.iron_block && world.getBlock(x + 1, y - 1, z) == Blocks.iron_block;
boolean flag1 = world.getBlock(x, y - 1, z - 1) == Blocks.iron_block && world.getBlock(x, y - 1, z + 1) == Blocks.iron_block;
if(flag || flag1){
world.setBlock(x, y, z, Blocks.air, 0, 2);
world.setBlock(x, y - 1, z, Blocks.air, 0, 2);
world.setBlock(x, y - 2, z, Blocks.air, 0, 2);
if(flag){
world.setBlock(x - 1, y - 1, z, Blocks.air, 0, 2);
world.setBlock(x + 1, y - 1, z, Blocks.air, 0, 2);
} else {
world.setBlock(x, y - 1, z - 1, Blocks.air, 0, 2);
world.setBlock(x, y - 1, z + 1, Blocks.air, 0, 2);
}
EntityIronGolem ironGolem = new EntityIronGolem(world);
ironGolem.setPlayerCreated(true);
ironGolem.setLocationAndAngles((double) x + 0.5D, (double) y - 1.95D, (double) z + 0.5D, 0.0F, 0.0F);
world.spawnEntityInWorld(ironGolem);
world.notifyBlockChange(x, y, z, Blocks.air);
world.notifyBlockChange(x, y - 1, z, Blocks.air);
world.notifyBlockChange(x, y - 2, z, Blocks.air);
if(flag){
world.notifyBlockChange(x - 1, y - 1, z, Blocks.air);
world.notifyBlockChange(x + 1, y - 1, z, Blocks.air);
} else {
world.notifyBlockChange(x, y - 1, z - 1, Blocks.air);
world.notifyBlockChange(x, y - 1, z + 1, Blocks.air);
}
}
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
@@ -0,0 +1,65 @@
package com.cricketcraft.chisel.client.render;
import com.cricketcraft.chisel.entity.EntityChiselSnowman;
import net.minecraft.block.Block;
import net.minecraft.client.model.ModelSnowMan;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.MinecraftForgeClient;
import static net.minecraftforge.client.IItemRenderer.ItemRenderType.*;
import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.*;
import org.lwjgl.opengl.GL11;
public class RenderChiselSnowman extends RenderLiving{
private static final ResourceLocation snowManTextures = new ResourceLocation("textures/entity/snowman.png");
private ModelSnowMan snowMan;
public RenderChiselSnowman() {
super(new ModelSnowMan(), 0.5F);
snowMan = (ModelSnowMan)super.mainModel;
setRenderPassModel(this.snowMan);
}
@Override
protected void renderEquippedItems(EntityLivingBase entityLivingBase, float size){
this.renderEquippedItems((EntityChiselSnowman) entityLivingBase, size);
}
@Override
protected ResourceLocation getEntityTexture(Entity entity) {
return this.getEntityTexture((EntityChiselSnowman) entity);
}
protected ResourceLocation getEntityTexture(EntityChiselSnowman snowman){
return snowManTextures;
}
protected void renderEquippedItems(EntityChiselSnowman snowman, float size){
super.renderEquippedItems(snowman, size);
ItemStack itemStack = snowman.getEquipmentInSlot(2);
if(itemStack.getItem() instanceof ItemBlock){
GL11.glPushMatrix();
this.snowMan.head.postRender(0.0625F);
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemStack, EQUIPPED);
boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemStack, BLOCK_3D));
if(is3D || RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemStack.getItem()).getRenderType())){
float f1 = 0.625F;
GL11.glTranslatef(0.0F, -0.34375F, 0.0F);
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
GL11.glScalef(f1, -f1, f1);
}
this.renderManager.itemRenderer.renderItem(snowman, itemStack, 0);
GL11.glPopMatrix();
}
}
}
@@ -0,0 +1,13 @@
package com.cricketcraft.chisel.entity;
import net.minecraft.entity.monster.EntitySnowman;
import net.minecraft.world.World;
public class EntityChiselSnowman extends EntitySnowman{
public EntityChiselSnowman(World world){
super(world);
}
//No special features just needed to get around the hardcoding
}
@@ -0,0 +1,61 @@
package com.cricketcraft.chisel.item;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.carving.CarvableVariation;
import com.cricketcraft.chisel.config.Configurations;
import com.cricketcraft.chisel.utils.General;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import java.util.List;
public class ItemCarvablePumpkin extends ItemBlock {
public ItemCarvablePumpkin(Block block) {
super(block);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public boolean isValidArmor(ItemStack itemStack, int armorType, Entity entity){
return true;
}
@Override
public int getMetadata(int i) {
return i;
}
@Override
public IIcon getIconFromDamage(int damage) {
return Block.getBlockFromItem(this).getIcon(2, damage);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) {
if (!Configurations.blockDescriptions)
return;
Item item = General.getItem(stack);
if (item == null)
return;
Block block = Block.getBlockFromItem(this);
if (!(block instanceof ICarvable))
return;
ICarvable carvable = (ICarvable) block;
CarvableVariation var = carvable.getVariation(stack);
if (var == null)
return;
lines.add(var.getDescription());
}
}
@@ -8,6 +8,7 @@ import com.cricketcraft.chisel.client.render.item.ItemChiselRenderer;
import com.cricketcraft.chisel.client.render.tile.RenderAutoChisel;
import com.cricketcraft.chisel.client.render.tile.RenderPresent;
import com.cricketcraft.chisel.entity.EntityBallOMoss;
import com.cricketcraft.chisel.entity.EntityChiselSnowman;
import com.cricketcraft.chisel.entity.EntityCloudInABottle;
import com.cricketcraft.chisel.entity.EntitySmashingRock;
import com.cricketcraft.chisel.init.ChiselBlocks;
@@ -58,6 +59,7 @@ public class ClientProxy extends CommonProxy {
RenderingRegistry.registerEntityRenderingHandler(EntityCloudInABottle.class, new RenderSnowball(ChiselItems.cloudinabottle));
RenderingRegistry.registerEntityRenderingHandler(EntityBallOMoss.class, new RenderSnowball(ChiselItems.ballomoss));
RenderingRegistry.registerEntityRenderingHandler(EntitySmashingRock.class, new RenderSnowball(ChiselItems.smashingrock));
RenderingRegistry.registerEntityRenderingHandler(EntityChiselSnowman.class, new RenderChiselSnowman());
MinecraftForgeClient.registerItemRenderer(ChiselItems.chisel, renderer);
MinecraftForgeClient.registerItemRenderer(ChiselItems.diamondChisel, renderer);