com.elytradev.thermionics.block.BlockPotStill.java Source code

Java tutorial

Introduction

Here is the source code for com.elytradev.thermionics.block.BlockPotStill.java

Source

/*
 * MIT License
 *
 * Copyright (c) 2017 Isaac Ellingson (Falkreon) and contributors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package com.elytradev.thermionics.block;

import java.util.UUID;

import com.elytradev.thermionics.Thermionics;
import com.elytradev.thermionics.data.IArmor;
import com.elytradev.thermionics.gui.EnumGui;
import com.elytradev.thermionics.tileentity.TileEntityPotStill;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;

import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class BlockPotStill extends BlockMachineBase implements ITileEntityProvider, IArmor {

    public BlockPotStill() {
        super("pot_still");
        this.setLightOpacity(2);
    }
    /* //This isn't even its final form. The world isn't ready yet for a big, beautiful still.
    public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World world, BlockPos pos) {
       return createBB(state).offset(pos);
    }
        
    public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) {
       return createBB(state);
    }
        
    public AxisAlignedBB createBB(IBlockState state) {
       return new AxisAlignedBB(-0.25, 0.0, -0.25, 1.25, 1.75, 1.25);
    }*/

    //overrides light opacity if true >:|
    @Override
    public boolean isFullCube(IBlockState state) {
        return false;
    }

    //controls hidden surface removal
    @Override
    public boolean isOpaqueCube(IBlockState state) {
        return false;
    }

    @Override
    public TileEntity createNewTileEntity(World worldIn, int meta) {
        return new TileEntityPotStill();
    }

    @Override
    public boolean isValidArmor(ItemStack stack, EntityEquipmentSlot armorType, Entity entity) {
        return armorType == EntityEquipmentSlot.HEAD;
    }

    @Override
    public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
        Multimap<String, AttributeModifier> modifiers = HashMultimap.create();
        if (slot == EntityEquipmentSlot.HEAD) {
            modifiers.put(SharedMonsterAttributes.ARMOR.getName(), new AttributeModifier(
                    UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150"), "Armor modifier", 3D, 0));

        }

        return modifiers;
    }

    @Override
    public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player,
            EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
        if (!world.isRemote) {
            player.openGui(Thermionics.instance(), EnumGui.POT_STILL.id(), world, pos.getX(), pos.getY(),
                    pos.getZ());
        } else {

        }
        return true;
    }
}