Merge branch 'master' of github.com:CrazyPants/EnderIO

This commit is contained in:
eracer committed 2014-07-23 12:39:10 -06:00
commit a3129b1f48
18 files changed
+304 -12

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

@@ -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());
@@ -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();
@@ -78,7 +78,8 @@ public enum ModObject {
blockTravelAnchor,
itemTravelStaff,
itemMagnet,
itemGliderWing;
itemGliderWing,
blockEndermanSkull;
public final String unlocalisedName;
@@ -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,
@@ -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;
@@ -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);
}
}
@@ -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<icons.length;i++) {
icons[i] = block.getIcon(i, 0);
}
float yaw = 0;
if(world != null) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEndermanSkull) {
yaw = ((TileEndermanSkull)te).yaw;
}
}
VertexRotation rot = new VertexRotation(Math.toRadians(yaw), new Vector3d(0,1,0), new Vector3d(0.5,0,0.5));
float size = 0.25f;
float height = 0.5f;
BoundingBox bb = new BoundingBox(size, 0, size, 1 - size, height, 1 - size);
CubeRenderer.render(bb, icons, rot, true);
tes.addTranslation(-x, -y, -z);
return true;
}
@Override
public boolean shouldRender3DInInventory(int modelId) {
return false;
}
@Override
public int getRenderId() {
return BlockEndermanSkull.renderId;
}
}
@@ -0,0 +1,25 @@
package crazypants.enderio.item.skull;
import net.minecraft.nbt.NBTTagCompound;
import crazypants.enderio.TileEntityEio;
import crazypants.enderio.enderface.TileEnderIO;
public class TileEndermanSkull extends TileEntityEio {
float yaw;
@Override
protected void writeCustomNBT(NBTTagCompound root) {
root.setFloat("yaw", yaw);
}
@Override
protected void readCustomNBT(NBTTagCompound root) {
yaw = root.getFloat("yaw");
}
public void setYaw(float yaw) {
this.yaw = yaw;
}
}
@@ -231,6 +231,9 @@ public class TileEnchanter extends TileEntityEio implements ISidedInventory {
if(item == null) {
return 0;
}
if(currentEnchantment == null) {
return 0;
}
Enchantment enchantment = currentEnchantment.getEnchantment();
int level = item.stackSize;
return getEnchantmentCost(currentEnchantment, level);
@@ -23,14 +23,16 @@ public abstract class AbstractMachineRecipe implements IMachineRecipe {
@Override
public List<MachineRecipeInput> getQuantitiesConsumed(MachineRecipeInput[] inputs) {
IRecipe rec = getRecipeForInputs(inputs);
List<MachineRecipeInput> result = new ArrayList<MachineRecipeInput>();
for (MachineRecipeInput input : inputs) {
if(input != null && (input.item != null || input.fluid != null)) {
for (RecipeInput ri : rec.getInputs()) {
List<MachineRecipeInput> result = new ArrayList<MachineRecipeInput>();
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;
}
}
}
@@ -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;
@@ -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);
@@ -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 {
}