Java Code Examples for net.minecraftforge.common.util.ForgeDirection#values()

The following examples show how to use net.minecraftforge.common.util.ForgeDirection#values() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TileEntityPresent.java    From Chisel-2 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound tag) {
	super.readFromNBT(tag);
	NBTTagList nbttaglist = tag.getTagList("Items", 10);

	for (int i = 0; i < nbttaglist.tagCount(); ++i) {
		NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
		int j = nbttagcompound1.getByte("Slot") & 255;

		if (j >= 0 && j < getTrueSizeInventory()) {
			inventory[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
		}
	}

	this.isParent = tag.getBoolean("isParent");

	this.rotation = tag.getInteger("rotation");
	if (tag.hasKey("conDir")) {
		cachedDir = ForgeDirection.values()[tag.getInteger("conDir")];
	}
	autoSearch = true;
}
 
Example 2
Source File: MessagePresentConnect.java    From Chisel-2 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf) {
	super.fromBytes(buf);
	dir = ForgeDirection.values()[buf.readInt()];
	connect = buf.readBoolean();
	preserveDir = buf.readBoolean();
}
 
Example 3
Source File: TileEntityAssemblyRobot.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound tag){
    super.readFromNBT(tag);
    for(int i = 0; i < 5; i++) {
        angles[i] = tag.getFloat("angle" + i);
        targetAngles[i] = tag.getFloat("targetAngle" + i);
    }
    slowMode = tag.getBoolean("slowMode");
    speed = tag.getFloat("speed");
    targetDirection[0] = ForgeDirection.values()[tag.getInteger("targetDir1")];
    targetDirection[1] = ForgeDirection.values()[tag.getInteger("targetDir2")];

}
 
Example 4
Source File: TileEntityPneumaticBase.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void updateEntity(){
    // volume calculations
    if(!worldObj.isRemote && getUpgradeSlots() != null) {
        int upgradeVolume = getVolumeFromUpgrades(getUpgradeSlots());
        setVolume(DEFAULT_VOLUME + upgradeVolume);

        if(getUpgrades(ItemMachineUpgrade.UPGRADE_SECURITY, getUpgradeSlots()) > 0) {
            if(getPressure(ForgeDirection.UNKNOWN) >= DANGER_PRESSURE - 0.1) {
                airLeak(ForgeDirection.DOWN);
            }

            //Remove the remaining air if there is any still.
            int excessAir = getCurrentAir(ForgeDirection.UNKNOWN) - (int)(getVolume() * (DANGER_PRESSURE - 0.1));
            if(excessAir > 0) {
                addAir(-excessAir, ForgeDirection.DOWN);
                onAirDispersion(-excessAir, ForgeDirection.DOWN);
            }
        }
    }

    super.updateEntity();
    // if(!worldObj.isRemote ) System.out.println("currentPressure: " +
    // getPressure());
    for(ForgeDirection pneumaticSide : ForgeDirection.values()) {
        if(!worldObj.isRemote && getPressure(pneumaticSide) > maxPressure) {
            worldObj.createExplosion(null, xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, 1.0F, true);
            worldObj.setBlockToAir(xCoord, yCoord, zCoord);
        }
    }
    if(!worldObj.isRemote) disperseAir();
    if(soundCounter > 0) soundCounter--;
}
 
Example 5
Source File: ResourceId.java    From Framez with GNU General Public License v3.0 4 votes vote down vote up
protected void readFromNBT(NBTTagCompound nbt) {
	index = new BlockIndex(nbt.getCompoundTag("index"));
	side = ForgeDirection.values()[nbt.getByte("side")];
	localId = nbt.getInteger("localId");
}
 
Example 6
Source File: Position.java    From Framez with GNU General Public License v3.0 4 votes vote down vote up
public void readFromNBT(NBTTagCompound nbttagcompound) {
	x = nbttagcompound.getDouble("i");
	y = nbttagcompound.getDouble("j");
	z = nbttagcompound.getDouble("k");
	orientation = ForgeDirection.values() [nbttagcompound.getByte("orientation")];
}
 
Example 7
Source File: ItemJetpackFueller.java    From SimplyJetpacks with MIT License 4 votes vote down vote up
@Override
public void onUsingTick(ItemStack itemStack, EntityPlayer player, int count) {
    MovingObjectPosition blockPos = BlockHelper.getCurrentMovingObjectPosition(player, true);
    if (blockPos == null || blockPos.sideHit < 0) {
        player.setItemInUse(null, 1);
    } else {
        player.setItemInUse(itemStack, this.getMaxItemUseDuration(itemStack));
        if (player.worldObj.isRemote) {
            return;
        }
        
        ItemStack chestplate = player.getCurrentArmor(2);
        if (chestplate == null || !(chestplate.getItem() instanceof ItemPack)) {
            return;
        }
        ItemPack packItem = (ItemPack) chestplate.getItem();
        PackBase pack = packItem.getPack(chestplate);
        if (pack == null) {
            return;
        }
        FuelType fuelType = pack.fuelType;
        
        ForgeDirection pullSide = ForgeDirection.values()[blockPos.sideHit];
        player.worldObj.getBlock(blockPos.blockX, blockPos.blockY, blockPos.blockZ);
        TileEntity tile = player.worldObj.getTileEntity(blockPos.blockX, blockPos.blockY, blockPos.blockZ);
        int toPull = Math.min(pack.fuelPerTickIn, packItem.getMaxFuelStored(chestplate) - packItem.getFuelStored(chestplate));
        int pulled = 0;
        
        if (fuelType == FuelType.ENERGY && tile instanceof IEnergyProvider) {
            IEnergyProvider energyTile = (IEnergyProvider) tile;
            pulled = energyTile.extractEnergy(pullSide, toPull, false);
            
        } else if (fuelType == FuelType.FLUID) {
            if (tile instanceof IFluidHandler) {
                IFluidHandler fluidTile = (IFluidHandler) tile;
                FluidStack fluid = fluidTile.drain(pullSide, toPull, false);
                if (fluid == null || !fluid.getFluid().getName().equals(pack.fuelFluid)) {
                    return;
                }
                fluid = fluidTile.drain(pullSide, toPull, true);
                pulled = fluid.amount;
            }
        }
        
        if (pulled > 0) {
            packItem.addFuel(chestplate, pulled, false);
        }
    }
}