add custom ore support to miners and fix flying robots upon being hit

This commit is contained in:
asiekierka 2014-10-26 14:54:23 +01:00
parent 5d7b5109d3
commit 0fd4ade49d
5 changed files with 53 additions and 15 deletions

View file

@ -49,10 +49,14 @@ public final class HeuristicBlockDetection {
continue;
}
if (creativeOnly) {
SchematicRegistry.INSTANCE.registerSchematicBlock(block, meta, SchematicBlock.class);
} else {
SchematicRegistry.INSTANCE.registerSchematicBlock(block, meta, SchematicBlockCreative.class);
try {
if (creativeOnly) {
SchematicRegistry.INSTANCE.registerSchematicBlock(block, meta, SchematicBlock.class);
} else {
SchematicRegistry.INSTANCE.registerSchematicBlock(block, meta, SchematicBlockCreative.class);
}
} catch(Exception e) {
e.printStackTrace();
}
}
}

View file

@ -23,6 +23,7 @@ import buildcraft.api.blueprints.ISchematicRegistry;
import buildcraft.api.blueprints.Schematic;
import buildcraft.api.blueprints.SchematicBlock;
import buildcraft.api.blueprints.SchematicEntity;
import buildcraft.api.core.BCLog;
import buildcraft.api.core.BlockMetaPair;
import buildcraft.api.core.JavaTools;
@ -94,6 +95,10 @@ public final class SchematicRegistry implements ISchematicRegistry {
}
public void registerSchematicBlock(Block block, int meta, Class<? extends Schematic> clazz, Object... params) {
if (block == null || Block.blockRegistry.getNameForObject(block) == null || Block.blockRegistry.getNameForObject(block).equals("null")) {
BCLog.logger.warn("Mod tried to register block with null name! Ignoring.");
return;
}
if (schematicBlocks.containsKey(new BlockMetaPair(block, meta))) {
throw new RuntimeException("Block " + Block.blockRegistry.getNameForObject(block) + " is already associated with a schematic.");
}

View file

@ -74,9 +74,16 @@ public class RenderRobot extends Render implements IItemRenderer {
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glTranslated(x, y, z);
renderManager.renderEngine.bindTexture(robot.getTexture());
try {
renderManager.renderEngine.bindTexture(robot.getTexture());
} catch(Exception e) {
e.printStackTrace();
// TODO: Figure out why the NPE inside Minecraft happens.
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
return;
}
float factor = (float) (1.0 / 16.0);
box.render(factor);

View file

@ -12,7 +12,6 @@ import java.util.Date;
import java.util.WeakHashMap;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
@ -23,15 +22,14 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityDamageSource;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
@ -39,7 +37,6 @@ import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import buildcraft.BuildCraftSilicon;
import buildcraft.api.boards.RedstoneBoardNBT;
import buildcraft.api.boards.RedstoneBoardRegistry;
@ -706,7 +703,13 @@ public class EntityRobot extends EntityRobotBase implements
@Override
public void setHealth(float par1) {
// deactivate healh management
// deactivate health management
}
@Override
public boolean attackEntityFrom(DamageSource par1, float par2) {
// deactivate being hit
return false;
}
@Override

View file

@ -9,16 +9,16 @@
package buildcraft.core.utils;
import java.util.ArrayList;
import java.util.HashSet;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.oredict.OreDictionary;
public class WorldPropertyIsOre extends WorldProperty {
public ArrayList<Integer> ores = new ArrayList<Integer>();
public HashSet<Integer> ores = new HashSet<Integer>();
public WorldPropertyIsOre(boolean extendedHarvest) {
ores.add(OreDictionary.getOreID("oreCoal"));
@ -32,6 +32,25 @@ public class WorldPropertyIsOre extends WorldProperty {
ores.add(OreDictionary.getOreID("oreLapis"));
ores.add(OreDictionary.getOreID("oreRedstone"));
}
for (String oreName : OreDictionary.getOreNames()) {
if(oreName.startsWith("ore")) {
ArrayList<ItemStack> oreStacks = OreDictionary.getOres(oreName);
if (oreStacks.size() > 0) {
Block block = Block.getBlockFromItem(oreStacks.get(0).getItem());
int meta = oreStacks.get(0).getItemDamage();
if (meta == OreDictionary.WILDCARD_VALUE) {
meta = 0;
}
if (block == null) {
continue;
}
if (extendedHarvest) {
ores.add(OreDictionary.getOreID(oreName));
}
}
}
}
}
@Override
@ -39,7 +58,7 @@ public class WorldPropertyIsOre extends WorldProperty {
if (block == null) {
return false;
} else {
ItemStack stack = new ItemStack(block);
ItemStack stack = new ItemStack(block, 1, meta);
if (stack.getItem() != null) {
for (int id : OreDictionary.getOreIDs(stack)) {