Double Check Crafting

This commit is contained in:
KitsuShadow
2015-07-06 23:22:12 -04:00
parent 091742b4fe
commit b001b20049
16 changed files with 147 additions and 160 deletions

View File

@@ -38,6 +38,7 @@ import com.kitsu.medievalcraft.tileents.machine.TileForge;
import com.kitsu.medievalcraft.util.CustomTab;
import com.kitsu.medievalcraft.util.TileForgePlaceables;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -76,44 +77,45 @@ public class Forge extends BlockContainer implements TileForgePlaceables{
public void randomDisplayTick(World world, int x, int y, int z, Random rand)
{
super.randomDisplayTick(world, x, y, z, random);
if(this.furnaceParts==true){
world.spawnParticle("fire", (double)locX, (double)locY+1f, (double)locZ, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)locX, (double)locY+1f, (double)locZ, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", (double)locX, (double)locY+1f, (double)locZ, 0.0D, 0.0D, 0.0D);
}
//if(x==locX&&y==locY&&z==locZ){
/*if(this.furnaceParts == true){
int l;
float f;
float f1;
float f2;
for (l = 0; l < 3; ++l)
{
f = (float)(locX+0.25) + (rand.nextFloat()/2);
f1 = (float)locY + rand.nextFloat() * 0.4F + 0.3F;
f2 = (float)(locZ+0.25) + (rand.nextFloat()/2);
world.spawnParticle("fire", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D);
//world.spawnParticle("smoke", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D);
}
if(world.getBlockMetadata(x, y, z)>=4&&world.getBlockMetadata(x, y, z)<=7){
int l;
float f;
float f1;
float f2;
for (l = 0; l < 3; ++l)
{
f = (float)(x+0.25) + (rand.nextFloat()/2);
f1 = (float)y + rand.nextFloat() * 0.4F + 0.3F;
f2 = (float)(z+0.25) + (rand.nextFloat()/2);
world.spawnParticle("fire", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D);
}
if(this.coalParts == true){
int l;
float f;
float f1;
float f2;
for (l = 0; l < 3; ++l)
{
f = (float)(locX+0.25) + (rand.nextFloat()/2);
//f1 = (float)y + rand.nextFloat() * 0.4F + 0.3F;
f1 = locY;
f2 = (float)(locZ+0.25) + (rand.nextFloat()/2);
world.spawnParticle("fire", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D);
//world.spawnParticle("smoke", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D);
}
}*/
//}
}
if(world.getBlockMetadata(x, y, z)>=8){
int l;
float f;
float f1;
float f2;
for (l = 0; l < 3; ++l)
{
f = (float)(x+0.25) + (rand.nextFloat()/2);
//f1 = (float)y + rand.nextFloat() * 0.4F + 0.3F;
f1 = y+1.1f;
f2 = (float)(z+0.25) + (rand.nextFloat()/2);
world.spawnParticle("fire", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D);
}
for (l = 0; l < 3; ++l)
{
f = (float)(x+0.25) + (rand.nextFloat()/2);
f1 = (float)y + rand.nextFloat() * 0.4F + 0.3F;
f2 = (float)(z+0.25) + (rand.nextFloat()/2);
world.spawnParticle("fire", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D);
}
}
}
public static int determineOrientation(World p_150071_0_, int p_150071_1_, int p_150071_2_, int p_150071_3_, EntityLivingBase p_150071_4_)
@@ -132,7 +134,15 @@ public class Forge extends BlockContainer implements TileForgePlaceables{
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack p_149689_6_) {
int l = determineOrientation(world, x, y, z, player);
if(l==1){
l=5;
}
if(l==0){
l=5;
}
l=l-2;
world.setBlockMetadataWithNotify(x, y, z, l, 2);
System.out.println(l);
world.markBlockForUpdate(x, y, z);
}
@@ -147,26 +157,25 @@ public class Forge extends BlockContainer implements TileForgePlaceables{
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
TileForge tileEnt = (TileForge) world.getTileEntity(x, y, z);
if(world.isRemote){
MovingObjectPosition mop = Minecraft.getMinecraft().renderViewEntity.rayTrace(5, 1.0F);
c = (int)mop.sideHit;
Main.sNet.sendToServer(new MsgPacketForge((int) c));
}
System.out.println(sideMeta + " " + world.getBlockMetadata(x, y, z));
if(!world.isRemote){
if(player.inventory.getCurrentItem()!=null){
if((player.inventory.getCurrentItem().getItem()==Item.getItemFromBlock(Blocks.torch))||
(player.inventory.getCurrentItem().getItem()==Items.flint_and_steel)||
(player.inventory.getCurrentItem().getItem()==ModItems.fireBow)
){
tileEnt.isBurning=true;
Main.sNet.sendToAll(new MsgPacketOn(tileEnt.isBurning));
Main.sNet.sendToAll(new MsgPacketForgeX(tileEnt.xCoord));
Main.sNet.sendToAll(new MsgPacketForgeY(tileEnt.yCoord));
Main.sNet.sendToAll(new MsgPacketForgeZ(tileEnt.zCoord));
(player.inventory.getCurrentItem().getItem()==ModItems.fireBow)){
if(world.getBlockMetadata(x, y, z)<=3){
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z)+4, 2);
}
tileEnt.markForUpdate();
if(tileEnt.getStackInSlot(1)!=null){
tileEnt.isOn=true;
Main.sNet.sendToAll(new MsgPacketBurning(tileEnt.isOn));
if(world.getBlockMetadata(x, y, z)>=4&&world.getBlockMetadata(x, y, z)<=7){
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z)+4, 2);
}
}
}
}
@@ -212,7 +221,7 @@ public class Forge extends BlockContainer implements TileForgePlaceables{
return true;
}
}
if(sideMeta == world.getBlockMetadata(x, y, z)){
if(sideMeta-2 == world.getBlockMetadata(x, y, z)||sideMeta == world.getBlockMetadata(x, y, z)-4||sideMeta == world.getBlockMetadata(x, y, z)-8){
if(player.inventory.getCurrentItem()!=null){
if(tileEnt.getStackInSlot(0)==null){
System.out.println();

View File

@@ -125,42 +125,4 @@ public class SolidFilter extends BlockContainer {
public boolean isOpaqueCube() {
return false;
}
}
/*public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_){
//System.out.println(Minecraft.getMinecraft().objectMouseOver.blockX);
//System.out.println(Minecraft.getMinecraft().objectMouseOver.blockY);
//System.out.println(Minecraft.getMinecraft().objectMouseOver.blockZ);
//System.out.println(x + ":" + y + ":" + z);
//int newX = Minecraft.getMinecraft().objectMouseOver.blockX;
//int newY = Minecraft.getMinecraft().objectMouseOver.blockY;
//int newZ = Minecraft.getMinecraft().objectMouseOver.blockZ;
TileEntitySandFilter tileSand = (TileEntitySandFilter) world.getTileEntity(x, y, z);
if(!world.isRemote){
//--------REMOVES THE FILTER FROM THE SLOT IF THE PLAYER IS SNEAKING------------------//
if(tileSand.getStackInSlot(0)!=null){
int a = player.inventory.currentItem;
if((player.inventory.getStackInSlot(a)==null)&&(player.isSneaking())){
player.inventory.setInventorySlotContents(a, tileSand.getStackInSlot(0));
tileSand.setInventorySlotContents(0, null);
world.setBlock(x, y, z, ModBlocks.sandFilterEmpty, 0, 2);
}
}
if(tileSand.getStackInSlot(0)!=null){
int a = player.inventory.currentItem;
if((player.inventory.getStackInSlot(a)==null)&&(!player.isSneaking())){
if(world.getBlock(x, y+1, z).equals(Blocks.sand)){
int h = tileSand.tag.getInteger("FILTERHITS");
tileSand.tag.setInteger("FILTERHITS", h+1);
player.worldObj.playSoundAtEntity(player, "step.sand", 0.5F, 0.5F);
tileSand.getStackInSlot(0).setItemDamage(tileSand.getStackInSlot(0).getItemDamage()+1);
}
}
}
}
return true;
}*/
}

View File

@@ -94,9 +94,9 @@ public class TestForge extends BlockContainer {
super.randomDisplayTick(world, x, y, z, random);
TileEntityTestForge tileEnt = (TileEntityTestForge) world.getTileEntity(x, y, z);
if(tileEnt.isRunning == true){
/*if(tileEnt.isRunning == true){
}
}*/
/*Block test = world.getBlock(x, y+1, z);
if (test == TestForgeCrafting.blockToCheck.get(0) || test == TestForgeCrafting.blockToCheck.get(1) || test == TestForgeCrafting.blockToCheck.get(2)
|| test == TestForgeCrafting.blockToCheck.get(3) || test == TestForgeCrafting.blockToCheck.get(4)) {

View File

@@ -106,16 +106,16 @@ public class ForgeRenderer extends TileEntitySpecialRenderer {
GL11.glScalef(scale, scale, scale);
GL11.glTranslatef(1.0F, 1.0F, 1.0F);
int dir = world.getBlockMetadata(i, j, k);
//System.out.println(dir);
if(dir == 4){
if(dir == 2||dir == 6||dir == 10){
GL11.glRotated(-180F, 0.0, 1.0F, 0.0F);
}
if(dir == 5){
if(dir == 3||dir == 7||dir == 11){
}
if(dir == 2){
if(dir == 0||dir == 4||dir == 8){
GL11.glRotated(90F, 0.0, 1.0F, 0.0F);
}
if(dir == 3){
if(dir == 1||dir == 5||dir == 9){
GL11.glRotated(-90F, 0.0, 1.0F, 0.0F);
}

View File

@@ -1,5 +1,7 @@
package com.kitsu.medievalcraft.tileents.machine;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
@@ -22,6 +24,10 @@ import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ingots.IngotBase;
import com.kitsu.medievalcraft.packethandle.forge.MsgPacketBurning;
import com.kitsu.medievalcraft.packethandle.forge.MsgPacketForgeX;
import com.kitsu.medievalcraft.packethandle.forge.MsgPacketForgeY;
import com.kitsu.medievalcraft.packethandle.forge.MsgPacketForgeZ;
import com.kitsu.medievalcraft.packethandle.forge.MsgPacketOn;
import com.kitsu.medievalcraft.tileents.ingots.TileIngotBase;
@@ -35,6 +41,7 @@ public class TileForge extends TileEntity implements IInventory{
public boolean isOn;
public boolean isBurning;
private int ticks;
private Random rand;
public TileForge(){
this.inv = new ItemStack[2];
@@ -205,7 +212,7 @@ public class TileForge extends TileEntity implements IInventory{
@Override
public void updateEntity() {
World world = getWorldObj();
World world = this.getWorldObj();
int x = this.xCoord;
int y = this.yCoord;
int z = this.zCoord;
@@ -215,6 +222,7 @@ public class TileForge extends TileEntity implements IInventory{
fireboxFuelDec(world, x, y, z,this.getStackInSlot(0), this.ticks);
fireboxFuelDec2(world, x, y, z,this.getStackInSlot(1), this.ticks);
}
if (worldObj.isRemote) return;
}
@@ -327,15 +335,23 @@ public class TileForge extends TileEntity implements IInventory{
{
return getItemBurnTime(stack) > 0;
}
//Main.sNet.sendToAll(new MsgPacketOn(tileEnt.isBurning));
//Main.sNet.sendToAll(new MsgPacketForgeX(tileEnt.xCoord));
//Main.sNet.sendToAll(new MsgPacketForgeY(tileEnt.yCoord));
//Main.sNet.sendToAll(new MsgPacketForgeZ(tileEnt.zCoord));
//Main.sNet.sendToAll(new MsgPacketBurning(tileEnt.isOn));
private void forgeMaint(World world, int x, int y, int z){
if(this.getStackInSlot(0)==null){
this.isOn = false;
this.isBurning = false;
Main.sNet.sendToAll(new MsgPacketOn(this.isBurning));
if(world.getBlockMetadata(x, y, z)>=4&&world.getBlockMetadata(x, y, z)<=7){
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z)-4, 2);
}
}
if(this.getStackInSlot(1)==null){
this.isOn = false;
if(world.getBlockMetadata(x, y, z)>=8){
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z)-4, 2);
}
}
}
}