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;
}
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);
}
}
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;
}
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);
}
}
Aggregations