Search in sources :

Example 1 with BlockTrapDoor

use of net.minecraft.block.BlockTrapDoor in project BetterWithAddons by DaedalusGame.

the class QuartzCrystalRecipe method getLidStrength.

private int getLidStrength(World world, BlockPos pos, IBlockState state) {
    Block block = state.getBlock();
    // Check the shape first. Trapdoors have holes but whatever.
    if (state.isSideSolid(world, pos, EnumFacing.DOWN) || (block instanceof BlockTrapDoor && !state.getValue(BlockTrapDoor.OPEN) && state.getValue(BlockTrapDoor.HALF) == BlockTrapDoor.DoorHalf.BOTTOM)) {
        Material material = state.getMaterial();
        float hardness = state.getBlockHardness(world, pos);
        // Material checks next
        if (material.isLiquid() || material.isReplaceable())
            // just replace with air
            return 0;
        else if (hardness < 1.5f || material.getCanBurn())
            // destroy without drop to prevent easy solutions to acquiring piles for the reaction
            return 1;
        else if (hardness < 5.0f)
            // destroy with drop
            return 2;
        else
            // stable
            return 3;
    }
    // don't even remove this block
    return -1;
}
Also used : BlockTrapDoor(net.minecraft.block.BlockTrapDoor) Block(net.minecraft.block.Block) Material(net.minecraft.block.material.Material)

Example 2 with BlockTrapDoor

use of net.minecraft.block.BlockTrapDoor in project Minestuck by mraof.

the class ServerEditHandler method onRightClickBlockControl.

@SubscribeEvent(priority = EventPriority.NORMAL)
public void onRightClickBlockControl(PlayerInteractEvent.RightClickBlock event) {
    if (!event.getWorld().isRemote && getData(event.getEntityPlayer()) != null) {
        EditData data = getData(event.getEntityPlayer());
        Block block = event.getWorld().getBlockState(event.getPos()).getBlock();
        ItemStack stack = event.getEntityPlayer().getHeldItemMainhand();
        event.setUseBlock(stack.isEmpty() && (block instanceof BlockDoor || block instanceof BlockTrapDoor || block instanceof BlockFenceGate) ? Result.ALLOW : Result.DENY);
        if (event.getUseBlock() == Result.ALLOW)
            return;
        if (stack.isEmpty() || !isBlockItem(stack.getItem()) || event.getHand().equals(EnumHand.OFF_HAND)) {
            event.setCanceled(true);
            return;
        }
        cleanStackNBT(stack);
        if (DeployList.containsItemStack(stack)) {
            GristSet cost = data.connection.givenItems()[DeployList.getOrdinal(stack)] ? DeployList.getSecondaryCost(stack) : DeployList.getPrimaryCost(stack);
            if (!GristHelper.canAfford(MinestuckPlayerData.getGristSet(data.connection.getClientIdentifier()), cost)) {
                StringBuilder str = new StringBuilder();
                if (cost != null) {
                    for (GristAmount grist : cost.getArray()) {
                        if (cost.getArray().indexOf(grist) != 0)
                            str.append(", ");
                        str.append(grist.getAmount() + " " + grist.getType().getDisplayName());
                    }
                    event.getEntityPlayer().sendMessage(new TextComponentTranslation("grist.missing", str.toString()));
                }
                event.setCanceled(true);
            }
        } else if (!isBlockItem(stack.getItem()) || !GristHelper.canAfford(data.connection.getClientIdentifier(), stack, false)) {
            event.setCanceled(true);
        }
        if (event.getUseItem() == Result.DEFAULT)
            event.setUseItem(Result.ALLOW);
    }
}
Also used : BlockDoor(net.minecraft.block.BlockDoor) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) BlockFenceGate(net.minecraft.block.BlockFenceGate) BlockTrapDoor(net.minecraft.block.BlockTrapDoor) Block(net.minecraft.block.Block) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with BlockTrapDoor

use of net.minecraft.block.BlockTrapDoor in project MC-Prefab by Brian-Wuest.

the class StructureAlternateStart method CustomBlockProcessingHandled.

