Grinding now working
This commit is contained in:
parent
f467c82f13
commit
d9a251905d
4 changed files with 52 additions and 15 deletions
|
@ -88,4 +88,16 @@ public final class MachineRecipes
|
||||||
|
|
||||||
return this.getOutput(machine, resourceInputs);
|
return this.getOutput(machine, resourceInputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Resource[] getRecipe(RecipeType machine, String... oreDictNames)
|
||||||
|
{
|
||||||
|
Resource[] resourceInputs = new Resource[oreDictNames.length];
|
||||||
|
|
||||||
|
for (int i = 0; i < oreDictNames.length; i++)
|
||||||
|
{
|
||||||
|
resourceInputs[i] = new OreDictResource(oreDictNames[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.getOutput(machine, resourceInputs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.DamageSource;
|
import net.minecraft.util.DamageSource;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import resonantinduction.core.base.BlockRotatableBase;
|
import resonantinduction.core.base.BlockRotatableBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,8 +44,15 @@ public class BlockGrinderWheel extends BlockRotatableBase implements ITileEntity
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
entity.attackEntityFrom(DamageSource.cactus, 1);
|
entity.attackEntityFrom(DamageSource.cactus, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Move entity based on the direction of the block.
|
||||||
|
ForgeDirection dir = this.getDirection(world, x, y, z);
|
||||||
|
entity.motionX += dir.offsetX * 0.1;
|
||||||
|
entity.motionZ += dir.offsetZ * 0.1;
|
||||||
|
|
||||||
|
entity.motionY += Math.random() * 0.3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -84,11 +84,11 @@ public class ItemDust extends ItemBase
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void generateDusts()
|
public static void generateDusts()
|
||||||
{
|
{
|
||||||
for (String materialName : materialNames)
|
for (String materialName : materialNames)
|
||||||
{
|
{
|
||||||
String name = materialName.substring(0, 1).toUpperCase() + materialName.substring(1);
|
String name = materialName.substring(0, 1).toUpperCase() + materialName.substring(1);
|
||||||
|
|
||||||
if (OreDictionary.getOres("ore" + name).size() > 0)
|
if (OreDictionary.getOres("ore" + name).size() > 0)
|
||||||
{
|
{
|
||||||
if (OreDictionary.getOres("dust" + name).size() == 0)
|
if (OreDictionary.getOres("dust" + name).size() == 0)
|
||||||
|
@ -99,7 +99,10 @@ public class ItemDust extends ItemBase
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add to machine recipes
|
// Add to machine recipes
|
||||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.GRINDER, "ore" + name, OreDictionary.getOres("dust" + name).get(0));
|
|
||||||
|
ItemStack dust = OreDictionary.getOres("dust" + name).get(0).copy();
|
||||||
|
dust.stackSize = 2;
|
||||||
|
MachineRecipes.INSTANCE.addRecipe(RecipeType.GRINDER, "ore" + name, dust);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,14 +46,19 @@ public class TileGrinderWheel extends TileElectrical
|
||||||
|
|
||||||
if (entry.getValue() <= 0)
|
if (entry.getValue() <= 0)
|
||||||
{
|
{
|
||||||
this.doGrind(entry.getKey());
|
|
||||||
|
if (this.doGrind(entry.getKey()))
|
||||||
|
{
|
||||||
|
entry.getKey().setDead();
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Make the entity not be able to be picked up.
|
// Make the entity not be able to be picked up.
|
||||||
EntityItem entity = entry.getKey();
|
EntityItem entity = entry.getKey();
|
||||||
entity.delayBeforeCanPickup = 20;
|
entity.delayBeforeCanPickup = 20;
|
||||||
this.worldObj.spawnParticle("smoke", entity.posX, entity.posY, entity.posZ, 0, 0, 0);
|
this.worldObj.spawnParticle("crit", entity.posX, entity.posY, entity.posZ, (Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,19 +68,28 @@ public class TileGrinderWheel extends TileElectrical
|
||||||
return MachineRecipes.INSTANCE.getRecipe(RecipeType.GRINDER, itemStack) == null ? false : MachineRecipes.INSTANCE.getRecipe(RecipeType.GRINDER, itemStack).length > 0;
|
return MachineRecipes.INSTANCE.getRecipe(RecipeType.GRINDER, itemStack) == null ? false : MachineRecipes.INSTANCE.getRecipe(RecipeType.GRINDER, itemStack).length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doGrind(EntityItem entity)
|
private boolean doGrind(EntityItem entity)
|
||||||
{
|
{
|
||||||
ItemStack itemStack = entity.getEntityItem();
|
if (!this.worldObj.isRemote)
|
||||||
|
|
||||||
Resource[] results = MachineRecipes.INSTANCE.getRecipe(RecipeType.GRINDER, itemStack);
|
|
||||||
|
|
||||||
for (Resource resource : results)
|
|
||||||
{
|
{
|
||||||
if (resource instanceof ItemStackResource)
|
ItemStack itemStack = entity.getEntityItem();
|
||||||
|
|
||||||
|
Resource[] results = MachineRecipes.INSTANCE.getRecipe(RecipeType.GRINDER, itemStack);
|
||||||
|
|
||||||
|
for (Resource resource : results)
|
||||||
{
|
{
|
||||||
entity.setEntityItemStack(((ItemStackResource) resource).itemStack);
|
if (resource instanceof ItemStackResource)
|
||||||
entity.setPosition(entity.posX, entity.posY - 1.2, entity.posZ);
|
{
|
||||||
|
EntityItem entityItem = new EntityItem(this.worldObj, entity.posX, entity.posY, entity.posZ, ((ItemStackResource) resource).itemStack.copy());
|
||||||
|
entityItem.delayBeforeCanPickup = 20;
|
||||||
|
entityItem.motionX = 0;
|
||||||
|
entityItem.motionY = 0;
|
||||||
|
entityItem.motionZ = 0;
|
||||||
|
this.worldObj.spawnEntityInWorld(entityItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue