diff --git a/resources/assets/enderio/textures/blocks/endermanSkullFront.png b/resources/assets/enderio/textures/blocks/endermanSkullFront.png new file mode 100644 index 00000000..3b82936c Binary files /dev/null and b/resources/assets/enderio/textures/blocks/endermanSkullFront.png differ diff --git a/resources/assets/enderio/textures/blocks/endermanSkullFrontEyes.png b/resources/assets/enderio/textures/blocks/endermanSkullFrontEyes.png new file mode 100644 index 00000000..bfdfff32 Binary files /dev/null and b/resources/assets/enderio/textures/blocks/endermanSkullFrontEyes.png differ diff --git a/resources/assets/enderio/textures/blocks/endermanSkullSide.png b/resources/assets/enderio/textures/blocks/endermanSkullSide.png new file mode 100644 index 00000000..5635dac9 Binary files /dev/null and b/resources/assets/enderio/textures/blocks/endermanSkullSide.png differ diff --git a/resources/assets/enderio/textures/blocks/endermanSkullTop.png b/resources/assets/enderio/textures/blocks/endermanSkullTop.png new file mode 100644 index 00000000..9b1457fd Binary files /dev/null and b/resources/assets/enderio/textures/blocks/endermanSkullTop.png differ diff --git a/resources/assets/enderio/textures/items/endermanSkull.png b/resources/assets/enderio/textures/items/endermanSkull.png new file mode 100644 index 00000000..7c95a77b Binary files /dev/null and b/resources/assets/enderio/textures/items/endermanSkull.png differ diff --git a/src/main/java/crazypants/enderio/ClientProxy.java b/src/main/java/crazypants/enderio/ClientProxy.java index b80cb333..783a6846 100644 --- a/src/main/java/crazypants/enderio/ClientProxy.java +++ b/src/main/java/crazypants/enderio/ClientProxy.java @@ -49,6 +49,9 @@ import crazypants.enderio.item.darksteel.PoweredItemRenderer; import crazypants.enderio.item.darksteel.SoundEntity; import crazypants.enderio.item.darksteel.SoundRenderer; import crazypants.enderio.item.darksteel.SoundDetector; +import crazypants.enderio.item.skull.BlockEndermanSkull; +import crazypants.enderio.item.skull.EndermanSkullRenderer; +import crazypants.enderio.item.skull.TileEndermanSkull; import crazypants.enderio.machine.AbstractMachineBlock; import crazypants.enderio.machine.AbstractMachineRenderer; import crazypants.enderio.machine.enchanter.BlockEnchanter; @@ -259,6 +262,9 @@ public class ClientProxy extends CommonProxy { ClientRegistry.bindTileEntitySpecialRenderer(TileConduitBundle.class, cbr); ClientRegistry.bindTileEntitySpecialRenderer(TileTravelAnchor.class, new TravelEntitySpecialRenderer()); + + BlockEndermanSkull.renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(new EndermanSkullRenderer()); conduitRenderers.add(RedstoneSwitchRenderer.getInstance()); conduitRenderers.add(new AdvancedLiquidConduitRenderer()); diff --git a/src/main/java/crazypants/enderio/EnderIO.java b/src/main/java/crazypants/enderio/EnderIO.java index 167bfe40..4e24296b 100644 --- a/src/main/java/crazypants/enderio/EnderIO.java +++ b/src/main/java/crazypants/enderio/EnderIO.java @@ -57,6 +57,7 @@ import crazypants.enderio.item.darksteel.ItemDarkSteelSword; import crazypants.enderio.item.darksteel.ItemGliderWing; import crazypants.enderio.item.darksteel.SoundEntity; import crazypants.enderio.item.darksteel.SoundRenderer; +import crazypants.enderio.item.skull.BlockEndermanSkull; import crazypants.enderio.machine.MachineRecipes; import crazypants.enderio.machine.PacketRedstoneMode; import crazypants.enderio.machine.alloy.AlloyRecipeManager; @@ -195,6 +196,7 @@ public class EnderIO { //Blocks public static BlockDarkSteelPressurePlate blockDarkSteelPressurePlate; + public static BlockEndermanSkull blockEndermanSkull; //Fluids public static Fluid fluidNutrientDistillation; @@ -364,6 +366,8 @@ public class EnderIO { itemDarkSteelPickaxe = ItemDarkSteelPickaxe.create(); itemDarkSteelAxe = ItemDarkSteelAxe.create(); + blockEndermanSkull = BlockEndermanSkull.create(); + MaterialRecipes.registerOresInDictionary(); diff --git a/src/main/java/crazypants/enderio/ModObject.java b/src/main/java/crazypants/enderio/ModObject.java index a3813ad6..920693ea 100644 --- a/src/main/java/crazypants/enderio/ModObject.java +++ b/src/main/java/crazypants/enderio/ModObject.java @@ -78,7 +78,8 @@ public enum ModObject { blockTravelAnchor, itemTravelStaff, itemMagnet, - itemGliderWing; + itemGliderWing, + blockEndermanSkull; public final String unlocalisedName; diff --git a/src/main/java/crazypants/enderio/config/Config.java b/src/main/java/crazypants/enderio/config/Config.java index 822ed47f..489bc2be 100644 --- a/src/main/java/crazypants/enderio/config/Config.java +++ b/src/main/java/crazypants/enderio/config/Config.java @@ -147,6 +147,7 @@ public final class Config { public static float darkSteelSwordSkullChance = 0.2f; public static float darkSteelSwordSkullLootingModifier = 0.15f; public static float vanillaSwordSkullLootingModifier = 0.1f; + public static float vanillaSwordSkullChance = 0.05f; public static int darkSteelSwordPowerUsePerHit = 750; public static double darkSteelSwordEnderPearlDropChance = 1; public static double darkSteelSwordEnderPearlDropChancePerLooting = 0.5; @@ -476,19 +477,30 @@ public final class Config { darkSteelSoundLocatorLifespan = config.get(sectionDarkSteel.name, "darkSteelSoundLocatorLifespan", darkSteelSoundLocatorLifespan, "Number of ticks the 'Sound Locator' icons are displayed for.").getInt(darkSteelSoundLocatorLifespan); + + darkSteelSwordSkullChance = (float) config.get(sectionDarkSteel.name, "darkSteelSwordSkullChance", darkSteelSwordSkullChance, + "The base chance that a skull will be dropped when using a powered dark steel sword (0 = no chance, 1 = 100% chance)").getDouble( + darkSteelSwordSkullChance); darkSteelSwordSkullLootingModifier = (float) config.get(sectionDarkSteel.name, "darkSteelSwordSkullLootingModifier", darkSteelSwordSkullLootingModifier, "The chance per looting level that a skull will be dropped when using a powered dark steel sword (0 = no chance, 1 = 100% chance)").getDouble( darkSteelSwordSkullLootingModifier); + darkSteelSwordWitherSkullChance = (float) config.get(sectionDarkSteel.name, "darkSteelSwordWitherSkullChance", darkSteelSwordWitherSkullChance, "The base chance that a wither skull will be dropped when using a powered dark steel sword (0 = no chance, 1 = 100% chance)").getDouble( - darkSteelSwordWitherSkullChance); + darkSteelSwordWitherSkullChance); darkSteelSwordWitherSkullLootingModifier = (float) config.get(sectionDarkSteel.name, "darkSteelSwordWitherSkullLootingModifie", darkSteelSwordWitherSkullLootingModifier, "The chance per looting level that a wither skull will be dropped when using a powered dark steel sword (0 = no chance, 1 = 100% chance)").getDouble( - darkSteelSwordWitherSkullLootingModifier); + darkSteelSwordWitherSkullLootingModifier); + + + vanillaSwordSkullChance = (float) config.get(sectionDarkSteel.name, "vanillaSwordSkullChance", vanillaSwordSkullChance, + "The base chance that a skull will be dropped when using a non dark steel sword (0 = no chance, 1 = 100% chance)").getDouble( + vanillaSwordSkullChance); vanillaSwordSkullLootingModifier = (float) config.get(sectionPersonal.name, "vanillaSwordSkullLootingModifier", vanillaSwordSkullLootingModifier, "The chance per looting level that a skull will be dropped when using a non-dark steel sword (0 = no chance, 1 = 100% chance)").getDouble( vanillaSwordSkullLootingModifier); + darkSteelSwordPowerUsePerHit = config.get(sectionDarkSteel.name, "darkSteelSwordPowerUsePerHit", darkSteelSwordPowerUsePerHit, "The amount of power (RF) used per hit.").getInt(darkSteelSwordPowerUsePerHit); darkSteelSwordEnderPearlDropChance = config.get(sectionDarkSteel.name, "darkSteelSwordEnderPearlDropChance", darkSteelSwordEnderPearlDropChance, diff --git a/src/main/java/crazypants/enderio/item/darksteel/ItemDarkSteelSword.java b/src/main/java/crazypants/enderio/item/darksteel/ItemDarkSteelSword.java index 876449c3..383a165d 100644 --- a/src/main/java/crazypants/enderio/item/darksteel/ItemDarkSteelSword.java +++ b/src/main/java/crazypants/enderio/item/darksteel/ItemDarkSteelSword.java @@ -106,9 +106,8 @@ public class ItemDarkSteelSword extends ItemSword implements IEnergyContainerIte if(evt.source.getEntity() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) evt.source.getEntity(); - - double skullDropChance = getSkullDropChance(player, evt); - if(Math.random() <= skullDropChance) { + double skullDropChance = getSkullDropChance(player, evt); + if(Math.random() <= skullDropChance) { ItemStack skull = getSkullForEntity(evt.entityLiving); if(skull != null && !containsDrop(evt, skull)) { //TODO: Shouldn't I add this to the list in the event? @@ -151,7 +150,7 @@ public class ItemDarkSteelSword extends ItemSword implements IEnergyContainerIte if(isEquippedAndPowered(player, Config.darkSteelSwordPowerUsePerHit)) { return Config.darkSteelSwordWitherSkullChance + (Config.darkSteelSwordWitherSkullLootingModifier * evt.lootingLevel); } else { - return 0; + return 0.01; } } float fromWeapon = 0; @@ -160,9 +159,10 @@ public class ItemDarkSteelSword extends ItemSword implements IEnergyContainerIte fromWeapon = Config.darkSteelSwordSkullChance; fromLooting = Config.darkSteelSwordSkullLootingModifier * evt.lootingLevel; } else { + fromWeapon = Config.vanillaSwordSkullChance; fromLooting = Config.vanillaSwordSkullLootingModifier * evt.lootingLevel; } - return Math.min(fromWeapon + fromLooting, 0.025); + return fromWeapon + fromLooting; } private boolean containsDrop(LivingDropsEvent evt, ItemStack skull) { @@ -187,6 +187,8 @@ public class ItemDarkSteelSword extends ItemSword implements IEnergyContainerIte return new ItemStack(Items.skull, 1, 2); } else if(entityLiving instanceof EntityCreeper) { return new ItemStack(Items.skull, 1, 4); + } else if(entityLiving instanceof EntityEnderman) { + return new ItemStack(EnderIO.blockEndermanSkull); } return null; diff --git a/src/main/java/crazypants/enderio/item/skull/BlockEndermanSkull.java b/src/main/java/crazypants/enderio/item/skull/BlockEndermanSkull.java new file mode 100644 index 00000000..b6927519 --- /dev/null +++ b/src/main/java/crazypants/enderio/item/skull/BlockEndermanSkull.java @@ -0,0 +1,100 @@ +package crazypants.enderio.item.skull; + +import java.util.ArrayList; +import java.util.Random; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import crazypants.enderio.BlockEio; +import crazypants.enderio.EnderIOTab; +import crazypants.enderio.ModObject; +import crazypants.enderio.machine.AbstractMachineEntity; +import net.minecraft.block.BlockSkull; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemSkull; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTUtil; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntitySkull; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class BlockEndermanSkull extends BlockEio { + + public static int renderId = -1; + + public static BlockEndermanSkull create() { + BlockEndermanSkull res = new BlockEndermanSkull(); + res.init(); + return res; + } + + IIcon frontIcon; + IIcon frontIconEyes; + IIcon sideIcon; + IIcon topIcon; + + private BlockEndermanSkull() { + super(ModObject.blockEndermanSkull.unlocalisedName, TileEndermanSkull.class, Material.circuits); + setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F); + } + + @Override + public void registerBlockIcons(IIconRegister iIconRegister) { + frontIcon = iIconRegister.registerIcon("enderio:endermanSkullFront"); + frontIconEyes = iIconRegister.registerIcon("enderio:endermanSkullFrontEyes"); + sideIcon = iIconRegister.registerIcon("enderio:endermanSkullSide"); + topIcon = iIconRegister.registerIcon("enderio:endermanSkullTop"); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + ForgeDirection orint = ForgeDirection.getOrientation(side); + if(orint == ForgeDirection.NORTH) { + return meta == 0 ? frontIcon : frontIconEyes; + } + if(orint == ForgeDirection.UP || orint == ForgeDirection.DOWN || orint == ForgeDirection.SOUTH) { + return topIcon; + } + return sideIcon; + } + + public int getRenderType() { + return renderId; + } + + public boolean isOpaqueCube() { + return false; + } + + public boolean renderAsNormalBlock() { + return false; + } + + @SideOnly(Side.CLIENT) + public String getItemIconName() { + return "enderio:endermanSkull"; + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) { + + int inc = MathHelper.floor_double((double)(player.rotationYaw * 16.0F / 360.0F) + 0.5D) & 15; + float facingYaw = -22.5f * inc; + TileEndermanSkull te = (TileEndermanSkull) world.getTileEntity(x, y, z); + te.setYaw(facingYaw); + if(world.isRemote) { + return; + } + world.markBlockForUpdate(x, y, z); + } + +} diff --git a/src/main/java/crazypants/enderio/item/skull/EndermanSkullRenderer.java b/src/main/java/crazypants/enderio/item/skull/EndermanSkullRenderer.java new file mode 100644 index 00000000..13d912ab --- /dev/null +++ b/src/main/java/crazypants/enderio/item/skull/EndermanSkullRenderer.java @@ -0,0 +1,92 @@ +package crazypants.enderio.item.skull; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; + +import crazypants.enderio.EnderIO; +import crazypants.enderio.machine.generator.zombie.TileZombieGenerator; +import crazypants.render.BoundingBox; +import crazypants.render.CubeRenderer; +import crazypants.render.RenderUtil; +import crazypants.render.VertexRotation; +import crazypants.vecmath.Vector3d; +import net.minecraft.block.Block; +import net.minecraft.client.model.ModelEnderman; +import net.minecraft.client.model.ModelSkeletonHead; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderEnderman; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class EndermanSkullRenderer implements ISimpleBlockRenderingHandler { + + public EndermanSkullRenderer() { + } + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + renderWorldBlock(null, 0, 0, 0, block, modelId, renderer); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + Tessellator tes = Tessellator.instance; + tes.addTranslation(x, y, z); + tes.setColorOpaque_F(1, 1, 1); + + int brightness; + if(world == null) { + brightness = 15 << 20 | 15 << 4; + } else { + brightness = world.getLightBrightnessForSkyBlocks(x, y, z, 0); + } + tes.setBrightness(brightness); + + + IIcon[] icons = new IIcon[6]; + for(int i=0;i getQuantitiesConsumed(MachineRecipeInput[] inputs) { IRecipe rec = getRecipeForInputs(inputs); - List result = new ArrayList(); - for (MachineRecipeInput input : inputs) { - if(input != null && (input.item != null || input.fluid != null)) { - for (RecipeInput ri : rec.getInputs()) { + List result = new ArrayList(); + for (RecipeInput ri : rec.getInputs()) { + for (MachineRecipeInput input : inputs) { + if(input != null && (input.item != null || input.fluid != null)) { if(ri.isInput(input.item)) { result.add(new MachineRecipeInput(input.slotNumber, ri.getInput().copy())); + break; } else if(ri.isInput(input.fluid)) { result.add(new MachineRecipeInput(input.slotNumber, ri.getFluidInput().copy())); + break; } } } diff --git a/src/main/java/crazypants/enderio/machine/spawner/TilePoweredSpawner.java b/src/main/java/crazypants/enderio/machine/spawner/TilePoweredSpawner.java index 601be252..b1330a63 100644 --- a/src/main/java/crazypants/enderio/machine/spawner/TilePoweredSpawner.java +++ b/src/main/java/crazypants/enderio/machine/spawner/TilePoweredSpawner.java @@ -16,14 +16,26 @@ import crazypants.enderio.machine.IMachineRecipe; import crazypants.enderio.machine.IPoweredTask; import crazypants.enderio.machine.PoweredTask; import crazypants.enderio.machine.SlotDefinition; +import crazypants.enderio.power.BasicCapacitor; +import crazypants.enderio.power.Capacitors; +import crazypants.enderio.power.PowerHandlerUtil; public class TilePoweredSpawner extends AbstractPoweredTaskEntity { public static final int MIN_SPAWN_DELAY_BASE = Config.poweredSpawnerMinDelayTicks; public static final int MAX_SPAWN_DELAY_BASE = Config.poweredSpawnerMaxDelayTicks; + public static final float POWER_PER_TICK_ONE = Config.poweredSpawnerLevelOnePowerPerTick; + private static final BasicCapacitor CAP_ONE = new BasicCapacitor((int) (POWER_PER_TICK_ONE * 1.25), Capacitors.BASIC_CAPACITOR.capacitor.getMaxEnergyStored()); + public static final float POWER_PER_TICK_TWO = Config.poweredSpawnerLevelTwoPowerPerTick; + private static final BasicCapacitor CAP_TWO = new BasicCapacitor((int) (POWER_PER_TICK_TWO * 1.25), + Capacitors.ACTIVATED_CAPACITOR.capacitor.getMaxEnergyStored()); + public static final float POWER_PER_TICK_THREE = Config.poweredSpawnerLevelThreePowerPerTick; + private static final BasicCapacitor CAP_THREE = new BasicCapacitor((int) (POWER_PER_TICK_THREE * 1.25), + Capacitors.ENDER_CAPACITOR.capacitor.getMaxEnergyStored()); + public static final int MIN_PLAYER_DISTANCE = Config.poweredSpawnerMaxPlayerDistance; public static final boolean USE_VANILLA_SPAWN_CHECKS = Config.poweredSpawnerUseVanillaSpawChecks; @@ -44,6 +56,25 @@ public class TilePoweredSpawner extends AbstractPoweredTaskEntity { logic.spawnDelay = 0; } + public void setCapacitor(Capacitors capacitorType) { + this.capacitorType = capacitorType; + switch (capacitorType) { + case BASIC_CAPACITOR: + PowerHandlerUtil.configure(powerHandler, CAP_ONE); + break; + case ACTIVATED_CAPACITOR: + PowerHandlerUtil.configure(powerHandler, CAP_TWO); + break; + case ENDER_CAPACITOR: + PowerHandlerUtil.configure(powerHandler, CAP_THREE); + break; + default: + PowerHandlerUtil.configure(powerHandler, CAP_ONE); + break; + } + forceClientUpdate = true; + } + @Override public String getMachineName() { return ModObject.blockPoweredSpawner.unlocalisedName; diff --git a/src/main/java/crazypants/enderio/material/MaterialRecipes.java b/src/main/java/crazypants/enderio/material/MaterialRecipes.java index 82b88cb0..929d2986 100644 --- a/src/main/java/crazypants/enderio/material/MaterialRecipes.java +++ b/src/main/java/crazypants/enderio/material/MaterialRecipes.java @@ -51,6 +51,7 @@ public class MaterialRecipes { //Skulls ItemStack skull = new ItemStack(Items.skull, 1, OreDictionary.WILDCARD_VALUE); OreDictionary.registerOre("itemSkull", skull); + OreDictionary.registerOre("itemSkull", new ItemStack(EnderIO.blockEndermanSkull)); //Glass stuff for compatability GameRegistry.addShapedRecipe(new ItemStack(Blocks.glass_pane, 16, 0), " ", "eee", "eee", 'e', pureGlass); diff --git a/src/main/java/crazypants/render/CubeRenderer.java b/src/main/java/crazypants/render/CubeRenderer.java index 9ee21dc9..35efae9e 100644 --- a/src/main/java/crazypants/render/CubeRenderer.java +++ b/src/main/java/crazypants/render/CubeRenderer.java @@ -178,6 +178,17 @@ public final class CubeRenderer { } + public static void render(BoundingBox bb, IIcon[] icons, VertexTransform xForm, boolean tintSides) { + float[] brightnessPerSide = null; + if(tintSides) { + brightnessPerSide = new float[6]; + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + brightnessPerSide[dir.ordinal()] = RenderUtil.getColorMultiplierForFace(dir); + } + } + render(bb, icons, xForm, brightnessPerSide); + } + public static void render(BoundingBox bb, IIcon[] faceTextures, VertexTransform xForm, float[] brightnessPerSide) { setupVertices(bb, xForm); float minU; @@ -310,4 +321,6 @@ public final class CubeRenderer { + + }