@Override
protected Boolean CustomBlockProcessingHandled(StructureConfiguration configuration, BuildBlock block, World world, BlockPos originalPos, EnumFacing assumedNorth, Block foundBlock, IBlockState blockState, EntityPlayer player) {
    HouseConfiguration houseConfig = (HouseConfiguration) configuration;
    if ((!houseConfig.addBed && foundBlock instanceof BlockBed) || (!houseConfig.addChest && foundBlock instanceof BlockChest) || (!houseConfig.addTorches && foundBlock instanceof BlockTorch) || (!houseConfig.addCraftingTable && (foundBlock instanceof BlockWorkbench || foundBlock instanceof BlockFurnace))) {
        // "handled"
        return true;
    }
    if (foundBlock instanceof BlockFurnace) {
        this.furnacePosition = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
    } else if (foundBlock instanceof BlockTrapDoor && houseConfig.addMineShaft) {
        // The trap door will still be added, but the mine shaft may not be
        // built.
        this.trapDoorPosition = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
    } else if (foundBlock instanceof BlockChest && this.chestPosition == null) {
        this.chestPosition = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
    } else if (foundBlock instanceof BlockStandingSign) {
        this.signPosition = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
    }
    if (foundBlock.getRegistryName().getResourceDomain().equals(Blocks.STAINED_GLASS.getRegistryName().getResourceDomain()) && foundBlock.getRegistryName().getResourcePath().equals(Blocks.STAINED_GLASS.getRegistryName().getResourcePath())) {
        blockState = blockState.withProperty(BlockStainedGlass.COLOR, houseConfig.glassColor);
        block.setBlockState(blockState);
        this.priorityOneBlocks.add(block);
        return true;
    } else if (foundBlock.getRegistryName().getResourceDomain().equals(Blocks.STAINED_GLASS_PANE.getRegistryName().getResourceDomain()) && foundBlock.getRegistryName().getResourcePath().equals(Blocks.STAINED_GLASS_PANE.getRegistryName().getResourcePath())) {
        block.setBlockState(foundBlock.getStateFromMeta(houseConfig.glassColor.getMetadata()));
        this.priorityOneBlocks.add(block);
        return true;
    }
    return false;
}
Also used : BlockFurnace(net.minecraft.block.BlockFurnace) BlockChest(net.minecraft.block.BlockChest) BlockWorkbench(net.minecraft.block.BlockWorkbench) BlockTrapDoor(net.minecraft.block.BlockTrapDoor) BlockStandingSign(net.minecraft.block.BlockStandingSign) BlockBed(net.minecraft.block.BlockBed) HouseConfiguration(com.wuest.prefab.Config.Structures.HouseConfiguration) BlockTorch(net.minecraft.block.BlockTorch)

Example 4 with BlockTrapDoor

use of net.minecraft.block.BlockTrapDoor in project Minestuck by mraof.

the class ClientEditHandler method onRightClickEvent.

@SubscribeEvent(priority = EventPriority.NORMAL)
public void onRightClickEvent(PlayerInteractEvent.RightClickBlock event) {
    if (event.getWorld().isRemote && event.getEntityPlayer() == ClientProxy.getClientPlayer() && isActive()) {
        Block block = event.getWorld().getBlockState(event.getPos()).getBlock();
        ItemStack stack = event.getEntityPlayer().getHeldItemMainhand();
        event.setUseBlock((block instanceof BlockDoor || block instanceof BlockTrapDoor || block instanceof BlockFenceGate) ? Result.ALLOW : Result.DENY);
        if (event.getUseBlock() == Result.ALLOW)
            return;
        if (event.getHand().equals(EnumHand.OFF_HAND) || !ServerEditHandler.isBlockItem(stack.getItem())) {
            event.setCanceled(true);
            return;
        }
        GristSet cost;
        if (DeployList.containsItemStack(stack))
            if (givenItems[DeployList.getOrdinal(stack)])
                cost = DeployList.getSecondaryCost(stack);
            else
                cost = DeployList.getPrimaryCost(stack);
        else
            cost = GristRegistry.getGristConversion(stack);
        if (!GristHelper.canAfford(MinestuckPlayerData.getClientGrist(), cost)) {
            StringBuilder str = new StringBuilder();
            if (cost != null) {
                for (GristAmount grist : cost.getArray()) {
                    if (cost.getArray().indexOf(grist) != 0)
                        str.append(", ");
                    str.append(grist.getAmount() + " " + grist.getType().getDisplayName());
                }
                event.getEntityPlayer().sendMessage(new TextComponentTranslation("grist.missing", str.toString()));
            }
            event.setCanceled(true);
        }
        if (event.getUseItem() == Result.DEFAULT)
            event.setUseItem(Result.ALLOW);
    }
}
Also used : BlockDoor(net.minecraft.block.BlockDoor) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) BlockFenceGate(net.minecraft.block.BlockFenceGate) BlockTrapDoor(net.minecraft.block.BlockTrapDoor) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

BlockTrapDoor (net.minecraft.block.BlockTrapDoor)4 Block (net.minecraft.block.Block)3 BlockDoor (net.minecraft.block.BlockDoor)2 BlockFenceGate (net.minecraft.block.BlockFenceGate)2 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 HouseConfiguration (com.wuest.prefab.Config.Structures.HouseConfiguration)1 BlockBed (net.minecraft.block.BlockBed)1 BlockChest (net.minecraft.block.BlockChest)1 BlockFurnace (net.minecraft.block.BlockFurnace)1 BlockStandingSign (net.minecraft.block.BlockStandingSign)1 BlockTorch (net.minecraft.block.BlockTorch)1 BlockWorkbench (net.minecraft.block.BlockWorkbench)1 Material (net.minecraft.block.material.Material)1 ItemStack (net.minecraft.item.ItemStack)1